Anthropic's Fermat Proof Is 13 Million Lines
Anthropic's formalized proof of Fermat's Last Theorem contains 13,499,380 lines of Lean across 60,478 files, verified at commit aa2d8b3 on 7 September 2026 88.5% of the repository consists of proof bodies (11,943,389 lines in P2M/Sol), with 562,341 top-level declarations — roughly three times the total declarations in all of Mathlib Individual proof steps are only 2x more verbose than human-written Mathlib (median 8 lines vs. 4 lines), meaning the enormity is structural (decomposition into many
Analysis
TL;DR
- Anthropic's formalized proof of Fermat's Last Theorem contains 13,499,380 lines of Lean across 60,478 files, verified at commit aa2d8b3 on 7 September 2026
- 88.5% of the repository consists of proof bodies (11,943,389 lines in P2M/Sol), with 562,341 top-level declarations — roughly three times the total declarations in all of Mathlib
- Individual proof steps are only 2x more verbose than human-written Mathlib (median 8 lines vs. 4 lines), meaning the enormity is structural (decomposition into many small steps) rather than stylistic (padding)
- Only 0.6% of the proof's theorem names overlap with Mathlib, reflecting that most of the underlying machinery (modular curves, Galois representations, Cerednik–Drinfeld theory) had never been formalized before
- The proof's trustworthiness rests on a complete audit trail: Lean kernel verification, independent Rust kernel validation (nanoda), axiom audit (#print axioms confirming exactly three standard axioms), and a comparator tool — a level of verification nearly unique in agent-generated output
Why It Matters
This analysis reframes the conversation about machine-generated formal proofs: the cost is not verbosity per step but the sheer number of decomposition steps an AI requires compared to a human mathematician. It also establishes the first clean example of a verifiable evidence layer for large-scale agent output, offering a template for how to build trust in AI-generated content across domains that currently lack independent verification mechanisms.
Technical Details
- Repository structure: Three directories — P2M/Sol (29,511 files, 11,943,389 lines of proof bodies), Theorems/ (29,511 files, 1,276,305 lines of theorem statements), and Definitions/ (1,450 files, 279,497 lines). Each theorem has a one-to-one mapping between statement and solution file.
- Declaration metrics: 562,341 top-level declarations in the Fermat proof vs. 185,411 in Mathlib (same commit, db584cd, Lean 4.33.1). Median lines per declaration: 8 (Fermat) vs. 4 (Mathlib); mean: 17.2 vs. 6.2; p99: 166 vs. 33.
- Verification pipeline: From-scratch lake build on Lean 4.33.1 with Mathlib compiled from source, validated by nanoda (independent Rust kernel), #print axioms confirming exactly three standard axioms, and a comparator tool confirming the proved statement matches Mathlib's formulation. One deliberate
sorryexists only in the comparator's challenge file. - Novelty of formalization: The proof follows the Frey–Serre–Ribet–Wiles–Taylor route through modular curves, Galois representations, and Cerednik–Drinfeld theory — areas largely unformalized. Only 0.6% of theorem names share a final name component with Mathlib entries.
- Methodology caveat: Line counts are a proxy, not a measure of effort or elegance. Redundancy was not measured. The 3x declaration ratio against Mathlib is a ceiling, not a floor, since some Mathlib lemmas are generated by attributes and invisible in source scans.
Industry Insight
- The Fermat proof demonstrates that agent-generated output at scale can achieve mathematical-grade verifiability when paired with a formal kernel — a pattern that could extend to code generation, compliance documentation, and scientific modeling, domains that currently ship unverified agent output at scale.
- The decomposition gap (562K declarations for one theorem vs. human mathematicians' compact arguments) suggests current AI reasoning lacks the high-level abstraction and lemma-reuse strategies of expert humans; progress will depend on improving strategic planning and library utilization, not just step-level quality.
- The absence of verification infrastructure outside formal mathematics is a critical risk: tool-call traces in open-source agent frameworks capture only 5 of 12 needed audit fields, and none record termination mechanisms behind silent failures. Building equivalent evidence layers should be a priority for any domain deploying high-stakes agent output.
Disclaimer: The above content is generated by AI and is for reference only.