Formalizing Fermat's Last Theorem with Large Language Models: A Technical Perspective
This article examines what it means for a large language model to assist in the formal proof of Fermat's Last Theorem. It clarifies the distinction between discovering a new proof, formalizing an existing proof, and verifying a formal proof. It then analyzes the technical requirements, the role of proof checkers, the gap between human-readable proofs and machine-verifiable formalizations, and the use of multi-agent workflows. The article also provides practical guidance for evaluating such projects and applying similar verification-based practices in software engineering.
Clarifying the Claim: Generating a Proof vs. Discovering a Proof
When we hear that a large language model has “completed the formal proof of Fermat’s Last Theorem,” the crucial point to clarify is not the model’s capability but what “completion” actually means.
At least three different types of achievements are often conflated in such claims:
- Discovering a new mathematical proof – proposing a previously unknown reasoning path and establishing its correctness.
- Formalizing an existing proof – converting a proof already constructed by mathematicians into strict formal language, filling in implicit conditions and intermediate deductions.
- Verifying a formalized proof – using a proof checker to confirm, according to explicit logical rules, that a submitted proof object is valid.
All three can be valuable, but they solve different problems. A model that can perform the second task did not necessarily perform the first. A system that reports “check passed” does not automatically mean that all engineering artifacts, external dependencies, and trusted assumptions have been made public and independently audited.
The original material referenced specific completion dates, code sizes, theorem counts, and resource usage, but it did not provide complete evidence that can be independently reviewed. Therefore, such details should not be treated as established facts. A more robust analysis discusses the technical conditions such a result must satisfy and what it means when they are met.
Why Fermat’s Last Theorem Is a Suitable Test for Formalization Engineering
Fermat’s Last Theorem states: for any integer exponent greater than two, there do not exist positive integer solutions to the corresponding power equation.
A schematic logical expression is:
For all natural numbers n, x, y, z,
if n > 2, and x > 0, y > 0, z > 0,
then xⁿ + yⁿ ≠ zⁿ.
This statement looks short, but a short statement of a theorem does not imply a short proof. Many results in modern mathematics depend on a wide range of cross-disciplinary theories. The final theorem may be one line, but its underlying system covers deep connections across algebra, number theory, geometry, and related structures.
Therefore, the main difficulty in formalization is usually not typing the final conclusion into a computer, but building a sufficiently complete and mutually compatible theoretical foundation.
For example, an informal paper may directly use a classical result. In a formal environment, the system must find the precise version of that result and confirm that it applies to the current objects. Whether the number field or structure has the required properties, or whether a mapping satisfies the relevant conditions, cannot be left for the reader to infer.
This makes the formalization of a major theorem a complex engineering task: it requires understanding mathematical structures as well as handling interface design, dependency organization, automated search, and build stability.
What the Machine Actually Checks
Formal proof systems typically treat a theorem as a logical proposition to be constructed, and a proof as a strict object that supports the proposition.
In type-theory-based systems, this can be intuitively understood as: the theorem corresponds to a type, and the proof corresponds to a term of that type. The checker’s job is to confirm that the term indeed has the claimed type.
This mechanism transforms “this argument looks plausible” into “this proof object satisfies explicit formal rules.”
However, the assurance provided by machine checking has boundaries.
First, it guarantees that the formal proposition holds under the logic and assumptions adopted. If the natural-language problem was translated incorrectly, a passing check cannot correct that semantic deviation.
Second, proofs may rely on axioms or external assumptions. Using axioms is not inherently unreasonable, but one must distinguish between foundational axioms intended by the system and strong assumptions added to bypass difficulties. In particular, one should check whether the target conclusion itself, or an equivalent statement, has been smuggled in as a premise.
Third, the checker’s implementation, the runtime environment, and certain computational mechanisms may also affect the trust boundary. Different verification paths have different trust requirements; we cannot treat all “automatically passed” results as the same kind of assurance.
Therefore, a serious formalization result should at least state: what proposition was proved, what assumptions were used, what checking mechanism was employed, and how a third party can re-run the verification.
From Human Arguments to Formal Proofs: What Is Missing
Mathematical papers aim to make the argument understandable to a reader with relevant background, not to spell out every foundational step. Authors may write “by standard results” or “by direct computation,” compressing a large amount of background knowledge.
Formal systems require that these compressed elements be explicitly supported somewhere. They need not all appear in the main proof, but they must already exist in the available library of definitions, lemmas, and theorems.
This conversion typically involves four layers of work.
1. Unifying representations of objects
The same mathematical object may have multiple equivalent definitions. Humans can often switch between them naturally, but formal systems require explicit conversion relations. If different modules use different representations, connecting them requires additional correspondence theorems.
2. Filling in implicit conditions
A conclusion may hold only under commutativity, finiteness, or a specific non-degeneracy condition. Conditions that are assumed by default in natural language must become explicit formal premises.
3. Decomposing intermediate deductions
A concise statement may contain several independent steps. Breaking it into stable auxiliary lemmas helps not only with passing the checker but also with later reuse and debugging.
4. Building cross-module interfaces
Individual proofs may be correct in isolation, but they can still fail to compose because of differences in definitions, parameter order, or premise strength. Thus, one core difficulty of formalization engineering is guaranteeing that modules can actually connect.
As a result, an increase in code size does not necessarily mean a comparable increase in mathematical content. A significant portion of the size comes from explicit statements, compatibility conversions, and infrastructure.
How Multi-Agent Collaboration Advances Long Proofs
Given a large dependency structure, it is unrealistic to expect a single model to continuously generate a complete proof. A more practical approach is to organize the global task into a dependency graph and assign local goals to multiple execution units.
A typical flow can be summarized as:
Goal analysis → Dependency decomposition → Interface specification → Local proof generation → Automated checking → Integration verification → Final audit.
Task decomposition is not necessarily better when it is finer. If a task is too large, it may exceed the model’s stable context window. If too small, it produces many low-value interfaces and increases communication and build cost.
A reasonable unit is usually a semantic, well-defined definition, lemma, or module. Each task should include:
- The precise target proposition
- Definitions and theorems allowed for use
- Required representation conventions
- Expected deliverable interfaces
- Extra assumptions that must not be introduced
- Clear checking and acceptance criteria
Collaboration systems must also prevent circular dependencies. For example, if module A calls module B during its proof, and B indirectly depends on A, the system may create a dependency loop that cannot be legally closed. A declaration that has not yet been proved cannot be treated as an available conclusion.
Therefore, the value of multi-agent systems is not simply “running more tasks at once.” It is transforming mathematical search into a schedulable, checkable, and reversible engineering process.
Why Check Failures Are Useful Feedback
Model-generated proofs often fail to pass the checker at first. Failures can arise from several layers: referencing a nonexistent theorem, object type mismatch, missing required premises, or actually choosing a proof route that does not work.
These failures should not all be handled with the same retry strategy.
If the interface usage is wrong, the system should provide accurate signatures of relevant definitions and candidate theorems. If the goal decomposition is unreasonable, the task boundaries need to be adjusted. If the mathematical route itself is problematic, endless local patching will only waste resources.
Thus, a feedback loop needs error classification capabilities, not just feeding error text back into the model.
At the same time, already-passed results should be solidified as reusable assets, and affected parts should be rechecked when dependencies change. This avoids local repairs breaking other modules, or the situation where “it passed earlier, but the whole cannot be rebuilt.”
It is important to emphasize that automated checking can eliminate invalid candidate proofs, but it cannot guarantee that the search process is efficient, nor that the model will find a proof at all.
How to Evaluate a Result with “Many Lines of Code and Many Theorems”
Code line counts, generation counts, and resource consumption can help convey the scale of a project, but they are not direct indicators of correctness or scholarly value.
Long code may indicate broad coverage, but it may also indicate repeated deductions, low abstraction levels, or redundant content produced by automated generation.
Many auxiliary lemmas may reflect good modularity, but they may also mean that simple processes were over-fragmented. What matters is whether these lemmas lie on the effective dependency chain of the final conclusion, and whether they form a reusable, maintainable knowledge structure.
To evaluate such results, the following metrics are more relevant:
- Independent reproducibility: Can a third party rebuild the result from public artifacts, rather than only seeing demonstration screenshots?
- Transparency of the trust boundary: Are the axioms, extra assumptions, and checking mechanisms fully disclosed?
- Dependency closure: Does the final theorem still rely on unproved claims or placeholder implementations?
- Semantic fidelity: Does the formal proposition accurately correspond to the original mathematical statement?
- Engineering maintainability: Does the proof have clear module boundaries, and can the impact of changes be located?
- Reusable knowledge value: Can the foundational theory and auxiliary results support other mathematical tasks?
“Shorter” is not necessarily more trustworthy, and “longer” is not necessarily more complete. Scale can only describe the artifact; it does not replace auditing.
Practices That Development Teams Can Adopt
Major mathematical theorems and enterprise software are not the same type of task, but they share a common problem: how to establish that critical conclusions in a complex system rest on explicit, checkable constraints.
For example, for a permission system, one can first define subjects, resources, and authorization relations, then prove that certain operations cannot bypass authorization premises. For a financial ledger module, one can define balance changes and conservation conditions, then check whether state transitions preserve these invariants.
However, proving that an abstract model satisfies a property does not mean that the actual deployed system is necessarily safe. The correspondence between the model and the implementation, as well as external inputs, concurrency behavior, and runtime environment, must be handled separately.
Thus, a more realistic adoption path is:
- Choose core modules with clear boundaries and high risk.
- Convert business requirements into checkable invariants.
- Let the model assist in writing specifications, decomposing proof goals, and supplementing local derivations.
- Use an independent checking mechanism for acceptance, rather than treating the model’s explanation itself as evidence.
At the organizational level, proof artifacts should be placed under version control, continuous checking, and change auditing, so that formalization results evolve with the implementation rather than becoming a one-time deliverable.
What Is Truly Promising: Verifiable Knowledge Production
The most meaningful change brought by large language models participating in mathematical formalization is the potential to reduce the conversion cost from “human understanding” to “machine-verifiable evidence.”
Humans excel at choosing problems, forming concepts, and judging research value. Models can assist with searching, completing, and organizing candidate derivations. Strict checkers handle the final logical acceptance. When these three roles are clearly separated, the overall process is more reliable than asking a model to take on all responsibilities alone.
Therefore, when viewing such achievements, we should neither undervalue their engineering significance because they follow existing proof routes, nor overstate their mathematical novelty because of the large scale of generation.
What truly matters in a significant result should rest on publicly inspectable artifacts: accurate proposition representation, closed dependency relationships, transparent trusted assumptions, and reproducible verification processes. Only when these conditions are satisfied can “the model wrote a proof” be further transformed into “we have obtained a mathematically verifiable piece of evidence that can be independently checked.”
