What Lean is and why mathematicians trust it
A mathematician writes a proof five hundred pages long. Only a handful of people understand it, and for years they cannot agree on whether it is correct. That is exactly what happened with the abc conjecture. Could a proof be checked in a way that leaves nothing to argue about?
Lean is a computer program and, at the same time, a language in which you write down a proof; the program then checks every single step. It skips nothing and nothing is “obvious” to it. So whom should you trust more, a referee or a machine? These days more and more mathematicians would say the machine. But only if the problem itself, that is, the statement being proved, has been written down correctly in Lean. Lean will, for example, accept without batting an eyelid that
A referee is only human. With a long proof they get tired, and they don’t pause at a sentence saying “clearly, this holds”. Even famous mathematicians have got things wrong: Henri Poincaré won a prize from the King of Sweden for a paper on the motion of the planets, in which a serious error was later found. In 1993 Andrew Wiles announced a proof of Fermat’s Last Theorem, and the referees found a gap in it, which he then spent another year fixing together with Richard Taylor.
What a proof in Lean looks like
Leonardo de Moura started developing Lean in 2013 at Microsoft Research. Today the version in use is Lean 4, and its development is led by the non-profit organisation Lean FRO. You don’t have to read all the code in the examples; it is enough to see where the theorem is and where the proof is. The simplest one looks like this:
theorem two_plus_two : 2 + 2 = 4 := rfl
theorem introduces a theorem, two_plus_two is its name, after the colon comes the statement 2 + 2 = 4 and after := comes the proof. It consists of the single word rfl, which tells Lean: “expand both sides according to the definitions and you get literally the same thing”. Lean does so and accepts the theorem. If we wrote 2 + 2 = 5, it would report an error.
The command decide can do the same; it settles the statement by computation. The word by introduces a proof built from such commands, and example is a theorem without a name:
example : 2 + 2 ≠ 5 := by decide
Things get more interesting with a variable. Lean doesn’t have addition handed down from above; it is defined like this:
def plus : Nat → Nat → Nat
| m, 0 => m
| m, n + 1 => plus m n + 1
Nat stands for the natural numbers including zero, and the arrows say that plus takes two such numbers and returns a third. The definition then says two things: adding zero means doing nothing. And adding n + 1 means adding n and then one more. So Lean computes 3 + 2 as (3 + 1) + 1. The second number is whittled down one at a time until only zero is left. The built-in + in Lean is defined in the same way, it is just called Nat.add, and that is what the other examples use.
Now two theorems that look equally obvious:
For the first one, Lean expands the left-hand side using the first line of the definition: n + 0 becomes n. Both sides are literally the same, so rfl works:
theorem plus_zero (n : Nat) :
n + 0 = n := rfl
For the second one, though, rfl fails. The definition looks at the second number and asks whether it is zero or something plus one. Lean doesn’t know that about an unknown n, so it has no way to expand 0 + n and gets stuck. The computer doesn’t take even the obvious on trust. It needs a proof.
The proof is by mathematical induction, which works like a row of dominoes. We show that the first domino falls: 0 + 0 = 0, which Lean computes. And we show that every falling domino knocks over the next one: if 0 + k = k holds, then 0 + (k + 1) = k + 1 holds too. By the definition, 0 + (k + 1) is the same as (0 + k) + 1, and we may replace 0 + k with k. Then all the dominoes fall.
For the curious: in Lean it takes five lines.
theorem zero_plus (n : Nat) :
0 + n = n := by
induction n with
| zero => rfl
| succ k ih => rw [Nat.add_succ, ih]
induction n splits the proof into the first domino (zero, that is, n = 0) and the step from k to k + 1 (succ, short for successor). In the step, ih stands for the assumption 0 + k = k. Nat.add_succ is a theorem from the library which says n + (k + 1) = (n + k) + 1, and rw means “rewrite using it”. The goal 0 + (k + 1) = k + 1 thus turns into (0 + k) + 1 = k + 1, and after rewriting with the assumption both sides come out as k + 1.
A stronger helper, omega, solves equations and inequalities with integers and natural numbers on its own, as long as they only involve adding, subtracting and multiplying by a specific number:
example (a b : Nat) (h : a < b) :
2 * a + 1 < 2 * b := by omega
Why trust it
The proof of a famous theorem in Lean can easily run to millions of lines, and nobody reads them. Why trust them?
Because commands such as rw, omega or decide don’t have the final say. They only assemble the proof into a detailed form. That form is then passed to Lean’s kernel, a small program that goes through one tiny step after another and checks for each one that it follows the rules. It works like a clerk who doesn’t read the whole file, but checks that every stamp in it is genuine. Each task is simple, which is why the kernel is small and people can read and inspect it. It does a similar job to a compiler, which makes sure you aren’t adding a number to a piece of text. And it doesn’t care who wrote the proof:
So you only need to trust the narrow gate, not the whole heap of code. This is called the de Bruijn criterion, and de Moura summed it up in these words: “You don’t need to trust me or my automation. You only need to trust the small kernel.” The kernel is also one of the few parts of Lean that were not rewritten from scratch in the move to Lean 4.
And what if you don’t trust even the kernel? There are independent kernels. Nanoda and lean4lean were written by other authors, independently of the Lean developers. Con-leche and con-ron were written by the Lean developers, but they come with a mathematical proof that they will not accept a wrong proof. For big results, the proof is run through several such gates. In the picture, they are the blue and green gates at the bottom.
The orange card at the top is the statement, the claim we are proving. The kernel checks that the proof proves exactly what is written on it. Whether what is written there is what we meant has to be judged by a human.
The Mathlib library
Nobody wants to prove 0 + n = n over and over again. That is why mathematicians are jointly building the Mathlib library, which today contains almost 300,000 theorems. A new theorem then simply refers to the old ones.
The picture shows the number of lines according to the official statistics. The blue line is the original library for the older Lean 3. The sharp jump in the red line in 2023 is not new theorems, but the conversion of the whole library to Lean 4. Today it has over two and a half million lines; printed at fifty lines per page, it would take up over 50,000 pages.
From four colours to the Riemann hypothesis
Computers were checking proofs even before Lean, in other programs too:
The square is the Coq proof assistant (now Rocq), the circles are Lean. In blue are the checks written by humans, in red those whose decisive part was written by artificial intelligence.
1. The four colour theorem says that every map can be coloured with four colours so that neighbouring countries have different colours. Its first proof, from 1976, relied on a computer calculation that no human can go through by hand. In 2005 Georges Gonthier translated a later, simplified proof from 1996 into Coq, so the computer checked the reasoning as well, not just the calculation.
2. Peter Scholze, one of the best mathematicians of today, asked the Lean community in 2020 to check his and Clausen’s brand-new theorem: “being 99.9% sure is not enough.” The community completed the work in July 2022.
3. Fermat’s Last Theorem says that the equation an + bn = cn has no solutions in positive integers for n>2. In September 2026 the company Anthropic announced that its model Claude had written its proof in Lean, according to Anthropic in about 11 days and in about 13 million lines. Kevin Buzzard, who since 2024 has led a human project to formalise the same theorem, compiled the code himself and verified it. Mathematically, he says, it “tells us essentially nothing”, because the proof had been trusted for a long time. But it shows what computers can achieve today when translating into Lean.
4. The Riemann hypothesis, one of the Millennium Prize Problems, says where the zeros of a certain function connected with the prime numbers lie. In November 2026 Levent Alpöge, a mathematician at Anthropic, published a proof of it, made with the help of Claude. It exists only as a Lean library of roughly 17 million lines. A day later, on 21 November, Lean FRO together with the Mathlib Initiative, the organisation that maintains Mathlib, issued a statement: “We hereby certify that both the statement and the proof of the Riemann Hypothesis are correct.” They checked that the theorem proved is exactly the formulation that experts had vetted in Mathlib long beforehand. The proof passed the official kernel and several independent ones, among them con-leche and con-ron. Dozens of people compiled the code independently.
In fairness, we should add that the formalisations of Fermat’s theorem and of the Riemann hypothesis were both produced at Anthropic with the model Claude, which also helped to write this article. The information on how they came about comes from Anthropic, but their correctness was verified by independent people.
A human-readable proof of the Riemann hypothesis doesn’t exist yet, only a four-page sketch, which the mathematician Andrew Granville criticised as incomprehensible. We describe the situation as of 24 November 2026.
Artificial intelligence writes, Lean keeps watch
Language models can write convincing-looking nonsense. That is why in 2024 Terence Tao suggested that artificial intelligence should write proofs directly in Lean: the errors Lean finds are sent back to it to fix, and whatever gets through has been checked. At the 2025 International Mathematical Olympiad, the Aristotle system from the company Harmonic solved five problems out of six in Lean, a gold-medal performance. The problems, however, had been translated into Lean for it by humans. AI can write proofs faster than people can read them, and Lean is a sieve that lets through nothing that doesn’t follow from the statement. You will come across new results in the articles on colouring the plane and on twin primes too.
Where the catch is
A badly written statement. A spell checker will let through the sentence “The cat barks at the Moon.” It is spelt correctly, and yet it is nonsense. Lean is in a similar position: it checks that the proof proves the statement as written, but not that this is the statement we wanted. Try this:
example : 2 - 5 = 0 := by decide
example : 7 / 0 = 0 := by decide
Lean accepts both. There are no negative numbers among the natural numbers, so subtraction in Lean stops at zero. And division by zero gives zero by convention, because every operation has to have some result. These aren’t errors, just conventions. But anyone who concluded from these lines that
Even more treacherous is an assumption that cannot hold:
example (n : Nat) (h : n < 0) :
n = 42 := by omega
“Every natural number less than zero is equal to 42.” Lean agrees, because there is no such number. In the same way, “Every unicorn in my garage is pink” is true, because there aren’t any in the garage. This happens on a large scale too. Artificial intelligence once solved one of Erdős’s problems, but in the easier of the two versions that Erdős posed. And in November 2026 Kevin Buzzard worked out that of roughly 290 papers with Lean published by the company OpenAI, about one in eight does not prove its main theorem in Lean. That is why, for big results, the statement is compared with a formulation that experts have vetted in advance, as with the Riemann hypothesis.
IOUs. A step we can’t prove yet can be skipped in Lean with the word sorry:
example : 2 + 2 = 5 := by sorry
Lean accepts such a “theorem” and only prints a warning saying that it contains sorry. An axiom, a statement we accept without proof, works in a similar way. The command #print axioms lists the axioms a theorem rests on, and it reveals hidden sorrys too. An honest theorem rests on at most three standard ones. The proof that the number
Bugs in the kernel itself. The kernel is a program too. In July 2026 two bugs were found in it, and thanks to one of them a false “disproof” of the Collatz conjecture was produced with the help of AI. Both could only be exploited with special code that interferes with the running of Lean itself, and both were fixed quickly, the second within an hour of being reported. That is exactly why big proofs are run through several independent kernels.
Verified does not mean understood. Lean tells you that a theorem holds, but not why. Yet mathematics is not a collection of true theorems. From a good proof, people learn new ideas and use them elsewhere. The Riemann hypothesis in 2026 is the starkest example of this: within a day, the Lean and Mathlib developers confirmed that the proof in Lean is correct, and yet nobody can explain it so far.
So what is Lean good for? It gives certainty about proofs that are too long for humans to check, and it doesn’t let artificial intelligence make up a proof; only the statement has to be watched by a human. And because it is also a programming language, it can be used to verify programs too.
Try it yourself
Open live.lean-lang.org in your browser (nothing needs installing) and paste in:
example : 2 + 2 = 4 := by decide
If the proof goes through, Lean reports no error. Then change the four into a five. The line gets a red underline, and Lean replies that it has proved that the statement 2 + 2 = 5 is false (proved that the proposition ... is false), and it does not accept the theorem.
Extra challenge: prove that n + m = m + n. Start with the line example (n m : Nat) : n + m = m + n := by and try omega. Then try the same by induction, without omega. You will need the theorem zero_plus from the example and one more: (k + 1) + m = (k + m) + 1, which you can prove in the same way, by induction on m.
Where next? The Natural Number Game takes you step by step through proofs about the natural numbers, including this one. The textbook Mathematics in Lean goes a step further. And at the Faculty of Mathematics and Physics of Charles University in Prague, Lean is taught in dedicated courses, for example this one.
You will find more famous problems in the Famous problems category.