Claude Formalizes Fermat's Theorem in Lean with 13 Million Lines and 11 Days of Autonomous Reasoning

Claude generated 13 million lines of Lean code in 11 days to formalize Fermat's Theorem, the most complex mathematical proof ever translated into computer-verifiable language. The project paves the way for autonomous AI in formal verification of critical systems.
Thirty years after Andrew Wiles spent seven years proving Fermat's Theorem on paper, Claude from Anthropic took 11 days to transcribe that same proof into Lean 4, a formal verification language that allows the computer to mechanically confirm each step of reasoning. The result is 13 million lines of code, the largest Lean file ever produced, according to Anthropic. The formalization was published last week with the complete source code of the project available for use.
What Prove2Me Made Possible
The first attempt failed. Claude began the formalization without additional support and couldn’t maintain logical coherence over such an extended task. The solution was to incorporate Prove2Me, an open-source tool that helps AI agents determine the next optimal action in long workflows when accumulated context starts to compromise the quality of intermediate decisions.
With Prove2Me and a multi-agent harness built on Claude Code, the project consumed approximately 6 billion tokens of output over the nearly two weeks of execution. The model was described by Anthropic as a research internal model comparable to Claude Fable 5.1. The codebase credits 106 files to Kevin Buzzard's FLT project, a mathematician from Imperial College London who had spent years building mathematical blocks in Lean for a manual formalization that Anthropic completed in a fraction of that time. "Anthropic beat me," Buzzard wrote on the Xena Project blog last week, acknowledging that the company had achieved before him the goal he had pursued for years with collaborators worldwide.
Why This Matters Beyond Mathematics
Fermat's Theorem is the most extreme stress test for formal verification: there is no more renowned theorem nor longer reasoning to follow step by step. The demonstration that Claude maintained logical coherence over 11 days and 13 million lines in Lean points to direct applicability in other tasks that require sustained and verifiable logic: analysis of derivative financial contracts, regulatory compliance in Basel IV, or formal verification of code in banking, aerospace, and medical device systems.
The software formal verification industry is small and strategic: it validates systems where failures have catastrophic consequences. Companies like Adacore, based in the US and France, and Galois, also American, build entire businesses around formal guarantees that programs behave as specified. This segment generated enough revenue to hire highly paid specialists due to its slow pace; Anthropic's demonstration compresses the analysis time from weeks to days.
What This Changes by Market
In the UK, Kevin Buzzard's project at Imperial College had attracted collaborators from dozens of universities to build proof blocks in Lean, a kind of academic open-source effort for mathematical formalization. This work functioned, in practice, as training data for systems like Claude, without researchers having formally negotiated this relationship with Anthropic. The Royal Society and British research groups are already debating what this means for funding pure mathematics when an American lab can utilize decades of collaborative academic work in days of compute.
In Japan, formal verification is a mandatory component in software certification for railway and industrial control systems; firms like NTT Data and Hitachi Consulting charge by the hour for specialists to conduct this validation. Anthropic's demonstration does not eliminate the regulatory demand for a responsible human in the process, but it drastically reduces the technical component of the task, opening space for smaller competitors to offer the same service at a lower cost using Claude as leverage.
What the CIO Takes from This Achievement
Anthropic has published the entire code. Any organization with the capability to adapt the harness can test the method on its own formal verification problems. The achievement is not just about mathematics: it is about demonstrating that an AI agent can maintain goal-directed reasoning over days, decompose a problem of maximum complexity into manageable subproblems, and produce verifiable output throughout the entire process.
The next question is not about theorems. It is about which banking system or critical infrastructure regulator will be the first to replace part of its formal validation process with a Claude-based agent, and what happens to the chain of responsibility when something fails.