Skip to content
Vibe Math Lab.

Lesson 10 of 23

How to check an AI-generated proof in Lean, step by step

Five checks for a proof written in Lean by an AI, in order: read the statement, look for gaps and extra axioms, build it yourself, compare it against a trusted statement with independent checkers, and know what a passing check still leaves open. The Riemann hypothesis claim of November 2026 is the running example.

I'm Tyler Orden, an independent researcher who does mathematics with AI agents. My research record is at Cyborg Mathematics.

Lean is a programming language in which a computer checks every step of a proof. When an AI writes a proof in Lean and the code compiles, it is tempting to treat the result as settled, but a compiled proof tells you something real only after a few more checks, and an AI that is rewarded for code that compiles may find shortcuts a person would not. Kevin Buzzard, a mathematician at Imperial College London, set out four questions to ask in a post on November 12, 2026: does the Lean statement match the real theorem, does the code compile, does it prove the theorem as stated with no hidden tricks, and does it exploit a bug in Lean's checker. Steps 1 to 4 below follow his questions, and step 5, on what a pass leaves open, is mine.

The running example is a claim made eight days after Buzzard's post. On November 20, 2026, Levent Alpöge, a mathematician at Anthropic, released about 17 million lines of Lean code that he says prove the Riemann hypothesis, a famous unsolved problem about prime numbers; he says he found the proof working with Claude, Anthropic's AI model. Under each step I say where that code stood at 10:30 p.m. Pacific time that night. In short: by the reports below it had passed steps 1 and 2, an independent build had succeeded, step 4 was still running, and the claim was not yet verified. My page Is the Riemann hypothesis solved? has the latest. For checking proofs in general, not only in Lean, see How to check an AI-written proof.

1. Read the statement before anything else

Every Lean project has a headline theorem: the statement it claims to prove. Lean checks the proof against that statement exactly as typed, and a statement typed slightly wrong still compiles. Buzzard's example is a statement that looks like Fermat's Last Theorem but allows the numbers to be 0. That version happens to be false, since 0³ + 0³ = 0³, so no proof of it will ever compile and the mistake comes to light. The dangerous mistake is the other kind: a mistyped statement that is true and easier than the real one, because then a proof compiles and looks like success. Reading the statement is a job for a person who knows both Lean and the mathematics.

The best case is a short statement file that uses only definitions from Mathlib, Lean's shared math library, which human experts review. The Riemann hypothesis code has one: a 16-line file that imports only Mathlib, and a main theorem whose type is Mathlib's own definition of the hypothesis:

Mathlib's definition of the Riemann hypothesis (at the version the project uses)
def RiemannHypothesis : Prop := ∀ (s : ℂ) (_ : riemannZeta s = 0) (_ : ¬∃ n : ℕ, s = -2 * (n + 1)) (_ : s ≠ 1), s.re = 1 / 2

In words: every complex number s where the zeta function is zero, other than the easy zeros at -2, -4, -6 and so on, and other than s = 1, has real part 1/2, which is what the hypothesis says (a plain explanation). The clause about s = 1 is there because Mathlib gives the zeta function a placeholder value at 1, where it is not really defined. When a statement depends on definitions the project wrote itself, every one of those has to be read too, and that can run to thousands of lines. Buzzard gives the example of a statement of the Hodge conjecture that rests on more than 10,000 lines of new definitions.

Where the Riemann code stood: this step had passed. I checked the statement, and it was read by hand by the people running the Lean community's public verification repository for this code.

2. Look for gaps and extra axioms

In Lean, "sorry" marks a step left unproved, and an axiom is a statement assumed without proof. Ordinary mathematics in Lean assumes three standard axioms, called propext, Classical.choice and Quot.sound. Anything beyond them means the proof rests on more than standard mathematics, and an added axiom could simply assume the answer. Two common ways in are "sorry" and "native_decide", a shortcut that trusts the result of running compiled code instead of checking it step by step; each adds an axiom behind the scenes. A text search for these words is a quick first pass. For the Riemann code, a search of all 175,187 files found none of them. The Lean community's notes add that the code uses tactics (commands that build parts of a proof automatically) which skip some of Lean's usual checks, leaving the kernel, the small core of Lean that has the final say, as the only check on those steps. Lean allows this, but it puts all the weight on the kernel being right, which is why step 4 uses more than one checker. A text search is only a first pass. The reliable test is Lean's own report, once the project builds:

Ask Lean which axioms a theorem depends on
import Main #print axioms riemannHypothesis -- A complete proof in standard mathematics lists only: -- [propext, Classical.choice, Quot.sound] -- sorryAx in the list means a step was left unproved.

3. Build it yourself, at the pinned versions, in a sandbox

A project pins the exact Lean version in a file called lean-toolchain and the exact library versions in lake-manifest.json. Build with those, not with whatever you have installed. Run AI-written code only in a sandbox, a container with no network and no access to your files, because compiling Lean runs code. Large proofs need large machines. To build a 13-million-line Lean version of the proof of Fermat's Last Theorem (proved by hand in the 1990s) that Anthropic produced, Buzzard needed a machine with 96 cores and 500 GB of memory, and the Lean community expected 7 to 10 hours on a machine with 48 cores and 503 GB of memory for the Riemann code. Also look up whether the pinned Lean version predates known fixes to its checker. The Riemann code uses Lean 4.33.1, and the community's notes say that a build with that version alone counts as limited evidence for that reason. That does not mean anything is wrong; it is why the final judging uses a newer Lean version and independent checkers.

Where the Riemann code stood: Andrew Sutherland, a mathematician at MIT who compiled the code independently, told Scientific American that the proof "has been compiled and independently rechecked by the Lean kernel with only the three standard axioms," so step 2 had passed in his run, and an independent build had succeeded.

4. Compare it against a trusted statement, with independent checkers

A statement file can be clean while somewhere in millions of lines of proof the meaning of its symbols is changed or an axiom is added. Comparator, a tool from the Lean developers, is built to catch that. You give it a trusted challenge file with the statement and only trusted imports, plus the untrusted solution, and it checks that the theorem proved is the same one and that only the standard axioms are used. In its paranoid mode it also has up to five further checkers, most of them written separately, recheck the whole proof. As Buzzard puts it, a proof that exploits a bug in Lean's own kernel would also have to exploit bugs in several independent programs at once to pass. Palomar, a public registry that rechecks Lean proofs by machine, runs the same kind of check on every proof submitted to it.

Where the Riemann code stood: a public repository run by the Lean community was doing this run and had not posted a result. Three of the five extra checkers cannot be used on it, for reasons unrelated to the proof's correctness: two cannot read one kind of definition the code uses, a limit the community reproduced on a small, correct example, and one rejects all code from this Lean version. So the judging relies on three checkers: Lean's kernel, a stricter build of it, and an independently written checker called nanoda, with one more independent checker run separately.

5. Know what a passing check does not show

Buzzard wrote that a Lean proof that passes all of these tests is overwhelmingly likely to be a correct proof of the theorem it states. A pass still leaves four things open. Whether the statement means what people mean by the theorem is settled only by step 1. The check trusts Mathlib's definitions, which experts review but which are still a human product. It does not explain why the theorem is true: the Riemann code may be correct and is still far too long to read, and mathematicians want an argument they can follow. And it says nothing about any accompanying paper. Buzzard notes that in one AI-assisted project the written proof and the Lean proof diverged in places, so a correct Lean proof does not make the paper correct.

I have taken one of my own proofs through these steps. Erdős Problem #112 asks how many points a network of one-way links needs before it must contain either 6 points with no links among them or three points where A links to B, B to C and A to C; my Lean proof shows the answer is 30, 31 or 32. Palomar rechecked it with three independent checkers and registered it on November 15, 2026. For step 1, the registration rests on an AI's reading: Palomar compared the statement with the problem using an AI review, and no person at Palomar reviewed the proof.

Checklist for a Lean proof an AI wrote
1. Statement: which file, which theorem? Does it use only Mathlib definitions? Read it against the standard statement, clause by clause. 2. Gaps: search for sorry, admit, axiom, native_decide; then run #print axioms on the headline theorem. Only propext, Classical.choice, Quot.sound? 3. Build: pinned Lean and library versions, in a sandbox with no network. Does the pinned Lean version predate known checker fixes? 4. Comparator: trusted challenge file against the solution, in paranoid mode with independent checkers. Which checkers accepted? 5. Record: write down which checks passed, which were not run, and who read the statement.

Disclosure: I use Claude, Anthropic's AI model, for my own research, including Lean proofs. I do not work for Anthropic.

Short answers

Does a Lean proof that compiles prove the theorem?

It proves the statement exactly as typed into Lean, provided there is no sorry, no extra axiom and nothing in the code that changes what the statement means. Whether that statement is the theorem people mean has to be checked by a person reading it.

What does #print axioms show?

It lists every axiom a theorem depends on. A complete proof in standard mathematics lists only propext, Classical.choice and Quot.sound. Anything else, such as sorryAx, means the proof assumes something more.

What is Comparator in Lean?

A tool from the Lean developers that checks that a proof built with untrusted code proves exactly the statement in a trusted file, using only the standard axioms. In paranoid mode it also has separately written checkers recheck the proof.