Engineering Formal Verification Around AI-Assisted Proofs

    A recent discussion of large language models helping formalize a proof related to the Riemann hypothesis highlights a practical engineering question: how to combine model generation with mechanically checkable verification. This article outlines a reproducible generate–verify–feedback–simplify pipeline, the trust assumptions behind formal proof, and practices for controlling proof size, dependencies, and human review.

    A recent discussion in technical communities concerned large language models assisting with a formal proof related to the Riemann hypothesis. Whatever the eventual academic assessment of that specific case, it places two long-separated capabilities on the same engineering table: the generative strength of large language models and the mechanical checkability of formal verification. Models are good at proposing candidates across a large search space. A proof kernel accepts only conclusions it can check step by step. Once the two are combined, the question that matters to developers is not whether a model claims to have proved a hard problem, but how to build a reproducible, auditable, and maintainable generate–verify–feedback–simplify pipeline.

    From Natural-Language Conjecture to Machine-Checkable Proof

    Mathematical proofs written in natural language often rely on shared background, implicit lemmas, and reader consensus. Human reviewers can tolerate some omission. Machine checking cannot. A formal proof must reduce every inference to a small set of axioms, definitions, and inference rules, with the proof kernel performing the final check. The core of AI-assisted proof is therefore not to have a model “say a proof that looks correct,” but to have it generate formal source that a prover can compile and check.

    The discussion cited a representative reduction in scale: proofs shrinking from about 17 million lines to 300,000 lines or even 76,000 lines, and a paper compressed from 250,000 pages to 1,200 pages or even 322 pages. Early automatic search often produces repeated lemmas, excessive expansion, and fragments that work locally but are redundant globally. Later simplification depends on abstraction, generalization, and refactoring. For engineering teams, this closely resembles moving a large codebase from “it runs” to “it is maintainable.” Passing verification is not the end of the work. Proof compression, module boundaries, and naming discipline matter as well.

    Why Large Language Models Can Join the Proof Loop

    A large language model can be treated as a learned input–output box: given context, it predicts the next token. Through human feedback or verifiable rewards, it gradually raises the probability of producing a correct candidate. In a proof setting, the model does not need to emit a complete proof in one shot. It can repeatedly propose local lemmas, tactics, or proof fragments, which a formal prover then checks.

    The essential loop is:

    1. Decompose the goal. Split a large theorem into checkable subgoals.
    2. Generate candidates. Using existing definitions, lemmas, and failure information, the model proposes a proof fragment.
    3. Check mechanically. The prover compiles the fragment and returns success or an error location.
    4. Feed failures back. Return error type, missing lemmas, and context to the model.
    5. Simplify the proof. On an accepted proof, remove redundancy, extract lemmas, and generalize through refactoring.
    6. Audit by hand. Focus on whether definitions are sound, whether extra axioms were introduced, and whether key lemmas match the intended mathematics.

    The loop can be sketched as:

    1. def prove(goal, model, verifier, budget):
    2. context = init_context(goal)
    3. for step in range(budget):
    4. candidate = model.propose(goal, context)
    5. result = verifier.check(candidate)
    6. if result.accepted:
    7. return simplify_and_review(candidate)
    8. context = update(context, result.errors)
    9. return None

    The point of this pseudocode is that the verifier stays in the loop. The model can be replaced and the prompting strategy can change, but the root of trust must be an independently checkable proof kernel, not the model’s self-reported confidence.

    Where Trust Comes From: A Minimal Base and Reproducible Builds

    Formal verification is valuable because it shifts “I trust the author” toward “I trust the kernel plus the axioms.” That does not mean the whole toolchain can be trusted unconditionally. Engineering attention should at least cover:

    • A minimal trust base. Audit whether extra axioms, unfinished placeholders, or unreviewed external dependencies were introduced.
    • Locked dependencies. Pin prover, library, and build-environment versions so verification can still be reproduced years later.
    • Reproducible builds. Record compiler flags, the dependency tree, and check results so a proof does not pass on one machine and fail on another.
    • Axiom audits. Visualize and diff the axiom set that a critical theorem depends on.
    • License and supply-chain compliance. Make the permitted use of proof source, dependent libraries, and generated content explicit.

    If these steps are skipped, “it passed the check” may only mean it passed in a relaxed checking environment. A reliable result should be rebuildable from a clean environment with fixed dependencies, pass the kernel check again, and have its critical axioms and definitions reviewed by people.

    Scale and Simplification After Automatic Generation

    A common side effect of large-scale automatic proof is proof bloat. An initial version may contain repeated patterns, overly long expressions, and lemmas that were never abstracted, which slows compilation, makes review harder, and raises maintenance cost. Simplification is not merely deleting code. It is rediscovering structure: extracting repeated fragments into general lemmas, generalizing special results into parameterized theorems, and splitting long chains of reasoning into stable interfaces.

    For product engineering, AI-generated material should pass quality gates before it enters the main branch. A successful compile is only the first gate. Size thresholds, dependency-depth checks, human review of critical paths, and regression verification should follow. For a proof library, a layered policy can keep interface lemmas stable while allowing internal implementations to be rewritten. For code generation, a similar pipeline is generate candidates, run static checks, verify with tests, and review by hand.

    Risks and Practical Controls

    AI-assisted formal proof does not remove risk. It moves risk. A model may emit fragments that look plausible but do not compile, choose unsuitable definitions, or, after a large search, produce a proof that is hard to understand. Practical controls include:

    1. Separate generation from verification. The model proposes candidates. The verifier decides. The boundary stays clear.
    2. Structure failure information. Turn error locations, missing goals, and type information into feedback the model can use.
    3. Budget and cache. Limit the search budget and cache verified subproofs to avoid repeated work.
    4. Sandbox execution. Compile automatically generated source in an isolated environment with limited resources and permissions.
    5. Human review of critical theorems. Machine-checkable does not mean the mathematical intent is correct. Definitions and axioms still need human judgment.
    6. Measure the pipeline. Track acceptance rate, proof size, dependency depth, audit time, and reproduction success rate.
    7. Adopt it gradually. Start with lower-risk uses such as local lemmas, specification checks, and test generation, then extend toward core libraries.

    From a Striking Moment to a Verifiable Pipeline

    AI-assisted mathematical proof draws a stunned reaction because it shows both the reach of generation and the necessity of verification engineering. For developers, the more durable stance is not to chase a single spectacular result, but to connect large language models to a closed loop of formal verification, testing, static checking, and human review. The model can propose candidates quickly. The prover can decide mechanically. The engineering system is responsible for reproduction, audit, and maintenance. Only when that pipeline runs steadily does AI contribute a reusable, governable development capability rather than a one-time spectacle.