| name | prove |
| description | Formal theorem proving with research, testing, and verification phases |
| triggers | ["prove","verify","show that","is it true","formalize"] |
| allowed-tools | ["Bash","Read","Write","Edit","WebSearch","WebFetch","AskUserQuestion","Grep","Glob"] |
| priority | high |
/prove - Machine-Verified Proofs (5-Phase Workflow)
For mathematicians who want verified proofs without learning Lean syntax.
Prerequisites
Before using this skill, check Lean4 is installed:
command -v lake &>/dev/null && echo "Lean4 installed" || echo "Lean4 NOT installed"
If not installed:
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh
lake --version
First run of /prove will download Mathlib (~2GB) via lake build.
Usage
/prove every group homomorphism preserves identity
/prove Monsky's theorem
/prove continuous functions on compact sets are uniformly continuous
The 5-Phase Workflow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ RESEARCH โ ๐๏ธ DESIGN โ ๐งช TEST โ โ๏ธ IMPLEMENT โ โ
VERIFY โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Phase 1: RESEARCH (before any Lean)
Goal: Understand if/how this can be formalized.
-
Search Mathlib with Loogle (PRIMARY - type-aware search)
loogle-search "pattern_here"
loogle-search "Nontrivial _ โ _"
loogle-search "(?a โ ?b) โ List ?a โ List ?b"
loogle-search "IsCyclic, center"
Query syntax:
_ = any single type
?a, ?b = type variables (same var = same type)
Foo, Bar = must mention both
-
Search External - What's the known proof strategy?
- Use Nia MCP if available:
mcp__nia__search
- Use Perplexity MCP if available:
mcp__perplexity__search
- Fall back to WebSearch for papers/references
- Check: Is there an existing formalization elsewhere (Coq, Isabelle)?
-
Identify Obstacles
- What lemmas are NOT in Mathlib?
- Does proof require axioms beyond ZFC? (Choice, LEM, etc.)
- Is the statement even true? (search for counterexamples)
-
Output: Brief summary of proof strategy and obstacles
CHECKPOINT: If obstacles found, use AskUserQuestion:
- "This requires [X]. Options: (a) restricted version, (b) accept axiom, (c) abort"
Phase 2: DESIGN (skeleton with sorries)
Goal: Build proof structure before filling details.
-
Create Lean file with:
- Imports
- Definitions needed
- Main theorem statement
- Helper lemmas as
sorry
-
Annotate each sorry:
-- SORRY: needs proof (straightforward)
-- SORRY: needs proof (complex - ~50 lines)
-- AXIOM CANDIDATE: vโ constraint - will test in Phase 3
-
Verify skeleton compiles (with sorries)
Output: proofs/<theorem_name>.lean with annotated structure
Phase 3: TEST (counterexample search)
Goal: Catch false lemmas BEFORE trying to prove them.
For each AXIOM CANDIDATE sorry:
-
Generate test cases
-- Create #eval or example statements
#eval testLemma (randomInput1) -- should return true
#eval testLemma (randomInput2) -- should return true
-
Run tests
lake env lean test_lemmas.lean
-
If counterexample found:
- Report the counterexample
- Use AskUserQuestion: "Lemma is FALSE. Options: (a) restrict domain, (b) reformulate, (c) abort"
CHECKPOINT: Only proceed if all axiom candidates pass testing.
Phase 4: IMPLEMENT (fill sorries)
Goal: Complete the proofs.
Standard iteration loop:
- Pick a sorry
- Write proof attempt
- Compiler-in-the-loop checks (hook fires automatically)
- If error, Godel-Prover suggests fixes
- Iterate until sorry is filled
- Repeat for all sorries
Tools active:
- compiler-in-the-loop hook (on every Write)
- Godel-Prover suggestions (on errors)
Phase 5: VERIFY (audit)
Goal: Confirm proof quality.
-
Axiom Audit
lake build && grep "depends on axioms" output
- Standard: propext, Classical.choice, Quot.sound โ
- Custom axioms: LIST EACH ONE
-
Sorry Count
grep -c "sorry" proofs/<file>.lean
- Must be 0 for "complete" proof
-
Generate Summary
โ MACHINE VERIFIED (or โ ๏ธ PARTIAL - N axioms)
Theorem: <statement>
Proof Strategy: <brief description>
Proved:
- <lemma 1>
- <lemma 2>
Axiomatized (if any):
- <axiom>: <why it's needed>
File: proofs/<name>.lean
Research Tool Priority
Use whatever's available, in order:
| Tool | Best For | Command |
|---|
| Loogle | Type signature search (PRIMARY) | loogle-search "pattern" |
| Nia MCP | Library documentation | mcp__nia__search |
| Perplexity MCP | Proof strategies, papers | mcp__perplexity__search |
| WebSearch | General references | WebSearch tool |
| WebFetch | Specific paper/page content | WebFetch tool |
Loogle setup: Requires ~/tools/loogle with Mathlib index. Run loogle-server & for fast queries.
If no search tools available, proceed with caution and note "research phase skipped".
Checkpoints (automatic)
The workflow pauses for user input when:
- โ ๏ธ Research finds obstacles
- โ Testing finds counterexamples
- ๐ Implementation hits unfillable sorry after N attempts
Output Format
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ MACHINE VERIFIED โ
โ โ
โ Theorem: โ ฯ : G โ* H, ฯ(1_G) = 1_H โ
โ โ
โ Proof Strategy: Direct application of โ
โ MonoidHom.map_one from Mathlib. โ
โ โ
โ Phases: โ
โ ๐ Research: Found in Mathlib.Algebra.Group.Hom โ
โ ๐๏ธ Design: Single lemma, no sorries needed โ
โ ๐งช Test: N/A (trivial) โ
โ โ๏ธ Implement: 3 lines โ
โ โ
Verify: 0 custom axioms, 0 sorries โ
โ โ
โ File: proofs/group_hom_identity.lean โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
What I Can Prove
| Domain | Examples |
|---|
| Category Theory | Functors, natural transformations, Yoneda |
| Abstract Algebra | Groups, rings, homomorphisms |
| Topology | Continuity, compactness, connectedness |
| Analysis | Limits, derivatives, integrals |
| Logic | Propositional, first-order |
Limitations
- Complex proofs may take multiple iterations
- Novel research-level proofs may exceed capabilities
- Some statements are unprovable over โ (need โ extension)
Behind The Scenes
- Lean 4.26.0 - Theorem prover
- Mathlib - 100K+ formalized theorems
- Godel-Prover - AI tactic suggestions (via LMStudio)
- Compiler-in-the-loop - Automatic verification on every write
- Research tools - Nia, Perplexity, WebSearch (graceful degradation)
See Also
/loogle-search - Search Mathlib by type signature (used in Phase 1 RESEARCH)
/math-router - For computation (integrals, equations)
/lean4 - Direct Lean syntax access