LLM-Assisted Formal Proofs: Closing the Verification Loop, from Gödel's Theorems to Enterprise Practice
Formal proof assistants like Lean, Isabelle, and Rocq verify every reasoning step rigorously, but writing proofs in them remains expensive. This article examines an engineering approach that uses large language models to generate candidate proof steps and a proof assistant to check each one, forming a generate-verify-feedback loop. It covers the preconditions of Gödel's incompleteness theorems, why traditional formalization is costly, a reference implementation of the verification loop, practical guidance for adopting formal verification in enterprise software, and the main limitations and risks of the current approach.
1. Scoping the Claims First
This article discusses an engineering method: using a large language model to generate candidate steps for a formal proof, and having a proof assistant check each step. It does not claim that AI has independently produced a new proof of Gödel’s theorems. Those theorems were proved by mathematicians long ago and have been machine-checked in several proof assistants. For example, in the 1980s, Shankar completed a machine-checked proof of the first incompleteness theorem using the Boyer-Moore theorem prover, and Lawrence Paulson formalized both incompleteness theorems in Isabelle/HOL, with the work archived in the Archive of Formal Proofs. Readers who want to verify the details should consult these original sources.
There are online claims that a large language model has “solved” Gödel’s theorem proofs, but no verifiable papers, system versions, or experiment records are currently available. This article draws no conclusions from those claims.
2. Preconditions of Gödel’s Incompleteness Theorems
The classical statement is roughly as follows. If a formal system satisfies three conditions—it is consistent (it cannot prove both a proposition and its negation); its set of axioms can be effectively enumerated; and it is expressive enough to represent basic arithmetic—then there must exist a proposition that can be neither proved nor refuted within the system. The second incompleteness theorem further states that such a system cannot prove its own consistency from within.
These preconditions make two things clear. First, incompleteness does not mean mathematics as a whole is unreliable; it bounds the capability of a particular class of formal systems. Second, a formal proof must specify the system, language, and axioms in advance; otherwise the conclusion has no definite meaning. This is one reason machine proof has long been considered a highly difficult task.
3. Why Traditional Formal Proofs Are Expensive
Commonly used proof assistants include Isabelle, Lean, and Coq (now renamed Rocq). These tools rigorously check every inference step, but users must translate mathematical intuition into low-level formal languages while handling extensive libraries, types, and syntax details. The process is time-consuming and typically requires a background in both mathematical logic and computer science.
Large language models lower the barrier for the step of “translating natural-language descriptions into formal code.” The table below compares the two approaches.
| Dimension | Traditional formal proof | LLM-assisted formal proof |
|---|---|---|
| Human cost | High; experts must write every step | Lower; the model can generate drafts |
| Scalability | Limited by the number of experts | Fast generation, but requires extensive checking |
| Hallucination risk | Essentially none, though humans make mistakes | Present; the model may produce plausible-looking but incorrect steps |
| Verification strength | Guaranteed by the proof assistant’s kernel | Still guaranteed by the proof assistant’s kernel |
For both approaches, final trustworthiness depends on the proof assistant’s kernel. The model accelerates the work; it does not judge correctness.
4. The Generate-Verify-Feedback Loop
LLM-assisted proving typically involves three roles. The large language model proposes proof drafts and search directions. The proof assistant rigorously verifies each step. Error messages are then fed back to the model, prompting it to correct the proof and generate new proof paths.
The following code is a structural sketch and is not directly runnable.
# For illustration only; not directly runnable.# assistant.check should return (is_valid, new_proof_state, error_message).# The actual interface depends on the proof assistant used (e.g., Lean, Isabelle, Rocq) and its version.class AutoProver:def __init__(self, llm_client, proof_assistant, max_attempts=5):self.llm = llm_clientself.assistant = proof_assistantself.max_attempts = max_attempts # Example value; should be set based on cost and measured success ratesdef generate_proof_step(self, theorem, context, error_feedback=None):prompt = f"Target theorem: {theorem}\nCurrent proof state: {context}\n"if error_feedback:prompt += f"The previous attempt failed. Verifier feedback: {error_feedback}\nPlease fix and continue."prompt += "Please generate the next step of the formal proof code:"return self.llm.generate(prompt)def verify_and_iterate(self, theorem):context = ""error_feedback = Nonefor _ in range(self.max_attempts):step_code = self.generate_proof_step(theorem, context, error_feedback)is_valid, new_context, error = self.assistant.check(step_code)if is_valid:context = new_contextif self.assistant.is_proof_complete(context):return True, "Proof complete"error_feedback = Noneelse:error_feedback = errorreturn False, "Maximum attempts reached; proof not completed"
This pattern has clear engineering boundaries. Every model output must pass the verifier, so incorrect steps are caught. But the loop count is limited: if the proof still fails after the maximum attempts, the system can only report failure—it cannot produce a “roughly correct” result.
5. Implications for Enterprise Software Development
Formal verification is expensive, so it is best suited to high-risk modules with well-defined rules—for example, consistency logic in distributed protocols, financial smart contracts, permission checks, and state machines. For ordinary business code, unit and integration tests are usually more cost-effective.
If your team decides to pilot this approach, consider the following checklist.
- Scope the verification: model only high-risk modules with clearly defined rules.
- Write the invariants: describe business rules in natural language first, then have humans review the formal specification. The model may produce specifications that are too weak, allowing proofs to pass easily while imposing no real constraints.
- Choose a verifier: base the choice on your team’s existing skills, language ecosystem, and library support.
- Integrate with continuous integration: run proof checks on every commit, and record the proof assistant version and proof artifacts.
- Design failure handling: block merges when a proof fails, and keep the existing tests—do not replace tests with proofs.
- Evaluate costs: track model calls, compute, and human time consumed per proof, and compare against the cost of fixing defects.
Note that formal verification can only prove that an implementation satisfies its specification. It cannot guarantee that the specification itself matches real requirements. Requirements reviews remain essential.
6. Key Limitations and Risks
The current approach has the following main limitations.
- Degraded long-range reasoning reliability: the more proof steps involved, the more likely the model is to forget preconditions or make mistakes mid-proof.
- Limited context length: the code for large proofs may exceed what the model can process in one pass, requiring splitting and retrieval.
- Trusted computing base risk: if the proof assistant’s kernel, the compiler, or the specification itself contains errors, the proof’s conclusion is invalidated.
- Requirement correctness cannot be guaranteed by formalization: verification only covers what the specification describes.
- Data security and compliance: before sending enterprise code to an external model service, confirm data compliance requirements and confidentiality agreements.
7. A Practical Next Step
If your team wants to try this approach, start with a small module with clear rules and run the full loop from specification writing to continuous integration. Based on the pilot’s success rate, time cost, and human effort, decide whether to expand to more modules.
