Formal Verification in Mathematics: How Machine-Checked Proofs and AI Coding Assistants Are Reshaping the Field

    This article examines the shift from human-persuaded mathematical proofs to machine-verified formal proofs, using a recently completed number theory result with roughly 17 million lines of interactive theorem proving code as the reference point. It explains why a small, auditable kernel makes such proofs reproducible and composable, what role AI coding assistants actually play as proposers rather than deciders, how to manage proof codebases at scale as a software engineering problem, and how generic cloud capabilities can support long-running verification jobs. It closes with the key limitations—kernel consistency, axiom strength, and semantic mapping—and practical recommendations for technical teams.

    1. The Real Shift: Not Who Won, but That the Proof Was Checked by a Machine

    On the opening day of a mathematics workshop, a researcher announced that, working with an AI coding assistant, they had completed a proof of a long-standing open problem in number theory, and released interactive theorem proving code of roughly 17 million lines. Public discussion tends to focus on whether artificial intelligence is replacing mathematicians. From an engineering perspective, however, the structurally meaningful change is different: this proof no longer depends on “persuasion” during peer review. It can be verified line by line by a proof assistant.

    Verifying a traditional mathematics paper is extremely expensive. Reviewers must reconstruct the author’s chain of reasoning, and any step marked “clearly follows” may hide a gap—gaps that have historically been far from rare. Formal verification turns this process into an executable check: as long as the implementation of the underlying logic system is trustworthy and the axiom assumptions are stated explicitly, a “pass” from the machine is a reproducible conclusion. In other words, the center of value has moved from producing proofs to producing proofs that a machine can判定 as correct—that a machine can decide to be correct.

    2. The Technical Foundation: Why Interactive Theorem Proving Is Trustworthy

    The core of an interactive theorem proving system is a small, auditable kernel. It does one thing only: starting from axioms and already-proven theorems, it constructs proof terms according to inference rules and checks that each proof term has the correct type. In such systems, a “proof” is a data structure that the kernel can verify, not a passage of natural-language narrative.

    This yields three engineering properties:

    • Reproducible: the same source code under the same logic version produces the same check result.
    • Auditable: axioms and dependencies can be enumerated, preventing a conclusion from quietly relying on a stronger assumption.
    • Composable: formalized theorems become library assets that later work can reuse directly, so marginal cost decreases over time.

    The cost is equally clear: formalization is enormously labor-intensive. A lemma that looks short may expand into thousands of lines of tactic scripts. This is the direct reason codebases reach the tens-of-millions-of-lines scale, and the fundamental reason long-running tasks must be managed with engineering discipline.

    A schematic proof skeleton (pseudocode, structure only):

    1. theorem main_claim : P := by
    2. -- 1. Reduction: rewrite the goal into a form known lemmas can handle
    3. rw [reduction_lemma]
    4. -- 2. Decomposition: split into finitely many subgoals
    5. apply finite_decomposition
    6. · exact base_case_proved
    7. · intro n hn
    8. -- 3. Inductive step, invoking existing theorems from the library
    9. exact inductive_step n hn

    3. What AI Coding Assistants Actually Do Here

    Understanding an AI coding assistant as a black box that automatically writes proofs is inaccurate. Its more practical role is search and proposal: suggesting candidate tactics for the current proof state, retrieving similar lemmas from the library, generating boilerplate code in bulk, and offering rewrite suggestions when a state fails. The decision authority always stays with the kernel—if a proposal is wrong, it does not compile, and no “seemingly correct” artifact is ever produced.

    This imposes an important engineering constraint: any generated result must pass through a mandatory verification gate. A workable flow is:

    1. Generate candidate proof fragments.
    2. Have the proof assistant compile them, keeping only the branches that pass the kernel check.
    3. Record failed states and error codes as context for the next round.
    4. Once all goals are closed, run a full re-verification in a clean environment.

    4. Managing Tens of Millions of Lines: Treat It as Large-Scale Software Engineering

    At this scale, a mathematics problem has become a software engineering problem. Practices worth borrowing include:

    • Modular layering: a base-lemma layer, a tooling layer, a domain layer, and a top-level theorem layer, with dependencies flowing in one direction.
    • Incremental builds: cache compilation artifacts at file granularity to avoid full recomputation every time.
    • Dependency governance: pin the logic version and library versions to prevent “it passes on my machine.”
    • Continuous integration: trigger a kernel check on every commit, blocking merges on failure.
    • Observability: track per-file timing, failure rates, and retry counts to locate bottleneck lemmas.

    A minimal viable pipeline sketch:

    1. stages:
    2. - lint_and_format
    3. - compile_incremental
    4. - kernel_check_all # full re-verification in a clean environment
    5. - axiom_audit # output the list of dependent axioms
    6. - publish_artifacts

    The axiom_audit stage is the easiest to overlook and the most critical: it turns “which assumptions were used” into a deliverable, so the scope within which a conclusion holds can be judged independently.

    5. Cloud Practice: Running Long Verification Jobs on General-Purpose Cloud Capabilities

    These tasks are compute-intensive, parallelizable, prone to frequent retries, and produce artifacts that must be retained long term. General-purpose cloud capabilities can cover the following categories:

    • Container platforms: provide isolated, version-pinned build environments for each proof task.
    • Object storage: store source snapshots, compilation artifacts, and proof terms, which are naturally reproducible.
    • Message queues: decouple task dispatch from execution, smooth out peaks, and support re-delivery of failed tasks.
    • Logging services and monitoring/alerting: track compilation time, failure clustering, and resource watermarks.

    When implemented on Baidu AI Cloud, the typical mapping is: the container platform handles parallel compilation, object storage keeps reproducible snapshots, message queues drive task scheduling, and the logging and monitoring system handles failure attribution for long-running tasks. Note that specific parameters and quotas should be taken from the official documentation; this article assumes no proprietary interfaces or performance figures.

    6. Boundaries and Risks: Do Not Treat “the Machine Passed” as “the Problem Is Gone”

    Three boundaries must be clear. First, consistency risk: if the kernel implementation has a defect, the trustworthiness of the conclusion drops accordingly, which is why a smaller kernel is easier to audit. Second, axiom risk: formalization only guarantees correctness “starting from the given axioms”; if overly strong auxiliary assumptions are introduced, the value of the conclusion is weakened. Third, semantic mapping risk: translating a natural-language proposition into a formalized statement may introduce distortion, so domain experts must review the statement itself, not just the code.

    The reasonable positioning is therefore this: AI coding assistants substantially compress the marginal cost of formalization, making verification that was previously shelved due to workload possible. But problem selection, proposition formulation, and the reasonableness of assumptions remain the researcher’s responsibility.

    7. Actionable Recommendations for Technical Teams

    • Start formalizing “small but critical” modules, such as protocol state machines and boundary conditions of numerical algorithms.
    • Build the gate before pursuing generation: do not ship a generation pipeline that lacks mandatory kernel checks.
    • Make the axiom list and dependency graph deliverables, and include them in review materials.
    • Establish reproducible builds: the three essentials are pinned versions, cached artifacts, and clean-environment re-verification.
    • Measure return on investment: use “reduction in manual verification hours” and “defect escape rate” as metrics, not lines of code.

    When verification shifts from labor-intensive effort to an automatically executable pipeline, mathematics and software engineering begin to converge methodologically: both require conclusions to be independently, cheaply, and repeatedly checkable. That is the real meaning of a “new era” in an engineering context.