Formalizing Fermat's Last Theorem with Large Language Models: Value and Engineering Limits
This article examines what large language models can and cannot show when they help formalize Fermat's Last Theorem in a proof assistant. It separates formalizing an existing proof from discovering a new one, explains what a proof checker actually verifies, and discusses why formal projects can grow very large. It also outlines a review process for judging whether a formalization is verified, reproducible, and reusable as a library.
1. Start by Separating Proof Discovery from Formal Proof
When discussing large language models in the formalization of Fermat’s Last Theorem, three easily confused concepts should be kept apart: proposing a mathematical conjecture, discovering a mathematical proof, and rewriting an existing proof as a checkable object in a formal system.
Fermat’s Last Theorem states that when the integer exponent n is greater than 2, there are no positive integers a, b, and c such that:
a^n + b^n = c^n.
The mathematical community has accepted a proof of this result since the 1990s. Therefore, formalizing an existing argument usually does not rediscover the result. Completing a formalization alone also does not justify the claim that a large language model independently solved a previously open mathematical problem.
The main task of formalization is to translate an argument, which natural language, formulas, and professional conventions jointly carry, into definitions, propositions, and proof terms that a proof assistant can process. Phrases in human papers such as “follows from a standard result,” “obviously holds,” or “proved by a similar method” often need to be spelled out explicitly in a formal system.
This is an independent and difficult task. Its difficulty lies mainly in knowledge representation, dependency completion, and proof engineering. It should not be equated with an original mathematical breakthrough.
When discussing concrete results, distinguish news descriptions, project documentation, and deliverables that can actually be reproduced. Whether the final proposition was completed, whether extra assumptions were used, and whether any step remains unverified must be confirmed through public code, dependency configuration, and check results. Such claims cannot be drawn from the amount of code or from a highly automated generation process.
2. What Formalization Actually Verifies
1. It verifies a precise proposition, not a natural-language claim
A proof assistant checks a precisely defined proposition. For example, whether variables are restricted to positive integers, how the range of exponents is expressed, and whether zero solutions are allowed all affect what the proposition actually says.
If a formal statement quietly narrows the variables or omits a key condition, the proof can pass checking while failing to establish the conclusion the reader has in mind.
Therefore, the first step of review is not to measure how long the proof file is. It is to read the complete statement of the final theorem and check whether it matches the natural-language goal.
2. It verifies derivability relative to axioms and dependencies
In a common architecture for formal proofs, an automated program searches for a proof, and a small trusted kernel checks whether the proof object follows the inference rules.
This separates responsibilities in an important way. The generator can be complex and error-prone, while the checker is kept as simple and strict as possible. A wrong proof produced by a large language model does not become accepted. As long as a reliable kernel checks the submitted proof object, an invalid inference should be rejected.
However, passing the check always depends on premises. The axioms, external results, and trusted mechanisms that the final conclusion relies on must be traceable. If the conclusion to be proved is itself declared as a hypothesis, the subsequent derivation may succeed, but this does not complete the original goal.
Therefore, trustworthiness should be stated as follows: under an explicit formal system, a defined set of assumptions, and a specified checking mechanism, the target proposition has a verifiable derivation.
3. Formalization does not automatically eliminate errors in expression
The kernel can check a formal derivation, but it cannot judge whether a definition matches the author’s mathematical intent.
For example, if a formal definition of some structure omits a property, or if the correspondence between two objects is not established correctly, the system may still verify a proposition that is logically valid but differs from the original problem.
A complete review therefore needs two tracks:
- Mechanical checking: whether the derivation follows the formal rules.
- Semantic review: whether the definitions, assumptions, and target faithfully express the original mathematical content.
Neither track can replace the other.
3. Why a Paper Can Grow into a Large Code Project
Human mathematical writing is highly compressed. Behind one technical term may lie a complete system of definitions. One citation may depend on dozens of intermediate results, and a short “standard argument” may require several layers of construction.
Formalization must turn this implicit knowledge into explicit dependencies, so a large increase in code volume is not surprising. However, growth usually comes from different sources, and each source needs separate analysis.
1. Genuine expansion of knowledge
Premises, type constraints, boundary conditions, and intermediate lemmas that natural language takes for granted may all need explicit expression. This growth has real value, because it turns content that once depended on expert judgment into checkable assets.
2. Library gaps and duplicated construction
If the underlying library lacks the needed theory, the project must add many definitions and theorems. If the generation process does not search existing results thoroughly, it may also reprove content that could have been reused directly.
Therefore, newly added code does not necessarily represent new knowledge. Some of it may be repeated work.
3. Generated boilerplate and local patches
Large language models tend to push forward along locally feasible directions. When one step fails, they add auxiliary lemmas. When an expression does not match, they add conversions. When one path is blocked, they try another similar construction.
These operations may raise the short-term pass rate, but they can also produce over-expanded proofs, duplicate definitions, and fragile proof scripts.
Thus, line count measures neither mathematical difficulty nor the quality of the result. When comparing sizes, state the scope of the count: whether it includes dependency libraries, automatically generated files, content the final proof does not use, and duplicated or abandoned attempts.
4. Passing Verification and Long-Term Reusability Are Different Completion Criteria
A formalization result can be assessed at two levels.
The first level is verification delivery. The target proposition has been established, its dependencies are explicit, and the check can be reproduced.
The second level is library-grade delivery. The proof structure is clear, key results can be searched and reused, interfaces are stable, documentation is adequate, and maintenance cost is under control.
The first level answers whether the conclusion can be checked mechanically. The second level answers whether others can continue working on top of it.
Difficult-to-read code does not cancel a formal derivation that holds. Nor does kernel acceptance mean the engineering quality meets the standard of a public mathematical library.
Readability lowers collaboration costs
Human readers do not need to read every low-level derivation line by line. They do need to understand the responsibilities of the main modules, how the core theorems relate, and why key assumptions appear.
If a proof is buried under a large amount of local detail, maintainers struggle to judge which conclusions a change will affect. They also struggle to find intermediate results that could support new research.
Reusability depends on the level of abstraction
A lemma customized for the current goal may work in that proof but serve no other problem. Appropriate abstraction lets one result cover a broader range of objects.
More abstraction is not always better, however. Over-generalization increases the burden of understanding and the complexity of proofs. A sound approach designs interfaces around real reuse needs rather than stacking layers to look general.
Separate specification issues from deeper engineering problems
File length, naming style, and documentation format are explicit requirements of a specification. Some of them can be fixed through mechanical cleanup.
Duplicate definitions, tangled dependencies, poor abstraction, and fragile proofs usually require redesign. A failure to follow library conventions should not be dismissed as “machine-generated code has no value.” Formatting fixes should not be mistaken for a structural refactor.
5. What Large Language Models Change: Generation Gets Cheaper, Review Matters More
Large language models suit high-frequency tasks with clear feedback. Examples include completing local proof steps, proposing auxiliary lemmas, trying different derivation paths, and revising expressions based on checker errors.
A proof assistant provides relatively clear feedback, which closes the generation loop:
State the goal → generate
