The Engineering Path for LLM-Assisted Formal Mathematical Proofs

    This article explores the engineering approach to leveraging large language models (LLMs) in formal mathematical proofs. It clarifies the boundaries of LLMs as accelerators rather than definitive provers, emphasizing a closed-loop system of generation, verification, feedback, and archiving. Key technical phases such as semantic alignment, retrieval augmentation, and feedback-driven repair are discussed, alongside practical engineering recommendations for building a verifiable and robust proof system.

    The Engineering Path for LLM-Assisted Formal Mathematical Proofs

    1. Decoding Cryptic Texts: Focusing on Verifiable Reasoning

    Discussions surrounding whether general-purpose large language models can assist in understanding Gödel’s incompleteness theorems are often sensationalized as “models reading the heavenly book of mathematics” or being “just one step away from top mathematical awards.” From an engineering perspective, such statements must be broken down into more specific questions: Can a model translate natural language mathematical propositions into formal statements? Can it generate checkable proof sketches under the constraints of a proof assistant? Can it locate errors based on verifier feedback and iteratively repair them? Can it archive the final result as a reproducible proof certificate?

    Gödel’s incompleteness theorems state that in a sufficiently strong and consistent formal system meeting certain conditions, there exist propositions that can neither be proved nor disproved. It describes the boundaries of formal systems rather than a “capability flaw” of a specific model. Therefore, LLMs cannot bypass the limitations of formal systems through language generation, nor should they be marketed as being able to automatically solve all undecidable problems. A more reasonable positioning is that LLMs act as “translators, retrievers, sketch generators, and error interpreters” between natural language and formal systems, while correctness is ultimately confirmed by machine verifiers or human audits.

    2. Capability Boundaries: The Model as an Accelerator, Not a Prover

    LLMs can undertake several high-value tasks in the mathematical formalization process. First, they can rewrite informal propositions into formal statement drafts, prompting quantifiers, assumptions, types, and dependencies. Second, they can retrieve relevant lemmas, definitions, and existing proof fragments based on the target. Third, they can generate proof strategy sketches such as division, induction, contradiction, or construction. Fourth, they can explain error locations and propose patch suggestions when verification fails. Fifth, they can refactor lengthy proofs into more easily auditable modules.

    However, they cannot replace the verifier. Model outputs are essentially candidate texts, carrying risks of hallucination, skipped steps, and incorrect citations. They also cannot guarantee the discovery of “new mathematical truths,” let alone forcibly decide undecidable propositions as true or false. Engineering-wise, it is imperative to adhere to the closed loop of “generation—verification—feedback—archiving.” Any model output that fails verification must be treated merely as a draft.

    3. System Architecture: The Generation and Verification Closed Loop

    A deployable system typically includes: proposition input and semantic parsing, formal statement confirmation, lemma retrieval, proof sketch generation, formal verification, error localization, iterative repair, and proof certificate archiving. The pseudo-code is as follows:

    1. def prove(statement, context, budget):
    2. formal = parse_statement(statement)
    3. formal = human_review(formal) # Key statements require human confirmation
    4. lemmas = retrieve(formal, context) # Retrieve definitions, lemmas, and historical proofs
    5. feedback = None
    6. for i in range(budget):
    7. sketch = model.generate_sketch(formal, lemmas, feedback)
    8. steps = normalize(sketch) # Normalize into checkable steps
    9. result = verifier.check(formal, steps)
    10. if result.ok:
    11. return certificate(formal, steps, result)
    12. feedback = result.localized_errors # Return unclosed goals and type errors
    13. return "Not verified within budget, escalate to human intervention"

    The core of this closed loop is not “letting the model write it correctly in one go,” but rather having the verifier continuously provide localizable feedback, with the model only responsible for searching for candidate proofs under constraints.

    4. Key Technical Phases

    4.1 Formal Representation and Semantic Alignment

    Natural language propositions often contain implicit assumptions, ambiguous quantifiers, and undefined objects. The system should first break the proposition down into types, variables, assumptions, and goals, retaining a human confirmation step. If the formal statement is incorrect, no matter how beautiful the subsequent proof is, it is meaningless.

    4.2 Retrieval Augmentation and Lemma Management

    Proof search is highly dependent on existing lemmas. A combination of symbolic indexing and vector retrieval can be used to version-control definitions, theorems, and proof fragments. Retrieval results must include sources and scopes of application to prevent the model from citing non-existent lemmas.

    4.3 Proof Sketch Generation and Strategy Decomposition

    The model should output checkable steps rather than large blocks of natural language arguments. Complex goals can be decomposed into sub-goals, verified separately, and then combined. Inductive proofs must clearly define induction variables, base cases, and inductive steps, while proofs by contradiction must clearly state assumptions and contradiction targets.

    4.4 Verifier Feedback-Driven Repair

    The verifier should return error types, failed goals, and local context. The system compresses the feedback into repair prompts usable by the model, setting iteration budgets and human escalation thresholds. For propositions that repeatedly fail, failure patterns should be recorded to form an evaluation set.

    4.5 Tool Calling and Symbolic Computation

    The model can orchestrate general symbolic computation, numerical checking, and constraint solving capabilities, but tool results must return to the verifier closed loop. The model only handles process orchestration and explanation, without directly declaring correctness.

    4.6 Evaluation and Safety Governance

    Evaluation should include metrics such as formal pass rate, human audit pass rate, average iteration count, and error localization effectiveness. Refusal-to-answer strategies for undecidable or out-of-scope propositions should also be set. Proof certificates, model versions, retrieval contexts, and verification logs must all be archived to ensure reproducibility.

    5. Engineering Practice Recommendations

    Enterprises or research teams building such systems in their own environments should prioritize building a proof library, a failure case library, and an evaluation pipeline. At the infrastructure level, general capabilities such as container platforms, object storage, logging services, and monitoring alarms provided by Baidu AI Cloud can be utilized to support training evaluation, proof archiving, and audit tracking; however, core correctness is still guaranteed by formal verifiers and human review. Process-wise, it is recommended to set a gatekeeper policy of “machine verification first, human audit as fallback” to prevent unverified proofs from entering the knowledge base.

    6. Conclusion

    The value of LLM-assisted mathematical formalization lies not in creating the myth of “deciphering cryptic texts,” but in lowering the barrier to formalization, accelerating lemma retrieval, and improving the iteration efficiency of proof sketches. Gödel’s incompleteness theorems remind us to respect the boundaries of formal systems; engineering practice requires us to place model outputs within a verifiable closed loop. Reaching top mathematical achievements is not about taking the “final step,” but rather involves long-term infrastructure construction, evaluation system development, and building human-machine collaboration capabilities.