Formal Proofs in Mathematics: How Machine Verification Reshapes Credibility and Reusability

    This article explains how formal proof differs from discovering a mathematical proof, using Fermat's Last Theorem as a reference point. It examines why formalized proofs expand into large software artifacts, where the trust boundary of proof assistants lies, how AI can improve formalization efficiency while introducing new risks, and why logical correctness is not the same as human understandability or knowledge reuse. It also outlines practical criteria for evaluating large formalization projects and principles for treating formal mathematics as long-term software infrastructure.

    Formal Proofs in Mathematics: How Machine Verification Reshapes Credibility and Reusability

    1. Distinguish “proving a theorem” from “checking an existing proof”

    Recent AI involvement in the formal verification of large mathematical theorems has prompted discussion about whether a machine has “proved” a famous theorem. To understand such claims accurately, it is necessary to separate two activities: producing a mathematical proof, and translating an existing proof into a machine-checkable formal system.

    Consider Fermat’s Last Theorem. It was proved by mathematicians in the 1990s. Later work did not ask an AI system to discover an entirely new proof path from scratch. Instead, it transcribed an existing and highly advanced number-theoretic argument into a strict formal language, then submitted that formalization to a proof assistant’s kernel for step-by-step checking.

    The core value of this work is not that it changes the theorem’s conclusion. It changes how the proof is verified. Traditional mathematical proofs rely mainly on peer review, expert judgment, and long-term rechecking. Formal proofs require every definition, premise, inference rule, and intermediate conclusion to be confirmed step by step by a small and relatively stable logical kernel.

    A more accurate description, therefore, is this: AI assisted with the formal encoding of a large mathematical proof, and a formal system performed machine verification of its logical validity. The AI did not independently discover Fermat’s Last Theorem.

    2. What formal proofs actually solve

    Traditional mathematics papers are highly compressed. Authors routinely omit many steps that are considered “obvious,” such as:

    • which implicit conditions a function satisfies;
    • whether an algebraic structure already has the necessary properties;
    • whether a limit, homomorphism, or mapping satisfies the premises of an applicable theorem;
    • whether a special case has already been covered by an earlier classification;
    • whether a series of symbolic transformations preserves the structure of the original object.

    For experts familiar with the field, these omissions improve reading efficiency. For a machine, every omission can become a gap that cannot be verified. A formal system does not accept “obviously true” as a default justification. It requires that the claim be expanded into explicit definitions, lemmas, and derivations.

    From an engineering perspective, a formal proof is comparable to converting an expert-oriented design document into a program that can be checked by a compiler and a logical kernel. It must describe not only the final conclusion but also:

    1. how objects are defined;
    2. which foundational axioms the theorem depends on;
    3. the inputs and outputs of each intermediate conclusion;
    4. how interfaces are established between different branches of mathematics;
    5. whether each inference step follows the rules allowed by the system.

    This rigor can significantly reduce the risk of typos, missing conditions, and hidden jumps in reasoning. For theorems with complex structures and long dependency chains in particular, a formal system can provide more stable local checking than manual review.

    3. Why a few hundred pages can expand into millions of lines of code

    The formalization of a large theorem often greatly exceeds the size of the original paper. This does not mean the formal version contains more mathematical ideas. It reflects the different goals of the two representations.

    Human mathematical text aims to “convey the core ideas in as few pages as possible.” Authors can use established theory, conventional notation, and domain consensus to compress multiple derivation steps into a single sentence.

    Machine-checkable text aims to “make every dependency explicit.” For example, a sentence in a traditional proof such as “the conclusion follows from a certain property” may need to be split, in a formal system, into:

    • introducing the type of the object;
    • declaring the assumptions the object satisfies;
    • invoking a known lemma;
    • instantiating the parameters;
    • handling boundary conditions;
    • proving that two expressions have the same structure;
    • converting the local result into the target proposition.

    The number of lines in formal code therefore cannot be directly equated with the amount of mathematical content. According to data disclosed by relevant projects, the complete codebase reached the scale of tens of millions of lines, the final dependency graph involved nearly 30,000 theorems, local supporting lemmas reached hundreds of thousands, and the number of files reached tens of thousands. The overall size was several times that of a general mathematical formalization library, and compilation costs were roughly an order of magnitude higher.

    These numbers show, first of all, that modern mathematical formalization already has the characteristics of large-scale software engineering. It requires module partitioning, dependency management, continuous builds, automated testing, naming conventions, and version maintenance. It is no longer merely an experimental script written by a small number of mathematicians.

    4. Where the trust boundary of a proof assistant lies

    The credibility of a formal proof comes from a trust chain that is as short as possible. It can usually be divided into four layers.

    The first layer is the mathematical statement. The objects, conditions, and conclusions of the theorem must be written explicitly to avoid ambiguity in natural language.

    The second layer is the formal definition. Mathematical concepts need to be translated into types, structures, and relations that the system can process. If the definition itself is inconsistent with the original mathematical concept, then even if everything later passes checking, it does not show that the original proposition has been proved.

    The third layer is the proof code. The code constructs the derivation from assumptions to conclusion. Automation tools can help search for steps, generate intermediate terms, or organize expressions, but their output still needs to be checked by the kernel.

    The fourth layer is the logical kernel. The kernel confirms whether the proof object is valid according to a limited set of rules. Ideally, complex automation strategies do not directly become the final basis of trust. What truly needs to be trusted is only the smaller checking component.

    This means that “passed machine checking” is not equivalent to “has no risk.” The following questions still matter:

    • Does the formal statement accurately express the original theorem?
    • Have axioms or additional assumptions been misused?
    • Did the encoding process omit certain constraints?
    • Does an automatically generated proof contain unnecessary complexity?
    • Have the underlying software and runtime environment been reasonably audited?

    Formal verification therefore addresses the checkability of the reasoning chain. It does not automatically solve problems of modeling, definition, or the choice of research direction.

    5. With AI involvement, efficiency gains and new risks coexist

    AI is particularly well suited to mechanical work in large formalization projects. For example, it can assist with symbolic transformation, completing local proofs, searching for similar lemmas, generating repetitive code, and analyzing complex dependencies. Doing all of this manually would be extremely costly.

    But formal code generated by AI can also introduce new problems.

    First, readability may decline. To pass checking as quickly as possible, a system may generate verbose, repetitive, and hard-to-understand proof terms. They may be logically correct, but they are not necessarily suitable for a long-term mathematical library.

    Second, the level of abstraction may be insufficient. High-quality mathematical code should not only prove conclusions; it should also extract reusable concepts and interfaces. If every local problem is handled as a special case, the project may be completed, but it will accumulate a large amount of duplicated code.

    Third, maintenance costs may rise. Formal libraries usually need to evolve over time. When underlying definitions, theorem names, or data structures change, code without a clear structure can require extensive cascading modifications.

    Fourth, the verification goal may be misunderstood. AI can help implement formalization, but it cannot replace mathematicians in judging whether a proof captures the essence of the problem. Nor can it replace expert confirmation that the formal statement matches the original mathematical intent.

    AI is therefore better understood as a high-efficiency engineering assistant for formalization, not as a complete replacement for mathematical modeling, theoretical design, and knowledge organization.

    6. “Correct” and “valuable” are not the same dimension

    A proof contains at least three kinds of value.

    The first is logical correctness. Can the conclusion be derived strictly from the given premises? This is the part formal systems are best at checking.

    The second is human understandability. Can readers quickly see what idea the proof uses, which steps are most important, and why the conclusion holds?

    The third is knowledge reusability. Can other researchers build new theorems on top of the existing definitions and lemmas, turning the original result into public infrastructure?

    Large automatically generated proofs often perform strongly on the first dimension, but they are not necessarily equally strong on the other two. Such a proof may resemble a building that has passed strict inspection: the structure is indeed stable, but it lacks clear design documents and an internal layout that is easy to modify.

    This is also the central tension in large formalization projects. If the only goal is to finish as quickly as possible, it is easy to produce a huge and hard-to-read codebase. If the only goal is elegance and reusability, the project timeline may be significantly extended. A more desirable practice is to separate “completing verification” from “organizing knowledge” into two stages: first establish a reliable machine-checked result, then carry out abstraction refactoring, documentation, and modular governance.

    7. How to evaluate a large formalization result

    Such results should not be evaluated only by lines of code or whether compilation succeeds. A multidimensional set of criteria is more appropriate.

    The following aspects can be considered:

    • whether the theorem statement is consistent with the original mathematical proposition;
    • whether the axioms and foundational theories it depends on are clear;
    • whether the proof covers all boundary cases;
    • whether the code has a reasonable module structure;
    • whether key definitions and lemmas are easy to reuse;
    • whether the documentation helps new readers enter the project;
    • whether the build process is stable and reproducible;
    • whether the cost of subsequent maintenance and version migration is controllable.

    If a project only completes machine verification but does not produce a clear abstraction layer, its direct value for mathematical dissemination may be limited. This does not mean the project is meaningless. It can still serve as a stress test of whether existing formalization infrastructure can support top-level mathematical results, and it can expose weaknesses in definition design, automation strategies, and engineering workflows.

    8. Implications for the future of mathematical software engineering

    These developments show that mathematical research and software engineering are becoming more closely integrated. Future large mathematical projects may simultaneously take the form of papers, formal code, automated build pipelines, and long-term maintenance communities.

    For formal results to become genuine public assets, project design should consider the following principles as early as possible:

    1. Design abstractions before writing proofs. Do not let local tricks dictate the overall structure.
    2. Split core concepts into stable modules and reduce cross-file and cross-layer coupling.
    3. Add documentation for important definitions, theorems, and complex algorithms.
    4. Preserve human-readable proof ideas; do not leave only machine-executable text.
    5. Use continuous integration to ensure that code remains reproducible after environment changes.
    6. Refactor automatically generated content and extract general lemmas and public interfaces.
    7. Preserve proof results, dependency relationships, and design decisions for the long term.

    From this perspective, AI completing the formalization of a large theorem should not be understood only as a “speed race.” It is more like a scale test: we are exploring whether the most complex human knowledge can be transformed into verifiable, maintainable, and reusable computational objects.

    Ultimately, the significance of formal proof is not merely to tell us that a conclusion “really holds.” More importantly, it moves mathematics from a practice that relies mainly on expert memory and peer trust toward a knowledge engineering system that combines machine verifiability with human understandability. Only when these two aspects are genuinely combined will formal mathematics be more than code that passes checking. It will become infrastructure capable of supporting the next generation of research.