Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wentorai avatar

Lean Theorem Proving Guide

  • 1 installs
  • 269 repo stars
  • Updated June 19, 2026
  • wentorai/research-plugins

Use LeanAgent, an LLM agent, to automate formal theorem proving in the Lean 4 proof assistant with verified proof steps.

About

Documents LeanAgent, an LLM-based agent that proposes proof tactics verified by Lean 4's type checker, with backtracking on failures. A developer uses it to automate formal theorem proving and verification.

  • Describes the goal-analysis, tactic-suggestion, verify, backtrack loop
  • Includes Python usage for invoking the agent on a theorem

Lean Theorem Proving Guide by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #14,102 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 1, 2026 (Skillselion catalog sync)
npx skills add https://github.com/wentorai/research-plugins --skill lean-theorem-proving-guide

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars269
Last updatedJune 19, 2026
Repositorywentorai/research-plugins

What it does

Use LeanAgent, an LLM agent, to automate formal theorem proving in the Lean 4 proof assistant with verified proof steps.

Files

SKILL.mdMarkdownGitHub ↗

Lean Theorem Proving Agent Guide

Overview

LeanAgent is an LLM-based agent for automated theorem proving in Lean 4, a modern proof assistant. It combines LLM reasoning with formal verification — proposing proof steps that are verified by Lean's type checker. Can prove novel theorems, not just benchmarks, by exploring proof strategies, backtracking on failures, and learning from successful proofs.

Architecture

Theorem Statement (Lean 4)
         ↓
   Goal Analysis Agent (understand proof obligations)
         ↓
   Tactic Suggestion Agent (propose proof steps)
         ↓
   Lean 4 Verification (check tactic correctness)
         ↓
   Backtracking (if tactic fails, try alternatives)
         ↓
   Proof or timeout

Usage

from lean_agent import LeanAgent

agent = LeanAgent(
    llm_provider="anthropic",
    lean_path="/path/to/lean4",
)

# Prove a theorem
result = agent.prove(
    theorem="""
    theorem add_comm (m n : Nat) : m + n = n + m := by
      sorry
    """,
    max_attempts=50,
    timeout=120,
)

if result.proved:
    print("Proof found!")
    print(result.proof)
else:
    print(f"Failed. Best attempt:\n{result.best_attempt}")
    print(f"Remaining goals: {result.remaining_goals}")

Proof Search Strategies

# Configure search strategy
agent = LeanAgent(
    search_config={
        "strategy": "best_first",   # best_first, bfs, dfs
        "max_depth": 20,            # Max proof steps
        "beam_width": 5,            # Tactics to try per step
        "temperature": 0.7,         # LLM sampling temp
        "backtrack_on_fail": True,
    },
)

# Interactive proof mode
session = agent.interactive_prove(
    theorem="theorem my_thm : ∀ n : Nat, n + 0 = n := by"
)

while not session.done:
    print(f"Current goals:\n{session.goals}")
    tactics = session.suggest_tactics(k=5)
    for i, t in enumerate(tactics):
        print(f"  {i}: {t.tactic} (confidence: {t.score:.2f})")
    # Agent automatically picks best tactic
    session.step()

Lean 4 Tactic Library

-- Common tactics LeanAgent uses:
-- intro, apply, exact, rfl, simp, omega
-- induction, cases, constructor, ext
-- rw, calc, have, let, show

-- Example theorem + proof
theorem list_append_nil (l : List α) : l ++ [] = l := by
  induction l with
  | nil => simp
  | cons h t ih => simp [ih]

Batch Proving

# Prove multiple theorems
theorems = [
    "theorem t1 : 1 + 1 = 2 := by sorry",
    "theorem t2 (n : Nat) : n + 0 = n := by sorry",
    "theorem t3 (n m : Nat) : n + m = m + n := by sorry",
]

results = agent.prove_batch(
    theorems=theorems,
    parallel=True,
    timeout_per=60,
)

for thm, result in zip(theorems, results):
    status = "PROVED" if result.proved else "FAILED"
    print(f"[{status}] {thm[:50]}...")

Use Cases

1. Automated proving: Prove mathematical theorems formally 2. Proof assistance: Suggest tactics during manual proving 3. Verification: Formally verify mathematical claims 4. Education: Learn Lean 4 tactics with AI guidance 5. Research: Explore new proof techniques

References

Related skills

AI & Agent Buildingagentsresearch

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.