TL;DR
This paper introduces COPRA, an in-context learning agent for formal theorem-proving in Lean and Coq. Unlike previous methods that fine-tune models on specific proof data, COPRA leverages a powerful general-purpose LLM (GPT-4) within a stateful backtracking search, significantly outperforming few-shot LLM approaches and even matching state-of-the-art fine-tuned methods.
What Problem Does This Paper Address?
Formal theorem-proving, the task of automatically generating rigorous mathematical proofs, has been a long-standing challenge. Traditional methods struggled with scalability, while recent neural approaches often require extensive fine-tuning on domain-specific proof data. This fine-tuning process is costly and limits the model's adaptability to new proof frameworks. The authors aim to bridge this gap by developing an agent that can perform theorem-proving using in-context learning with a general-purpose LLM, avoiding the need for specialized training.
Methods
COPRA employs a novel approach that combines in-context learning with a structured search strategy. At each step, it:
- Prompts a high-capacity LLM (GPT-4): The LLM is asked to propose the next tactic (a command to simplify the proof goal) to apply.
- Executes the tactic: The proposed tactic is run within the formal proof environment (Lean or Coq).
- Utilizes execution feedback: The outcome of the tactic execution (success, error, or no progress) is fed back into the LLM's prompt for the next step.
- Incorporates search history and retrieved knowledge: The prompt also includes relevant information from the search history and lemmas retrieved from an external database.
- Employs stateful backtracking: A symbolic progress check is used to avoid cyclic tactic sequences and to backtrack when necessary, guided by error messages.
This iterative process allows the LLM to learn from its mistakes and refine its proof-generating strategy in real-time, without explicit fine-tuning.
Datasets
- miniF2F-test: A benchmark for Lean theorem-proving, comprising formalizations of mathematical problems from various sources, including the MATH dataset, high school math competitions, and hand-designed problems.
- CompCert: A set of Coq proof tasks derived from the CompCert compiler verification project.
Key Insights and Ideas
- In-context learning for theorem-proving is viable: The paper demonstrates that a powerful general-purpose LLM like GPT-4, when guided by a sophisticated search strategy, can achieve competitive performance in formal theorem-proving without domain-specific fine-tuning.
- Stateful backtracking and feedback are crucial: Simply prompting an LLM for a full proof is insufficient. COPRA's success hinges on its ability to iteratively propose tactics, execute them, and use the resulting feedback (including errors) to inform subsequent prompts. This allows it to learn from its mistakes and navigate complex proof spaces.
- Retrieval and informal proofs enhance performance: Integrating external lemma databases and even LLM-generated informal proof sketches significantly boosts COPRA's theorem-proving capabilities.
- GPT-4's scale is important: While COPRA improves performance over few-shot GPT-4, using a smaller model like GPT-3.5 results in a substantial drop in performance, highlighting the need for a highly capable LLM.
Key Results
- Outperforms few-shot LLMs: COPRA significantly outperforms few-shot GPT-4 invocations on the miniF2F benchmark, solving more than twice as many problems.
- Competitive with fine-tuned models: COPRA achieves performance comparable to, and in some cases better than, state-of-the-art fine-tuned approaches like REPROVER on the miniF2F dataset, achieving a pass@1 metric of 29.09% without any fine-tuning.
- Efficient query usage: COPRA converges to correct proofs with significantly fewer LLM queries than REPROVER, indicating a more efficient use of the LLM's capabilities.
- Cross-framework capability: COPRA is the first system to demonstrate proof generation capabilities in both Lean and Coq environments using the same in-context learning approach.
- Qualitative improvements: COPRA generates proofs that are often shorter and more direct than those produced by baselines.
Limitations and Future Work
- Data Leakage Concerns: The authors acknowledge the inherent risk of data leakage with closed-source LLMs like GPT-4, although they present arguments suggesting it's not a primary driver of their results.
- LLM Scale Dependency: The effectiveness of COPRA appears to be tied to the scale of the LLM used, with GPT-3.5 performing significantly worse than GPT-4.
- Future Work:
- Investigating the impact of larger inference budgets on learning dynamics.
- Exploring whether models smaller than GPT-4, but explicitly fine-tuned on interaction data, could achieve similar results.
- Synthetically generating interaction data to train such models.
- Extending COPRA to support more proof languages.
- Developing domain-agnostic retrieval mechanisms and exploring more sophisticated ways to integrate informal proofs.
Summary updated