Framework combining formal verification feedback with long chain-of-thought reasoning to enable deep and broad mathematical reasoning for automated theorem proving. Achieves 78.1% on formalized IMO problems through lemma-based refinement and test-time inference strategies.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Framework combining formal verification feedback with long chain-of-thought reasoning to enable deep and broad mathematical reasoning for automated theorem proving. Achieves 78.1% on formalized IMO problems through lemma-based refinement and test-time inference strategies.
Seed-Prover: Automated Theorem Proving with Formal Verification
Seed-Prover represents a major advancement in automated theorem proving by combining reinforcement learning with formal verification feedback from the Lean proof assistant. The system enables language models to iteratively refine mathematical proofs through multiple inference strategies, achieving state-of-the-art performance on formal mathematics.
Core Concept
The key insight is that formal verification provides clear, unambiguous supervision signals: a proof is either correct (accepts in Lean) or indicates specific errors that guide refinement. Rather than relying solely on language model outputs, Seed-Prover uses this structured feedback to:
Iteratively refine proofs based on Lean error messages
Leverage previously proved lemmas to build progressively more complex proofs
Apply self-summarization to extract essential proof structures
Employ three test-time inference strategies for both deep (single proof exploration) and broad (multiple proof attempts) reasoning
Architecture Overview
The system consists of the following components:
Proof Generation Module: Language model generates proof attempts in Lean formal syntax
Formal Verification Loop: Lean type-checker provides binary feedback (accept/reject) with specific error messages
Lemma Library: Repository of previously proved theorems enabling compositional proof building
Refinement Agent: Takes verification feedback and reformulates proof attempts
Test-Time Strategies:
Deep reasoning: Extends single proof branch with detailed exploration
Broad reasoning: Generates multiple proof hypotheses in parallel
Hybrid: Combines deep and broad strategies adaptively
Implementation Steps
Step 1: Set up formal verification infrastructure
The system requires integration with the Lean proof assistant to provide structured feedback on proof attempts:
"""
Verify a proof in Lean and return status and feedback.
Args:
theorem: The theorem statement in Lean syntax
proof: The proof attempt in Lean syntax
Returns:
(is_valid, feedback) where is_valid is bool and feedback is error msg or success
"""
f"{theorem}\n{proof}"
try
self
"--stdin"
input
True
5
if
0
return
True
"Proof accepted"
else
return
False
except
return
False
"Proof verification timeout"
The LeanVerifier class handles communication with Lean, capturing whether the proof type-checks and returning specific error messages that guide refinement.
Step 2: Implement the lemma library and proof state tracker
Maintain a database of previously proved lemmas to enable compositional proof construction:
classLemmaLibrary:
"""Stores and retrieves previously proved lemmas"""def__init__(self):
self.lemmas: dict[str, str] = {} # name -> proof codeself.theorem_statements: dict[str, str] = {} # name -> statementdefadd_lemma(self, name: str, theorem: str, proof: str):
"""Store a successfully verified lemma"""self.lemmas[name] = proof
self.theorem_statements[name] = theorem
defget_applicable_lemmas(self, goal: str, top_k: int = 5) -> list[Tuple[str, str]]:
"""
Retrieve lemmas relevant to current goal using semantic matching.
In practice, use embeddings to find related lemmas.
"""# Simplified: could use embedding similarity in production
relevant = []
for name, statement inself.theorem_statements.items():
ifself._relevance_score(statement, goal) > 0.7:
relevant.append((name, self.lemmas[name]))
return relevant[:top_k]
def_relevance_score(self, lemma: str, goal: str) -> float:
"""Simple relevance scoring; use embeddings in production"""# Placeholder for semantic similarity computation
common_terms = set(lemma.split()) & set(goal.split())
returnlen(common_terms) / max(len(lemma.split()), 1)
This component enables the system to build on previous successes, reducing redundant proof search.
Step 3: Implement refinement through verification feedback
Use Lean's error messages to guide proof reformulation:
classProofRefinement:
"""Refines proofs based on verification feedback"""def__init__(self, llm, verifier: LeanVerifier, lemma_library: LemmaLibrary):
self.llm = llm # Language model for generationself.verifier = verifier
self.lemma_library = lemma_library
defrefine_proof(self, theorem: str, proof_attempt: str,
feedback: str, context_lemmas: list[str]) -> str:
"""
Given a failed proof and Lean's error message, generate improved version.
Args:
theorem: The theorem statement
proof_attempt: Previous attempt that failed
feedback: Error message from Lean
context_lemmas: Available lemmas to use
Returns:
Refined proof attempt
"""
prompt = f"""You are a formal proof assistant. Fix the following Lean proof.
Theorem: {theorem}
Previous proof attempt:
{proof_attempt}
Error feedback:
{feedback}
Available lemmas:
{chr(10).join(context_lemmas)}
Generate a corrected proof:"""
refined = self.llm.generate(prompt, max_tokens=1500)
return refined
defiterative_refinement(self, theorem: str, max_iterations: int = 5) -> Tuple[bool, str]:
"""
Iteratively refine proof until it verifies or max iterations reached.
"""# Get relevant lemmas
lemmas = self.lemma_library.get_applicable_lemmas(theorem)
lemma_strs = [f"-- {name}: {stmt}"for name, stmt in lemmas]
# Generate initial proof
proof = self.llm.generate(f"Prove: {theorem}", max_tokens=1500)
for iteration inrange(max_iterations):
is_valid, feedback = self.verifier.verify_proof(theorem, proof)
if is_valid:
returnTrue, proof
# Refine based on feedback
proof = self.refine_proof(theorem, proof, feedback, lemma_strs)
returnFalse, proof
This refinement loop embodies the core of Seed-Prover: using formal verification signals to guide iterative improvement.
Step 4: Implement test-time inference strategies
Implement both deep and broad reasoning modes:
classTestTimeStrategies:
"""Multiple reasoning strategies at inference time"""def__init__(self, prover: ProofRefinement):
self.prover = prover
defdeep_reasoning(self, theorem: str, max_depth: int = 10) -> Tuple[bool, str]:
"""
Deep reasoning: explore a single proof path exhaustively.
Uses extended chain-of-thought with detailed intermediate steps.
"""
prompt = f"""Prove this theorem with detailed step-by-step reasoning:
{theorem}
Provide extensive intermediate steps and justifications. Show your complete reasoning process."""
proof = self.prover.llm.generate(prompt, max_tokens=3000) # Extended context
is_valid, _ = self.prover.verifier.verify_proof(theorem, proof)
return is_valid, proof
defbroad_reasoning(self, theorem: str, num_attempts: int = 3) -> Tuple[bool, str]:
"""
Broad reasoning: generate multiple proof hypotheses in parallel.
Returns the first valid proof found.
"""for attempt inrange(num_attempts):
prompt = f"""Generate a proof for: {theorem}
Attempt {attempt + 1} - Try a different approach from previous attempts."""
proof = self.prover.llm.generate(prompt, max_tokens=1500)
is_valid, _ = self.prover.verifier.verify_proof(theorem, proof)
if is_valid:
returnTrue, proof
returnFalse, Nonedefhybrid_reasoning(self, theorem: str) -> Tuple[bool, str]:
"""
Hybrid: apply broad reasoning first to find viable approaches,
then deep reasoning to refine the best candidate.
"""# Phase 1: Broad search for viable approaches
is_valid, candidate = self.broad_reasoning(theorem, num_attempts=2)
ifnot is_valid:
# Phase 2: If broad search fails, apply deep reasoningreturnself.deep_reasoning(theorem)
# Phase 3: Refine the candidate with deep reasoning
theorem_with_hint = f"{theorem}\n-- Hint: Start with the approach above"returnself.deep_reasoning(theorem_with_hint)
These strategies allow the system to adapt its reasoning depth based on proof complexity.
Step 5: Integrate self-summarization for proof compression
Enable the system to extract and summarize key proof structures:
classProofSummarization:
"""Summarizes proofs to extract essential structures"""def__init__(self, llm):
self.llm = llm
defsummarize_proof(self, theorem: str, proof: str) -> str:
"""
Extract high-level proof structure, removing low-level tactics.
"""
prompt = f"""Summarize the key logical steps of this proof, ignoring low-level Lean tactics:
Theorem: {theorem}
Proof:
{proof}
Provide a high-level summary of the proof's logical structure:"""
summary = self.llm.generate(prompt, max_tokens=500)
return summary
defextract_subgoals(self, proof: str) -> list[str]:
"""
Parse proof to extract intermediate subgoals.
These become candidates for lemmatization.
"""# Simple heuristic: find "have" and "show" statements
lines = proof.split('\n')
subgoals = []
for line in lines:
if'have 'in line or'show 'in line:
subgoals.append(line.strip())
return subgoals
This enables iterative proof building where intermediate results are captured as lemmas.
Practical Guidance
When to use Seed-Prover:
Formal mathematics problems with well-specified Lean definitions (best case)
Competition problems (IMO style) with rich mathematical structure
Multi-step reasoning where lemma reuse provides significant value
When proof search benefit from multiple diverse attempts
When NOT to use Seed-Prover:
Informal, natural language mathematical reasoning
Domains without formal verification infrastructure
Real-time applications where iterative refinement is too slow
Problems solvable by simple symbolic computation
Key hyperparameters and tuning:
max_iterations: Control refinement depth (5-10 typically sufficient)