# AI Formalization of Fermat's Last Theorem: Correctness Is Only the Baseline

    A machine-checked formalization of Fermat's Last Theorem has passed proof-kernel verification, and the discussion around it exposes a gap between "formally correct" and "engineering-useful." This article separates what the project actually delivered (a completed formal script, not a new theorem) from what it did not, explains why roughly 129 pages of human proof expand into about 13.4 million lines of formal code, and uses a four-layer evaluation framework (trust, spec alignment, understandability, reusability) to assess any formalization effort. It also offers concrete engineering practices — spec alignment before generation, layering and modularization, naming and documentation conventions, automated form gates, build efficiency planning, and a two-part definition of "done" — for teams that want machine-generated formal artifacts to become maintainable assets rather than one-off credibility certificates.

    1. Setting the facts straight: this is formalization, not discovery

    In the discussion around “AI has completed a machine formalization proof of Fermat’s Last Theorem,” the first thing that needs correcting is a misreading of the word “proof.” Fermat’s Last Theorem states that for integers n greater than 2, the equation x^n + y^n = z^n has no solutions in positive integers. It was proved by number theorist Andrew Wiles in 1994 and formally published in 1995, and for the three decades since, almost no one has genuinely doubted the conclusion itself.

    So the input to this work was not an open conjecture waiting to be cracked. It was a set of arguments long accepted as correct. The output is not a new theorem either; it is a formal script that a proof kernel can check line by line. In software engineering terms: the specification was settled long ago, the requirements never changed, and what was delivered here is a complete “executable implementation” rather than a new product design.

    Interestingly, the original paper was followed by several cleaned-up and generalized treatments, including the argument assembled by Darmon–Diamond–Taylor. Work of this kind in number theory typically replaces the more tedious local arguments of an original proof with more systematic formulations that generalize better. Such treatments are themselves regarded as foundational engineering on the path to broader conjectures — which also shows that a mature argument can have multiple implementations inside the academic community.

    Before rewriting or expanding on the event, a role mapping helps developers grasp its exact nature:

    Mathematical concept Software engineering analogue
    Fermat’s Last Theorem (a proven statement) A requirement specification that passed acceptance long ago
    The argument in the original paper Prototype code containing only the critical path
    The formal script Every branch and boundary condition explicitly implemented, and verifiable line by line
    The proof kernel A type system in a formal checker or compiler
    The community-maintained math library A long-evolving base dependency library

    Researchers who have worked at scale on formalization hold a clear-eyed view. The lead of the related human collaboration project said he already had 99.9% confidence that the proof was correct, and most people in number theory have confidence closer to 100%. In their view, this formalization simply walked the proof again along the early literature, and produced nothing new mathematically.

    To be fair, walking an argument end to end in formal form is far from easy, and the engineering difficulty is high; the next section covers the data in detail. But the judgment that “no new mathematical knowledge was added” does not diminish the engineering value of the work. It only reminds us that the right yardstick is not “did it discover a new theorem,” but “what form of artifact did it deliver, and who can use that artifact.”

    2. From 129 pages to millions of lines: an experiment in amplifying omission

    Start with the numbers (compiled from public information):

    Metric Figure Note
    Total formalization code ~13.4 million lines ~10.5 million lines after excluding auto-generated boilerplate
    Existing theorems cited directly 29,511 Most come from the community-maintained math library
    Local supporting lemmas ~533,000 Intermediate results added to fill in argumentative detail
    Number of files 60,474 Roughly 220 lines per file on average
    Size relative to the community math library ~5x The output of one formalization exceeds the entire base math library
    Compilation time ~20x the math library on a 96-core machine Near single-core serial execution, the gap can exceed two orders of magnitude

    The human paper is 129 pages. A rough division suggests the same argument expands by roughly 100,000x in machine form.

    1. Different omission rules: experts write for experts, the machine accepts only the kernel. Human proofs follow a long-standing “omission contract”: standard results can be cited, routine computations can be dismissed with “similarly,” structural facts can be waved through with “obviously.” These omissions rely on knowledge shared by the reader, yet they hardly reduce the credibility of the argument, because reviewers are themselves able to fill in the skipped steps. A machine has no such background knowledge. It can only derive step by step from what has been declared in the formalization library, and a single step without explicit support causes the whole check to fail. That is the root of the expansion.

    2. Composability produces nonlinear blow-up. The basic requirement of formalization — that every step be independently checkable — makes proofs naturally composable. In mathematics, repeatedly invoking an intermediate result is extremely common. Suppose a lemma is used N times in a proof. Human writing keeps a single derivation; a machine tends to expand it into an independently checkable form at every use site, or to generate a separate intermediate lemma for each use. In arguments heavy with recursive nesting and case analysis, the expanded volume grows exponentially with nesting depth. This is much like the tradeoff between inlining and a function call: the former makes every call site self-contained and checkable, while the latter relies on a trusted calling convention.

    3. The price of composability: two implementations of the same proof share one core argument. The same argument can be formalized more than once. One notable clue is that a formalization researcher who had already pushed the Fermat equation to higher exponents in 2024 also took part in this work. Two people appearing together usually means there is meaningful cross-reuse between branches. At the same time, different implementations can share the same core argument, with the difference lying in how (the organization of the formalization) rather than what (the correctness of the argument). That also explains why “form” has become the point of contention.

    3. The argument is about form: correctness is just the entry ticket

    Buzzard compared this event with the project he is working on and offered a sharp judgment: correctness is not the difference, the difference is form. That line is worth unpacking.

    The form delivered here is a finished, almost entirely machine-generated proof. It carries the theorem from statement to conclusion, passes kernel verification, and is mathematically unimpeachable. The human project has a different form: it is not finished, but it is a library organized around human reading habits that can be consulted, cited, modified, and maintained over the long term.

    The difference between the two is not “right versus wrong” but “who can use it, and for what”:

    • Auditability: Human mathematicians can follow the thread of an argument, inspect key lemmas, and trace which prior results a given conclusion depends on. Facing tens of millions of lines of machine code, such inspection is not feasible with human effort, even for a reviewer with sufficient mathematical background.
    • Evolvability: Mathematics is cumulative; new theorems are usually built on old ones. The next researcher needs to be able to enter the building, understand the load-bearing structure, and add a new floor on top of one particular beam. A completed machine proof offers no such “enterability.”
    • Maintainability: Once a base definition in a formalization library is revised, reference relationships in a human-curated library are easy to trace and the blast radius is controllable. Machine code lacks stable naming and layering, so a revision can ripple through vast numbers of automatically expanded intermediate steps.
    • Teachability: Formalization libraries are also important teaching material; students can see line by line how theorems are composed inside a real proof. An unreadable, completed proof cannot serve that function.

    There is also a frequently overlooked signal: under the community math library’s mechanical intake rules (file length, single-line length, docstrings, naming conventions, and so on), this proof would essentially be rejected in its entirety. In other words, it is a proof that passes the Lean kernel but cannot get through the door of the human mathematical community.

    The deeper significance is this: for the first time, “formalize a theorem” has two distinctly different meanings.

    Before, formalizing a theorem meant two things holding at once: the machine accepted it as correct, and the code left behind became a public asset that others could inspect, use, and change. Now those two things can be decoupled: correctness can be obtained almost immediately, while the public-asset property still has to be built by people.

    Evaluation dimension Completed machine proof Human-readable formalization library
    Kernel verification Passes Passes as it approaches completion
    Mathematical novelty None None (same goal)
    Human comprehensibility Very low High
    Reusability Low, lacks stable interfaces High, organized per library conventions
    Maintainability Low, hard to converge after base definitions change Relatively high, dependency relationships are clear
    Intake and review Likely rejected by mechanical rules Meets community conventions
    Primary value A credential of trustworthiness Trustworthiness plus a public asset

    Pull your gaze back from mathematics to software engineering and the pattern is familiar: code that passes every unit test is not necessarily maintainable code; a program that passes the type checker is not necessarily well designed; a model inference that runs is not necessarily a production-ready service. Machine generation lowered the cost of “achieving correctness” and, in doing so, turned “is the form acceptable” into the new central question.

    4. A four-layer framework for evaluating such results

    To avoid getting stuck in a binary “is the proof correct or not” argument, any formalization result can be assessed on four layers:

    1. Trust layer (kernel verification passes): This answers only “is the derivation legal.” It is the baseline, guaranteed jointly by the proof kernel and the formalization language.
    2. Verification layer (spec alignment): This answers “is the proposition the machine proved actually the proposition humans intended to prove.” In formalization projects, incorrectly encoded statements are not rare — for example, reversed quantifier positions, strict versus loose boundary conditions used the wrong way, or definitions that diverge from the textbook. This is the most underestimated risk in formalization engineering.
    3. Understandability layer (clear structure): This answers “can humans grasp the main line of the argument without reading all the code.” It depends on layering, naming, documentation, and explicit expression of the proof strategy.
    4. Reusability layer (asset accumulation): This answers “can it serve as a starting point for someone else’s work.” It depends on interface stability, dependency boundaries, and long-term maintenance arrangements.

    Most of the debate about this event is actually happening between layer one and layer three: one side emphasizes that layer one has been reached, while the other points out that layer three is nearly empty. The two positions do not actually contradict each other.

    5. Engineering practice for turning “completion” into an “asset”

    If a team wants machine-generated formalization output to genuinely accumulate into an asset, the following steps are a place to start. This section is experience-based and does not depend on any specific tool.

    1. Align the specification before generating the proof. Before letting a model begin formalizing, write down in human-readable form: the original statement of the theorem, all preconditions, the source of each definition, and the textbook version being used. Then require the model to output a formal statement, and have a domain expert compare it item by item. This step costs far less than post-hoc rework, so make it a mandatory gate.

    2. Layer and modularize. Split the proof into modules that can be verified independently, for example “algebraic number theory infrastructure,” “modular forms and representation theory,” “Galois representations and deformations,” and “the contradiction construction.” Each module should have a clear entry theorem and explicit dependency boundaries. The benefit is that when a base definition changes, the affected scope can be located quickly.

    3. Build naming and documentation in. Even machine-generated code should follow a unified naming convention (for instance, hierarchical prefixes over namespace, theorem, and lemma), and every public theorem should carry a one-line note explaining what role it plays in the overall argument. This is not formalism; it lets whoever maintains the work later build a mental map quickly.

    4. Turn conventions into constraints with automated gates. Rather than relying on human reviewers to read line by line, convert the library conventions into machine-executable checks:

    1. # Illustrative code: form gate for formalization output (pseudocode, not a real interface)
    2. def gate(formalization):
    3. # 1. Convention consistency: file length, line length, docstring coverage
    4. assert formalization.max_file_lines <= FILE_LIMIT
    5. assert formalization.max_line_length <= LINE_LIMIT
    6. assert formalization.docstring_coverage >= 0.9
    7. # 2. Dependency minimization: count existing theorems actually referenced
    8. assert formalization.reference_count <= REFERENCE_BUDGET
    9. # 3. Spec alignment: the mapping table between human-readable and formal statements must be complete
    10. assert formalization.spec_mapping.is_complete()
    11. # 4. Maintainability: public theorems must be referenced by other modules or marked as entry points
    12. assert formalization.orphan_public_decls == []
    13. # 5. Reproducibility: pin dependency versions so rebuilds are identical
    14. assert formalization.dependency_lock.is_valid()
    15. return True

    5. Plan for build efficiency and resources. In a formalization project at the tens-of-millions-of-lines scale, compilation time is a real constraint. Workable approaches include on-demand incremental builds, caching intermediate artifacts, running full verification in an environment with higher parallelism, and moving full verification off the critical path to run asynchronously. Concrete resource specifications should be determined by load-testing against the actual code size, rather than reusing someone else’s numbers.

    6. Define what “done” means. It is advisable to split completeness into two metrics: coverage (the proportion of the target theorem list that has been formalized) and convention compliance rate (the proportion passing the form gate). Only when both targets are met should the result be called a “deliverable asset.”

    6. Practical advice for developers

    1. Distinguish a one-off credibility credential from a long-term public asset. If your only goal is to confirm that a set of arguments has no gaps, a completed machine proof is already sufficient, and it may even cost less than building a readable library. If your goal is for a team, a community, or later projects to keep working on top of it, form governance has to be planned at the same time.

    2. Do not underestimate the cost of spec alignment. In software engineering, a wrong specification is more dangerous than a wrong implementation, because both implementation and tests will “faithfully” amplify the spec’s error. The same holds for formalization: a formalization proof that passes kernel verification perfectly is worth zero if it encodes the wrong proposition.

    3. Be wary of over-optimism about formalization cost. The expansion from just over a hundred pages to millions of lines shows that the marginal cost of formalization is not low. When planning a formalization into a project, estimate the effort by order of magnitude, not by experience drawn from “writing a few pages of documentation.”

    4. Treat machine output as a first draft, not a final one. Machines are good at exhaustive enumeration and expansion; humans are good at abstraction and naming. The optimal combined form is usually: the machine handles completeness, while humans handle structure, naming, documentation, and reuse interfaces.

    5. Pay attention to long-term maintainability design. If this output is going to be cited continuously over the coming years, settle the versioning strategy, dependency-locking approach, and change process early, rather than retrofitting them after the scale has ballooned.

    7. Conclusion: the mismatch between a machine proof’s “correct” and the mathematics community’s standards

    What is actually worth remembering from this event is neither the misreading “AI proved Fermat’s Last Theorem” nor the oversimplification “AI formalization capability is already strong,” but a more precise judgment: machines can already deliver “correct” at extremely low cost, while “useful” still requires human design of form.

    Buzzard’s line — correctness is not the difference, the difference is form — carries universal meaning for developers. As generative tools make “passing verification” cheap in more and more engineering settings, the center of value inevitably shifts from “can it pass” to “is the form sustainable, collaborative, and reusable.”

    For the mathematics community, this event splits “formalize a theorem” into two tasks: obtaining trustworthiness, and accumulating a public asset. The first is being automated; the second still depends on the community’s conventions, review process, and long-term investment.

    For software engineering practitioners, the most valuable takeaway is this: in an era when generation capability is rising fast, evaluation criteria should move forward to form and specification, instead of stopping at whether the result is correct. Whoever can reliably convert “correct” into a “maintainable asset” is the one who actually captures the value of this capability.