Fermat's Last Theorem and the Engineering Path to LLM-Driven Formal Proof
Claims that large language models (LLMs) can formalize major mathematical theorems in a short time grab headlines, but developers should ask a different question: what exactly was proven, what dependencies were used, and can the result be independently verified? This article reframes "30 hours to formalize Fermat's Last Theorem" as an engineering problem. It explains what formal verification actually checks, why formalizing major theorems is a large-scale engineering effort, and how to build a reliable LLM-assisted proof workflow with staged goals, retrieval, verifiable intermediate lemmas, budget-controlled search, and audit records. It also proposes metrics for evaluating real model capability and a five-module system design, and extends the discussion to software reliability. Readers will learn how verifiable, reproducible proof artifacts—not impressive speed numbers—define trustworthy AI-assisted mathematics.
1. From “Fast Proofs” to a Verifiable Engineering Problem
News about an LLM formalizing a major mathematical theorem in a very short time tends to focus attention on model speed and reasoning ability. For developers and researchers, however, the more important questions are: what did the system actually produce, what did it depend on, and can the result be independently checked?
The original claim mentioned “formalizing Fermat’s Last Theorem in 30 hours,” but did not provide a complete proof artifact, verification logs, base library versions, task starting points, or records of human involvement. This timing figure therefore cannot be treated as a verified technical conclusion, and it certainly does not imply that the model can independently solve arbitrary mathematical problems.
The more valuable discussion reframes such claims as an engineering problem: how can an LLM convert a mathematical argument into definitions, lemmas, and proofs inside a formal system, pass strict verification, and ultimately produce a reproducible proof artifact?
This problem involves not only mathematical reasoning but also software engineering, dependency management, task scheduling, resource control, and trusted computing.
2. What Does a Formal Proof Actually Verify?
Fermat’s Last Theorem states: for integer exponent n greater than 2, there are no positive integers a, b, c such that a^n + b^n = c^n.
The statement itself is easy to understand, but its modern proof involves deep mathematical theory. Formalizing such a proof is far more than translating natural language into some syntax.
1. Natural-language proofs allow omissions; formal proofs demand explicit justification
Mathematical papers typically assume the reader can fill in routine steps. Phrases like “by continuity,” “applying the standard result,” or “without loss of generality” are acceptable in the right context.
A formal system instead requires explicit answers to:
- What type does each object belong to?
- Which assumptions does the conclusion depend on?
- Does the cited theorem actually satisfy its applicability conditions?
- Do expressions mean the same thing before and after a transformation?
- Can each inference step be accepted by the rules?
A seemingly short mathematical argument, once converted into a machine-checkable proof, may require a large number of auxiliary definitions and lemmas.
2. Generating proofs and verifying proofs are different jobs
An LLM can generate candidate proofs based on context, propose intermediate conclusions, find existing theorems, or repair errors. But generated content is only a candidate—it does not become valid merely because the language is fluent or the reasoning looks plausible.
What determines whether a proof is accepted is the checking mechanism of the formal system.
In common proof architectures, automation tactics handle proof search and construction, while a small trusted kernel checks the final proof object. This design separates the complex and potentially buggy search process from the verification process, which is governed by clear rules.
This is precisely why LLMs are well suited to formalization work: the model can attempt, fail, and revise, while the final result still must pass a deterministic check.
3. “Passing the check” still has trust boundaries
Passing a formal check does not mean all related engineering risks disappear. You still need to confirm:
- Whether the formalized statement accurately expresses the original mathematical proposition;
- Whether unapproved axioms or external assumptions were introduced;
- Whether the proof depends on additional trusted components;
- Whether any proof steps were skipped or left incomplete;
- Whether the runtime environment and dependencies are reproducible.
Formal verification provides guarantees relative to a given logical system, its assumptions, and its trusted components. Public reports should state these boundaries clearly.
3. Why Formalizing a Major Theorem Is Large-Scale Engineering
The proof of a complex mathematical theorem is rarely a single file—it is a large dependency graph.
Top-level conclusions depend on key theorems; key theorems depend on foundational theory; foundational theory depends on still lower-level definitions and properties. If these dependencies already exist in mature formal libraries, the new work may mainly consist of filling in the connecting steps. If dependencies are missing, the workload grows significantly.
Evaluating a claim of “completing the formalization of theorem X” therefore requires distinguishing at least three scenarios:
- Completing the final compositional proof on top of a complete base library.
- Supplying some missing key lemmas, then connecting them to existing results.
- Building substantial necessary theory from relatively basic mathematical definitions.
All three can be valuable research contributions, but their difficulty, resource requirements, and scope of contribution differ—total elapsed time alone is not a valid comparison.
Additionally, we should distinguish discovering a new mathematical proof from formalizing an existing one. The former requires finding a previously unknown argument; the latter mainly means expressing established mathematical results in a checkable formal system. The two overlap, but they are not the same task.
4. A Reliable Workflow for LLM-Assisted Proof
A practical system should not operate in a single-step “input theorem, output full proof” mode. It should build a staged, backtrackable verification loop.
1. Confirm the statement before starting proof search
The system must first check that the natural-language proposition and the formalized statement agree.
Key points include variable ranges, quantifier order, boundary conditions, and implicit assumptions. For example, writing “positive integers” as “non-negative integers,” or omitting the “exponent greater than 2” restriction, changes the proposition.
It is advisable to split the task into two independent reviews:
- Statement review: confirm the formalized statement matches the original intent.
- Proof correctness review: confirm the statement is proven under the permitted assumptions.
Otherwise, the system may successfully prove a weaker, easier proposition that is not the one the user actually wanted.
2. Retrieve reusable mathematical results
In large formal libraries, finding suitable existing results often matters more than proving from scratch.
Retrieval must attend to a theorem’s type, premises, and conclusions—not just its name. Two similarly named results may target different objects; two very differently named results may, after an appropriate transformation, satisfy the current goal.
In practice, you can combine text retrieval, structural matching, and semantic retrieval to narrow the candidate set, then let the checker confirm applicability. Retrieved results should carry source locations and dependency information to support auditing and reproduction.
3. Decompose large goals into verifiable intermediate lemmas
The model should first propose a proof plan and then process sub-goals step by step, rather than emitting a large volume of unchecked text at once.
Effective task decomposition typically includes:
- Supplying necessary definitions;
- Establishing conversions between objects;
- Proving local properties;
- Handling key special cases;
- Composing intermediate conclusions;
- Closing the final goal.
Each intermediate lemma should have explicit input assumptions and output conclusions. Lemmas that are too large make it hard to localize failures; decomposition that is too fine increases scheduling and maintenance overhead. Adjust the granularity based on the structure of the proof.
4. Use checker feedback for local repair
When verification fails, first classify the error type, then decide how to repair:
- Syntax errors can usually be fixed locally;
- Type mismatches may require adjusting how an object is expressed;
- Missing premises mean you must supply a proof or choose a different theorem;
- An unprovable goal may indicate the overall path is wrong.
Repeatedly rewriting the entire proof wastes resources and can break parts that were already correct. A more robust approach: persist the nodes that passed checking, and re-search only the failed nodes and their affected downstream dependencies.
5. Set explicit budgets for search
Proof search can fall into loops, repeated generation, and unproductive branch expansion. The system should set limits on total time, per-check time, retry counts, parallel task count, and resource consumption.
The following pseudocode illustrates the control logic only and does not represent any specific product interface:
Initialize the goal set to prove and the set of verified resultsWhile the budget is not exhausted and goals remain:Select a goal whose dependencies are satisfiedRetrieve relevant definitions and existing lemmasGenerate candidate proofsRun the checker in a controlled environmentIf the check passes:Save the proof and its dependency recordElse:Classify the error and adjust local strategyFinally, summarize completed goals, incomplete goals, and blocking reasons
The system must allow “not yet proven” to be an official outcome, rather than generating unverified conclusions just to finish the task.
5. How to Evaluate a Model’s Real Capability
The original material also covered benchmarks in coding, robotic manipulation, computer use, and multi-disciplinary reasoning. However, scores on different tasks are not interchangeable. Strong code-editing ability does not imply the ability to complete complex mathematical proofs; success in simulated environments does not mean real-device deployment is reliable.
For formal proof, an independent metric system is recommended:
1. Proof pass rate
Measure the proportion of candidate results that pass the checker within a given time, retry count, and tool permissions. You must state how many attempts are allowed; otherwise a single-attempt success rate is easily confused with the final success rate after repeated search.
2. Statement fidelity rate
Check whether the system preserves the variable ranges, conditions, and conclusions of the original proposition. A high proof pass rate with frequent weakening of the statement still does not indicate high task quality.
3. Dependency and assumption completeness
Record the base libraries, external results, extra axioms, and trusted components used. For major mathematical conclusions, this information is essential for understanding the scope of the proof.
4. Degree of human intervention
Record whether humans supplied key lemmas, corrected the statement, chose the proof path, or wrote parts of the proof. Reasonable human–AI collaboration deserves recognition, but collaborative results must not be presented as fully autonomous.
5. Total cost and reproduction success rate
Beyond generation time, track checking time, failed retries, resource consumption, and human review time. Whether another team can reproduce the same result from a fixed environment is a more convincing indicator than any single demo.
6. System Design for Engineering Deployment
Developers can organize an assisted-proof system into five modules:
- Task management module: stores propositions, acceptance criteria, budgets, and status.
- Knowledge retrieval module: manages definitions, lemmas, and their versions, and provides traceable retrieval results.
- Candidate generation module: proposes proof plans and candidate steps, but holds no final acceptance authority.
- Verification execution module: runs checks in an isolated environment, restricting network access, file access, and compute resources.
- Artifact audit module: preserves the final statement, proof files, dependency lists, check logs, and records of human operations.
Modules should communicate through explicit data contracts. In particular, avoid treating “the model reports success” as equivalent to “the task is complete.” The final status can only be determined by verification results combined with acceptance rules.
For long-running tasks, you also need checkpointing, deduplicated caching, and failure attribution. Proof processes often repeatedly explore similar branches; caching verified conclusions and known failure paths reduces wasted computation.
7. From Mathematical Proof to Software Reliability
The value of assisted formal proof is not limited to major mathematical theorems.
In software engineering, it can help developers express algorithm invariants, data structure properties, protocol state constraints, and access control rules. For example: whether a workflow permits an unauthorized state transition, whether a resource counter always stays non-negative, or whether exception handling preserves necessary system constraints—all of these can be subjects of formal analysis.
But here too, we must distinguish the model from reality.
Proving that an abstract protocol satisfies a property does not automatically prove that a concrete implementation is defect-free. Proving that a function is correct under specific input assumptions does not mean the deployed environment will never suffer misconfiguration, resource exhaustion, or external dependency failures.
A more sensible practice is to combine formal methods with testing, code review, and runtime monitoring: formal proof checks explicitly stated properties, tests cover actual behavior, and monitoring detects deviations in production.
8. Conclusion: Trustworthy Capability Comes from a Complete Chain of Evidence
The most meaningful progress in LLM-assisted formal mathematics is not that output increasingly resembles an expert’s, but that more and more output can be strictly checked, traced, and reproduced.
For claims like “a major theorem completed in a short time,” professional judgment should shift from speed to evidence: what proposition was proven, which dependencies were used, which assumptions were accepted, how much human contribution was involved, and whether the result can be independently rerun.
A reliable engineering path can be summarized as: confirm the statement first, then decompose the task; reuse verified knowledge first, then generate candidate proofs; drive repair through checker feedback, and define contributions through audit records.
When generation capability and trusted verification form a closed loop, LLMs can move beyond producing plausible-sounding answers and become technical assistants that deliver checkable results.
