TL;DR
This paper introduces KG-Prover, a novel framework that enhances large language models (LLMs) for automated theorem proving by integrating them with a knowledge graph derived from mathematical texts. KG-Prover significantly boosts LLM performance on theorem proving tasks by providing relevant contextual information during inference, without requiring additional model fine-tuning.
What Problem Does This Paper Address?
Automated theorem proving (ATP) is a challenging task that requires deep logical reasoning and a precise understanding of mathematical concepts and their relationships. While Large Language Models (LLMs) have shown promise in various reasoning tasks, they struggle with the formalization and rigorous logical inference needed for ATP. Key challenges include identifying relevant mathematical concepts, understanding their interconnections, and correctly formalizing proofs in a structured, verifiable manner. Existing LLM-based approaches often require extensive formal training data or complex fine-tuning, limiting their applicability and interpretability.
Methods
The core of KG-Prover is its novel approach to augmenting general-purpose LLMs at test time using a knowledge graph (KG). Here's how it works:
- Knowledge Graph Construction: The authors built a KG from ProofWiki, a comprehensive online repository of mathematical proofs. This KG represents mathematical concepts (definitions, axioms, theorems, lemmas) as nodes and their interrelationships (e.g., "uses definition," "similar proof") as edges. Each node is embedded using OpenAI's text-embedding-3-large model for semantic querying.
- Retrieval-Augmented Generation (RAG): When presented with a theorem to prove, KG-Prover first embeds the problem statement. It then queries the KG to retrieve the most semantically similar nodes. These retrieved nodes, representing relevant mathematical concepts and proofs, are injected into the LLM's context.
- Iterative Refinement and Scaling: If the initial proof attempt fails, KG-Prover iteratively deepens its search within the KG. This involves exploring neighboring nodes (BFS or semantic similarity) and adding more context to the LLM. This "test-time compute scaling" allows the model to explore more related concepts and refine its proof generation.
- LLM as Judge and Generator: The framework uses LLMs for both generating informal proofs and for autoformalizing them into a formal language (Lean 4). A "judge" LLM can also be employed to evaluate and rank multiple proof candidates generated by the primary LLM.
- Verification: Generated formal proofs are verified using the Lean 4 theorem prover. Failed proofs provide feedback for further refinement.
What's novel here is the test-time integration of a KG with LLMs for theorem proving, focusing on augmenting existing LLMs without requiring specialized fine-tuning. The scaling of this KG-based retrieval at inference time is also a key contribution.
Datasets
The authors evaluated KG-Prover on three established benchmarks for automated theorem proving:
- miniF2F: A benchmark of formal mathematics problems sourced from undergraduate-level math competitions.
- ProofNet: A large-scale dataset of mathematical proofs and theorem statements, covering diverse domains and difficulties.
- MUSTARDSAUCE: A dataset generated by GPT-4 for theorem proving tasks.
Key Insights and Ideas
- Knowledge Graphs are Powerful for ATP: Integrating a structured knowledge graph significantly enhances LLMs' ability to perform complex logical reasoning required for theorem proving, even without model fine-tuning.
- Test-Time Augmentation is Key: The ability to dynamically retrieve and inject relevant contextual information from a KG during inference is a highly effective strategy for improving LLM performance on specialized tasks like ATP.
- Scaling Matters: Increasing the depth of traversal within the knowledge graph (i.e., retrieving more related concepts) leads to consistent performance improvements, especially for smaller LLMs.
- Informal Proofs as a Bridge: Using natural language informal proofs as an intermediate step between KG retrieval and formalization allows LLMs to leverage their inherent reasoning capabilities more effectively.
- LLMs as Judges: Employing LLMs to evaluate and rank proof candidates (e.g., in a "Best of N" strategy) can help select higher-quality proofs.
Key Results
KG-Prover demonstrated significant performance improvements across various LLMs and datasets:
- General-Purpose LLMs: When combined with KG-Prover, general-purpose LLMs saw improvements of up to 21% on miniF2F-test.
- Consistent Gains: Consistent improvements ranging from 2-11% were observed on ProofNet, miniF2F-test, and MUSTARDSAUCE datasets without additional scaling.
- High Performance: KG-Prover, when used with the
o4-minimodel, achieved over 50% accuracy on miniF2F-test. - Finetuned Models: Even finetuned Lean provers benefited, showing an 1.85 percentage point improvement with KG-Prover.
- Scaling Impact: Figure 2 clearly shows that increasing traversal depth (
r) generally leads to higher accuracy, with diminishing returns after a certain point. - Beam Search Benefits: Combining KG-Prover with beam search further boosted accuracy, achieving up to 26.40% improvement in the highest scaling configuration.
Limitations and Future Work
- Embedding Limitations: Vector embeddings might lose fine-grained logical structure or struggle with preserving contextual dependencies across very long passages, potentially leading to challenges in retrieving highly specific or abstract mathematical statements. XML dumps can also introduce noise.
- Novelty of Problems: The framework's performance on entirely novel or highly abstract mathematical problems remains uncertain, as models trained on existing proofs might struggle with unconventional approaches.
- Context Window Limits: LLMs have finite context windows, which could lead to incomplete reasoning or loss of critical details for very lengthy or complex proofs.
- Informal to Formal Translation: The translation of informal proofs to formal Lean code can be error-prone, especially when dealing with implicit assumptions or natural language shortcuts. Approximately 35% of failures were attributed to incorrect formal proofs despite valid informal ones.
- Future Work: The authors suggest enhancing the knowledge graph and improving the autoformalization process to handle more complex mathematical concepts. They also note that while BFS and semantic search are effective, exploring hybrid approaches could be beneficial.
Summary updated