Formalizing Fermat's Last Theorem

Sep 05, 2026 01:42 AM - 1 hour ago 2

We are sharing the first complete computer-checked impervious of Fermat’s Last Theorem. Claude worked mostly autonomously complete 11 days to constitute the impervious successful the Lean programming language. Below, we picture really the formalization was done and stock immoderate thoughts astir what this activity could mean for investigation mathematics.Around 1637, Pierre de Fermat jotted down a declare successful the separator of his transcript of Diophantus’s Arithmetica that would go 1 of the astir celebrated mathematical conjectures of each time: nary affirmative integers a, b, c fulfill aⁿ + bⁿ = cⁿ for immoderate n > 2. Fermat’s Last Theorem (FLT), arsenic the conjecture became known, turned retired to beryllium incredibly difficult to prove. The first proof, from Sir Andrew Wiles in 1995, ran to 129 pages and required months of painstaking activity to verify.

A decade later, Dutch machine intelligence Jan Bergstra projected “formalizing” Wiles’s proof: converting the mathematical reasoning into a shape computers tin cheque automatically. Since then, mathematicians person been processing the methods needed to encode specified a analyzable proof, including a multi-year organization effort kicked disconnected successful 2024 by Kevin Buzzard astatine Imperial College London to complete the formalization utilizing the Lean impervious assistant.

Recently, Tianyi Peng, an Anthropic interrogator whose group astatine Columbia University builds devices for AI formalization, group retired to trial whether Claude could make advancement connected formalizing FLT.1 The consequence went further than he expected. In 11 days, moving mostly autonomously, Claude produced the first end-to-end, computer-checked impervious of FLT. Along the way, it wrote 13 cardinal lines of Lean and proved 29,500 intermediate theorems.

We shared the resulting proof pinch Kevin Buzzard, who said:

This bonzer autoformalization achievement, which Anthropic researchers opportunity only took 11 days, proves Fermat’s Last Theorem pinch nary assumptions different than the axioms of mathematics. Along the measurement we spot autoformalization of algebra, harmonic analysis, geometry and number theory, and we study that AI autoformalization artefacts are now robust capable to beryllium built upon; the impervious is multi-layered.

Automatically formalizing a impervious arsenic analyzable arsenic FLT is simply a important measurement towards a early successful which each of mathematics tin beryllium readily checked. As AI produces ever much proofs, the expertise to easy formalize activity tin lighten the load of evaluating caller results (a process that tin return years). We are hopeful that it will go easier, not harder, to spot the assemblage of knowledge upon which mathematics is built.

The situation of verifying mathematical proofs

Unlike recent AI-driven activity connected the Riemann hypothesis, which produced caller mathematics, what’s caller present is the verification—checking a mathematical impervious arsenic 1 would cheque a mathematical computation pinch a calculator. Proving mathematics theorems requires assembling analyzable logical chains, and if a azygous nexus is broken, everything that follows it mightiness move retired to beryllium false. Understanding a caller consequence profoundly capable to beryllium assured successful its correctness tin return months, aliases moreover years, of work.

Fermat’s Last Theorem is an schematic example.2 Fermat wrote down the theorem’s connection successful the separator of a book, alongside a tantalizing note:

I person discovered a genuinely marvelous impervious of this, which this separator is excessively constrictive to contain.

For complete 350 years, generations of mathematicians searched for a impervious of FLT, marvelous aliases otherwise. In 1908, a prize of 100,000 German golden marks (the balanced of 1–2 cardinal dollars today) was announced for anyone who could nutrient a correct proof, and 621 incorrect attempts were produced successful the first twelvemonth alone.

In June 1993, Wiles presented what he believed to beryllium the first correct impervious of FLT successful a three-day bid of lectures. Two months into an intensive verification effort by respective mathematicians, a reviewer asked Wiles a mobility that exposed a captious gap. Wiles spent a twelvemonth trying to hole it, first unsocial and past pinch his erstwhile student Richard Taylor. He was connected the brink of abandoning the task erstwhile he yet realized an attack he’d discarded earlier could hole the proof.

Wiles published the first correct impervious of FLT successful May 1995; it relied connected modern mathematical techniques that were acold beyond what would person been known to Fermat successful 1637. Since an simple impervious has not been recovered aft hundreds of years of trying, the mathematical organization now believes Fermat’s ain original “marvelous proof” was incorrect.

Formalizing Fermat’s Last Theorem

One measurement to cheque a proof’s correctness is to inquire a machine to do it. Proof assistants for illustration Lean verify the logic of a impervious algorithmically, demonstrating its correctness beyond a doubt. The difficult portion for humans is rewriting the impervious truthful Lean tin understand it. While a impervious written for quality readers will skip galore evident steps, Lean needs to spot each step, nary matter really trivial. Human proofs besides build connected hundreds of years of published work, while a formalization starts from the mini fraction of mathematics that’s been formalized already.

For FLT, the formalization process was expected to return years. Just the blueprint the mathematical organization has been utilizing to picture the first shape of the task runs to 86 pages.

Claude completed the impervious successful 11 days, producing computer-verifiable proofs of 30,300 theorems on the measurement (using 29,500 successful the last proof). Dozens of Claude agents collaborated to specify concepts, beryllium intermediate theorems, and usage those theorems to beryllium ever harder statements. At 13 cardinal lines of Lean code, Claude’s impervious is complete 5x the size of Mathlib, the main organization room of mathematical proofs this theorem builds on.3

Time progression of FLT formalization

Claude’s impervious follows a simplified type of Wiles’s impervious from Darmon, Diamond and Taylor. Mathematical input from humans was constricted to occasional high-level instructions from Tianyi: “Jacobian arsenic a strategy sounds precocious priority,” “push [the] Mazur [theorem] to beryllium done soon.” You tin find excerpts of Claude’s reasoning here.

“THE FLT guidelines sounds Proved connected the site. Historic infinitesimal (modulo re-check).” “!!! The FLT ROOT 62eb32c0 sounds PROVED. R = T closed and cascaded to the root. This is the campaign's goal: e2e FLT connected prove2me.” “🏁🏁🏁The FLT guidelines sounds PROVED connected prove2me astatine 02:00:57Z Aug-18 (10:00:57pm ET Aug-17). Historic infinitesimal for this campaign.”

Excerpts of Claude’s reasoning arsenic it realizes what it has conscionable accomplished.

A number of Claude’s first attempts failed: while agents had immoderate early success, they quickly mislaid way of the project’s authorities and stopped collaborating effectively. Their grounded efforts contributed ~7% of the non-boilerplate lines successful the last proof.

The effort succeeded erstwhile we switched to utilizing Prove2Me, an unfastened collaborative level for formalizing mathematics designed by Tianyi Peng and his collaborators astatine Columbia University. Prove2Me helped by:

  1. Maintaining a directed acyclic chart (DAG) of theorem statements that agents utilized to determine what proofs they should effort next. This was peculiarly adjuvant for mitigating representation degradation and allowing aggregate agents to activity successful parallel.
  2. Speeding up Lean compilation and minimizing assets consumption by separating theorem statements and proofs into different files, pinch the links betwixt them maintained independently.
  3. Enabling hunt and reuse by maintaining a natural-language explanation of each theorem statement, resulting successful a simpler impervious path.
DAG showing Claude formalizing sub-theorems connected the measurement to FLTKey milestones from the Prove2Me scheme that Claude utilized to formalize Fermat’s Last Theorem. The 3 colored sections correspond to 3 halfway sub-theorems that Claude had to beryllium connected the measurement to its last goal. This chart intimately follows Wiles’s original proof.

With Prove2Me and a Claude Code-based multi-agent harness, a squad of agents completed the impervious successful a small nether 2 weeks, consuming astir six cardinal output tokens from a general-purpose soul investigation exemplary astir comparable to Claude Fable 5.1. The vanished impervious was checked by Lean; it uses conscionable Lean’s 3 modular axioms, and a comparator confirmed that the theorem’s connection matches Mathlib’s ain connection of FLT.

Reducing the load of general verification

The velocity pinch which we were capable to nutrient this impervious demonstrates that it is now imaginable to formalize ample swaths of mathematics, which whitethorn some drawback errors successful the communal assemblage of mathematical proofs and trim the load of refereeing caller work. After reviewing Claude’s Lean proof, Kevin Buzzard told us:

If the automatic formalization of FLT is imaginable now, past we person taken a large measurement towards automatic formalization of the modern mathematical literature. Such autoformalization techniques will lead to caller tools, rooting retired errors successful the existent mathematical corpus and lightening the load of referees. The techniques will besides alteration america to rigorously cheque LLM-generated mathematics, which is presently typically an highly costly human-led process.

Formalization is besides a awesome facet successful really humans tin summation assurance successful AI-generated mathematical results. As AI and AI-assisted mathematicians nutrient much (purported) proofs than ever before, AI-assisted formalization takes portion of the load disconnected quality reviewers. We expect it will go communal to nutrient a formalized impervious alongside immoderate write-up intended for a quality reader. Although we do not deliberation a formalized impervious should switch a human-understandable exposition, it whitethorn beryllium the only feasible measurement for the mathematical organization to support up pinch AI-generated contributions.

Writing Lean besides seems to thief Claude beryllium caller results. Many of our caller Claude-authored results person been formalized successful parallel pinch their proofs, and Claude appears to usage these partial proofs to independently cheque its hypotheses overmuch for illustration it writes numerical simulations to cheque that it’s connected the correct track.

Formalizing FLT was a token-intensive project, but it is besides the largest Lean impervious ever constructed. Anthropic researchers did a mini research utilizing 3 individual Claude Max plans to formalize applications of the Hardy-Littlewood Circle Method. Collaborating wholly done Prove2Me, the agents jointly completed a formalization of Vinogradov’s Three Primes Theorem successful conscionable 3 days. We deliberation pinch the correct scaffold, collaborative formalization of awesome results pinch user AI subscriptions is achievable.

To this end, Anthropic arsenic good arsenic other labs person precocious expanded their support for outer researchers—including mathematicians moving connected axenic mathematics and formalization—with free and discounted subscriptions and investigation credits. We besides connection dedicated grants for larger technological projects, which could see formalizing different awesome theorems aliases improving Lean aliases Mathlib.

With AI quickly changing what it looks for illustration to do mathematics research, mathematicians—at Anthropic and elsewhere—are grappling pinch what that intends for their work. Formalization, however, is simply a spot wherever we consciousness unambiguously bully astir the domiciled of AI. As formalization becomes a much commonplace tool, we are hopeful that it will thief support spot successful the communal assemblage of mathematical knowledge.

Acknowledgments

Our formalization effort is simply a mini portion of the agelong history of Fermat’s theorem and the improvement of general mathematics. The first afloat impervious from Andrew Wiles together pinch Richard Taylor was a culmination of much than 3 100 years of mathematics, integrating ideas from Gerhard Frey, Jean-Pierre Serre, Ken Ribet, Barry Mazur, Robert Langlands, Jerrold Tunnell, Yutaka Taniyama, Goro Shimura, and André Weil, among others. Claude’s impervious follows the exposition by Henri Darmon, Fred Diamond, and Richard Taylor.

Our impervious adapts pieces from the Imperial College London FLT project led by Kevin Buzzard and the flt-regular project. Lean and Mathlib are some their ain labors of emotion and person received contributions from hundreds of mathematicians, galore moving pinch the Lean FRO. We convey Kevin Buzzard for reviewing the impervious and for his comments.

Learn more

The afloat impervious is disposable connected GitHub on pinch a written walk-through of the proof.

  • The Proof successful the Code is simply a caller book astir the history of the Lean theorem prover and the formalization of mathematics.
  • The 1996 “Fermat’s Last Theorem” BBC documentary has interviews pinch Wiles and different mathematicians progressive successful the proof, and is fondly remembered by immoderate authors of this post.
  • For those pinch a mathematical background, a method history of propositions-as-types (the underlying subject of impervious assistants specified arsenic Lean, Rocq, and Agda) tin beryllium recovered successful Propositions arsenic Types by Philip Wadler.
  • Chen, S., Marwaha, K., Lu, X., Yuen, H., & Peng, T. (2026). Prove2Me: An unfastened collaborative level for scaling mathematics formalization. arXiv. https://doi.org/10.48550/arXiv.2608.28433
  • Automating Math, Adam Marblestone, successful Asterisk Magazine.

Footnotes

  1. During his undergrad, Peng’s investigation advisor wanted to see results from Peng’s thesis successful a Nature article. He asked Peng whether he was judge the impervious was correct. Peng’s honorable reply was: “I'm 99% sure, but it's difficult to beryllium 100% definite astir a impervious this long.” Peng missed retired connected getting his activity published successful Nature.
  2. There are galore different stories of the mathematical organization struggling pinch verification. Among the astir celebrated is Thomas Hales’s 1998 impervious of the Kepler conjecture, which spent 4 years successful reappraisal earlier a 12-referee sheet settled for “99% certain” (Hales yet led a twenty-person project, Flyspeck, that formalized the proof). Grigori Perelman’s 2002 impervious of the Poincaré conjecture took the organization astir 4 years and 3 300-page expositions to accept. Harald Helfgott’s 2013 impervious of the weak Goldbach conjecture is still nether review. Sometimes results that move retired to beryllium incorrect are accepted for years, and different mathematicians build their theories connected these faulty foundations.
  3. This is partially because Mathlib is concise and well-reviewed, while our impervious is apt overmuch longer than it needs to be.
More