MathFin

Mathematical finance, machine-checked.

A Lean 4 library on Mathlib and Rémy Degenne's BrownianMotion: stochastic calculus, arbitrage and pricing, term structure and credit, portfolios and risk, each statement checked by Lean's kernel. There is no sorry, and every theorem the corpus cites is pinned, by the build, to Lean's three standard axioms (propext, Classical.choice, Quot.sound).

Learn

Start from the landmark results, then read a section and its module pages, where each statement is shown as Lean elaborates it. The beginners' manual teaches Lean through the library, and worked examples use it.

Build

Depend on it from a Lean project with a [[require]] entry for https://github.com/formal-applied-math/formal-mathfin pinned to a release tag; the README has the lines. To add a theorem, read CONTRIBUTING and the onboarding guide, or use the search above.

Research

The blueprint lists what is proved and what is stated and open; the program tree shows where a new result would attach. The open-problem catalogue lists questions in the field.
787
modules
7,500
public declarations · 6,114 theorems
906
corpus entries · 884 delivery-ready
180
blueprint results proved · 115 on the frontier
0
sorry · axioms pinned

The map

Each disc is a cell of the taxonomy (docs/taxonomy.toml), sized by its declarations: probability and statistics at the centre, positions and markets around them, valuation, choice and risk outside. An arrow runs from a cell to one that builds on it, thicker the more of its modules are imported. Hover to see a cell's neighbours, click to open it.

Probability and statisticsPositions and marketsValuation, choice and risk
Table view
CellLayerModulesDeclarationsCorpus entries
Valuation · American options and optimal stoppingValuation, choice and risk177131025
Probability · Brownian calculusProbability and statistics108120072
Valuation · Black–Scholes and BachelierValuation, choice and risk67547125
Valuation · Interest ratesValuation, choice and risk5453997
Valuation · The smileValuation, choice and risk5441621
Positions and marketsPositions and markets2733837
Valuation · TreesValuation, choice and risk2433137
Valuation · Jump modelsValuation, choice and risk2329778
Valuation · Volatility modelsValuation, choice and risk1118715
Probability · Gaussian analysisProbability and statistics121756
Probability · Continuous martingalesProbability and statistics171584
Risk · Value at risk and expected shortfallValuation, choice and risk1615538
Choice · Portfolio choiceValuation, choice and risk1813832
StatisticsProbability and statistics1213621
Valuation · Static replication and model-free boundsValuation, choice and risk2113432
Probability · DependenceProbability and statistics713318
Valuation · CreditValuation, choice and risk1312822
Valuation · Life contingenciesValuation, choice and risk812421
Risk · Risk measuresValuation, choice and risk1112429
Probability · LawsProbability and statistics912015
Choice · Market microstructureValuation, choice and risk811911
Probability · JumpsProbability and statistics1511715
Valuation · Arbitrage pricingValuation, choice and risk138714
Risk · Credit portfolio riskValuation, choice and risk108418
Probability · Discrete timeProbability and statistics13819
Probability · Analysis and convexityProbability and statistics12754
Risk · Aggregation and diversificationValuation, choice and risk75513
Valuation · Forwards, FX and commoditiesValuation, choice and risk74817
Choice · PreferencesValuation, choice and risk3425
Choice · Dynamic choiceValuation, choice and risk2348
Risk · ExposureValuation, choice and risk3306
Choice · EquilibriumValuation, choice and risk3226
Risk · Collective risk theoryValuation, choice and risk2164

Landmarks

The proved results on the blueprint that the most other results build on.

Compound Poisson moment generating function

For i.i.d.
17 results build on it · Probability.Jumps.CompoundPoissonMGF

Itô's formula

For an Itô process $X = x_0 + \int b\,ds + \int \sigma\,dB$ with adapted continuous coefficients (no boundedness) and $f(t,x)$ with jointly continuous $f_t$, $f_x$, $f_{xx}$, almost surely for every $t \in [0,T]$ at once…
17 results build on it · Probability.Brownian.Ito.ItoFormulaAdaptedProcess

Girsanov's theorem

For bounded predictable $\theta$ and a horizon $T$, under $Q = Z_T\,\mu$ with $Z_T = \exp(-\int_0^T\theta\,dB - \tfrac12\int_0^T\theta^2\,dt)$, the process $B^\theta$, a modification of $B + \int_0^{\cdot\wedge T}\theta\,ds$, is a…
16 results build on it · Probability.Brownian.Girsanov.GirsanovFiltered

Carr–Madan spanning identity

A payoff $f$ twice differentiable on $[L,U]$ with continuous $f''$ decomposes, at every spot in $[L,U]$, as cash, a forward, and a static book of OTM options on the strikes in $[L,U]$ weighted by its convexity $f''$ — one integration by…
14 results build on it · Models.ModelFree.CarrMadan

Quantile transform and probability integral transform

For a probability measure $\mu$ on $\mathbb{R}$ the quantile function pushes the uniform law on $(0,1)$ to $\mu$.
13 results build on it · Probability.Laws.Quantile

Martingale transform

For a martingale $M$ and a bounded predictable $A$ on a finite measure space, $(A \cdot M)_n = \sum_{k<n} \langle A_{k+1}, M_{k+1} - M_k \rangle$ is a martingale: the discrete stochastic integral, and the gains process of a trading…
13 results build on it · Probability.Discrete.MartingaleTransform

Black–Scholes pricing under the physical measure

For the physical asset $S_u = S_0 e^{(m-\sigma^2/2)u + \sigma W_u}$ and the constant market price of risk $\theta = (m-r)/\sigma$, under the horizon-$H$ Girsanov measure every fixed-dated contract observed in $[0,H]$ has the same value on…
12 results build on it · Models.BlackScholes.BlackScholesPhysical

The Black–Scholes price of a call in the Black–Scholes market

In the Black–Scholes market of a pre-Brownian motion $W$ with $S_0, K, \sigma, T > 0$, the European call struck at $K$ with maturity $T$ is worth $S_0\Phi(d_1) - Ke^{-rT}\Phi(d_2)$ under the Girsanov pricing measure of the market price of…
11 results build on it · Models.BlackScholes.Market

Existence and uniqueness of solutions of Lipschitz SDEs

For Lipschitz $b$, $\sigma$, any horizon $T$ and any initial value in the predictable $L^2$ space $E$ on $[0,T]$, the Picard map of $dX = b(X)dt + \sigma(X)dB$ has exactly one fixed point in $E$, with no smallness condition: its $n$-th…
9 results build on it · Probability.Brownian.SDE.SDEExistence

Stochastic Fubini theorem for the Itô integral

Let $I_T$ be the Itô integral on $[0,T]$, a linear isometry out of $L^2$ of the predictable measure.
8 results build on it · Probability.Brownian.Ito.StochasticFubiniIto

Carr–Madan replication in a market

In a market with unit numéraire, let $Q$ be a pricing measure up to $T$ under which $S_T \in [L,U]$ almost surely.
8 results build on it · Models.ModelFree.CarrMadanMarket

The one-date market and its pricing measures

The market with one asset, quoted at $s_0e^{rt}$ before a date $\tau$ and at a random value $X$ from $\tau$ on, with the money market $e^{rt}$ as numéraire and no information before $\tau$, is priced up to $\tau$ by every probability…
8 results build on it · Pricing.OneDateMarket

Cells

Valuation · American options and optimal stopping

early exercise as optimal stopping: the Snell envelope in trees, the American put and its free boundary
177 modules · 1310 declarations · 25 entries

Probability · Brownian calculus

integration against Brownian motion: the Itô integral and formula, Girsanov, martingale representation, Feynman–Kac, SDEs
108 modules · 1200 declarations · 72 entries

Valuation · Black–Scholes and Bachelier

the Gaussian diffusion models: the market and its pricing measure, formula, PDE, Greeks, hedging, exotics
67 modules · 547 declarations · 125 entries

Valuation · Interest rates

bonds and curves, durations, short-rate and affine models, HJM, forward measures, caps
54 modules · 539 declarations · 97 entries

Valuation · The smile

call prices across strikes and their static no-arbitrage: Roper's theorem, implied volatility, SVI
54 modules · 416 declarations · 21 entries

Positions and markets

payoffs and contracts, the market and its numéraire, strategies and their gains, value under a measure, and the fundamental theorems: no arbitrage is the existence of an equivalent martingale measure
27 modules · 338 declarations · 37 entries

Valuation · Trees

one-period, binomial and trinomial markets, replication, CRR and its Black–Scholes limit
24 modules · 331 declarations · 37 entries

Valuation · Jump models

Merton and general jump diffusions, the Esscher measure, variance swaps with jumps
23 modules · 297 declarations · 78 entries

Valuation · Volatility models

local and stochastic volatility: Dupire, Heston, SABR, time-dependent volatility
11 modules · 187 declarations · 15 entries

Probability · Gaussian analysis

Φ and its moments, the bivariate normal, the heat kernel
12 modules · 175 declarations · 6 entries

Probability · Continuous martingales

changes of measure, localisation, brackets, convergence, stopped and time-changed processes; no semimartingale integral yet
17 modules · 158 declarations · 4 entries

Risk · Value at risk and expected shortfall

the quantile measures, their dual forms and closed forms under standard laws
16 modules · 155 declarations · 38 entries

Choice · Portfolio choice

mean–variance, the efficient frontier, risk parity, Black–Litterman
18 modules · 138 declarations · 32 entries

Statistics

estimation, empirical laws, performance statistics, backtesting: what every question consumes
12 modules · 136 declarations · 21 entries

Valuation · Static replication and model-free bounds

Carr–Madan spanning, price bounds, variance swaps, liquidity-pool positions as option portfolios
21 modules · 134 declarations · 32 entries

Probability · Dependence

copulas, Sklar's theorem, Hoeffding's covariance identity
7 modules · 133 declarations · 18 entries

Valuation · Credit

structural and intensity models of default, CDS, counterparty valuation
13 modules · 128 declarations · 22 entries

Valuation · Life contingencies

survival models, annuities and life insurances valued as contracts, reserves
8 modules · 124 declarations · 21 entries

Risk · Risk measures

acceptance sets, coherent and convex measures and their representation, elicitability
11 modules · 124 declarations · 29 entries

Probability · Laws

quantiles, the exponential tilt, Student-t, extreme-value and Pareto laws
9 modules · 120 declarations · 15 entries

Choice · Market microstructure

price formation under asymmetric information, market making, price impact, optimal execution
8 modules · 119 declarations · 11 entries

Probability · Jumps

Poisson processes and random measures, the compensated integral, compound Poisson laws
15 modules · 117 declarations · 15 entries

Valuation · Arbitrage pricing

what no arbitrage fixes: state prices and the pricing kernel, replication and completeness, superhedging duality, parity, the American price
13 modules · 87 declarations · 14 entries

Risk · Credit portfolio risk

default correlation, the large-pool limit, IRB capital, tranche losses, protocol liquidations
10 modules · 84 declarations · 18 entries

Probability · Discrete time

martingale transforms, Doob decomposition, the Snell envelope, path measures, Markov chains
13 modules · 81 declarations · 9 entries

Probability · Analysis and convexity

separation and convex duality, isometries, bisection, the inequalities the limbs share
12 modules · 75 declarations · 4 entries

Risk · Aggregation and diversification

dependence and diversification, its failure, risk contributions, concentration
7 modules · 55 declarations · 13 entries

Valuation · Forwards, FX and commodities

forward and futures prices, interest-rate parity, storage and convenience yield, Black-76
7 modules · 48 declarations · 17 entries

Choice · Preferences

expected utility and risk aversion
3 modules · 42 declarations · 5 entries

Choice · Dynamic choice

growth-optimal and log-utility investment, Merton's problem, time consistency
2 modules · 34 declarations · 8 entries

Risk · Exposure

counterparty exposure profiles and their regulatory measures
3 modules · 30 declarations · 6 entries

Choice · Equilibrium

CAPM, factor models, the stochastic discount factor
3 modules · 22 declarations · 6 entries

Risk · Collective risk theory

premium principles as risk-loaded functionals, the compound claims process, ruin
2 modules · 16 declarations · 4 entries