Formal Verification of Fermat's Last Theorem by AI: Technical Lessons
This article examines a recent milestone in which a cloud vendor's AI coding tool completed an end-to-end formal verification of Fermat's Last Theorem in about 11 days with minimal human intervention. It clarifies what formal verification actually proves, contrasts the roles of mathematical papers and formal proof code, and explains the dependency management and multi-agent architecture behind the roughly 13 million lines of formal code and nearly 30,000 verified intermediate theorems. The key takeaway for software engineering is that when correctness can be checked mechanically, scale becomes manageable through explicit constraints, parallel scheduling, and dependency pruning.
Introduction: A Milestone for Machine-Checked Proofs
A cloud vendor recently announced that its AI coding tool completed an end-to-end formal verification of Fermat’s Last Theorem in about 11 days with minimal human intervention. The significance of this event is not that a machine “reinvented a mathematical theorem.” Rather, for the first time, a machine checked a complete logical chain leading to the theorem all the way from the lowest-level axioms to the final root node.
To understand this accurately, three boundaries must be drawn. First, the system did not discover a new proof strategy. Second, it did not reproduce the original derivation of the classic paper line by line. Third, the work was actually carried out by a collaborative system made up of dozens of agents, auxiliary proof engines, and theorem libraries. The system ultimately produced about 13 million lines of formal code, constructed and verified more than 30,000 intermediate theorems along the way, and referenced about 29,500 of them in the final chain, consuming roughly 6 billion output tokens in total.
These numbers are large, but a more important question is what they bought that is stronger than “many people have reviewed it.”
1. What Formal Verification Actually Verifies
Fermat’s Last Theorem states that when an integer n is greater than 2, the equation xⁿ + yⁿ = zⁿ has no positive integer solutions. After human mathematicians patched a critical gap in 1994, they published a main paper of 129 pages the following year.
This automated system followed the classic simplified route of that proof, rewriting it into a form that a formal kernel can check. In a human paper, a casually stated “it is easy to see” must, in a formal environment, spell out clearly: what the type of each involved object is, which existing premises are referenced, and which rule each step of the derivation relies on.
Therefore, “verified” precisely means that the entire derivation chain from the set of premises to the final proposition passed the mechanical checking of a computer kernel. It does not mean the machine originated the proof, nor does it mean the 129-page paper was translated into code line by line.
-- Illustration: in a formal environment, every step must state its justification explicitlytheorem no_positive_solution (n : ℕ) (hn : 3 ≤ n)(x y z : ℤ) (hx : 0 < x) (hy : 0 < y) (hz : 0 < z) :x ^ n + y ^ n ≠ z ^ n := byintro h-- Reference verified intermediate theorems to form a dependency chainhave key := modularity_lifting (n := n) hnexact contradiction_from_key key h
2. 129 Pages vs. 13 Million Lines: Two Texts Solving Two Kinds of Problems
Mathematical papers serve “understanding.” Authors omit shared background, compress several routine derivations into a single sentence, and rely on readers to fill the gaps through long training. Peer review can improve credibility, but it is limited by time, attention, and coverage of knowledge.
Formal proofs serve “verification.” A formal kernel does not accept “readers should understand”; any logical gap becomes a check item that cannot pass. The value of 13 million lines lies in the completeness of coverage, not in length itself. The system also explicitly notes that this proof is very likely far longer than necessary, at a scale more than five times that of a general-purpose mathematics theorem library. It is an engineering artifact of astonishing completeness, not the concise version a human would pursue.
This distinction determines that the two kinds of text will not replace each other: papers let mathematicians see the ideas, while formal code lets checking be repeated infinitely.
3. How Nearly 30,000 Theorems Form a Single Dependency Path
Long proofs are most easily dragged down by dependencies. The system’s key engineering capability is reflected in dependency management, which can be abstracted into four layers:
- Dependency graph construction: Each intermediate theorem registers its type, premises, and conclusion, forming a directed acyclic graph.
- Parallel scheduling: Nodes without dependency conflicts are dispatched to multiple agents to advance simultaneously, maximizing throughput.
- Failure rollback and retry: When a node fails checking, only that subtree is rolled back, without affecting the parts that already passed.
- Final chain pruning: Traversing backward from the root node removes unreferenced theorems, yielding a minimal closure of about 29,500.
Root node (Fermat's Last Theorem)├── Theorem A (passed) ── Theorem A1, Theorem A2├── Theorem B (passed) ── Theorem B1└── Theorem C (failed → retried → passed)
4. Engineering Architecture of the Multi-Agent System
What supported the 11-day timeline was not a single model but a layered collaborative system: a planning layer that decomposes goals and generates a task graph; an execution layer where dozens of agents attempt proofs in parallel; a verification layer where a formal kernel makes the sole authoritative judgment; and a memory layer that reuses passed theorems to avoid duplicate work. On a general-purpose cloud platform, such a system typically relies on a container platform for elastic scheduling, object storage to save intermediate artifacts, message queues to decouple tasks, and logging, monitoring, and alerting services to track failed nodes.
5. Lessons for Software Engineering
The most direct takeaway for developers is this: when “correctness” can be checked mechanically, scale is no longer an uncontrollable variable. The same architectural approach can be transferred to formal verification of critical code, protocol conformance checks, and invariant validation in data pipelines. The core methodology is clear—turn vague human conventions into explicit constraints that machines can decide, then use parallel scheduling and dependency pruning to control complexity.
