Skip to main content

Can a Computer Check Your Proof? Lean for Financial Economists

AI
LLM
Lean
Research
Author

Vincent Grégoire, PhD, CFA

Published

November 28, 2026

If you follow mathematicians online, you have probably noticed that the past two years have been strange ones. AI models went from failing at high-school olympiad problems to reaching gold-medal scores, solving open problems that had been sitting on lists for decades, and producing proofs so long that no human could reasonably check them. Running through almost every one of these stories is a programming language and theorem prover most finance researchers have never heard of: Lean.

I have been playing with Lean for a few months now, mostly to check the derivations in my own theory work. In this post, I want to explain what the fuss is about, what Lean and formal verification actually are, and how they could be useful for finance research. I then walk through a concrete example, a machine-checked proof of the classic Kyle (1985) equilibrium, before discussing what is (still) missing for this to become a standard tool in our field.

Companion video

This post has a companion video on YouTube.

AI, math, and the race to prove things

Here is a quick (and very incomplete) tour of what happened.

The first big moment came in July 2024, when Google DeepMind’s AlphaProof and AlphaGeometry 2 reached silver-medal level at the International Mathematical Olympiad (IMO), with AlphaProof working entirely in Lean on problems translated by hand. At IMO 2025, an experimental OpenAI model and Gemini Deep Think both reached gold-medal level with proofs in plain English graded by humans, and Harmonic’s Aristotle matched them with proofs verified in Lean.

Olympiad problems are hard, but they are not research, and the move to research mathematics was messier. In October 2025, an OpenAI executive claimed that GPT-5 had solved 10 open Erdős problems, and Thomas Bloom, who maintains the Erdős problems database, called it a dramatic misrepresentation: the model had found existing solutions in the literature that the database had missed. Within a few months, however, AI systems did produce genuine solutions to some Erdős problems, several of them checked in Lean.

Then things accelerated. In early 2026, Donald Knuth published Claude’s Cycles, a note on an open graph decomposition problem that Claude Opus 4.6 solved for odd sizes (Kim Morrison then formalized the proof in Lean). Math Inc’s Gauss agent, after formalizing the strong Prime Number Theorem in about three weeks, completed the formalization of sphere packing in dimensions 8 and 24. In July, Levent Alpöge announced a counterexample to the Jacobian conjecture in dimension 3, found with help from Claude Fable and checked in Lean and Isabelle (another theorem prover) the same day. In August, OpenAI released ten new results, each with a Lean certificate, and in September, Anthropic announced that Claude had formalized Fermat’s Last Theorem in Lean in 11 days, a goal toward which Kevin Buzzard had started a project in 2024, with five years of funding just to reduce the theorem to results known in the 1980s. His reaction is worth reading in full.1

The biggest news came in November. On November 20, Alpöge released a proof of the Riemann hypothesis, developed with an unreleased Claude model as a Lean library of about 17 million lines, which the Lean FRO and the Mathlib Initiative certified the next day. On November 20 as well, Alpöge and Tristan Buckmaster claimed that the Navier–Stokes equations can blow up in finite time without any external force. If you heard that OpenAI “solved” Navier–Stokes in September, this is a different and stronger claim. The Clay Millennium Prize problem can be settled in the negative by a solution that blows up under a smooth external force, and that is what OpenAI announced in September (it said it would not claim the prize). Many experts, however, saw that force as a loophole: it is finely tuned to stir the fluid in just the right way, and nothing like it acts on a real fluid. The unforced case, the one mathematicians actually care about, remained open, and that is the case Alpöge and Buckmaster claim to have closed. Both claims come with Lean formalizations, but as of this writing neither has been independently verified, and the numerical certificate that the Alpöge–Buckmaster proof relies on has not been released yet. The Riemann hypothesis proof shows what Lean does and does not give you: the community confirmed within a day that the proof is correct, but no complete human-readable account of it has been published, and mathematicians do not yet understand why it works.

Notice the pattern. When an AI writes a proof in English, someone has to read it: when prominent mathematicians set up the First Proof challenge in early 2026 to test AI on unpublished research-level lemmas, the answers had to be graded by human experts, and that reading is now the bottleneck. When an AI writes a proof in Lean, whether it is correct is answered by a program. That is why Lean keeps showing up in these stories. As AI makes proofs cheap to produce, verifying them becomes the scarce resource, and Lean makes verifying (almost) free.

What is Lean?

Lean is two things at once: a functional programming language and a proof assistant. It was started by Leonardo de Moura at Microsoft Research in 2013 and is now developed by the Lean Focused Research Organization, a non-profit. The current version is Lean 4.

The proof assistant part is what matters here. In Lean, you write a mathematical statement as a precise, typed expression, and then you write a proof of that statement, step by step, using commands called tactics (ring to close an algebraic identity, linarith to combine linear inequalities, field_simp to clear denominators, and so on). Lean checks every step. If the proof is complete and correct, the file compiles. If there is a gap or an unjustified step, Lean tells you.

If you are an empirical researcher, the closest analogy I can give you is unit tests. A unit test checks that your code returns the right answer for a few inputs you chose. A Lean proof checks that a statement holds for every possible input, with no exceptions. It is a unit test that covers the entire input space.

The other key ingredient is Mathlib, a community-built library of formalized mathematics. It contains close to 300,000 theorems (it passed two million lines of code in late 2025), covering most of undergraduate mathematics and large parts of graduate algebra, analysis, topology, measure theory, and probability. When you prove something in Lean, you are not starting from the axioms: you are building on Mathlib, the same way a Python data pipeline builds on pandas.

What is formal verification?

Formal verification is the general idea of proving, with a computer, that something (a theorem, a program, a chip design) satisfies a precise specification. It has a long history in computer science, where it is used to verify compilers, operating system kernels, and cryptographic code. Lean is one tool for it; others include Coq/Rocq and Isabelle.

The important thing to understand is what a formal proof does and does not guarantee. Lean’s guarantees rest on a small kernel, a few thousand lines of code that check every proof against a handful of logical axioms. You do not have to trust the tactics, the AI that wrote the proof, or the person who submitted it. You only have to trust the kernel (which is small and heavily scrutinized) and, crucially, the statement of the theorem.

That last part is the catch. Lean will tell you, with near certainty, that your proof proves your statement. It will not tell you whether your statement is the one you meant. If you formalize the wrong model, or add a hypothesis that quietly assumes away the hard part, Lean will happily certify a correct proof of something useless. This is not a hypothetical concern: in the community discussion around the AI-generated Prime Number Theorem formalization, the team behind it explained that some intermediate statements were formalized incorrectly along the way, and that human supervision was needed to catch them. So formal verification does not remove the need to read. It moves the reading from hundreds of lines of proof to a few lines of statement.

Why should financial economists care?

Most of finance theory is not deep mathematics by the standards of number theorists. It is, however, full of derivations: first-order conditions, fixed points, comparative statics, closed-form solutions that run over several pages of an appendix. Authors, co-authors, and referees do check them, but checking a full derivation line by line is tedious, time-consuming, and hard to do well. Papers often skip steps, so verifying a result can mean redoing much of the algebra yourself, and not every referee has the time to do that for every proposition. Some mistakes are also hard to spot even for a careful reader: a sign that flips halfway through, a second-order condition that only holds for some parameter values, a division by something that could be zero. They are harder still for the author, who already knows what the answer is supposed to be.

AI makes this problem worse and better at the same time. Worse, because as I described in my Vibe Research posts, models are now very good at producing derivations, and they produce them faster than I can read them. When Fable found closed-form solutions to propositions in one of my papers that I had only solved numerically, it was exciting, but it also left me with several pages of new derivations to check. Better, because the same models are now good enough at Lean to write the formal proof for you. The workflow becomes: the AI writes the derivation, the AI writes the Lean proof, Lean checks it, and you read the statements.

This is what I did for my AGI investment paper: it now has a Lean package that machine-checks the closed forms, first-order conditions, and comparative statics in the paper. I now do the same for new derivations in my other projects.

I wouldn’t be surprised if publishing a Lean package with a paper becomes the norm (or a journal requirement), just like sharing code is.

Example: proving Kyle (1985) in Lean

To make this concrete, let’s prove the main result of Kyle (1985), one of the most famous models in market microstructure. I use the one-period version.

The model

A risky asset has value v \sim N(p_0, \Sigma_0). An insider observes v and submits a market order x. Noise traders submit an order u \sim N(0, \sigma_u^2), independent of v. A competitive market maker observes only the total order flow y = x + u and sets the price equal to the conditional expectation of the value, p = E[v \mid y].

Kyle looks for a linear equilibrium, in which the insider trades x = \beta (v - p_0) and the market maker sets p = p_0 + \lambda y. The equilibrium is:

\beta = \sqrt{\frac{\sigma_u^2}{\Sigma_0}}, \qquad \lambda = \frac{1}{2}\sqrt{\frac{\Sigma_0}{\sigma_u^2}}.

The proof has three steps:

  1. Insider. Given \lambda > 0, the insider maximizes expected profit E[(v - p)x \mid v] = (v - p_0 - \lambda x)x (noise trading has mean zero), so x = (v - p_0)/(2\lambda), i.e., \beta = 1/(2\lambda).
  2. Market maker. Given \beta, v and y are jointly normal, so E[v \mid y] is linear in y with slope \lambda = \text{Cov}(v, y)/\text{Var}(y) = \beta\Sigma_0/(\beta^2\Sigma_0 + \sigma_u^2).
  3. Fixed point. Solve the two equations together.

As corollaries, half of the insider’s private information is incorporated into the price (the posterior variance is \Sigma_0/2), and the insider’s expected profit is \frac{1}{2}\sigma_u\sqrt{\Sigma_0}.

The Lean proof

I asked Claude Code to write the proof in Lean 4 with Mathlib. The full file is about 310 lines and you can download it here, along with the lakefile.toml, lean-toolchain, and lake-manifest.json needed to build it (or grab all four in a single zip file). Let’s go through the main pieces.

If you want to follow along on your own computer, the recommended way to install Lean is through VS Code and its Lean 4 extension, which walks you through the rest of the setup (see the official install guide); the commands to build the project are at the end of this example.

Step 1: the insider. We define the insider’s expected profit as a function of the price impact lam2, the value surprise d = v - p_0, and the order x, and prove that trading d / (2 * lam) beats any other order:

def profit (lam d x : ℝ) : ℝ := (d - lam * x) * x

theorem insider_best_response {lam : ℝ} (hlam : 0 < lam) (d x : ℝ) :
    profit lam d x ≤ profit lam d (d / (2 * lam)) := by
  -- Complete the square
  have key : profit lam d (d / (2 * lam)) - profit lam d x
      = lam * (x - d / (2 * lam)) ^ 2 := by
    unfold profit
    field_simp
    ring
  -- The difference is lam times a square, so it cannot be negative
  nlinarith [mul_nonneg hlam.le (sq_nonneg (x - d / (2 * lam)))]
1
def defines a function. profit takes three real numbers (ℝ is the set of real numbers) and returns a real number. The formula after := is the insider’s expected profit, (d - \lambda x)x.
2
theorem introduces a statement that Lean will check, here named insider_best_response. Each term in brackets is an input. (d x : ℝ) are two real numbers. (hlam : 0 < lam) is a hypothesis: a proof that \lambda > 0, which we can use in the proof. Curly braces mean Lean works out lam on its own from the other inputs.
3
The statement itself, after the colon: profit at any x is at most profit at d / (2 * lam). The := by that follows starts the proof, written as a sequence of tactics. Lines starting with --, like the next one, are comments.
4
have states an intermediate result, named key: the difference between the two profits is \lambda(x - d/(2\lambda))^2. This is the “complete the square” step you would write on paper.
5
Three tactics prove key. unfold replaces profit with its definition, field_simp clears the denominators (it needs \lambda \neq 0, which follows from hlam), and ring checks that the two sides are the same polynomial.
6
nlinarith (nonlinear arithmetic) proves the main statement. It is given one hint: \lambda times a square is non-negative. Combined with key, that is all it needs.

Let d = v - p_0 and \pi(x) = (d - \lambda x)x.

Statement. If \lambda > 0, then for all d, x \in \mathbb{R},

\pi(x) \le \pi\left(\frac{d}{2\lambda}\right).

Proof. At the candidate optimum, \pi\left(\frac{d}{2\lambda}\right) = \left(d - \frac{d}{2}\right)\frac{d}{2\lambda} = \frac{d^2}{4\lambda}. Completing the square,

\begin{aligned} \pi\left(\frac{d}{2\lambda}\right) - \pi(x) &= \frac{d^2}{4\lambda} - dx + \lambda x^2 \\ &= \lambda\left(x - \frac{d}{2\lambda}\right)^2 \ge 0. \end{aligned}

The equality is key in the Lean proof, and the inequality is the hint given to nlinarith.

Apart from the notation, the statement reads like math, and the proof follows the argument you would write on paper. The file also proves that this best response is unique, and that profit is indeed the expectation over noise trading of (v - p)x.

We can now say what it means for the insider’s strategy to be optimal, and show that this is the case exactly when \lambda > 0 (the second-order condition) and \beta = 1/(2\lambda) (the first-order condition):

def InsiderOptimal (β lam : ℝ) : Prop :=
  ∀ d x, profit lam d x ≤ profit lam d (β * d)

theorem insider_condition (β lam : ℝ) :
    InsiderOptimal β lam ↔ 0 < lam ∧ β = 1 / (2 * lam) := by
  constructor
  -- (⇒) Optimality implies the two conditions
  · intro h
    have hlam : 0 < lam := by
      have h0 := h 0 1
      have h1 := h 1 (β + 1)
      unfold profit at h0 h1
      by_contra hneg
      have hzero : lam = 0 := by linarith
      rw [hzero] at h1
      linarith
    have hβ := insider_best_response_unique hlam 1 (β * 1) (h 1 _)
    rw [mul_one] at hβ
    exact ⟨hlam, hβ⟩
  -- (⇐) The two conditions imply optimality
  · rintro ⟨hlam, hβ⟩ d x
    have hd : β * d = d / (2 * lam) := by
      rw [hβ]
      ring
    rw [hd]
    exact insider_best_response hlam d x
1
This definition returns a Prop (a proposition, a statement that is either true or false) rather than a number. It says that trading β * d is at least as good as any other order x, for any value surprise d. ∀ means “for all”.
2
The statement: ↔︎ means “if and only if” and ∧ means “and”.
3
constructor splits the “if and only if” into two goals, one for each direction. Each · below starts the proof of one of them.
4
intro assumes the left-hand side, that the strategy is optimal, and names this assumption h.
5
Since h holds for any d and x, we can plug in the values we want. With d = 0 and x = 1, we get h0, which simplifies to \lambda \ge 0. With d = 1 and x = \beta + 1, we get h1. at means that the tactic is applied to these hypotheses instead of the goal.
6
A proof by contradiction: suppose that \lambda is not positive. Given h0, it has to be 0, but then h1 says \beta + 1 \le \beta, which is false.
7
Now that we know that \lambda > 0, we can use the uniqueness of the best response: for d = 1, the order \beta \times 1 has to be equal to 1/(2\lambda). rw (rewrite) then replaces \beta \times 1 with \beta.
8
exact closes the goal with a proof we already have. Here the goal has two parts joined by “and”, so we give it a pair of proofs, written ⟨_, _⟩.
9
The other direction. rintro assumes the right-hand side, splits it into its two parts, hlam and hβ, and picks an arbitrary d and x.
10
An intermediate result: \beta d is the best response d/(2\lambda).
11
Replace \beta d with the best response, and apply the theorem we proved above.

Definition. The strategy x = \beta d is optimal if, for all d, x \in \mathbb{R}, \pi(x) \le \pi(\beta d), where \pi(x) = (d - \lambda x)x.

Statement. The strategy is optimal if and only if \lambda > 0 and \beta = \frac{1}{2\lambda}.

Proof (\Rightarrow). With d = 0 and x = 1, optimality says -\lambda \le 0. If \lambda = 0, then with d = 1 and x = \beta + 1, optimality says \beta + 1 \le \beta, a contradiction. So \lambda > 0. The best response is then unique and, for d = 1, it is equal to \frac{1}{2\lambda}, so \beta = \frac{1}{2\lambda}.

Proof (\Leftarrow). If \lambda > 0 and \beta = \frac{1}{2\lambda}, then \beta d = \frac{d}{2\lambda} is the best response for any d.

Step 2: the market maker, with actual random variables. Step 1 is pure algebra, and step 3 will be too. For step 2, I wanted to use real probability theory, so the order flow is a random variable on a probability space and the moments come from Mathlib’s covariance and variance library. The file proves that when u is independent of v and both have finite variance, the order flow y = β (v - p₀) + u satisfies \text{Cov}(v, y) = \beta\,\text{Var}(v) and \text{Var}(y) = \beta^2\text{Var}(v) + \text{Var}(u):

theorem orderflow_moments {v u : Ω → ℝ} (hv : MemLp v 2 P) (hu : MemLp u 2 P)
    (hind : IndepFun v u P) (p₀ β : ℝ) :
    cov[v, fun ω ↦ β * (v ω - p₀) + u ω; P] = β * Var[v; P] ∧
    Var[fun ω ↦ β * (v ω - p₀) + u ω; P] = β ^ 2 * Var[v; P] + Var[u; P] := by
  -- Preliminaries
  have hd : MemLp (fun ω ↦ β * (v ω - p₀)) 2 P :=
    (hv.sub (memLp_const p₀)).const_mul β
  have hcov_vu : cov[v, u; P] = 0 := hind.covariance_eq_zero hv hu
  have hcov_d : ∀ X : Ω → ℝ, MemLp X 2 P →
      cov[fun ω ↦ β * (v ω - p₀), X; P] = β * cov[v, X; P] := by
    intro X hX
    rw [covariance_const_mul_left,
      covariance_sub_const_left (hv.integrable one_le_two)]
  have hy : (fun ω ↦ β * (v ω - p₀) + u ω) = (fun ω ↦ β * (v ω - p₀)) + u := rfl
  constructor
  -- Cov(v, y) = β Var(v)
  · rw [hy, covariance_add_right hv hd hu, covariance_comm, hcov_d v hv,
      covariance_self hv.aemeasurable, hcov_vu]
    ring
  -- Var(y) = β² Var(v) + Var(u)
  · rw [variance_fun_add hd hu, hcov_d u hu, hcov_vu,
      ← covariance_self hd.aemeasurable, hcov_d _ hd, covariance_comm,
      hcov_d v hv, covariance_self hv.aemeasurable]
    ring
1
v u : Ω → ℝ says that v and u are functions from the sample space Ω to the real numbers. This is the textbook definition of a random variable (the textbook also asks for measurability, which MemLp takes care of here). Ω and the probability measure P are declared once at the top of the file. MemLp v 2 P means that v has a finite second moment under P.
2
IndepFun v u P means that v and u are independent under P. The price p₀ and the intensity β are ordinary numbers.
3
cov[X, Y; P] is Mathlib’s notation for the covariance of X and Y under P. fun ω ↦ β * (v ω - p₀) + u ω is an anonymous function: the order flow y, built from v and u outcome by outcome. This line says \text{Cov}(v, y) = \beta\,\text{Var}(v).
4
Var[X; P] is the variance. This line says \text{Var}(y) = \beta^2\text{Var}(v) + \text{Var}(u).
5
A technical step: \beta(v - p_0) has a finite second moment, because subtracting a constant and multiplying by a constant preserve that property.
6
Independence implies \text{Cov}(v, u) = 0. This is a Mathlib theorem applied to our hypotheses.
7
An intermediate result: for any random variable X with a finite second moment, \text{Cov}(\beta(v - p_0), X) = \beta\,\text{Cov}(v, X). → means “implies”. intro picks an arbitrary X, and rw transforms the goal using two Mathlib theorems (constants factor out of a covariance, and subtracting a constant does not change it).
8
Writes the order flow as the sum of two random variables, which is the form Mathlib’s theorem on the covariance of a sum expects. rfl (reflexivity) says that both sides are the same by definition.
9
The goal has two parts joined by “and”, and constructor splits them.
10
A chain of rewrites, applied in order: write the order flow as a sum, split the covariance of the sum, swap the arguments of the first covariance, factor out \beta, replace \text{Cov}(v, v) with \text{Var}(v), and replace \text{Cov}(v, u) with 0.
11
What is left is \beta\,\text{Var}(v) + 0 = \beta\,\text{Var}(v), which ring proves.
12
Same idea: expand the variance of the sum, then show that the covariance term is zero. The ← applies a theorem from right to left, here to write \text{Var}(\beta(v - p_0)) as the covariance of \beta(v - p_0) with itself, so that \beta can be factored out twice.
13
What is left is \beta(\beta\,\text{Var}(v)) + 2(\beta \cdot 0) + \text{Var}(u) = \beta^2\,\text{Var}(v) + \text{Var}(u).

Statement. Let v and u be independent random variables with finite second moments, and let y = \beta(v - p_0) + u for constants p_0 and \beta. Then

\text{Cov}(v, y) = \beta\,\text{Var}(v), \qquad \text{Var}(y) = \beta^2\,\text{Var}(v) + \text{Var}(u).

Proof. Independence implies \text{Cov}(v, u) = 0. Since covariance is bilinear and the constant p_0 drops out,

\begin{aligned} \text{Cov}(v, y) &= \text{Cov}(v, \beta(v - p_0)) + \text{Cov}(v, u) \\ &= \beta\,\text{Cov}(v, v) + 0 \\ &= \beta\,\text{Var}(v), \end{aligned}

and

\begin{aligned} \text{Var}(y) &= \text{Var}(\beta(v - p_0)) + 2\,\text{Cov}(\beta(v - p_0), u) + \text{Var}(u) \\ &= \beta^2\,\text{Var}(v) + 2\beta\,\text{Cov}(v, u) + \text{Var}(u) \\ &= \beta^2\,\text{Var}(v) + \text{Var}(u). \end{aligned}

The market maker sets the price equal to E[v \mid y], and because everything is Gaussian, this conditional expectation is linear in y. That result is in every graduate textbook, but I could not find it in Mathlib (more on this below), so we have to prove it. The trick is to look at the regression residual R = v - ky, with k = \text{Cov}(v, y)/\text{Var}(y). It is uncorrelated with y and, with Gaussian variables, uncorrelated means independent:

abbrev info (y : Ω → ℝ) : MeasurableSpace Ω :=
  MeasurableSpace.comap y inferInstance

theorem gaussian_conditioning {v y : Ω → ℝ} (hvm : Measurable v)
    (hym : Measurable y) (hG : HasGaussianLaw (fun ω ↦ (v ω, y ω)) P)
    (hy : Var[y; P] ≠ 0) :
    P[v | info y] =ᵐ[P]
      fun ω ↦ P[v] + cov[v, y; P] / Var[y; P] * (y ω - P[y]) := by
  -- Define the regression residual R = v - k y
  set k := cov[v, y; P] / Var[y; P] with hk
  set R : Ω → ℝ := fun ω ↦ v ω - k * y ω with hR
  have hv2 : MemLp v 2 P := hG.fst.memLp_two
  have hky2 : MemLp (fun ω ↦ k * y ω) 2 P := hG.snd.memLp_two.const_mul k
  have hvi : Integrable v P := hv2.integrable one_le_two
  have hkyi : Integrable (fun ω ↦ k * y ω) P := hky2.integrable one_le_two
  have hRi : Integrable R P := hvi.sub hkyi
  -- R and y are jointly Gaussian and uncorrelated, so they are independent
  have hRy : HasGaussianLaw (fun ω ↦ (R ω, y ω)) P := by
    let L : ℝ × ℝ →L[ℝ] ℝ × ℝ :=
      (ContinuousLinearMap.fst ℝ ℝ ℝ - k • ContinuousLinearMap.snd ℝ ℝ ℝ).prod
        (ContinuousLinearMap.snd ℝ ℝ ℝ)
    simpa [L, hR, Function.comp_def] using hG.map L
  have hcov : cov[R, y; P] = 0 := by
    have h : cov[R, y; P] = cov[v, y; P] - cov[fun ω ↦ k * y ω, y; P] :=
      covariance_sub_left hv2 hky2 hG.snd.memLp_two
    rw [h, covariance_const_mul_left, covariance_self hym.aemeasurable, hk]
    field_simp
    ring
  have hind : IndepFun R y P := hRy.indepFun_of_covariance_eq_zero hcov
  -- So E[R | y] = E[R], and E[k y | y] = k y
  have hER : P[R | info y] =ᵐ[P] fun _ ↦ P[R] :=
    condExp_indep_eq (hvm.sub (hym.const_mul k)).comap_le hym.comap_le
      (comap_measurable R).stronglyMeasurable hind
  have hEy : P[fun ω ↦ k * y ω | info y] = fun ω ↦ k * y ω :=
    condExp_of_stronglyMeasurable hym.comap_le
      ((comap_measurable y).const_mul k).stronglyMeasurable hkyi
  -- Add the two pieces: v = R + k y
  have hadd := condExp_add hRi hkyi (info y)
  have hsum : v = R + fun ω ↦ k * y ω := by funext ω; simp [hR]
  have hmean : P[R] = P[v] - k * P[y] := by
    rw [hR, integral_sub hvi hkyi, integral_const_mul]
  rw [← hsum, hEy] at hadd
  filter_upwards [hadd, hER] with ω h1 h2
  rw [h1, Pi.add_apply, h2, hmean]
  ring
1
info y is a shorthand for \sigma(y), the information revealed by observing y (Mathlib calls it MeasurableSpace.comap).
2
The hypotheses: v and y are random variables (Measurable), they are jointly Gaussian, and y is not a constant.
3
The conclusion: E[v \mid y] = E[v] + \frac{\text{Cov}(v, y)}{\text{Var}(y)}(y - E[y]). P[v] is the expectation of v under P, and P[v | info y] is its conditional expectation given y. =ᵐ[P] means “equal almost surely”.
4
set gives a name to the regression coefficient, k, and to the residual, R. The with keeps their definitions at hand, as hk and hR.
5
Housekeeping: Gaussian variables have finite second moments, so all the expectations we need exist.
6
The residual and y are jointly Gaussian, because (R, y) is a linear function of (v, y). L is that linear function, and simpa simplifies both sides until they match.
7
The residual is uncorrelated with y: \text{Cov}(R, y) = \text{Cov}(v, y) - k\,\text{Var}(y) = 0.
8
Jointly Gaussian and uncorrelated implies independent. This is a Mathlib theorem.
9
Independence means that y tells us nothing about the residual: E[R \mid y] = E[R]. This is also a Mathlib theorem.
10
Given y, ky is known: E[ky \mid y] = ky. Another Mathlib theorem.
11
Conditional expectation is linear, and the value is the sum of the two pieces, v = R + ky.
12
The mean of the residual is E[R] = E[v] - kE[y].
13
Combine: E[v \mid y] = E[R \mid y] + ky.
14
filter_upwards takes an outcome ω at which the almost sure equalities hold. We substitute them, and ring checks what is left, E[v] - kE[y] + ky = E[v] + k(y - E[y]).

Statement. If (v, y) is jointly Gaussian and \text{Var}(y) > 0, then

E[v \mid y] = E[v] + \frac{\text{Cov}(v, y)}{\text{Var}(y)}\left(y - E[y]\right).

Proof. Let k = \text{Cov}(v, y)/\text{Var}(y) and R = v - ky. Then

\text{Cov}(R, y) = \text{Cov}(v, y) - k\,\text{Var}(y) = 0.

As a linear function of (v, y), (R, y) is jointly Gaussian, so R and y are independent and E[R \mid y] = E[R]. Since v = R + ky,

\begin{aligned} E[v \mid y] &= E[R \mid y] + E[ky \mid y] \\ &= E[R] + ky \\ &= E[v] - kE[y] + ky \\ &= E[v] + k\left(y - E[y]\right). \end{aligned}

We can now link the price to the market maker’s condition, \lambda = \beta\Sigma_0/(\beta^2\Sigma_0 + \sigma_u^2). The theorem says that the price p_0 + \lambda y is equal to E[v \mid y] if and only if this condition holds:

def zeroProfitPricing (V σ β lam : ℝ) : Prop := lam = β * V / (β ^ 2 * V + σ ^ 2)

theorem market_maker_pricing {v u y : Ω → ℝ} {p₀ β lam : ℝ} {V σ : ℝ≥0}
    (hvm : Measurable v) (hum : Measurable u)
    (hv : HasLaw v (gaussianReal p₀ V) P)
    (hu : HasLaw u (gaussianReal 0 (σ ^ 2)) P)
    (hind : IndepFun v u P) (hσ : 0 < σ)
    (hy : y = fun ω ↦ β * (v ω - p₀) + u ω) :
    P[v | info y] =ᵐ[P] (fun ω ↦ p₀ + lam * y ω) ↔
      zeroProfitPricing V σ β lam := by
  -- Moments of the value, the noise, and the order flow
  have hvg : HasGaussianLaw v P := hv.hasGaussianLaw
  have hug : HasGaussianLaw u P := hu.hasGaussianLaw
  have hEv : P[v] = p₀ := by rw [hv.integral_eq, integral_id_gaussianReal]
  have hEu : P[u] = 0 := by rw [hu.integral_eq, integral_id_gaussianReal]
  have hVv : Var[v; P] = V := by rw [hv.variance_eq, variance_id_gaussianReal]
  have hVu : Var[u; P] = σ ^ 2 := by
    rw [hu.variance_eq, variance_id_gaussianReal, NNReal.coe_pow]
  obtain ⟨hcov, hvar⟩ := orderflow_moments hvg.memLp_two hug.memLp_two hind p₀ β
  rw [← hy, hVv] at hcov
  rw [← hy, hVv, hVu] at hvar
  have hEy : P[y] = 0 := by
    have hd : Integrable (fun ω ↦ β * (v ω - p₀)) P :=
      (hvg.integrable.sub (integrable_const p₀)).const_mul β
    rw [hy, integral_add hd hug.integrable, integral_const_mul,
      integral_sub hvg.integrable (integrable_const p₀), hEv, hEu]
    simp
  have hpos : Var[y; P] ≠ 0 := by rw [hvar]; positivity
  -- The value and the order flow are jointly Gaussian
  have hym : Measurable y := by rw [hy]; fun_prop
  have hG : HasGaussianLaw (fun ω ↦ (v ω, y ω)) P := by
    let L : ℝ × ℝ →L[ℝ] ℝ × ℝ := (ContinuousLinearMap.fst ℝ ℝ ℝ).prod
      (β • ContinuousLinearMap.fst ℝ ℝ ℝ + ContinuousLinearMap.snd ℝ ℝ ℝ)
    have := ((hind.hasGaussianLaw hvg hug).map L).isGaussian_map
    have h : (fun ω ↦ (v ω, y ω))
        = (fun x ↦ x + ((0 : ℝ), -β * p₀)) ∘ L ∘ fun ω ↦ (v ω, u ω) := by
      funext ω
      simp [L, hy]
      ring
    constructor
    rw [h, ← Measure.map_map (by fun_prop) (by fun_prop)]
    infer_instance
  -- Gaussian conditioning gives E[v | y] = p₀ + k y, with k = Cov(v, y) / Var(y)
  have hE := gaussian_conditioning hvm hym hG hpos
  rw [hcov, hvar, hEv, hEy] at hE
  unfold zeroProfitPricing
  constructor
  · intro h
    by_contra hne
    have hy0 : y =ᵐ[P] 0 := by
      filter_upwards [h, hE] with ω h1 h2
      have h3 : (lam - β * V / (β ^ 2 * V + σ ^ 2)) * y ω = 0 := by linarith
      exact (mul_eq_zero.mp h3).resolve_left (sub_ne_zero.mpr hne)
    exact hpos (by rw [variance_congr hy0, variance_zero])
  · intro h
    rw [h]
    simpa using hE
1
The market maker’s condition. Like InsiderOptimal, it is a Prop.
2
The setup: three random variables, v, u, and y, and the parameters of the model. ℝ≥0 is the set of non-negative real numbers, which we use for the variance V and the standard deviation σ.
3
The assumptions of the model: v \sim N(p_0, V), u \sim N(0, \sigma^2), the two are independent, and \sigma > 0.
4
The order flow: y = \beta(v - p_0) + u.
5
The statement: E[v \mid y] = p_0 + \lambda y (almost surely) if and only if the market maker’s condition holds.
6
The moments of v and u, which Mathlib knows for normal random variables.
7
Our previous theorem gives the moments of the order flow. obtain names its two parts, hcov for the covariance and hvar for the variance, and we substitute the values of \text{Var}(v) and \text{Var}(u) in them.
8
The order flow has mean zero, because E[v] = p_0 and E[u] = 0.
9
The order flow is not a constant, because \text{Var}(y) = \beta^2 V + \sigma^2 > 0.
10
The value and the order flow are jointly Gaussian. Independent Gaussian variables are jointly Gaussian, so this is true of (v, u), and L is the linear function (v, u) \mapsto (v, \beta v + u).
11
(v, y) is equal to L plus a constant, and adding a constant keeps it Gaussian. Mathlib knows this last part, and infer_instance finds it.
12
Apply Gaussian conditioning and substitute the moments: E[v \mid y] = p_0 + ky, with k = \beta V/(\beta^2 V + \sigma^2).
13
What is left to prove is that E[v \mid y] = p_0 + \lambda y if and only if \lambda = k. We look at one direction at a time.
14
First direction, by contradiction: suppose that E[v \mid y] = p_0 + \lambda y, but that \lambda \neq k.
15
Then (\lambda - k)y = 0, so y = 0 almost surely, which contradicts the fact that y is not a constant.
16
Other direction: replace \lambda with k, and this is what Gaussian conditioning says.

Statement. Let v \sim N(p_0, \Sigma_0) and u \sim N(0, \sigma_u^2) be independent, with \sigma_u > 0, and let y = \beta(v - p_0) + u. Then

E[v \mid y] = p_0 + \lambda y \iff \lambda = \frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2}.

Proof. We have E[v] = p_0 and E[y] = 0. Since v and u are independent and normal, (v, y) is jointly normal. By Gaussian conditioning and the moments of the order flow,

E[v \mid y] = p_0 + ky, \qquad k = \frac{\text{Cov}(v, y)}{\text{Var}(y)} = \frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2}.

If \lambda = k, then E[v \mid y] = p_0 + \lambda y. Conversely, if E[v \mid y] = p_0 + \lambda y, then (\lambda - k)y = 0 and, because y is not a constant, \lambda = k.

Step 3: the fixed point. We are back to pure algebra. The theorem says that the insider’s condition (step 1) and the market maker’s condition (step 2) hold together if and only if \beta and \lambda take Kyle’s values:

theorem kyle_equilibrium {V σ β lam : ℝ} (hV : 0 < V) (hσ : 0 < σ) :
    ((0 < lam ∧ β = 1 / (2 * lam)) ∧ zeroProfitPricing V σ β lam) ↔
      (β = σ / √V ∧ lam = √V / (2 * σ)) := by
  -- Preliminaries
  unfold zeroProfitPricing
  have hsV : 0 < √V := Real.sqrt_pos.mpr hV
  have hsq : √V ^ 2 = V := Real.sq_sqrt hV.le
  constructor
  -- (⇒) The conditions imply Kyle's values
  · rintro ⟨⟨hlam, hb⟩, hl⟩
    have hβ : 0 < β := by rw [hb]; positivity
    have hl' : lam = 1 / (2 * β) := by
      rw [hb]; field_simp
    rw [hl'] at hl
    field_simp at hl
    -- hl now says β² V + σ² = 2 β² V, which gives (β √V)² = σ²
    have hb2 : (β * √V) ^ 2 = σ ^ 2 := by nlinarith [hsq]
    have hbs : β * √V = σ := by
      have h1 : 0 < β * √V := mul_pos hβ hsV
      nlinarith [sq_nonneg (β * √V - σ), sq_nonneg (β * √V + σ)]
    have hβ' : β = σ / √V := by field_simp; linarith
    refine ⟨hβ', ?_⟩
    rw [hl', hβ']
    field_simp
  -- (⇐) Kyle's values satisfy the conditions
  · rintro ⟨hb, hl⟩
    refine ⟨⟨?_, ?_⟩, ?_⟩
    · rw [hl]; positivity
    · rw [hb, hl]; field_simp
    · rw [hl, hb]
      field_simp
      rw [hsq]
      ring
1
The hypotheses: the prior variance V and the noise volatility σ are strictly positive.
2
The left-hand side is the equilibrium: the insider’s condition and the market maker’s condition both hold.
3
The right-hand side is Kyle’s closed-form solution. √ is Mathlib’s square root.
4
unfold replaces zeroProfitPricing with its definition. The two have lines record that \sqrt{V} > 0 and (\sqrt{V})^2 = V, which both follow from V > 0.
5
constructor splits the “if and only if” into its two directions.
6
Assume the left-hand side and split it in three: hlam is \lambda > 0, hb is \beta = 1/(2\lambda), and hl is the market maker’s condition. What is left to prove is the right-hand side.
7
\beta is positive, because \lambda is.
8
An intermediate result, \lambda = 1/(2\beta). rw [hb] substitutes the formula for \beta, and field_simp simplifies the fractions. The ; separates two tactics on the same line.
9
Substitute \lambda = 1/(2\beta) in the market maker’s condition, then clear the denominators.
10
nlinarith gets (\beta\sqrt{V})^2 = \sigma^2 from hl, with the hint that (\sqrt{V})^2 = V.
11
Take the square root. Since \beta\sqrt{V} (shown in h1) and \sigma are both positive, equal squares imply equal numbers. The terms in brackets are hints for nlinarith.
12
Divide by \sqrt{V} to get the first of Kyle’s values, \beta = \sigma/\sqrt{V}.
13
The goal has two parts joined by “and”. refine ⟨hβ', ?_⟩ proves the first part with hβ', and ?_ leaves the second part, \lambda = \sqrt{V}/(2\sigma), for the next two lines: substitute and simplify.
14
The other direction. This time we assume Kyle’s values, and refine splits the goal into three parts, each with its own ·.
15
\lambda is positive.
16
The first-order condition: substitute Kyle’s values and simplify.
17
The market maker’s condition: substitute, simplify, replace (\sqrt{V})^2 with V, and let ring check what is left, V + V = 2V.

Statement. For \Sigma_0, \sigma_u > 0,

\begin{aligned} & \lambda > 0, \;\; \beta = \frac{1}{2\lambda} \;\text{ and }\; \lambda = \frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2} \\ \iff\; & \beta = \frac{\sigma_u}{\sqrt{\Sigma_0}} \;\text{ and }\; \lambda = \frac{\sqrt{\Sigma_0}}{2\sigma_u}. \end{aligned}

Proof (\Rightarrow). The insider’s condition gives \beta > 0 and \lambda = \frac{1}{2\beta}. Substituting into the market maker’s condition,

\begin{aligned} \frac{1}{2\beta} &= \frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2} \\ \beta^2\Sigma_0 + \sigma_u^2 &= 2\beta^2\Sigma_0 \\ \beta^2\Sigma_0 &= \sigma_u^2. \end{aligned}

Since \beta, \sqrt{\Sigma_0}, and \sigma_u are all positive, we can take the positive square root, \beta\sqrt{\Sigma_0} = \sigma_u, so

\beta = \frac{\sigma_u}{\sqrt{\Sigma_0}}, \qquad \lambda = \frac{1}{2\beta} = \frac{\sqrt{\Sigma_0}}{2\sigma_u}.

Proof (\Leftarrow). With Kyle’s values, \lambda > 0 and \frac{1}{2\lambda} = \frac{\sigma_u}{\sqrt{\Sigma_0}} = \beta. Moreover, \beta\Sigma_0 = \sigma_u\sqrt{\Sigma_0} and \beta^2\Sigma_0 = \sigma_u^2, so

\frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2} = \frac{\sigma_u\sqrt{\Sigma_0}}{2\sigma_u^2} = \frac{\sqrt{\Sigma_0}}{2\sigma_u} = \lambda.

The “if and only if” gives us both existence (Kyle’s values satisfy the conditions) and uniqueness (among linear equilibria of this form; Kyle also derives the intercepts). The proof is mostly clearing denominators and taking a square root carefully (Lean insists that you justify why \beta\sqrt{\Sigma_0} = \sigma_u follows from \beta^2\Sigma_0 = \sigma_u^2, which needs \beta > 0). The file also checks the algebra of the two corollaries, the posterior variance and the insider’s expected profit, in a few lines each.

Putting everything together, the end-to-end theorem is:

theorem kyle {v u y : Ω → ℝ} {p₀ β lam : ℝ} {V σ : ℝ≥0}
    (hvm : Measurable v) (hum : Measurable u)
    (hv : HasLaw v (gaussianReal p₀ V) P)
    (hu : HasLaw u (gaussianReal 0 (σ ^ 2)) P)
    (hind : IndepFun v u P) (hV : 0 < V) (hσ : 0 < σ)
    (hy : y = fun ω ↦ β * (v ω - p₀) + u ω) :
    (InsiderOptimal β lam ∧ P[v | info y] =ᵐ[P] fun ω ↦ p₀ + lam * y ω) ↔
      (β = σ / √V ∧ lam = √V / (2 * σ)) := by
  rw [insider_condition, market_maker_pricing hvm hum hv hu hind hσ hy]
  exact kyle_equilibrium hV hσ
1
The setup is the same as for the market maker: random variables v, u, and y, and the parameters of the model.
2
The assumptions of the model: v \sim N(p_0, V) and u \sim N(0, \sigma^2) are independent, and both variances are strictly positive.
3
The order flow when the insider follows the linear strategy: y = \beta(v - p_0) + u.
4
The definition of an equilibrium: the insider’s strategy is optimal given \lambda, and the price p_0 + \lambda y is equal to E[v \mid y] given \beta.
5
The conclusion: this is an equilibrium if and only if \beta and \lambda take Kyle’s values.
6
Replace the two equilibrium conditions with the formulas from steps 1 and 2. In Lean, theorems behave like functions: we give market_maker_pricing proofs of its hypotheses and it gives us back a proof of its conclusion.
7
What is left is exactly the fixed point from step 3.

Statement. Let v \sim N(p_0, \Sigma_0) and u \sim N(0, \sigma_u^2) be independent, with \Sigma_0, \sigma_u > 0, and let y = \beta(v - p_0) + u. Then the following are equivalent:

  1. The strategy x = \beta(v - p_0) maximizes the insider’s expected profit given \lambda, and p_0 + \lambda y = E[v \mid y].
  2. \beta = \dfrac{\sigma_u}{\sqrt{\Sigma_0}} and \lambda = \dfrac{\sqrt{\Sigma_0}}{2\sigma_u}.

Proof. By step 1, the strategy is optimal if and only if \lambda > 0 and \beta = \frac{1}{2\lambda}. By step 2, the price is equal to E[v \mid y] if and only if \lambda = \frac{\beta\Sigma_0}{\beta^2\Sigma_0 + \sigma_u^2}. By step 3, these conditions hold together if and only if \beta and \lambda take Kyle’s values.

Read this statement carefully, because it defines what is being verified and the underlying assumptions. Everything before the final := is what you have to trust: the distributions, the order flow, and the definition of an equilibrium. Everything after it is checked by Lean, all the way down to the axioms. And notice what we did not have to assume: \lambda > 0 and \beta > 0 come out of the proof.

Did it work?

Yes. The file compiles against Mathlib, with no sorry (Lean’s placeholder for “I’ll prove this later”), and #print axioms Kyle.kyle confirms that the proof relies only on Lean’s three standard axioms.

What does a failure look like? Here is what happens if I claim that the posterior variance is \Sigma_0/3 instead of \Sigma_0/2:

example {V σ : ℝ} (hV : 0 < V) (hσ : 0 < σ) :
    let β := σ / √V
    let lam := √V / (2 * σ)
    V - lam * β * V = V / 3 := by
  intro β lam
  simp only [β, lam]
  field_simp
  ring
1
example is a theorem without a name, handy for quick checks.
2
let defines local shorthands for Kyle’s \beta and \lambda.
3
The (false) claim: the posterior variance is \Sigma_0/3.
4
intro brings the two shorthands into the proof, and simp only replaces them with their definitions.
5
The same tactics as in step 1: clear the denominators, then check the polynomial identity. This time ring cannot close the goal.

(False) claim. With \beta = \frac{\sigma_u}{\sqrt{\Sigma_0}} and \lambda = \frac{\sqrt{\Sigma_0}}{2\sigma_u}, the posterior variance is \Sigma_0 - \lambda\beta\Sigma_0 = \frac{\Sigma_0}{3}.

Where it breaks. The product of the two coefficients is

\lambda\beta = \frac{\sqrt{\Sigma_0}}{2\sigma_u} \cdot \frac{\sigma_u}{\sqrt{\Sigma_0}} = \frac{1}{2},

so the left-hand side is \Sigma_0 - \frac{1}{2}\Sigma_0 = \frac{\Sigma_0}{2}, and the claim reduces to

\frac{\Sigma_0}{2} = \frac{\Sigma_0}{3} \iff 3 = 2,

since \Sigma_0 > 0.

Lean refuses, and after simplifying, it shows me exactly what is left to prove (I trimmed the output; ⊢ marks the goal that remains):

error: unsolved goals
⊢ 3 = 2

Three more observations about the process. First, the algebraic part compiled on the first attempt. The probability part did not: the agent called a lemma, covariance_fun_add_right, that does not exist in Mathlib. That is a hallucination, the same kind that could slip into LLM-generated \LaTeX, except that here Lean flagged it immediately and the agent fixed it in one iteration. This is the whole point. Second, the first version, including setting up the project, took well under an hour.

Third, and most importantly, that first version was not the theorem I wanted. It compiled, with no sorry, but it assumed the insider’s condition and the slope of the price instead of deriving them, and Claude’s draft claimed that proving the Gaussian step would be a real project. When I asked two other models (Fable 5.2 and GPT-6.2 Astra) to review the draft, both pointed out that the theorem did not say what the text claimed, and one noticed that Mathlib already had the pieces for the Gaussian step. The complete proof above came out of that review. Lean could not have caught this: the first proof was a correct proof, just not of the right statement.

NoteRunning it yourself

You need elan, the Lean version manager (the Lean install guide also sets up the VS Code extension, which shows the proof state as you move through a proof). Then, from the folder with the four files above (the kyle-lean folder if you used the zip file):

lake exe cache get
lake build
1
Downloads a precompiled copy of Mathlib (it takes several GB of disk space).
2
Builds the project, which means checking every proof. If it finishes without errors (or warnings about sorry), every theorem in the file is proved.

Always fetch the Mathlib cache first. Building Mathlib from source takes hours.

The limits: what Mathlib does not (yet) know

The Kyle example also shows the main limitation of Lean for finance today. The Gaussian conditioning formula from step 2 is core to much of market microstructure, to Kalman filtering, and to most noisy rational expectations models. It is in every graduate textbook. I could not find it in Mathlib.3 In this case, all the pieces were there and connecting them took about 40 lines. But proving textbook results before you can get to your own is not how most of us work, and the gap is often much larger.

That is a recurring theme. Mathlib was built by mathematicians, and its coverage follows what pure mathematicians care about. Some primitives that financial economists use every day are missing or only partially there:

  • Stochastic calculus. As of the release I used, Mathlib has martingales, stopping times, and (very recently) a definition of Brownian motion. Degenne et al. (2025) construct Brownian motion in a separate project that is being moved into Mathlib over time, and work on the stochastic integral and Itô’s lemma is in progress there. For now, Itô’s lemma, Girsanov’s theorem, and stochastic differential equations are not in Mathlib, which puts most of continuous-time asset pricing out of reach if you rely on Mathlib alone, including Black-Scholes and the continuous-time version of Kyle’s model.
  • The linear-Gaussian toolbox. The scalar case is short, as we just saw, but I could not find the multivariate version or the Kalman filter.
  • Dynamic programming and optimal control. HJB equations, verification theorems, and optimal stopping. In my AGI paper, the Lean package checks the closed forms and the algebra, but the derivation of the HJB equation and the optimal-stopping verification theorem are explicitly out of scope.
  • Econometric asymptotics. The central limit theorem is there (in dimension 1), but the machinery econometricians use on top of it (delta method, M-estimation, GMM, HAC estimators) is not.
  • Numerics. Lean is not built for numerical work. It can certify a bound on a number, but if your result comes from a numerical solver, Lean will not check it for you without a verified solver or a certificate it can check.

There is some movement on the finance side. Isabelle has had a formalization of discrete-time option pricing since 2018, and, in 2026, an independent researcher posted Lean formalizations of the fundamental theorem of asset pricing in finite markets, Itô’s formula, and a large finance library that includes Black-Scholes replication (Coelho 2026). These are interesting, but they live outside Mathlib, so building on them means trusting definitions that are not widely accepted yet. And remember: Lean guarantees the proofs, not the definitions.

Beyond missing primitives, there are a few more general limitations to keep in mind:

  • The statement problem. As discussed above, Lean checks the proof, not the statement. A hypothesis that assumes away the hard part is harmless when you know it is there, but an AI that quietly adds one will produce a “verified” result that does not mean what you think it means, as my first version shows. Reading the statements and the hypotheses is still your job.
  • Your model is still a model. Lean can verify that the equilibrium follows from the assumptions. It cannot tell you whether the assumptions describe any real market.
  • Friction. Mathlib changes quickly, and lemmas are renamed or reorganized from one release to the next, so proofs need maintenance. Pin your Mathlib version like you would any other library.

Closing thoughts

What strikes me most about the past two years is how quickly formalizing math went from a niche hobby of a few mathematicians and computer scientists to the backbone of AI-for-math. The reason is simple: as AI makes proofs cheap, the bottleneck becomes checking them, and Lean turns checking into compilation.

Finance theory is not there yet. The missing primitives are a real limitation, and for anything involving continuous time, you will either assume the key step or spend a long time formalizing it. But the algebra, the first-order conditions, the fixed points, the comparative statics, and even a complete one-period Kyle model are already within reach today, at a cost of minutes or hours, not weeks. For any new derivation, especially one written with the help of an AI, I think asking for a Lean proof should become the default.

And if you are looking for a high-impact project, adding the linear-Gaussian toolbox to Mathlib, or contributing to the stochastic calculus effort, would unlock a lot of finance theory for everyone.

Resources

References

Coelho, Raphael. 2026. A Formally Verified Library of Mathematical Finance in Lean 4. https://arxiv.org/abs/2606.01356.
Degenne, Rémy, David Ledvinka, Etienne Marion, and Peter Pfaffelhuber. 2025. Formalization of Brownian Motion in Lean. https://arxiv.org/abs/2511.20118.
Kyle, Albert S. 1985. “Continuous Auctions and Insider Trading.” Econometrica: Journal of the Econometric Society 53 (6): 1315–35. https://doi.org/10.2307/1913210.

Changelog

  • 2026-11-28. Added a link to the formal-mathfin repository, the code for the Coelho (2026) finance library, in the text and in the resources.

Footnotes

  1. Buzzard’s point is that the formalization tells us essentially nothing new about the mathematics, but it is a huge step for autoformalization. I think that is exactly the right way to read it.↩︎

  2. Lean reserves λ (for anonymous functions) and Σ (for dependent pairs), so the code uses lam for \lambda, V for \Sigma_0, and σ for \sigma_u.↩︎

  3. Claude checked the Mathlib release I used (v4.31.0, from June 2026) and searched the community Zulip. Mathlib has Gaussian distributions (including multivariate ones), conditional expectation, and covariance, but I could not find the theorem that connects them. If I missed it, please let me know!↩︎

Reuse