What is Lean (the language in which computers check that math proofs are correct)?
Also called: Lean 4, Lean theorem prover
In one minute
Lean is a programming language in which you write a math proof in a fixed form, and a computer then checks, one step at a time, whether the proof is correct.
Whether a person or an AI wrote the proof, a small part inside Lean called the kernel checks at the end that each step follows the rules, and rejects the proof if even one step doesn’t. Because the kernel is small and simple, there is little in it to doubt, and proofs can be rechecked with checkers that other people built. That is why even proofs tens of thousands of lines long can be trusted without people reading every line.
Leonardo de Moura started Lean in 2013 at Microsoft Research. It has Mathlib, a math library that many people build together, and it is used to check big proofs by mathematicians and proofs written by AI. But Lean does not check whether the problem itself was written correctly in Lean.
A common mix-up
“Lean is an AI that solves math problems by itself.”
Only partly right. Lean does have tools that fill in simple steps automatically (tactics, such as simp, which keeps rewriting an expression using given equations), and short proofs can sometimes be finished inside Lean alone. But Lean itself is not an AI that reads a problem and figures out how to solve it. Lean’s main job is to check whether a proof written by a person or an AI follows the rules step by step. Google DeepMind’s AlphaProof, known as an AI that solves math problems, searches for proof steps in Lean’s language and builds proofs that Lean can check. The AI does the thinking, and Lean does the checking. Proofs that an AI writes in ordinary language can contain plausible-looking mistakes (hallucinations), but if the AI writes them in Lean’s language, Lean catches the wrong steps.
Explained in pictures
You’re free to use these figures in lessons, slides and posts if you credit Naru News (naru.news). CC BY 4.0.
Think of it like this
A referee who checks a game record against the rules
Imagine being handed the record of a long chess game, with every move written down in order, and being asked: “Did every move follow the rules, and does the game end in checkmate?” Coming up with which move to play is hard even for strong players. But checking that each move follows the rules for how the pieces move takes no skill at all. You just compare the moves with the rules, one at a time.
Lean’s kernel is that referee. The proof is the game record, and the rules of logic and the axioms are the rules of the game. Whether a person or an AI came up with the moves, the referee only compares them one by one, so as long as the comparing is done right, the result can be trusted. And because the referee’s job is simple, it is easier to check the referee itself for mistakes. But the referee doesn’t look at whether the starting position was really the game you meant to play. Likewise, Lean doesn’t check whether the problem was written down correctly.
The comparison has limits, though. You can learn chess rules just by learning how the pieces move, but Lean’s rules are far more abstract, built so that almost all of mathematics can be written in them. Also, in chess a person writes the record move by move, while in Lean the elaborator turns a short proof that a person wrote into detailed steps and passes them to the kernel together with steps filled in by automatic tools.
Key points
How does Lean check a proof?
In Lean, you write what you want to show (in math, called a proposition) and its proof in a fixed form. For example, the line “example (a b : Nat) : a + b = b + a := Nat.add_comm a b” is a proof that “for whole numbers a and b from 0 up, a + b equals b + a.”
Here’s how to read it. “example” starts an unnamed example. “(a b : Nat)” means “a and b are Nat (whole numbers from 0 up).” Between the second “:” and “:=” is a + b = b + a, the thing to show, and after “:=” comes the proof. Nat.add_comm is a theorem built into Lean saying that the order of adding doesn’t matter, and a and b are handed to it.
Lean treats what you want to show as a type (a kind of value), and a proof as a value of that type. Just as 7 is a value of the kind “whole number,” this proof is a value of the kind “a + b = b + a.” What Lean checks is whether the kind of the proof you wrote fits exactly what you want to show. It finds mistakes in proofs the same way a program flags an error when you put letters where a number should go.
Some proofs are checked by calculation. In “example : 2 + 3 = 5 := rfl,” rfl means “both sides are the same,” and Lean computes both sides, gets 5 for each, and accepts it. If you wrote 2 + 3 = 6 instead, the calculation wouldn’t match, and Lean would reject it.
Long proofs are usually written with tactics (commands that tell Lean how to build the proof). Lean’s elaborator turns short proofs and tactics written by people into the detailed form that the kernel can read. At the end, the kernel checks that form.
Why can we trust Lean’s checking?
The tools for writing proofs can be large and complex. The elaborator and tactics may even contain bugs. Even so, whenever a theorem or definition is added to Lean, the kernel always checks at the end that it follows the rules. The kernel stands guard so that a bug in the elaborator can’t let a wrong proof through.
The kernel is a small program made of only the minimum needed to check the rules. It is kept small so that there is less in it to doubt and its checking can be trusted. In the field of proof assistants, this idea of leaving proofs in a form that a small kernel can check is called the “de Bruijn criterion.”
Because the kernel is small, other people can build their own checkers that follow the same rules. There is a checker called nanoda, built separately from Lean in a different programming language, Rust, and a tool called lean4checker that runs stored proofs through Lean’s kernel again. That way, you don’t have to rely on a single checker being free of mistakes.
Lean also records the axioms (basic rules of mathematics accepted without proof) that a proof relies on. A command, “#print axioms,” lists every axiom a theorem ultimately depends on. The important foundations for doing math in Lean are three axioms: Classical.choice, propext and Quot.sound. If a sorry (a mark meaning “not proved yet,” used in unfinished spots) is left anywhere, it shows up in the list too. A sorry can make anything count as proved, so it isn’t used in finished proofs.
Who made it, and who keeps it growing?
Leonardo de Moura started Lean in 2013 at Microsoft Research in the United States. The first version (0.1) came out in 2014, and Lean 3 in 2017. Work on Lean 4, the version used today, began in 2018, and its official release (4.0) came out in September 2023.
Lean 4 was rebuilt in Lean itself. Lean is both a tool for checking proofs and a functional programming language (a language for building programs by combining functions) that can make fast programs. Many people write their own tools for finding proofs automatically in Lean. It is also used outside math: for example, Amazon Web Services (AWS) uses Lean to formally verify Cedar, a language for writing rules about who may do what.
In July 2023, de Moura and Sebastian Ullrich founded the Lean FRO, a non-profit organization that develops Lean.
Mathlib is a library of formalized mathematics that Lean users build together. It began on Lean 3 in 2017 and finished moving to Lean 4 in July 2023. It now has over a million lines, and the official statistics seen on November 17, 2026 showed 140,046 definitions, 294,155 theorems and 772 contributors. New proofs can use the theorems in it as building blocks.
What have mathematicians used it for?
In December 2020, the mathematician Peter Scholze called for Lean to check what he said might be his most important theorem to date, which he had proved with Dustin Clausen. He wrote that nobody else had gone through the details, that a mistake could remain uncaught if others used the theorem without looking inside, and that for such an important theorem, being 99.9% sure was not enough. The challenge became known as the Liquid Tensor Experiment.
Half a year later, in June 2021, the part Scholze had been unsure about was checked, and he wrote that he had no remaining doubts about the correctness of the main proof. Along the way, a few slight imprecisions were found and fixed, and he said that using Lean deepened his understanding of the proof. The whole project, led by Johan Commelin, was completed on July 14, 2022.
On November 9, 2023, Tim Gowers, Ben Green, Freddie Manners and Terence Tao released a proof of one case of the polynomial Freiman–Ruzsa (PFR) conjecture, a conjecture spanning number theory and combinatorics (the math of counting and arranging). Tao and others soon started a group project to check it in Lean, and on December 5 the proof went through without a single sorry. That was about three weeks after the project began.
Fermat’s Last Theorem (no positive whole numbers a, b and c satisfy aⁿ + bⁿ = cⁿ when n is 3 or more) was proved by Andrew Wiles in 1995. Kevin Buzzard is leading a project at Imperial College London in the UK to check a modern form of this proof in Lean. The route, based on the proof by Wiles and others, was planned by Richard Taylor, and the project is funded by a UK research grant until September 2029.
How is it connected to AI?
Large language models (AI that writes text, like ChatGPT) can now solve math problems too, but they sometimes slip in plausible-looking mistakes (hallucinations). Checking a long proof that an AI wrote in ordinary language by reading every line is hard work for people. If the AI writes the proof in Lean’s language instead, Lean finds any wrong step.
In July 2024, Google DeepMind announced AlphaProof, an AI that searches for proofs in Lean’s language. People translated that year’s six International Mathematical Olympiad problems into a fixed form a computer can work with (Lean’s language, for AlphaProof), and AlphaProof solved two algebra problems and one number theory problem and proved its answers correct. Together with another AI (AlphaGeometry 2) that solved the geometry problem, the company says it scored 28 points, at silver-medal standard. It says one problem was solved within minutes and the others took up to three days.
In September 2026, the AI company Anthropic announced that its AI, Claude, working largely on its own for 11 days, had written a proof of Fermat’s Last Theorem in about 13 million lines of Lean (a company announcement). It says the proof relies only on Lean’s three standard axioms and that a tool also confirmed the proved statement matches the statement of Fermat’s Last Theorem in Mathlib. It describes the work as separate from Buzzard’s project but adapting parts of it, and says Buzzard reviewed the proof and gave comments.
This split, with AI writing proofs and Lean checking them, is spreading to formal verification, which checks that programs are correct (see the “Formal verification” page). There is also research on letting AI translate problems from ordinary language into Lean’s language, which brings the pitfall of mistranslation (see the “Autoformalization” page).
What doesn’t Lean check?
What Lean checks is “whether the statement written in Lean was proved according to the rules.” It does not check whether that statement means the same thing as the problem you really wanted to check. For example, if you write “for whole numbers from 0 up” where you meant “for any integer,” you have proved a different, easier problem, and Lean still accepts it (see the “Autoformalization” page).
Even partway through the Liquid Tensor Experiment, Scholze wrote that checking that all the definitions in the Lean statement of the theorem are exactly right is still a job that a person must do. When you doubt a statement, you need to look carefully at it and at every definition it uses.
Also, the kernel and the axioms are trusted as correct. The kernel is small and can be rechecked by other checkers, but these are all programs, so we can’t say there is no chance of a mistake at all. A proof that relies on axioms can be trusted only as far as those axioms are true and don’t contradict each other.
So when you hear “it was checked in Lean,” it’s important to look at which statement was checked, and on top of which axioms.
Check yourself
Q1Proofs tens of thousands of lines long that have passed in Lean, a programming language for writing out math proofs, are considered trustworthy. What is the main reason?
Answer and explanation
Answer: C A small kernel checked it one step at a time
Whoever wrote the proof, a person or an AI, a small part inside Lean called the kernel checks at the end, step by step, that it follows the rules. Because the kernel is small and simple, there is little in it to doubt, and checkers that other people built can recheck the proof. Even if the tools for writing proofs (the elaborator or automatic tools) have bugs, the kernel’s check stops them. Lean itself is not an AI, and the kernel’s check can be trusted without crowds of people rereading the proof.
More on this → Key points: Why can we trust Lean’s checking?
Q2How do AlphaProof, an AI for solving math problems announced by Google DeepMind in 2024, and Lean, a programming language for writing out math proofs, divide the work?
Answer and explanation
Answer: B AlphaProof searches for proofs, and Lean checks them
AlphaProof is an AI that searches, step by step, for proofs in Lean’s language, and Lean checks whether those proofs follow the rules. The AI does the thinking, and Lean does the checking. Lean itself is not an AI that reads a problem and figures out how to solve it. Also, the 2024 International Mathematical Olympiad problems given to AlphaProof had been translated into Lean’s language by people. Lean is not a tool for translating proofs into ordinary language, either.
Q3An AI rewrote a math problem as a statement in Lean, the programming language for checking proofs, proved it, and the proof passed Lean’s check. What should a person still check separately?
Answer and explanation
Answer: A Whether the Lean statement means the original problem
What Lean checks is whether the statement written in Lean was proved according to the rules. Lean does check how the steps of the proof connect and the calculations inside it. But it does not check whether the statement means the same thing as the original problem. For example, rewriting “for any integer” as “for whole numbers from 0 up” proves a different, easier problem, and Lean still accepts it. The mathematician Scholze also wrote that a person must check whether all the definitions in the Lean statement of a theorem are right.
Related terms
- Formal verification
- Autoformalization
- Proof assistant
- Formal proof
- Theorem proving
- Mathlib
- Large language model
- Hallucination
- Reinforcement learning
- Functional programming
- Type theory
- Fermat’s Last Theorem
Sources and how we checked
- Lean FRO, “Lean” (the official Lean website; Lean as an open-source programming language and proof assistant, a real functional language that compiles to native code, its minimal trusted kernel, Mathlib with over a million lines, and AWS using Lean to formally verify Cedar, the AWS authorization policy language; read November 17, 2026)
- Lean FRO, “About” (the Lean FRO’s introduction and timeline: the first commit in July 2013, Lean 0.1 in June 2014, Lean 3.0 in January 2017, Mathlib3 in July 2017, Lean 4 development beginning in April 2018, the Lean FRO founded by Leonardo de Moura and Sebastian Ullrich in July 2023 as a non-profit under Convergent Research, the port of Mathlib to Lean 4 completed in July 2023, and Lean 4.0 in September 2023; read November 17, 2026)
- Leonardo de Moura and Sebastian Ullrich, “The Lean 4 Theorem Prover and Programming Language” (CADE-28, July 2021; abstract on Microsoft Research’s publication page: Lean 4 as a reimplementation of the Lean interactive theorem prover in Lean itself, also an efficient functional programming language, and many users writing custom proof automation in Lean. The paper’s full text [PDF] could not be read from here; read November 17, 2026)
- Jeremy Avigad, Leonardo de Moura, Soonho Kong and Sebastian Ullrich, “Theorem Proving in Lean 4” (the official introductory book: Chapter 1 [the Lean project launched by de Moura at Microsoft Research Redmond in 2013, its basis in the Calculus of Constructions with inductive types, and Lean as also a programming language], the chapter Propositions and Proofs [a proposition seen as the type of its proofs, and t : p read as t being a proof of p], the chapter Quantifiers and Equality [example : 2 + 3 = 5 := rfl and example : a + b = b + a := Nat.add_comm a b], and the chapter Tactics [tactics as instructions that tell Lean how to construct a proof term, and simp rewriting the goal by applying given identities repeatedly]; read November 17, 2026)
- Lean FRO, “The Lean Language Reference,” chapter Elaboration and Compilation (the official manual: elaboration transforming user-facing syntax into the core type theory, the simpler core letting the trusted kernel be very small, the kernel checking results to guard against bugs in elaboration, and everything added to the environment being checked by the kernel first; read November 17, 2026)
- Lean FRO, “The Lean Language Reference,” chapter Axioms (Lean tracking the axioms each proof depends on, which #print axioms lists, the sorry axiom sorryAx being able to prove anything and not meant for finished proofs, Classical.choice, propext and Quot.sound as important parts of how mathematics is done in Lean, and a proof relying on an axiom being trustworthy only to the extent that the axiom is true and consistent; read November 17, 2026)
- Lean FRO, “The Lean Language Reference,” chapter Validating a Lean Proof (a check being meaningful only if the formal theorem statement corresponds to its intended meaning, investigating the statement and all referenced definitions carefully when in doubt, lean4checker replaying stored proofs through the kernel, nanoda as an independently developed checker written in Rust, and the soundness of Lean’s logic and the absence of an implementation bug affecting all the checkers used at once as remaining assumptions; read November 17, 2026)
- “Type Checking in Lean 4,” section What is the kernel? (an unofficial community guide to Lean’s kernel, not the official manual: the kernel as an implementation of Lean’s logic with the minimum machinery, isolating a small kernel to increase the trustworthiness of the proof system, the “de Bruijn criterion” quoted from Adam Chlipala’s book, and the kernel being small enough for others to write their own and check Lean proofs independently; read November 17, 2026)
- Adam Chlipala, “Certified Programming with Dependent Types,” Introduction, section An Easy-to-Check Kernel Proof Language (a book on proof assistants: proof assistants satisfy the “de Bruijn criterion” when they produce proof terms in small kernel languages, even when they use complicated procedures to seek out proofs; read November 17, 2026)
- Mathlib, “mathlib” (Mathlib’s official page: a community-driven effort to build a unified library of mathematics formalized in Lean, also containing definitions useful for programming; read November 17, 2026)
- Mathlib, “Mathlib statistics” (Mathlib’s official statistics: 140,046 definitions, 294,155 theorems and 772 contributors. The page shows no date for the figures, so they are given as of the day they were read; read November 17, 2026)
- Peter Scholze, “Liquid tensor experiment” (guest post on Kevin Buzzard’s Xena blog, December 5, 2020: possibly his most important theorem to date, being 99.9% sure not being enough, nobody else having looked at the details, a mistake possibly remaining uncaught if others use it as a black box, and the challenge to formalize the proof of Theorem 1.1; read November 17, 2026)
- Peter Scholze, “Half a year of the Liquid Tensor Experiment: Amazing developments” (guest post on the Xena blog, June 5, 2021: the part he was unsure about being verified, no remaining doubts about the correctness of the main proof, some slight imprecisions found and fixed, and the proof assistant helping him understand the proof; in Scholze’s reply in the comments on June 15, 2021, checking that all definitions entering the Lean statement are exactly correct still being something a human must do; read November 17, 2026)
- Lean community, “Completion of the Liquid Tensor Experiment” (Lean community blog, July 15, 2022: completion on July 14, 2022, the main theorem of liquid vector spaces by Clausen and Scholze, the project led by Johan Commelin, and a year and a half after Scholze posed the challenge; read November 17, 2026)
- W. T. Gowers, Ben Green, Freddie Manners and Terence Tao, “On a conjecture of Marton” (arXiv:2311.05762, v1 November 9, 2023; abstract [proving a conjecture of Marton, widely known as the polynomial Freiman–Ruzsa conjecture, in characteristic 2] and subject classes [Number Theory math.NT and Combinatorics math.CO]; read November 17, 2026)
- Terence Tao, “Formalizing the proof of PFR in Lean4 using Blueprint: a short tour” (Tao’s blog, November 18, 2023: starting, with Yael Dillies and Bhavik Mehta, a project to formalize the proof of the PFR conjecture in Lean4, less than a week after its launch, and sorry as a mark that a proof is not yet provided; read November 17, 2026)
- Lean Zulip archive, “Project completed! Thoughts and reflections?” (the PFR project’s discussion stream; Terence Tao’s message of December 5, 2023: Lean proving PFR_conjecture without any sorrys, the project’s primary goals being completed, and it not being something one person could have done. The figure of about three weeks was counted from the November 18 blog post’s “less than a week” to this day; in the same thread, Patrick Massot also refers to “the three weeks of this project”; read November 17, 2026)
- Imperial College London, “Fermat’s Last Theorem” (the GitHub description of the project led by Kevin Buzzard: an ongoing multi-author open-source project to formalize a proof of Fermat’s Last Theorem in Lean, funded until September 2029 by EPSRC grant EP/Y022904/1, and a route planned out essentially entirely by Richard Taylor in discussions with Buzzard, a modern variant of the original Wiles/Taylor–Wiles proof; read November 17, 2026)
- Google DeepMind, “AI achieves silver-medal standard solving International Mathematical Olympiad problems” (company announcement, July 25, 2024: AlphaProof training itself to prove statements in the formal language Lean and searching over possible proof steps in Lean, the problems being manually translated into formal language, AlphaProof solving two algebra problems and one number theory problem and AlphaGeometry 2 the geometry problem, 28 points at silver-medal standard, one problem solved within minutes and up to three days for the others, and natural-language approaches being able to hallucinate plausible but incorrect steps; read November 17, 2026)
- Anthropic, “Formalizing Fermat’s Last Theorem” (company announcement, September 4, 2026: Claude working largely autonomously for 11 days to write what the company calls the first complete computer-checked proof of Fermat’s Last Theorem in Lean, about 13 million lines, relying only on Lean’s three standard axioms, a comparator confirming that the theorem’s statement matches Mathlib’s, Wiles’s 1995 proof, adapting pieces of Buzzard’s project and others, and Buzzard reviewing the proof and commenting; read November 17, 2026)
- Lean JA, the Japanese Lean community (Japanese page describing Lean as a purely functional language that is also a proof assistant able to check mathematical proofs; used for the Japanese names; read November 17, 2026)
AI wrote this page from the sources above, and a different AI checked it against the text of those sources (November 17, 2026). A person with a master’s degree in science and a Japanese high-school science teaching license also read and checked it before publishing. Numbers are as of that date. If anything was hard to follow, you spot a mistake, or there’s a term you’d like explained, please write to [email protected].
AI terms
- AI agent
- AI alignment
- Alignment faking
- Artificial general intelligence (AGI)
- Artificial intelligence (AI)
- Autoformalization
- Backdoor
- Benchmark
- Chain of thought (CoT)
- Context window
- Data poisoning
- Deep learning
- Deepfake
- Diffusion model
- Embedding
- Emergent misalignment
- Evaluation awareness
- Fine-tuning
- Formal verification
- Generalization
- Generative adversarial network (GAN)
- Generative AI
- Gradual disempowerment
- Hallucination
- Hyperparameter
- Intelligence explosion
- Interpretability
- Jailbreaking
- Large language model (LLM)
- Latent space
- You are hereLean
- Machine learning
- Mixture of experts (MoE)
- Neural network
- Neuralese
- Overfitting
- Parameter
- Persona vectors
- Pre-training
- Prompt
- Prompt injection
- Reasoning model
- Recursive language model (RLM)
- Recursive self-improvement (RSI)
- Red teaming
- Reinforcement learning (RL)
- Retrieval-augmented generation (RAG)
- Reward hacking
- Shutdown resistance
- Sleeper agent
- Subliminal learning
- Superintelligence (ASI)
- System prompt
- Technological singularity
- Time horizon
- Token
- Transfer learning
- Transformer