
A library of mathematical finance in Lean 4, built on
Mathlib and Rémy Degenne’s
BrownianMotion. A theorem enters only when every
hypothesis is stated and every step is checked by Lean’s kernel. It covers stochastic calculus,
no-arbitrage theory, derivative pricing, fixed income, portfolio choice, risk measures and
actuarial mathematics.
The corpus records 1000 results from the literature in
benchmarks/, each with a Lean statement and proof. Of these, 950 are proved in
full, 19 restate a lemma from Mathlib or BrownianMotion, and 31 are
reduced cores that prove less than the result they are named after,
and say so. The library contains no sorry, and a build-time audit checks that every library
theorem the corpus cites depends only on the axioms propext, Classical.choice and
Quot.sound.
Here is the convergence of the Cox–Ross–Rubinstein call price to the Black–Scholes price
(CRRClosedForm.lean):
theorem binomialPrice_call_tendsto_bs_closed {r σ T S₀ K : ℝ}
(hσ : 0 < σ) (hT : 0 < T) (hS₀ : 0 < S₀) (hK : 0 < K)
(hna : ∀ n, 0 < n → BinomialNoArb (crrUp σ T n) (crrDown σ T n) (crrPerStepRate r T n)) :
Tendsto (fun n : ℕ ↦ binomialPrice (crrUp σ T n) (crrDown σ T n) (crrPerStepRate r T n)
(fun x ↦ max (x - K) 0) n S₀) atTop
(𝓝 (S₀ * Phi (bsd1 S₀ K r σ T)
- K * Real.exp (-(r * T)) * Phi (bsd2 S₀ K r σ T)))
The textbook proof leaves hna implicit: the tree must be free of arbitrage at every step. Lean
will not proceed without it, and binomialNoArb_crr
shows it holds whenever $|r|\sqrt{T} < \sigma$.
Main results
The landmarks page prints
the Lean statements of selected results below and describes the scope of each.
- Brownian motion. The reflection principle, and almost surely no derivative at any time.
- Stochastic calculus. Itô’s formula for f(t, B_t) with no growth condition, and for one or
two Itô processes on one Brownian motion with continuous adapted coefficients; Lévy’s characterization; Girsanov’s theorem for
bounded θ; martingale representation; for Lipschitz coefficients, a unique fixed point of the
SDE’s Picard map.
- No arbitrage. The fundamental theorems of asset pricing on a finite space, and for one real
asset on any probability space (Dalang–Morton–Willinger).
- Black–Scholes. The PDE from Feynman–Kac, the delta hedge, and the call value as the value of
a contract.
- Contracts. The compiler turns piecewise-linear expressions in one terminal price into a
bond, a forward and calls. Their path values agree whenever the terminal price is nonnegative.
Under a pricing measure with a deterministic numéraire, the prices of those instruments give
the price of the payoff. In Black–Scholes with positive initial stock price and nonzero volatility,
a fixed-date contract whose observations and payments fall by T has a unique hedge in the stock
if its total discounted payoff is square-integrable. Its initial cost is the contract value.
For the European call the holding agrees with Φ(d₁) almost everywhere for the stock’s bracket
measure. An autocall redeems at the first scheduled barrier hit or at maturity.
- Trees and the limit. Cox–Ross–Rubinstein converges to Black–Scholes.
- The smile. An exact polynomial-sign certificate for butterfly-free raw SVI; calendar
arbitrage as monotone total variance; Dupire’s equation in the sense of distributions, with no
smoothness assumed of the call surface.
- The American put. Its exercise boundary is convex in time to expiry for 0 ≤ q ≤ r, an open
question settled here by Robert Martin’s proof.
- Jumps and rates. Merton’s jump-diffusion price derived from the model; Vasicek and
Hull–White bonds, Jamshidian’s bond options, swaptions under the annuity measure.
- Risk, insurance and choice. On a finite state space, a coherent risk measure is the supremum
of expected losses over a set of probability vectors. Lundberg’s bound on the probability of
ruin of a random-walk surplus. The von Neumann–Morgenstern theorem on finitely many outcomes.
- Markov chains. The strong Markov property and the recurrence criterion on a countable state
space. A nonempty finite irreducible chain has a unique stationary distribution. With
aperiodicity, its transition probabilities converge to that distribution and its time averages
converge in mean square.
How it is kept honest
- Every entry has a status, and only
full and library_wrapper entries may be cited as the
named theorem. Each entry also publishes, beside its description, what it leaves out.
- Reduced cores. Thirty-one of the results prove less than the theorem they are named after.
Two assume a structure whose fields include the textbook conclusion, seven rest on a named
hypothesis that is not proved, and twenty prove a special case or part of the theorem. The
kinds overlap and are not exhaustive (several entries are narrow re-exports of one identity
or bound). Each is listed in
docs/coverage.md with what is missing.
- Known gaps. Girsanov is proved for bounded θ only; under Novikov’s condition only
E[Z_T] = 1 is proved. In the Brownian market only completeness ⇒ uniqueness of the pricing
measure is proved, and the hedge of a general claim is not identified with a formula
(Clark–Ocone, #182).
The two-factor Itô formula covers a single driver with time-dependent tests. A separate formula
on a common filtration treats an independent Brownian pair with bounded spatial derivatives.
- Below the elaborator. Axiom pins on every constant the corpus cites, a comparator check of
the Palomar statements, and a monthly
leanchecker replay of every module.
BrownianMotion has sorrys of its own; the pins show that no cited theorem depends on one.
Outside the library, sorry appears on purpose in Challenge.lean, the
comparator’s statement, and in MathFinFrontier/, which states open problems
in Lean.
How the library is organized
Financial mathematics has one economic object, a price system: positions in a market and the set
of pricing measures that price them. Its deep theorems are three dualities of that set: with
trading gains (valuation), with the positions a risk measure accepts (risk), and with the positions
an investor prefers (choice). The library is one tree: probability at the roots, the price system
as the trunk, valuation, choice and risk as the limbs, with the model families as a second axis.
Contracts are terms of their own language, priced by any model.
The program tree draws it, with
what is proved and what is stated next. docs/organization.md gives the
account; one file, docs/taxonomy.toml, drives the directories, the
blueprint, the issue labels and the site.
Where to start
Building and using
git clone https://github.com/formal-applied-math/formal-mathfin.git
cd formal-mathfin
lake exe cache get # prebuilt Mathlib
lake build # checks every proof
To depend on it, add to your lakefile.toml, with a lean-toolchain matching the library’s:
[[require]]
name = "MathFin"
git = "https://github.com/formal-applied-math/formal-mathfin"
rev = "v2.1.0"
and import MathFin. scripts/reproduce.sh reproduces a release’s claims
from its tag; docs/README.md indexes the rest of the documentation.
Contributors
Raphael Coelho maintains the library, with contributions from:
- Granville Gu: the Heston characteristic function and its stochastic integration foundations.
- Godstime Aburu: the issue-label taxonomy.
- Adam Benenson: the CRR cash-or-nothing call price limit.
- Alfredo Garcia: Glosten–Milgrom adverse selection, a drift term
in the Itô-process price and the CIR bond loadings.
- Robert Martin: log-convexity of the American put exercise
boundary, and the SVI polynomial-sign certificate, ported from his
AmericanPutConvexity and
ButterflyFreeSVI.
- Anoop R. Menon: Doob’s Lᵖ maximal inequality for
right-continuous submartingales, ported from his
MindFormal.
- Aleksey Salkutsan: forward rate agreements and downside
performance metrics.
- Mert Unsal: the Black–Scholes charm.
- WorldianAI: the Ho–Lee bond price, the security policy and the
pin-bump policy.
- Yang Ye, much of whose work mirrors QuantLib’s pricing engines
in Lean and proves the limits and special cases the code handles by hand: the integrated
Itô–drift identity, Hull–White calibration, a Monte Carlo pricer, Cox credit, CMS rates and
curve bootstrapping; the bivariate normal CDF, the Schwartz futures price, CVA, inflation, the
LHP tranche loss, calendar arbitrage, joint elicitability, CreditMetrics, SA-CCR, two-asset
options and DeFi lending and AMM mechanics; trinomial and willow lattices, arbitrage-free
interpolation of call quotes, natural cubic splines, FX smile quotes, SABR chain-rule Greeks,
the continuous lookback and the shout floor, Marchenko–Pastur edges and historical VaR for
concentrated liquidity; the Bachelier spread call, the Nelson–Siegel–Svensson decay limit, the
backward-looking caplet, the lognormal volatility swap, the Jarrow–Yildirim inflation caplet and
year-on-year forward, the average-strike Asian conditioning bound, the Heston transform at
maturity and the Broadie–Glasserman–Kou barrier shift for discrete monitoring; the forward-start
call, the strict American put premium, contango and basis convergence, the Balancer
constant-mean pool, the numéraire density as a Radon–Nikodym derivative and the Ho–Lee limit of
Vasicek.
- Adam Kiezun: whole-life insurance on the survival function, the
life table, two-life annuities, Thiele’s reserve equation, Bühlmann credibility, sampled stopping
rules, CDS recovery timing, the stop-loss recursion, discrete Almgren–Chriss liquidation, and
the chain ladder with its exact rational evaluation.
Each module’s header names its authors.
Citation and acknowledgements
Cite the library paper, arXiv:2606.01356, or the software
through the Zenodo DOI 10.5281/zenodo.20477781, which
resolves to the latest release; both are in CITATION.cff.
The library depends on Mathlib and on BrownianMotion, the formalization of Brownian motion and
stochastic integration led by Rémy Degenne. The stochastic-processes part of the corpus follows
Yuri F. Saporito’s Stochastic Processes. The contract language takes its design ideas, but no
code, from Paul Bilokon’s The Contract Is Not the Model (2026), and the survival models draw on
Yosuke Ito’s Archive of Formal Proofs entry on actuarial mathematics
(docs/sources.md).
Apache 2.0. See LICENSE.
评论