Back to Blog

What Is Lean? The Proof Assistant Refereeing AI Mathematics

By ML Team••7 min read
LeanFormal VerificationAI for MathExplainer

Lean is a programming language that doubles as a proof assistant. You state a mathematical theorem as a type, write a proof as a program, and Lean’s small trusted kernel checks every logical step. If the file compiles, the proof is correct relative to the axioms and the statement you wrote. No referee has to take anything on trust.

That property is why Lean has become central to AI-for-mathematics. A language model can produce a persuasive-looking proof that is wrong. A Lean proof that compiles cannot be wrong in that way, so Lean turns “the model says it proved it” into something anyone can verify in seconds.

2013
Lean started by Leonardo de Moura at Microsoft Research
Lean 4
Current version: a full functional language and prover
Mathlib
Community library of formalized mathematics
Small kernel
The only code you have to trust

The Core Idea: Propositions Are Types

Lean is built on a version of dependent type theory (the calculus of inductive constructions). Its central trick is the Curry–Howard correspondence: a mathematical statement is a type, and a proof of that statement is a value of that type. Checking a proof is the same operation as type-checking a program. A false statement is a type with no values, so no program can inhabit it.

Here is a complete Lean 4 file that proves addition of natural numbers is commutative:

-- The statement is the type; the proof is the term after :=
theorem add_comm' (a b : Nat) : a + b = b + a := by
  induction b with
  | zero => simp
  | succ n ih => omega

-- Or simply reuse the library lemma:
example (a b : Nat) : a + b = b + a := Nat.add_comm a b

The by block is written in tactics: commands such as induction, simp and omega that build the proof term for you. Mathematicians mostly work in tactics; the kernel only ever sees the resulting term. While you write, the editor shows the current goal, what is left to prove, after every line. That interactive feedback is also what makes Lean a good environment for AI agents.

Why the Answer Can Be Trusted

  • A small kernel. Tactics, automation and AI tools can be as clever or buggy as they like. Everything they produce is re-checked by a compact kernel, and independent re-implementations of the checker exist. This is the “de Bruijn criterion”: only the small checker needs to be trusted.
  • Explicit axioms. #print axioms my_theorem lists exactly which axioms a proof depends on, so a hidden sorry (Lean’s placeholder for a missing proof) cannot slip through.
  • The catch: the statement. Lean proves what you wrote, not what you meant. If a definition or theorem statement is subtly wrong, the proof is still valid, but about the wrong thing. Reviewing formal statements is where human expertise now concentrates.

Mathlib and the Milestones That Made Lean Mainstream

Mathlib

A single, community-maintained library covering undergraduate mathematics and a large and growing part of research mathematics: algebra, analysis, topology, number theory, measure theory and more. New results build on what is already there, so formalization gets cheaper over time. Lean development itself is now stewarded by the non-profit Lean FRO.

2020–2022: The Liquid Tensor Experiment

Peter Scholze challenged the community to formalize a central theorem of his and Clausen’s condensed mathematics that he was not fully sure of himself. The Lean community completed it, the first time a proof assistant checked a cutting-edge result at a working mathematician’s request.

2023: PFR in three weeks

Terence Tao led a collaborative project that formalized the newly proved Polynomial Freiman–Ruzsa conjecture (Gowers, Green, Manners and Tao) in about three weeks, splitting the proof into a dependency graph of small lemmas that dozens of contributors could take on in parallel.

2024 onward: Fermat’s Last Theorem and AI provers

Kevin Buzzard started a multi-year project to formalize the proof of Fermat’s Last Theorem. The same year, Google DeepMind’s AlphaProof wrote its International Mathematical Olympiad solutions in Lean, and AI provers have since been judged on whether their Lean output compiles.

Why Lean Matters for AI and Mathematics

Training an AI to do mathematics needs a reward signal that cannot be gamed. Natural-language proofs are graded by humans or by other models, both slow and fallible. Lean gives a binary, machine-checkable verdict: the proof compiles or it does not. That makes it a natural target for reinforcement learning, and a natural filter: let a model generate thousands of attempts and keep the ones Lean accepts.

It also changes how claims are reviewed. When an AI system announces a new result, the first question is now whether there is a Lean proof, and whether its statement matches the claim. The clearest example so far came in November 2026. Levent Alpöge released a 17-million-line Lean proof of the Riemann Hypothesis, built with Claude, and the Lean FRO and Mathlib Initiative certified that both statement and proof are correct. This happened before any human-readable proof existed. Our companion piece, Will AI-Driven Mathematics Break Modern Encryption?, explains why that distinction matters when the claim is about cryptography.

Limits Worth Knowing

  • Formalizing is still slow. Turning a paper proof into Lean can take many times longer than writing the paper, though AI autoformalization is cutting that cost quickly.
  • Coverage gaps. Some fields are well covered by Mathlib; others still lack basic definitions, so a formal proof there means building foundations first.
  • Verification is not discovery. Lean checks proofs; it does not tell you which theorem is worth proving or which idea will work.

Try It

The quickest start is the browser-based Lean 4 web editor. For a guided introduction, the Natural Number Game builds arithmetic from scratch one tactic at a time, and Mathematics in Lean covers how Mathlib is used in practice.

Blog | MachinaLearning