Anthropic Lean 4 Verified Formal Mathematics (Lean 4) 2026-10-08

Autonomous 11-Day Lean 4 Formalization of Fermat's Last Theorem (13 Million Lines)

Pierre de Fermat's 1637 marginal claim — that $x^n + y^n \neq z^n$ for all positive integers $x,y,z$ and exponents $n \ge 3$ — takes a single line to state, yet Andrew Wiles and Richard Taylor's 1994/1995 proof traverses a vast edifice of twentieth-century arithmetic geometry: Galois representations, modular forms, Hecke algebras, étale cohomology of modular curves, and universal deformation rings. Whereas human formalization roadmaps projected multi-year timelines to mechanize that machinery, an autonomous **Anthropic** agent swarm completed the entire kernel-verified derivation on October 8, 2026 in **11 days**, spanning **13 million lines of Lean 4 code** and **29,500 proved intermediate lemmas**.

Mathematical Core & Governing Equations

Primary Governing Equation
\[\forall n \ge 3,\;\forall x,y,z \in \mathbb{Z}_{>0}: \quad x^n + y^n \neq z^n\]
Secondary Structural Relation & Implication Chain
\[E_{a,b,c}: Y^2 = X(X - a^p)(X + b^p) \implies \bar{\rho}_{E,p} \sim f \in S_2(\Gamma_0(2)) = \{0\}\]

After classical reductions to odd primes $p \ge 5$ (the exponents $n=3$ and $n=4$ dating back to Euler and Fermat), any putative nontrivial solution $a^p + b^p = c^p$ attaches to the semistable **Frey–Hellegouarch elliptic curve** $E_{a,b,c}: Y^2 = X(X - a^p)(X + b^p)$. By the **Wiles / Taylor–Wiles modularity theorem**, its mod-$p$ Galois representation $\bar{\rho}_{E,p}$ arises from a weight-$2$ cuspidal eigenform. Because the minimal discriminant $(abc)^{2p}$ is an exact $p$-th power up to powers of $2$, **Ribet's level-lowering theorem** strips all odd prime levels down to $\Gamma_0(2)$ — yet the cusp-form space $S_2(\Gamma_0(2)) = \{0\}$ has dimension zero, yielding an airtight contradiction.

Interactive Parametric Calculator (Arte Sheets)

Inspect the engineering throughput of Anthropic's 11-day formalization sprint across verified line count, lemma modularity, and the final S_2(Gamma_0(2)) dimension contradiction.

Lean 4 Formalization Throughput Calculator (Fermat's Last Theorem)

Modify any numeric input cell in Column B — all dependent metrics recalculate instantly.

Open in Arte Sheets

Historical Context & Why the Problem Mattered

In early 2024, Imperial College London number theorist **Kevin Buzzard** launched a flagship EPSRC-backed open-source initiative to formalize Fermat's Last Theorem in Lean 4. Buzzard famously articulated why FLT serves as the ultimate stress test for formal verification: its target statement involves only elementary natural numbers — leaving zero room to misstate the theorem — while any valid proof forces the formalizer to construct deep cohomology, finite flat group schemes over $\mathbb{Z}_p$, and local Langlands/Jacquet–Langlands bridges.

That vast architectural breadth defeated earlier theorem-proving models: an AI capable of solving self-contained Olympiad inequalities routinely collapsed when forced to maintain typeclass coherence across hundreds of interdependent algebraic geometry files without triggering Lean diamond-inheritance conflicts.

How the AI-Assisted Proof or Discovery Worked

Building directly atop Mathlib4 and the public architectural blueprints pioneered by Buzzard's FLT repository, Anthropic deployed a hierarchical **Architect–Worker–Refactorer swarm**. High-level specification agents decomposed modularity lifting ($R = \mathbb{T}$) and Ribet's level lowering into a directed acyclic graph of **29,500 strictly typed lemma signatures**, allowing thousands of parallel tactic workers to discharge subgoals asynchronously against the Lean 4 compiler.

Why did the proof reach **13 million lines of Lean 4**? Rather than pausing for months to engineer maximally terse, category-theoretic Mathlib abstractions, the autonomous swarm deliberately traded conciseness for certainty: whenever general functorial APIs encountered universe or typeclass friction, Claude instantiated explicit, fully unrolled commutative-diagram and cohomology calculations on concrete modular curves $X_0(N)$, guaranteeing deterministic kernel acceptance at massive throughput.

Formal Verification, Peer Review & Open Boundaries

Reaction across the formal methods community was immediate. **Kevin Buzzard publicly praised the 11-day milestone** as a watershed moment for mechanized mathematics, while constructively highlighting the next engineering frontier: distilling and refactoring verbose multi-million-line machine proofs into clean, idiomatic abstractions suitable for upstreaming into Mathlib4. Epistemically, however, the top-level theorem compiles end-to-end through the Lean 4 kernel (**Lean 4 Verified**).

Engineering & Scientific Takeaways

01

Repository-Scale Formal Verification Reaches 10M+ Lines

Coordinating 13 million lines of type-consistent Lean 4 in 11 days proves autonomous agents can scale formal verification to OS microkernels, compilers, and cryptographic protocol stacks.

02

Blueprint DAG Decomposition Beats Monolithic Proof Search

Freezing 29,500 typed interface lemmas ahead of tactic generation decouples global mathematical architecture from embarrassingly parallel local proof search.

03

The Rise of Automated Proof Compression & Refactoring

Machine proofs optimize first for kernel acceptance and wall-clock speed, inaugurating a new engineering discipline of AI-assisted proof distillation into reusable library APIs.

04

End-to-End Mechanization of Taylor–Wiles & Ribet Machinery

Deformation rings, Hecke algebras, and the final cusp-form vanishing $\dim S_2(\Gamma_0(2)) = 0$ now sit under complete mechanical typecheck.

Technical Frequently Asked Questions

Did Anthropic invent a brand-new mathematical proof of Fermat's Last Theorem?

No — the high-level mathematical route follows the celebrated Frey–Serre–Ribet–Wiles–Taylor architecture (incorporating modern Kisin and Diamond–Fujiwara simplifications mapped out in Buzzard's blueprint). The breakthrough is mechanizing that monumental proof autonomously in 11 days.

Why does the mechanized proof span 13 million lines of Lean 4?

Human textbooks elide thousands of routine ring isomorphisms, base-change compatibilities, and diagram chases; furthermore, the autonomous swarm unrolled concrete scheme calculations directly whenever abstract categorical wrappers would have stalled parallel workers.

How does this relate to Kevin Buzzard's human-led FLT formalization project?

Buzzard's open-source Lean blueprint provided foundational definitions and structural guidance. Buzzard applauded Anthropic's achievement and noted that human-AI collaboration now shifts toward compressing verbose machine proofs into clean, maintainable Mathlib4 abstractions.

Could a subtle bug in the definitions invalidate the 13-million-line proof?

That is precisely why Fermat's Last Theorem is uniquely trustworthy: the top-level statement $\forall n \ge 3, x^n + y^n \neq z^n$ uses only elementary arithmetic in three lines of Lean, auditable by any human reader in seconds regardless of internal proof length.