Lesson 10 of 24 ·
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.
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:
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.
The theorem statement is the spec
Added November 27, 2026, evening. A software team would recognize the situation at once. The statement is the requirement, the proof is the implementation, and Lean is a test suite with a single test: does this proof prove this statement? It answers that question very reliably, and it has nothing to say about whether the requirement was written correctly. So I read a statement the way a careful reviewer reads acceptance criteria, before looking at the work: every definition it depends on, every quantifier, every hypothesis, and anything the conjecture's own wording leaves unsaid.
Vibe proving, the name some people now use for proofs produced by AI and checked in Lean, makes this matter more. When a model can produce a proof in hours, as LuminaBench reports below, the slow and careful part of the work moves to the statement. The same idea, applied before any agent computes, is the subject of Acceptance criteria for AI agents, and Managing AI agents like a product manager puts it next to the other habits I borrow for this work.
Does the statement say what the paper says? Three ways to check
Added November 27, 2026. Reading the statement, step 1 above, has become the weakest link in many AI-made Lean proofs, because the other steps can be run by machine and this one cannot. On November 27 a GitHub account, LuminaBench, posted Lean proofs that it says settle three conjectures from published papers, made with a public AI model in a couple of hours by its own account (my news note); they are claimed, not yet independently verified. When proofs come that fast, the question that decides whether a result means anything is whether each Lean statement says what the paper's conjecture says. There are three ways to check it, and they catch different things.
- A second AI model compares the Lean statement with the paper. A model from a different family translates the Lean statement back into plain words and compares it with the paper's wording: the definitions, the quantifiers (for every, there exists), the ranges, the edge cases such as n = 0. This is what LuminaBench does, and it is cheap enough to run on every result. It catches slips of encoding well; in one of LuminaBench's transcripts the second model spotted a probable typo in the paper itself. Its limit is independence. Both models read the same text, and the comparison asks whether two readings agree, so if the paper can be read two ways, both models can settle on the same reading without saying that a choice was made.
- A person reads the two side by side. Someone who knows the area puts the Lean statement next to the paper and reads it clause by clause, including every definition the statement depends on that is not from Mathlib. A person brings what the models lack: knowledge of the field's conventions, of what the authors obviously meant, and of which reading is the interesting one. It is slow, it needs someone who reads both Lean and the mathematics, and for a long project it is a real job, and it is the only one of the three that brings knowledge from outside the paper and the AI's statement.
- Write the statement first, blind. Before looking at the AI's Lean statement, someone writes their own formal statement from the paper or a textbook, then the two are compared, ideally by proving in Lean that they are equivalent. Carlos Toledo did this for OpenAI's matrix multiplication claim in November 2026: his open audit checked the Lean theorem against "two statements written blind from the textbooks" and recorded where they agreed (the news item). The strength is that the blind statement owes nothing to the AI's reading, so any difference between the two is exactly the question to settle. The writer can be a person or a separate model that never sees the AI's version.
My answer to which is best: use them in this order and let each feed the next. Run the second-model comparison on everything, because it is nearly free. Write a blind statement for anything that matters, because a disagreement between two independent readings is the most useful signal you can get cheaply. Then have one person read the statement next to the paper, starting with the places where the readings disagreed and with any hypothesis that is not written in the conjecture itself. The machine checks, once someone outside has reproduced them, tell you Lean accepts the proof; only these three tell you it is a proof of the right thing.
An example of why the person matters. Benfield and Lippard's Conjecture 5.2 says a table from their Theorem 4.27 "also applies" in a new setting, without repeating that theorem's conditions on parity. LuminaBench proved it with the conditions included. Without them it is false: in my own check, with a = -12 the counts are 1 and 2 at the moduli 2 and 5 but 1 at 10, where the table says 2. Including the conditions is probably what the authors meant, and the repository says plainly which reading it proved. The referee model noted that the conditions were carried over from Theorem 4.27 and judged the encoding faithful; it did not raise whether the authors intended them, or that the statement is false without them. A summary that says "Conjecture 5.2 is proved" hides that choice. Deciding which reading the paper's authors would sign is the job for a human reader, and it does not require redoing the proof.
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:
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.
A practical example came five days after the original, when checking at home became realistic. On November 25 a rewrite of the same proof was posted at github.com/lsernau/grh-lean, its README says with colleagues at Anthropic and with Claude, in a readable edition of about 300,000 lines and a compact one of about 76,000. Its README gives a build of one to two hours on 12 cores with 24 GB of memory (about 85 minutes more if the Mathlib cache is missing), where the original needed a 48-core server. In between, the Lean community had been compressing the original itself: the unofficial dashboard rh-shrink.github.io counts its repository falling from 175,187 files to about 59,000 by November 25, and Sebastian Ullrich of the Lean FRO wrote on LinkedIn that this version compiled in about 35 minutes on one large off-the-shelf AWS machine with 192 cores. The rewrite's README also lists exactly what a reader must trust: Statements.lean, which imports only Mathlib, the five statements in Main.lean, and the axiom list. Everything else is for the machine.
I have not built it myself. Andrew Sutherland of MIT, who ran his checks with Claude Code, reports on his page for the shorter proof that a sandboxed build of each edition took about half an hour on a 16-core machine with 128 GB, that a kernel replay of every module took about 12 minutes, and that lake comparator in its --paranoid mode reports "Your solution is okay!" for both editions. One caution from his page: one checker, lean4lean, needed 332 GB of memory on the readable edition, so the full paranoid run is still a job for a big machine.
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.
Update, November 25: Sutherland's page for the original records that Comparator finished on it, passing on November 23 (an unmodified Comparator run) and on November 25 (lake comparator from exports), and that the shorter rewrite passed lake comparator --paranoid the same day. Update, November 26: Sutherland's page for the shorter proof now says all of its checks have finished, and the Lean community's repository switched on November 25 to the readable edition, 803 files and about 298,000 lines of code. Mathematicians have since begun a public effort to read the proof (my news note).
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.
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.
How do I check that a Lean statement matches the paper?
Three ways, best combined: have a second AI model from a different family translate the Lean back into words and compare it with the paper; write your own statement from the paper before seeing the AI's and compare the two; and have a person who knows the area read the Lean statement next to the paper, clause by clause. The blind statement is independent of the AI's reading, and the person brings knowledge from outside the text.
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.
Did this make sense?
Was this helpful?
Learn to do real math research with AI agents
Get the lessons by email and hear first when the live course opens.