Lean Theorem Prover: Lean 4 and Mathlib Explained
Quick answer: Lean is a free, open-source programming language and proof assistant used to write and check mathematical proofs. You express a statement and its proof in Lean’s formal language, and its small kernel checks that the proof follows from the permitted assumptions. Lean 4 is the current major version, and Mathlib is its community library of mathematical definitions, theorems and proofs.
A calculator can confirm that \(7 + 0 = 7\). Lean can check a proof that \(n + 0 = n\) for every natural number \(n\). That is the difference between testing a case and proving a statement: a calculation checks one input, while a proof covers every case its assumptions allow.
What Is Lean?
Lean is an open-source proof assistant and programming language. Leonardo de Moura started it in 2013 at Microsoft Research; the current version, Lean 4, is developed by the nonprofit Lean FRO, which de Moura co-founded with Sebastian Ullrich. You write definitions, statements and proofs in Lean’s formal language. Tactics and other code build a formal proof object, and Lean’s small trusted kernel checks it.
| Component | Role |
|---|---|
| Lean 4 | The language and system for writing programs and formal proofs |
| Mathlib | A shared library of mathematical definitions and proved results |
| Tactic | A command that helps build a proof or transform the current goal |
| Kernel | The core checker that validates the finished proof |
Lean is not an AI system (though AI tools can write Lean), not a calculator (it proves general statements), and not like LaTeX (which only displays math; Lean checks it).
A Tiny Example
Here is a complete Lean proof that adding zero to a natural number changes nothing:
theorem add_zero_example (n : Nat) : n + 0 = n := by
simp
| Code | Meaning |
|---|---|
theorem add_zero_example | Give the theorem a name |
(n : Nat) | Let \(n\) be any natural number, including 0 |
: n + 0 = n | The claim to prove |
:= by | Begin a proof written with tactics |
simp | Simplify using a database of established rewriting rules |
This proves the statement for every natural number, not for a list of tested values. Longer proofs combine tactics, named lemmas from the library and intermediate steps. You can paste this example into the free online Lean editor at live.lean-lang.org and watch the goal disappear.
What Is Mathlib?
Mathlib is Lean’s community library, a separate project from the Lean language itself. It covers many areas of undergraduate mathematics and a growing collection of research results, written and reviewed by hundreds of contributors. You load it with import Mathlib, and the practical benefit is reuse: you can build on established definitions and proved results instead of rebuilding them for every project.
Lean in the 2026 Headlines
| Date | Result | Scope of the Lean formalization |
|---|---|---|
| January 2026 | Erdős Problem 728 | Kevin Barreto used GPT-5.2 Pro and Harmonic’s Aristotle to produce a Lean proof of the intended statement |
| September 2026 | Fermat’s Last Theorem, complete formal proof | A formalization of the existing proof: Anthropic reported that Claude agents wrote about 13 million lines of Lean in 11 days, following the Darmon–Diamond–Taylor account; Kevin Buzzard compiled it and ran the standard checker |
| September 2026 | Navier–Stokes blow-up (forced case) | OpenAI released a writeup and a Lean formalization for the forced case, with a smooth external force |
| October 2026 | Unit distance exponent about 1.043 | The manuscript claims 1.043171; the Lean file proves the slightly weaker 1.04315, conditional on one numerical inequality checked outside Lean |
What Lean Does and Does Not Guarantee
- Compiling is not enough. Lean allows the placeholder
sorryfor unfinished steps, and a theorem can depend on extra axioms. The command#print axiomsshows what a theorem really relies on. Before trusting a result, check that it and its dependencies contain nosorryor unintended axioms. - It guarantees, once those checks pass, that the formal statement follows from the axioms and the library, assuming Lean’s small kernel is correct.
- It does not guarantee that the formal statement says what the human statement says. A typo in a definition can make a “proof” of the wrong thing. This is why reviewers check statements carefully.
- It does not guarantee novelty. A checked proof can still be of something already known.
- It does not make a proof readable. Kevin Buzzard noted that the 13-million-line Fermat formalization faithfully follows the earlier literature. Its main achievement is large-scale formal verification of existing mathematics.
How to Start
The free Natural Number Game teaches Lean in a web browser by proving facts about addition and multiplication. After that, the book Mathematics in Lean walks through real undergraduate topics.
Common Misconceptions
“Lean finds proofs by itself.” Lean checks proofs. Tactics and AI systems can help find them, but Lean is the referee.
“A Lean proof can never be wrong.” The logic is checked, but the statement must still be checked by people.
Watch: Lean in Video
If you learn better by watching, these videos are worth your time.
Check Your Understanding
Five quick questions to see how much of this has stuck. Pick an answer and press Submit; you will see a short explanation either way.
Answer each question and press Submit to see your result right away.
Frequently Asked Questions
What is the Lean theorem prover?
Lean is an open-source proof assistant and programming language in which mathematical statements and proofs are written formally so a computer can check every step. It was created by Leonardo de Moura and is now developed by the Lean FRO.
Is Fermat’s Last Theorem proved in Lean?
Yes. In September 2026, Anthropic announced a complete Lean proof written largely autonomously by Claude agents over 11 days, about 13 million lines long. Kevin Buzzard compiled and checked it, noting it follows the early literature on Wiles’s proof.
Can a Lean proof be wrong?
The kernel checks the logic, so errors there are very unlikely. But a file can compile while using sorry or extra axioms, and the formal statement might not match the intended mathematics, so both must be checked.
What is the difference between Lean and Mathlib?
Lean 4 is the language and proof checker. Mathlib is a separate community library of mathematics written in Lean that you import to reuse definitions and theorems.
How do I learn Lean?
Start with the free Natural Number Game in your browser, then read Mathematics in Lean. Both are free online.
Keep Exploring
- Erdős Problems Explained: What AI Has Actually Solved
- Navier-Stokes Solved? The 2026 Proof Claims Explained
- Busy Beaver Explained: BB(5) Solved, BB(6) Still Open
Sources and Further Reading
Related to This Article
More math articles
- DAT Math Flashcards (Free Online: Formulas, Terms & Concepts)
- Emergency Fund Calculator: How Much Should You Save?
- Algebra 1 Worksheets: FREE & Printable
- Simple But Practical: First-Order Ordinary Differential Equations
- 3rd Grade WVGSA Math Worksheets: FREE & Printable
- Socialization, the Self, and the Life Course
- Digital Tools for Teaching Math at a Distance
- Top 10 Tips to Overcome TSI Math Anxiety
- Area Models Unveiled: How to Divide Unit Fractions by Whole Numbers
- Stratification, Life Chances, and Unequal Dimensions


What people say about "Lean Theorem Prover: Lean 4 and Mathlib Explained - Effortless Math"?
No one replied yet.