Anthropic’s Fermat Proof Is 13 Million Lines.
From the publisher’s feed, collected in the ZeroLabs newsroom.
Anthropic’s Fermat Proof Is 13 Million Lines. We Counted What’s Actually In It: 562,341 Declarations.We cloned the repo and counted. 13,499,380 lines, 88.5% of them proof bodies, and a median proof step of 8 lines against Mathlib’s 4.Where the 13.5 million lines actually sit: 88.5% of the repository is proof bodies in P2M/Sol, against 1.28M lines of theorem statements and 0.28M of definitions. Counted from a shallow clone at commit aa2d8b3, 7 September 2026. Chart: Decoding AI.Anthropic published the first formalized proof of Fermat’s Last Theorem on 4 September, and the number everyone repeated was 13 million lines of Lean. Its own write-up says the proof is “likely much longer than it needs to be” — and gives no figure for how much longer, or where the length sits.So we cloned it. The 13 million lines are real: 13,499,380 across 60,478 files. But they are not bloated proofs. Measured per declaration with the same counter on both sides, the median machine-written proof step is 8 lines against 4 lines for human-written Mathlib. Two times, not fifty. The size does not come from verbose proofs. It comes from 562,341 declarations — the number of steps Claude generated to close one theorem.That reframes the question about machine-generated proof length. The interesting cost is not how wordy each step is. It is how many steps a machine needs where a human would take one.Key takeaways13,499,380 lines of Lean across 60,478 files, at head aa2d8b3. The headline figure checks out.88.5% of it is proof bodies — 11,943,389 lines in P2M/Sol. Theorems/ holds only statements.562,341 top-level declarations. Mathlib, by the identical count, shows 185,411.Median proof step: 8 lines, against Mathlib’s 4. Mean 17.2 against 6.2.Exactly one sorry, and it is deliberate — the comparator's challenge file says so in its own header.29,511 target theorems, one per solution file, 99.7% of them named theorem solution.TL;DRThe proof is enormous, and the enormity is structural rather than stylistic. Individual steps are close to human density. There are simply an extraordinary number of them, and they are almost entirely new statements rather than reuses of what Mathlib already had.How big is Anthropic’s Lean proof of Fermat’s Last Theorem?13,499,380 lines of Lean in 60,478 .lean files, cloned at commit aa2d8b3 on 7 September 2026. The working tree is 1.9 GB.It divides into three unequal parts:P2M/Sol — 29,511 files, 11,943,389 lines. The proof bodies. This is 88.5% of the repository.Theorems/ — 29,511 files, 1,276,305 lines. Statement files, around 43 lines each, each ending in a one-line delegation into its solution.Definitions/ — 1,450 files, 279,497 lines.The one-to-one match between Theorems/ and P2M/Sol is the architecture: every theorem is stated in one place and proved in another, and 99.7% of the solution files carry a top-level declaration literally named theorem solution.The actual run: the repository cloned at head aa2d8b3, every .lean file counted, and the total broken down by directory. 13,499,380 lines across 60,478 files, 88.5% of them proof bodies. Run 7 September 2026. Terminal capture: Decoding AI.Is the machine-written Lean more verbose than a human’s?Yes, and by less than the raw file sizes suggest.We scanned both corpora with the same counter — lines from a declaration to the next top-level construct — against Mathlib at the exact commit the proof pins, db584cd (Lean 4.33.1, Mathlib v4.33.0):Mathlib: 185,411 declarations. Median 4 lines, mean 6.2, p99 33, longest 256.Fermat proof: 562,341 declarations. Median 8 lines, mean 17.2, p99 166, longest 3,123.That is 2.0x on the median and 2.8x on the mean. For machine-generated code closing a proof that took human mathematicians decades, twice the verbosity per step is a narrow gap, not a pathological one.Lines per declaration, counted with the same rule on both corpora. The median machine-written proof step is 8 lines against Mathlib’s 4. The gap widens with length and becomes large only in the tail, where the 99th percentile is 166 lines against 33. Counted 7 September 2026. Chart: Decoding AI.The tail is where the two diverge properly. Mathlib’s longest proof is 256 lines. The Fermat proof has steps of 3,123. Its 99th percentile, 166 lines, is longer than anything in Mathlib at all.So where do 13 million lines come from?From decomposition, not from padding.562,341 declarations closed one theorem. Mathlib — the accumulated formalization of a very large part of undergraduate and graduate mathematics — shows 185,411 by the same count. One theorem, on that measure, took roughly three times the declarations of the whole library.Read that as a ceiling rather than a fact, for a reason we hit ourselves and explain below. But the shape survives the caveat: the machine’s route to the theorem is decomposed into far more, and far smaller, pieces than a human would write, and it is almost entirely new ground. Only 0.6% of the proof’s theorem names share even a final name component with anything in Mathlib.Why does this matter outside of Lean?Because this is the cleanest example anyone has published of a working evidence layer for agent output.Dozens of agents worked for 11 days and produced 13.5 million lines that no human will ever read. The reason anyone believes the result is not that the process was trustworthy. It is that Lean’s kernel checked every declaration, #print axioms confirms the proof rests on exactly three standard axioms, an independent Rust kernel accepted an export of the same environment, and a comparator confirmed the proved statement matches Mathlib's own.That is an unusually complete audit trail, and it exists because formal mathematics had already built one. Everywhere else agents act, the record is far thinner. We counted the tool-call record in six open-source agent frameworks and the median captures 5 of the 12 fields an audit record needs, with none recording why a run stopped — which is the mechanism behind the silent agent failures no dashboard catches. The same gap shows up on the input side: the 38,900 tokens of tool definitions an agent is handed before it does anything are invisible in every trace we looked at.The contrast is the point. Verification made 13 million unreadable lines trustworthy. Almost no other domain has the equivalent.What this does not showWe did not measure redundancy. “Longer than it needs to be” is Anthropic’s phrase about its own artifact, not our finding. Establishing genuine redundancy would need semantic analysis or a shorter proof of the same statements, and we did neither.185,411 is a lower bound on Mathlib, so the 3x is a ceiling, not a floor. Many Mathlib lemmas are generated by attributes such as @[to_additive] and never exist as source text, so a source scan cannot see them. We caught this by probing eight well-known theorems and finding four missing. The per-declaration median ratio is unaffected, because it is a statistic over whatever was counted on each side.Two earlier versions of this measurement were wrong and were killed. A name-matched comparison found exactly one overlapping theorem in 29,191, which the lossy extractor above makes indefensible. A file-level comparison produced a 51x length ratio, which collapsed once we checked that only 24.9% of solution files hold a single declaration — the rest bundle helper lemmas that Mathlib keeps elsewhere.Line counts are not effort, correctness or elegance. They are one cheap proxy, and the only one we ran.We did not build the proof. All claims are static counts over the source at one commit.FAQDoes the proof actually verify? Anthropic reports a from-scratch lake build on Lean 4.33.1 with Mathlib compiled from source, checked further by the comparator tool and by nanoda, an independent Lean kernel in Rust. We did not reproduce the build; we counted source.Is there a sorry hiding in it? One file contains sorry, and its own header explains why: verification/comparator/Challenge.lean states the theorem using only Mathlib as the comparator's challenge, and its proofs are deliberately left open. The proof proper is checked under #print axioms against the three standard axioms.Is 13 million lines a lot for a formal proof? Yes, by a wide margin, and the size is dominated by step count rather than step length. Mathlib in total carries about 1.15 million lines of proof body by our count.Why is only 0.6% of it recognisable from Mathlib? The proof follows the Frey–Serre–Ribet–Wiles–Taylor route through modular curves, Galois representations and Cerednik–Drinfeld theory. Most of that machinery had never been formalized, so the repository is largely new statements rather than reuses.Can I check these numbers? Yes. git clone --depth 1 the repository, then count .lean lines per directory. The commit is aa2d8b3.One question, if you work with agent output. This proof is trustworthy because a kernel checked all 13.5 million lines, and formal mathematics is nearly alone in having that. In your own work, what is the largest volume of machine-generated output you have shipped that had no independent verifier — and what stood in for one?Anthropic’s Fermat Proof Is 13 Million Lines. was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.