A Formally Verified Library of Mathematical Finance in Lean 4

arXiv:2606.01356 · q-fin.MF, q-fin.CP · Submitted 2026-05-31 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Quantitative Finance. The day in quantitative finance: models of markets, risk and prices.

Ruth: We're looking at the paper: "A Formally Verified Library of Mathematical Finance in Lean 4".

Warren: Here's the gist of the paper. A Formally Verified Library of Mathematical Finance in Lean 4 describes a comprehensive machine-checked development of mathematical finance that yields certified unification of known results rather than new financial theory.

Ruth: Scope and Breadth The library spans eleven areas, providing more than three hundred sorry-free theorems across various domains in mathematics and finance.

Warren: This breadth includes continuous-time stochastic calculus foundations, no-arbitrage pricing foundations, Black–Scholes pricing (call and put formulas), the binomial model, futures, fixed income theory, portfolio theory, risk measures (coherence and CVaR), actuarial mathematics, and DeFi.

Ruth: The development is built upon Mathlib and the BrownianMotion package.

Title and authors: Ruth: So we're looking at this paper, "A Formally Verified Library of Mathematical Finance in Lean four" and the authors are Raphael Coelho <ref:2606.01356#pg1,A Formally Verified Library of Mathematical Finance in Lean 4>. It’s pretty ambitious to build an entire library of mathematical finance this way.

Warren: Am I missing something? It sounds like they aren't just writing a textbook or a collection of formulas; they're trying to create something machine-checked. That’s a big undertaking, especially when you think about the complexity of financial math.

Iris: I think the key word here is "verified." When you say verified, it means there's a formal proof that every single theorem in this library is absolutely solid, not just assumed or sketched out somewhere.

Ruth: Exactly. It’s about creating a system where the results are certified. They're taking established financial math and putting it into Lean four on top of Mathlib and the BrownianMotion package, to make it machine-checkable <ref:2606.01356#pg1,on top of Mathlib and the BrownianMotion package>.

Warren: So instead of just having some models that work, they want to prove *why* they work from a very rigorous foundation. That suggests a huge effort in structuring the underlying math itself.

Iris: Right. And what’s interesting is their goal isn't necessarily to invent new financial theory, but rather to achieve this certified unification of known results across eleven different areas of finance and math.

Ruth: That's the core idea, isn't it? They’re not trying to discover a new pricing model from scratch; they’re using this formal system to show that all these existing models fit together in one coherent, verified framework.

Warren: It shifts the focus from just getting a result that works on paper to proving that the underlying structure is sound under certain conditions. That’s a different kind of assurance for us as traders or model builders.

The paper's summary: Ruth: So, what does this library actually cover? It spans eleven areas, from the continuous-time stochastic calculus foundations all the way down to things like fixed income and even some DeFi applications. It’s quite a broad scope.

Warren: Eleven areas is a lot. I always worry that when you try to cover everything, you end up missing something important in practice. Is this truly comprehensive?

Iris: The paper states they have more than three hundred sorry-free theorems across all those domains, which they claim makes it one of the most comprehensive machine-checked developments of mathematical finance available right now.

Ruth: That number is impressive, but I want to know what that means for us. It means we can trust the foundational pieces of pricing theory—like no-arbitrage pricing foundations and Black–Scholes pricing formulas—because they've been checked extensively.

Warren: Trusting the foundation is good, but how do these theorems translate into actual trading strategies? Are we talking about something that lets an AI build a model on this base without needing to constantly re-verify every step?

Iris: That’s where the methodology comes in. They use a faithfulness-audit methodology where every theorem is classified by how closely its Lean statement matches the actual mathematical claim, using tiers like full, library wrapper, reduced core, and placeholder.

Ruth: That auditing process is crucial. It doesn't just give you a result; it tells you exactly how much faith to put in that result based on the level of proof verification they achieved.

Warren: So if I'm looking at a theorem that’s only in the "placeholder" tier, what does that tell me about its reliability? Is it just theoretical exploration, or is it something I can rely on for my risk calculations?

Iris: It means you know precisely where the gap is. The build-enforced gate called AxiomAudit pins the exact print axioms used for load-bearing theorems to ensure everything is sorry-free. This makes the difference between "we proved X" and "we proved a weaker X under added hypotheses" very explicit and checkable.

The paper's improvements: Ruth: Beyond just compiling the library, the paper highlights some really deep constructions they’ve done that go further than what earlier work usually assumes. They’ve built foundational objects that other researchers only sketch or assume exist.

Warren: Can you give me an example of one of these deep constructions? I mean, in finance, we often start with assumptions about the process itself, like assuming a certain type of diffusion.

Iris: One major construction is them building the continuous Itô integral as a bounded linear isometry on L two from zero to T. That means they are not just using an existing definition; they are constructing it and proving it behaves perfectly in terms of norms for stochastic processes.

Ruth: So, instead of taking the Itô integral as a given tool, they’ve built the tool itself and verified its properties rigorously. That’s a significant step up in foundational rigor.

Warren: That sounds like something that would give us more control over the noise term in our simulations. If you know exactly how bounded that integral is, it helps with understanding the errors when we try to price things continuously.

Iris: They also derived the risk-neutral measure directly from a static Girsanov change of measure instead of just assuming it exists. This process turns what was once a hypothesis into a proven theorem, specifically BSCallHyp. exists of physical >

Ruth: That’s significant for model building because it means the pricing hypothesis—that you can switch to the risk-neutral measure—is derived from physical laws and mathematical constructions, not just an assumption about market behavior.

Warren: If we can derive that measure this way, it strengthens the connection between theoretical finance and actual market dynamics. It makes the link more direct than just picking a Girsanov density that looks right for our specific asset class.

Conclusion: Ruth: So, to wrap things up on "A Formally Verified Library of Mathematical Finance in Lean four" the main point is that this work provides reusable verified foundations for mathematical finance <ref:2606.01356#pg1,A Formally Verified Library of Mathematical Finance in Lean 4>. It’s about creating a verified infrastructure we can build complex quantitative models on.

Warren: I see it as building a highly reliable toolkit where the results are certified, and the process itself is auditable by an AI system before any deployment. That infrastructure is what matters most for running real strategies at scale.

Iris: I think the most important part is that this library certifies when two independently built modules denote the same mathematics, like checking if different methods for calculating Markowitz portfolio variance are actually equivalent. It provides a benchmark of mathematical equivalence between different approaches >

Ruth: Exactly. It’s about providing certified unification across the field, showing that when we follow these formal rules, we arrive at the same verified truths. It’s less about finding a new financial theory and more about proving the consistency of existing knowledge >

Warren: For me, it means less time spent debugging foundational assumptions and more time building actual trading logic on top of a proven mathematical bedrock. That efficiency is key for anyone running a large quantitative system >

Iris: I just want to say that this work is most faithful where the mathematics is classical and elementary, but the partial cores are sitting at the continuous-time frontier, which tells us exactly where we are standing in this formalization effort >

Ruth: It’s a huge project, fifty-two thousand lines of code, reproducible via a pinned Docker image. It sets a very high bar for how we should be thinking about verifying complex quantitative systems moving forward >

Warren: Yeah, it's heavy lifting on the math side, but the promise is that once you have this verified library in place, the path to deploying models built on it becomes much more structured and trustworthy >

q-fin.MF, q-fin.CP

Submitted: 2026-05-31

Updated: 2026-11-07

Comments: 15 pages. Lean 4 artifact (Apache-2.0): https://github.com/formal-applied-math/formal-mathfin ; archived at doi:10.5281/zenodo.24043549

Code: https://github.com/raphaelrrcoelho/formal-mathfin

License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/

Importance score: 83/100

The gist: A Formally Verified Library of Mathematical Finance in Lean 4 describes a comprehensive machine-checked development of mathematical finance that yields certified unification of known results rather…

Key concepts

Faithfulness-Audit Methodology
This is a classification system used to rate theorems based on how closely their formal Lean statement matches the actual mathematical claim. It uses four tiers (full to placeholder) to explicitly show the gap between what is proven and what assumptions are made, ensuring transparency in verification.
Continuous Itô Integral
The library constructs this integral as a bounded linear isometry on L2([0, T]). This means it provides a concrete, rigorously defined mathematical object for stochastic calculus that AI systems can use with verified structural guarantees instead of relying on sketched or assumed calculus definitions.
Static Girsanov Change of Measure
Instead of assuming the risk-neutral measure, the library derives it directly from physical laws using formal constructions like an Esscher density. This ensures pricing hypotheses are derived from foundational principles rather than being arbitrarily assumed in the model.

Terminology

Summary

A Formally Verified Library of Mathematical Finance in Lean 4 describes a comprehensive machine-checked development of mathematical finance that yields certified unification of known results rather than new financial theory. p. 5

Scope and Breadth

The library spans eleven areas, providing more than three hundred sorry-free theorems across various domains in mathematics and finance. This breadth includes continuous-time stochastic calculus foundations, no-arbitrage pricing foundations, Black–Scholes pricing (call and put formulas), the binomial model, futures, fixed income theory, portfolio theory, risk measures (coherence and CVaR), actuarial mathematics, and DeFi. p. 1 The development is built upon Mathlib and the BrownianMotion package. p. 0

Methodology of Verification

A key contribution is a faithfulness-audit methodology where every theorem is classified by how its Lean statement relates to the mathematical claim, using four tiers: full, library wrapper, reduced core, and placeholder. A build-enforced gate called AxiomAudit. p. 1lean pins the exact print axioms used for load-bearing theorems to ensure every result is sorry-free. p. 1 This mechanism makes the gap between we proved X and we proved a weaker X under added hypotheses explicit and checkable.

Depth of Mathematical Construction

The library achieves depth beyond prior formalizations by constructing foundational objects that earlier work only assumes or sketches. Specifically, the development constructs the continuous Itô integral as a bounded linear isometry on L2([0, T]). p. 1 Furthermore, it derives the risk-neutral measure from a static Girsanov change of measure rather than assuming it. p. 2 The binomial-to-Black–Scholes scaling limit is also machine-checked end to end using a characteristic-function / Lévy-continuity argument. p. 2

Architectural Principles

The library maintains coherence through a principle-based design anchored by four reusable principles. These include the linear no-arbitrage pricing functional, which yields put-call parity as a corollary. p. 1 The Garman normal form dictates the structure of Black–Scholes family prices. p. 3 The Brownian-motion grounding bridge connects pricing hypotheses to pre-Brownian motion infrastructure. p. 3 Finally, the faithfulness gate serves as a cross-cutting discipline binding the whole structure together. p. 3

Contribution and Future Directions

The primary contribution is infrastructural and methodological, providing reusable verified foundations for mathematical finance. The library certifies when two independently built modules denote the same mathematics, such as the N-asset Markowitz portfolio variance. p. 1 Future work is directed toward developing the general multi-period Dalang–Morton–Willinger theorem and its continuous-time counterpart. p. 5 The open frontier involves the fully general (progressively measurable) Girsanov change of measure and results still classified as reduced core. p. 5 The library is most faithful where the mathematics is classical and elementary, with partial cores sitting at the continuous-time frontier. p. 5 The build itself serves as evidence that audited results are sorry-free. p. 5 The library is about 52,300 lines and is reproducible via a pinned Docker image. p. 5

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Develop machine-checked foundations for financial mathematics by creating reusable verified libraries, which allows AI systems to build complex quantitative models on a rigorously proven mathematical base rather than assuming results from unverified sources.

  2. Implement an automated faithfulness audit mechanism where every theorem is classified by how its Lean statement relates to the mathematics it claims, enabling AI systems to precisely check the logical status of any financial claim before deployment.

  3. Enhance model construction by leveraging explicit constructions of continuous mathematical objects, such as the continuous Itô integral as a bounded linear isometry on [0, T], allowing AI systems to handle stochastic processes with verified structural guarantees instead of relying on sketched or assumed calculus.

  4. Improve risk management by enabling AI systems to derive the risk-neutral measure directly from physical laws using formal constructions like GaussianGirsanov.lean performs a static Girsanov change of measure by an Esscher density, ensuring pricing hypotheses are derived, not assumed.

Sources

Related papers