Proof Automation with Large Language Models

Minghai Lu, Benjamin Delaware, Tianyi Zhang

Abstract

Formal verification is a critical process for ensuring software correctness, yet it remains notoriously labor-intensive, often requiring years of expert effort for complex systems. While Large Language Models (LLMs) have shown promise in generating natural language proofs, they frequently struggle with the rigid syntactic and logical requirements of formal theorem provers like Coq. This paper discusses PALM, a novel "generate-then-repair" framework that bridges the gap between LLM intuition and symbolic precision. By utilizing LLMs to draft high-level proof structures and symbolic "hammers" to resolve low-level tactical errors, PALM achieves a 40.4% success rate on the CoqGym benchmark, representing a significant improvement over previous state-of-the-art automated systems.

Introduction

Formal verification involves mathematically proving that a program adheres to its specification. In environments like Coq, this requires the creation of "proof scripts"—sequences of tactics that guide the prover through logical steps. The difficulty of this task stems from a dual challenge: one must possess the high-level mathematical intuition to structure the proof (e.g., identifying when to use induction) and the pedantic accuracy to satisfy the compiler's strict logical requirements.

Traditional automated theorem provers, or "hammers," excel at closing small logical gaps but lack the strategic foresight needed for multi-step proofs. Conversely, LLMs are adept at identifying high-level strategies but often "hallucinate" theorem names or fail to manage complex proof states. PALM (Proof Automation with LLMs) addresses these limitations by combining the architectural strengths of LLMs with the precise execution of symbolic tools.

The PALM Framework

PALM operates through a structured four-stage pipeline designed to mimic the workflow of a human proof engineer.

1. Premise Retrieval

Given the vast library of lemmas available in Coq, providing an LLM with every possible theorem is infeasible. PALM employs an information retrieval approach, using TF-IDF and BM25 to identify and retrieve the most relevant premises for a given goal. These premises are then included in the LLM's prompt to ground its generation in valid logic.

2. Initial Generation

Using the retrieved premises and few-shot prompting, an LLM (such as GPT-4o or Llama-3) generates a complete initial proof script. This script serves as a "skeleton" or draft of the intended proof strategy.

3. Iterative Repair

PALM executes the generated script within the Coq environment. When a tactic fails, the system applies one of four targeted repair mechanisms:

  • Reference Replacement: Correcting hallucinated or slightly misspelled theorem names.
  • Renaming: Resolving variable name collisions that cause logical ambiguity.
  • Bullet Transformation: Adjusting structural markers used to organize subgoals.
  • Premise Augmentation: Leveraging symbolic tools to correctly apply a theorem that the LLM identified but misused.

4. Backtracking and Symbolic Integration

If a specific repair fails, PALM does not abandon the proof. Instead, it reverts to a previous valid proof state and invokes CoqHammer, a symbolic automated theorem prover. This allows the system to bypass specific tactical failures by using brute-force symbolic logic to bridge the gap between the LLM's high-level steps.

Experimental Evaluation

Dataset and Setup

The framework was evaluated using the CoqGym dataset, comprising 10,842 theorems across 27 open-source projects. This benchmark is particularly rigorous as it spans diverse mathematical domains and excludes theorems used in the initial development of the tool to prevent memorization bias.

Key Results

PALM demonstrated a substantial leap in automated reasoning capabilities:

  • State-of-the-Art Performance: Using GPT-3.5, PALM successfully proved 40.4% of the theorems. This outperforms previous leaders like Draft, Sketch, and Prove (DSP) (22.9%) and Passport (14.4%).
  • Novel Discoveries: PALM successfully proved 1,270 theorems that had never been solved by any previous baseline method.
  • Handling Complexity: Unlike many tools that fail on long proofs, PALM solved 129 theorems requiring 20 or more tactics, demonstrating its ability to maintain logical coherence over extended sequences.
  • Efficiency: The system averaged approximately 33 seconds per proof, offering a massive speedup compared to manual human verification.

Insights and Discussion

A formative study of LLM errors revealed that these models act effectively as "architects"; they are generally correct about the high-level approach (e.g., "I should use induction here") but fail as "builders" (e.g., using the wrong variable name). The backtracking mechanism proved to be the most critical component of the framework, increasing the number of solved theorems fivefold compared to using repair rules alone.

Furthermore, PALM's performance remained consistent across different underlying models (GPT-3.5, GPT-4o, Llama-3), suggesting that the "generate-then-repair" philosophy is a robust paradigm for augmenting neural reasoning with symbolic verification.

Limitations and Future Work

Despite its success, PALM remains dependent on the quality of the initial LLM-generated skeleton. If the high-level strategy is fundamentally flawed, symbolic repairs are often insufficient. Additionally, the system currently struggles with project-specific custom tactics that lack standardized semantic patterns. Future research may explore using LLMs to suggest the repairs themselves or sampling multiple initial drafts to further increase the probability of finding a valid proof path.

Conclusion

PALM represents a significant step forward in formal verification. By treating LLMs as strategic planners and symbolic tools as rigorous executors, the framework overcomes the individual weaknesses of both approaches. This hybrid methodology not only sets a new state-of-the-art in Coq proof automation but also provides a blueprint for applying LLMs to other highly technical, zero-tolerance domains.

Summary updated

BibTeX
@inproceedings{lu2024proof,
  author = {Minghai Lu and Benjamin Delaware and Tianyi Zhang},
  title = {{Proof Automation with Large Language Models}},
  booktitle = {ASE},
  year = {2024},
  url = {https://openreview.net/forum?id=MlmritwbS4},
}
Figure