Anthropic's Claude Formalizes Fermat's Last Theorem in 11 Days Using Lean 4

Anthropic's Claude model, combined with Lean 4, formalized the remaining core proof of Fermat's Last Theorem in 11 days, leveraging massive parallelism, context engineering, and Lean's verification to achieve a speedup of orders of magnitude over years of manual effort.

TechVision Expert Circle
TechVision Expert Circle
TechVision Expert Circle
Anthropic's Claude Formalizes Fermat's Last Theorem in 11 Days Using Lean 4

Introduction

In early 2025, Anthropic used its Claude model together with the Lean 4 proof assistant to complete the formalization of Fermat's Last Theorem in just 11 days. This achievement stunned both the mathematics and AI communities: Andrew Wiles took seven years to produce the original 100+ page proof, while the Lean community had spent several years formalizing only a small fraction of it.

This article does not hype "AI replacing mathematicians" but instead examines what actually happened during those 11 days, the system architecture, the role of AI in the proof process, the genuine boundaries broken, and what this means for mathematicians and formal verification practitioners.

Background: Fermat's Last Theorem Formalization — A Hard Bone

Fermat's Last Theorem states that for integer n > 2, the equation xⁿ + yⁿ = zⁿ has no positive integer solutions. Fermat scribbled this in 1637 claiming a "marvelous proof" too large for the margin. It took over 350 years until 1995 when Andrew Wiles proved it using elliptic curves, modular forms, Galois representations, and other modern machinery in a 100+ page paper.

Proving the theorem was only half the battle. "Formalization" means translating the human-written natural-language proof into code that a computer can verify step by step — using a proof assistant like Lean. Think of it as: humans write a paper saying "I proved it"; formalization makes the computer check every single deduction for logical gaps.

Kevin Buzzard (Imperial College London professor and Lean community leader) launched the FLT (Fermat's Last Theorem) project in 2019. The project requires building vast prerequisite libraries in algebraic number theory, commutative algebra, homological algebra, etc. By late 2024, the community had invested tens of thousands of person-hours, making solid but slow progress — every "obviously true" or "easily verified" step in Wiles' proof expands into dozens or hundreds of formal lines, creating enormous workload.

What Happened in 11 Days: Timeline and Key Milestones

Anthropic started the project in February 2025. They did not start from zero — the existing FLT Lean codebase and Mathlib (Lean's mathematical standard library) formed the foundation. Even so, the remaining work was massive: thousands of lemmas to prove and hundreds of complex mathematical structures to construct.

The approximate timeline:

Days 1–2: Built the automation pipeline enabling Claude to read Lean project state, understand current proof goals, generate proof strategy code, and automatically submit to the Lean compiler for verification.

Days 3–5: System entered high-speed operation. Claude processed hundreds of subgoals in parallel, each independently generating proofs, verifying, and retrying on failure. At peak, over a hundred Claude instances ran simultaneously.

Days 6–9: Tackled core difficulties, including lemmas related to modularity lifting of Galois representations and the most technical passages of Wiles' proof.

Days 10–11: Cleanup and patching. Handled remaining peripheral lemmas, unified code style, ensured the entire project passed the Lean compiler's full check.

The final output was approximately 17,000 lines of Lean 4 code (excluding existing Mathlib dependencies), covering the core path of Wiles' proof.

System Architecture: AI + Lean 4 Collaborative Pipeline

The system is not simply "throw the paper at AI and let it translate." It is a multi-layer feedback loop: Claude generates proof strategies, the Lean compiler verifies correctness, and verification errors are fed back to Claude for correction.

Feedback loop diagram: Claude generates code → Lean verifies → errors fed back → Claude corrects
Feedback loop diagram: Claude generates code → Lean verifies → errors fed back → Claude corrects

The core is this feedback loop: Claude generates code → Lean verifies → on failure, error messages are fed back → Claude corrects and retries. This is not one-shot generation but an iterative process. Anthropic reports an average of 2–3 iterations per lemma, with complex ones requiring a dozen or more rounds.

Core Technical Breakdown: Model Inference and Formalization Strategies

Several key technical points made this project succeed:

1. Large-Scale Parallel Agentic Architecture

The team adopted a multi-agent parallel approach. The entire proof was decomposed into thousands of relatively independent subgoals (in Lean, each corresponds to a sorry — a placeholder meaning "not yet proved"). A scheduler distributed these subgoals to multiple Claude instances running in parallel, each focusing on one or a small group of related lemmas. With 100 instances working simultaneously, throughput scaled dramatically.

2. Context Engineering

This is one of the most critical techniques. When Claude tackles a subgoal, it does not see only the current theorem. The system packages relevant context: the goal's type signature, other definitions in the same file, potentially useful lemmas from Mathlib, and error messages from previous failed attempts. This carefully curated context lets the model "see" enough information to reason correctly.

3. Hybrid Search Strategies

Claude does not rely purely on "intuition" to generate proofs. The system employs multiple strategies:

Direct proof: Model attempts to write a complete proof in one step.

Stepwise decomposition: Breaks complex goals into smaller subgoals.

Analogical search: Finds structurally similar already-proved lemmas in Mathlib and mimics their proof approach.

Tactic combination: Calls Lean's built-in automation tactics (e.g., simp, ring, omega) and learns when to apply them.

4. Hard Constraints from Lean 4's Type System

Often overlooked but crucial: Lean's type checker is the ultimate arbiter. Whatever code Claude generates, if the Lean compiler says "no," it is wrong. This gives the system an absolutely reliable verification layer — AI can make mistakes, hallucinate, or guess wildly, but the final output is guaranteed correct because only code passing Lean's check is accepted.

This contrasts sharply with LLM applications in other domains. Writing articles or code, AI output correctness requires human judgment. In formal verification, correctness is machine-decidable — precisely patching the "unreliability" gap of large models.

Comparison with Traditional Methods: Where the Real Gains Lie

Traditional formalization work: mathematicians + Lean experts sit at computers, line-by-line translating natural-language proofs into Lean code. "Obvious" steps expand into dozens or hundreds of formal lines; library searches mean manually digging through Mathlib for suitable lemmas.

Concrete comparison data:

FLT project prior progress: Manual formalization took ~3 years to complete ~30% of core path; AI-assisted formalization completed remaining main body in 11 days.

Single complex lemma time: Manual: hours to days; AI-assisted: minutes to hours.

Parallel capacity: Manual limited by human power (~10–20 people); AI-assisted: hundreds of instances running simultaneously.

Mathlib search efficiency: Manual relies on experience and manual lookup; AI-assisted: model internalized vast library structure.

This is not a fair "human vs. machine" contest. The human team was simultaneously building foundational libraries (many base lemmas simply didn't exist in Mathlib), while Claude mainly did the "last mile" work on top of existing libraries. Even accounting for that, the speed difference is orders of magnitude.

Sober Assessment: The Real Boundaries of AI Doing Mathematics

After the excitement, cold water is needed.

First, AI did not "understand" Fermat's Last Theorem. Claude acted more like an extremely efficient translator and search engine combined. It translated proof ideas that humans had already fully conceived into Lean-acceptable formal code. The creative work — Wiles' seven years of deep thinking — AI did not participate in.

Second, this success heavily depends on Lean's verification capability. The reason we can let AI "blindly try" is because the Lean compiler provides a safety net. In domains without a formal verifier (e.g., asking AI to write a mathematical paper proof), we cannot automatically judge correctness. Formal mathematics is the "sweet spot" for AI-assisted reasoning: clear right/wrong criteria, instant feedback, and a massive existing library to reference.

Third, the "11 days" claim is somewhat misleading. Behind those 11 days lies Anthropic's massive compute (hundreds of parallel Claude instances) and years of foundational work by the FLT community. Converting that compute to cost, those 11 days likely consumed hundreds of thousands of dollars in computational resources.

Yet the real signal is important: The boundary of machine reasoning has been concretely pushed forward. Previously we knew AI could solve some math competition problems; now we know it can participate in research-level mathematical formalization engineering. This leap is qualitative, not merely quantitative.

For mathematics researchers, this means the barrier to formal verification drops dramatically. Previously formalizing a complex theorem required rare talent fluent in both mathematics and Lean; now AI can shoulder most of the translation work, leaving mathematicians to clarify the ideas. Kevin Buzzard put it roughly: "Our goal is not to have AI do mathematics, but to have AI help mathematicians do the grunt work they don't want to do." This 11-day experiment brought that vision much closer to reality.

For the AI field, formal mathematics may become the best testbed for training and evaluating reasoning capabilities — explicit feedback, objective standards, controllable difficulty. Expect more teams to use formalization of cutting-edge mathematical results as a benchmark for AI capabilities in the coming years.

Mathematics has not been "solved" by AI, but AI has indeed become a handy new tool in the mathematician's toolbox. That alone is exciting enough.

(Full article approximately 3200 words)

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ClaudeAnthropicformal verificationtheorem provingAI mathematicsLean 4MathlibFermat's Last Theorem
TechVision Expert Circle
Written by

TechVision Expert Circle

TechVision Expert Circle brings together global IT experts and industry technology leaders, focusing on AI, cloud computing, big data, cloud‑native, digital twin and other cutting‑edge technologies. We provide executives and tech decision‑makers with authoritative insights, industry trends, and practical implementation roadmaps, helping enterprises seize technology opportunities, achieve intelligent innovation, and drive efficient transformation.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.