A minimal Lean 4 theorem proving agent, inspired by pi.
Lea translates natural-language math statements into Lean 4 proofs that compile with zero errors and zero sorrys.
Requires uv and at least one API key.
# Install elan (Lean version manager — provides lean, lake, etc.)
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh
# Set your API key
export GOOGLE_API_KEY=... # for Gemini models (default)
export ANTHROPIC_API_KEY=... # for Claude models
export OPENAI_API_KEY=... # for GPT/o-series models
# Build the Lean workspace (downloads Mathlib — takes a while the first time)
cd workspace && lake build && cd ..
# That's it. Run:
uv run lea "Prove that the square root of 2 is irrational"Define the Ackermann function, prove it's strictly monotone and grows faster than its argument, and compute ackermann 4 1 = 65533:
uv run lea "Define the Ackermann function using well-founded recursion. Prove that \
for all m n, ackermann m n > n. Prove that for all m n, \
ackermann m (n+1) > ackermann m n. Prove ackermann 4 1 = 65533. Do not use Mathlib."See examples/ for generated proofs.
Lea runs a simple loop:
- Write a
.leanfile with a first-attempt proof - Compile with
lean_check - If it compiles — done. If not — read the errors, edit, retry.
- If stuck, search Mathlib for relevant lemmas, or use
bashto explore.
Six tools: read_file, write_file, edit_file, lean_check, search_mathlib, bash. Supports Gemini, Anthropic, and OpenAI models. See USAGE.md for full CLI reference.
Best result so far: 6/23 (26%) on FormalQualBench with Claude Opus 4.7 best-of-5 (Lea v2.1, independent attempts, SafeVerify-audited). See EVALS.md for full methodology, configuration history, and per-run reports.
Drop a lea.md file in your working directory or workspace root to add project-specific instructions to the system prompt (preferred tactics, import conventions, etc.).