Interest

Bjørn Kjos-Hanssen

Standard actuarial education includes an exam on financial mathematics, specifically the mathematical theory of interest rates. In this article we describe a project taking the first steps toward formalizing this theory in the proof assistant Lean. As Lean’s Mathlib library already has a thorough coverage of calculus, we are able to develop the theory of interest directly.

We start with the Annuity Equation, a staple of actuarial science and financial mathematics, relating a payment, present value, future value, interest rate, and maturity date. Using the Lean proof assistant, we verify the unique solvability of the Annuity Equation for each variable under reasonable assumptions. We next do the same for a Macaulay duration equation, with some help from Harmonic’s mathematical superintelligence tool Aristotle.

Finally, using Radisic’s verified numerical computation tool LeanCert, we are able to formally prove the correctness of solutions to actuarial exam questions having numerical answers.

0.1 Introduction

In this article we report on a project to formalize interest theory in the proof assistant Lean [ 3 ] in a library, Interest [ 8 ] .

Presently it includes results on the existence of a unique solution for any of these given the others: the present value of an annuity PV; future value FV; periodic payment PMT (equivalently, coupon rate \(r\) for a bond); prevailing interest rate I/Y (yield); Macaulay duration \(D\); maturity date \(n\).

In order to deduce the maturity date and the yield rate from the Macaulay duration we made use of Aristotle [ 1 ] by Harmonic, which saved a lot of time.

The mathematical theory of interest, often known simply as financial mathematics within actuarial science, is important in the real world and is due for a formal treatment.

We focus on the pricing of bonds and annuities in settings in which financial calculators are used by actuaries.

Calculators such as the BA II Plus Professional are used by actuaries to make critical decisions. Consequently, formal verification of the underlying mathematics is important.

The Annuity Equation is a staple of actuarial science and financial mathematics, relating a payment [PMT], present value [PV], future value [FV], interest rate [I/Y], and number of periods [N]. The BA II Plus Professional calculator allows a solution for any one of these five variables given the others, using keystrokes such as [CPT] [PMT]. In the first half of the project we verify the unique solvability of the Annuity Equation for each variable under a non-par bond assumption. In the second half, we replace the annuity equation by an equation defining the Macaulay duration in terms of maturity, yield rate, and coupon rate for a bond, and obtain similar results. In this half we make use of Harmonic’s tool Aristotle.

0.2 The annuity equation

The Annuity Equation ?? is often left implicit in textbooks on financial mathematics such as [ 2 ] . (We write interest per year, I/Y, as IY since it is a single variable.)

\begin{equation} \label{ann_eq} \PV + \PMT \cdot \sum _{k=1}^{\N } (1 + (\IY /100))^{-k} + \FV \cdot (1 + \IY /100)^{-\N } = 0. \end{equation}
1

Nevertheless, it should be considered well known. In our formalization, we assume that PV has the opposite sign of the common sign of PMT and FV. This avoids uniqueness issues stemming from Descartes’ Rule of Signs, as in Norstrøm’s Criterion [ 11 ] .

The form ?? gives the impression that division \(x \mapsto x^{-1}\) is necessary, but the equation can also be stated in a future value perspective that makes sense over a ring if we define the interest rate by \(i=\IY /100\).

\[ \PV \cdot (1 + i)^{\N } + \PMT \cdot \sum _{k=0}^{\N -1} (1 +i)^{k} + \FV = 0. \]

In terms of the discount factor \(v=1/(1+i)\), another form is

\[ \alpha + \beta (1-v^n)/i + \gamma v^n = 0. \]

In terms of \(x=v^{-n/2}{\gt}0\), this becomes

\[ \alpha x + \frac{\beta (x-x^{-1})}i + \gamma x^{-1} = 0. \]

Solving for \(x\), we obtain

\[ 0 {\lt} x^2 = \frac{\beta /i-\gamma }{\beta /i+\alpha } \]

This inequality is (unsurprisingly) also encountered in our Lean code.

The Annuity Equation has apparently been implemented in financial calculators since their introduction half a century ago (June 13, 1976 for the original Texas Instruments Business Analyst [ 13 ] ). Here we formalize the fact one can solve for any of these five variables given the other four. This is rather explicit for PV, FV, PMT, and N, but requires Newton’s method for I/Y (interest per year). However, our proof is mathematical and does not concern itself with computability. It instead sticks to mathematical existence and uniqueness.

0.2.1 Some sample results from the project

The following results should be cross-referenced with the dependency graph at [ 8 ] and may be skipped if the reader is not simultaneously studying that graph and the associated documentation pages.

Definition 1 id_mul_geom_sum
#

The expression \(\sum _{k=1}^n k v^k\).

Definition 2 Ia
#

Present value of an increasing annuity: \(\sum _{k=1}^n k v^k\) where \(v=1/(1+i)\).

Definition 3 geom_sum
#

\(\mathrm{geom\_ sum}\) is the function \(g : \mathbb N \to \mathbb R \to \mathbb R\) given by \(g(n,v)= \sum _{k=1}^n v ^k\).

Definition 4 bond_price_sum
#

The bond price sum is \(r \cdot \text{geom\_ sum} (n, v) + v ^n\).

Definition 5 bond_price
#

The bond price is the bond price sum with \(v=1/(1+i)\).

Definition 6 D
#

Macaulay duration:
(r * Ia n i + n * (1+i)\(^{-n}\)) / bond_price n i r

Lemma 7 id_mul_geom_sum_formula
#

Given \(x\in \mathbb R\) with \(x \ne 1\) and \(n\in \mathbb N\), we have

\[ \sum _{k=1}^n k \cdot x^k = \frac{x \cdot (n \cdot x ^{n + 1} - ((n + 1) \cdot x ^n) + 1)}{(x - 1) ^2}. \]
Proof

A well-known formula from undergraduate mathematics.

Definition 8 annuity.a
#

The present value of annuity function \(a : \mathbb N \to \mathbb R \to \mathbb R\) is defined by

\[ a_{\overline n|i}=g(n, (1 + i)^{-1}) \]

with \(g\) as in Definition 3.

Definition 9 annuity.a_formula
#

The expression for the present value of annuity that is well-defined even for non-integer \(n\): \((1 - (1+i)^{-n}) / i\).

Lemma 10 a_eq_a_formula
#

The value of the expression for the present value of annuity that is well-defined even for non-integer \(n\) is equal to the original value.

Proof

Apply the formula \(\sum _{i=0}^{n-1} x^i = \frac{x^n - 1}{x - 1}\) to \(x\) being the discount factor \((1+i)^{-1}\).

Definition 11 CPT_PV
#

Defines a function to compute PV, as
- PMT * (annuity.a N (IY / 100)) - FV * (1 + IY/100)\(^{-N}\).

Definition 12 CPT_PMT
#

Defines a function to compute PMT, as
(-PV - FV * (1 + IY / 100)\(^{-N}\)) / annuity.a N (IY / 100).

Definition 13 CPT_IY
#

Defines a function to compute IY.

Definition 14 CPT_N
#

Defines a function to compute N, as
(log ((PV * (IY / 100) + PMT) / (PMT - FV * (IY / 100)))) / (log (1 + IY / 100)\(^{-1}\)).

Definition 15 [CPT_FV]
#

Defines a function to compute FV, as
(- PV - PMT * (annuity.a N (IY / 100))) / ((1 + IY/100)\(^{-N}\)).

Lemma 16 PMT_eq_CPT_PMT
#

If \(\IY {\gt} -100\) and \(\N \ne 0\) then \(\PMT =\CPTPMT \).

Proof

An exercise in algebraic manipulation.

Lemma 17 IY_eq_CPT_IY
#

If \(\N \ne 0\), \(\PMT \ge 0\), \(0 \le \PV + \PMT \cdot \N + \FV \), \(\PV {\lt} 0\), \(\FV {\gt} 0\), \(\IY {\lt} -100\), and the annuity equation holds for IY, PMT, PV, FV, and N, then \(\IY =\CPTIY \).

Proof

Use the Intermediate Value Theorem and strict monotonicity in the Annuity Equation as a function of interest rate.

Lemma 18 PV_eq_CPT_PV
#

Assume the annuity equation holds for \(\IY , \PMT , \PV , \FV \) and \(\N \). Then \(\PV =\CPTPV \).

Proof

Another exercise in algebraic manipulation.

Lemma 19 FV_eq_CPT_FV
#

Assume the annuity equation holds for \(\IY , \PMT , \PV , \FV \) and \(\N \), and \(\IY \ne -100\). Then \(\FV =\CPTFV \).

Proof

Another exercise in algebraic manipulation.

Lemma 20 N_eq_CPT_N
#

Assume the annuity equation holds for \(\IY , \PMT , \PV , \FV \) and \(\N \).

Assume \(\IY /100\notin \{ -2,-1,0\} \), and \(\FV \cdot (\IY / 100) - \PMT \ne 0\). Then maturity \(\N \) equals \(\CPTN \).

Proof

An exercise is algebraic manipulation.

Theorem 21 annuity_equation_unique_solvability

Given real numbers \(\IY {\gt}0\), \(\PMT \ge 0\), \(\PV {\lt}0\), \(\FV {\gt}0\) and a natural number \(\N \ge 1\), satisfying the annuity equation, with \((\FV \cdot (\IY / 100) - \PMT \ne 0\), we can compute each of the five variables uniquely from the other four.

Proof

We combine the results of Lemmas 16, 17, 18, 19, and 20.

0.3 Macaulay duration

Whether maturity of a bond can be recovered from the Macaulay duration [ 9 ] depends on whether the coupon rate \(r\) is less than the yield rate \(i\). See Table 1. The fact that there can be two solutions when \(r{\lt}i\) and \(1+1/i{\lt}d\) is illustrated in [ 2 , Figure 8.3 on page 251 ] , where the situation is described as a “deep discount” bond. It was first discovered by Hawawini [ 6 , 5 ] .

Table 1 Recoverability of maturity \(n\) from Macaulay duration \(d\). The number of solutions for \(n\) shown. \(d_{\max }\) is the maximum duration as a function of \(n\), which only exists when \(r {\lt} i\).
 

\(r {\lt} i\)

\(r \ge i\)

\(d {\lt} 1 + 1/i\)

1

1

\(d = 1 + 1/i\)

1

0

\(d {\gt} 1 + 1/i\)

 

0

\(1 + 1/i {\lt} d {\lt} d_{\max }\)

2

 

\(d = d_{\max }\)

1

 

\(d {\gt} d_{\max }\)

0

 

Aristotle [ 1 ] provided a single proof that \(D{\lt}1+1/i\) suffices, without doing a case split on whether \(r{\lt}i\).

Lemma 22 AriMagic.exists_pos_root_of_limits
#

If a continuous function starts positive at 0 and tends to a negative limit, it has a positive root.

Proof

A simple application of the Intermediate Value Theorem, formalized by Aristotle.

Definition 23 duration_equation
#

Defined to equal d * annuity.bond_price n i r
- (r * annuity.Ia n i + ↑n * (1 + i)\(^{-n}\)) = 0.

Lemma 24 AriMagic.unique_solution_n
#

Given \(D{\gt}0, i{\gt}0, r{\gt}0\), with \(D {\lt} 1 + 1/i\), there is a unique solution for the maturity \(N\) in the duration equation with duration \(D\), yield rate \(i\), and coupon rate \(r\).

Proof

This is a subtle result, outsourced to Aristotle.

Theorem 25 eq_CPT_I_of_D
#

If \(D{\gt}1\), \(n \ge 2\), and \(r {\gt} 0\) then we can uniquely compute the yield rate \(i {\gt} -1\) from the duration equation.

Proof

This proof was outsourced to Aristotle.

Theorem 26 eq_CPT_N_of_D
#

Given \(n\in \mathbb N\) with \(n{\gt}1\) and \(i,d,r\) positive real numbers, with \(d {\lt} 1 + 1 / i\), if the duration equation holds for \(n,i,r,d\) then \(n\) is uniquely determined, and given by the Lean function CPT_N_from_D.

Proof

This result is simply a wrapper for Lemma 24.

0.4 Solving exercises with Aristotle and LeanCert

Actuarial exam questions are used to qualify students for actuarial careers. As such, the correctness of their solution affects actuaries directly. We demonstrate that LeanCert [ 12 ] , a new tool for verified interval arithmetic in Lean, can be used to formally verified such solutions. Since solutions may also involve tedious computations, we also make use of Aristotle. Our test case is [ 2 , Exercise 1.36 ] , which reads as follows:

Assume that \(\delta (t)=\frac1{10(1+t)^3}\) and \(A(0)=100\). Find the amount of interest earned in the fifth year.

The correct solution is \((e^{7/144}-e^{6/125})\cdot 100\) which in the solution at the end of the book [ 2 , Appendix B ] is given simply as 0.064.

To verify this we prove the following lemma:

Lemma 27 chan_tse_exe_1_36
#

Assume that \(\delta (t)=\frac1{10(1+t)^3}\) and \(A(0)=100\), that \(a(t)\ne 0\) for all \(t\), and that \(a\) is differentiable on \(\mathbb R\) with \(a(0)=1\). Then \(I(A_0,a,5)\in (0.064, 0.065)\).

Here \(a\) is the accumulation function, \(A\) is the accumulated amount function, and \(I\) is the earned interest function as introduced in [ 2 ] . We evaluate the associated integrals by hand, then use Aristotle to formally verified the solutions, and finally use LeanCert to obtain the bounds \((0.064, 0.065)\). This proof of concept opens the door to formally verifying financial mathematics exams (such as Exam FM of the Society of Actuaries) prior to delivering them to students.

0.5 Conclusion

The actuarial and financial mathematics literature is vast (see for example [ 7 ] ) and we have only laid some of the groundwork. A general continuation would be to add stochastic components. Related initiatives include formalization of Brownian motion in Lean [ 4 ] and, tangentially, formalization of smart contracts [ 10 ] .

A very concrete next task would be to clarify to what extent two of our six variables can be computed from the other four: For instance, can yield rate and maturity be computed from present value, future value, Macaulay duration, and coupon rate?

Acknowledgments.

This work was partially supported by grants from the Simons Foundation (#704836 to Bjørn Kjos-Hanssen) and Majesco Inc. (University of Hawai‘i Foundation Account #129-4770-4).