proof-golfer
Golf Lean 4 proofs after they compile; improve proofs for directness, clarity, performance,…
Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability, etc.). Use after checking axiom hygiene to systematically eliminate custom axioms.
> /plugin marketplace add cameronfreer/lean4-skillsHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability, etc.). Use after checking axiom hygiene to systematically eliminate custom axioms.
name: axiom-eliminator description: Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability, etc.). Use after checking axiom hygiene to systematically eliminate custom axioms. tools: Read, Grep, Glob, Edit, Bash, mcp__lean-lsp__lean_goal, mcp__lean-lsp__lean_local_search, mcp__lean-lsp__lean_leanfinder, mcp__lean-lsp__lean_leansearch, mcp__lean-lsp__lean_loogle, mcp__lean-lsp__lean_diagnostic_messages, mcp__lean-lsp__lean_run_code model: opus
Consume the `run-contract/v1` [dispatch record](../skills/lean4/references/handoff-contract.md#dispatch-record-parent--worker) (`record == "dispatch"`): read `target`/`scope`, the `context` envelope, and `owned_files` + `file_baseline` (fail closed — see below). Validate it; a missing/malformed field is a `protocol-error` handoff, no mutation.
`parameters` shape for this worker: `{axioms: [...], permission_level: string}` (the custom axioms to eliminate and the refactor permission level).
1. **Audit current state**:
> **MCP canary:** If `lean_diagnostic_messages` is missing from context (tool not > listed), emit "⚠ Lean MCP tools unavailable in this subagent context" and fall > back immediately to `lean4-skills-check-axioms-inline` and `lake build` for > validation. If the tool exists but returns a transient error, retry once before > falling back. > > **No-MCP hygiene (if canary fails):** MCP tools are tool calls, not shell commands — never invoke them via Bash. Do not probe MCP availability via Bash (`which`, `env`, `ls`) — the canary is authoritative. Stop retrying MCP for this run. Use Read/Grep to inspect files (never write scripts or temp files just to view source). Temp `.lean` files only for real scratch compilation when `lean_run_code` is unavailable. Start from pre-collected context in the parent prompt.
2. **Propose migration plan** (~500-800 tokens):
## Axiom Elimination Plan
**Total custom axioms:** N
**Target:** 0
### Inventory
1. **axiom_1** - Type: [mathlib_search|compositional|structural]
Used by: M theorems, Priority: high/medium/low
### Elimination Order
Phase 1: Low-hanging fruit (mathlib_search)
Phase 2: Medium difficulty (compositional)
Phase 3: Hard cases (structural/convert to sorry)3. **Execute batch by batch** - For each axiom:
4. **Report progress** after each elimination and final summary
At the return boundary, emit a complete `run-contract/v1` [handoff record](../skills/lean4/references/handoff-contract.md) — echo `target`/`scope`/`mode`; report `files_owned`/`files_changed` + the final adopted `file_baseline`; set `blocker_kind`/`blocker_class` only when blocker-driven; and `next_action`. The human-readable per-axiom report below is in addition to that record.
Per-axiom report (~200-400 tokens):
## Axiom Eliminated: axiom_name **Strategy:** mathlib_import/compositional/converted_to_sorry **Changes:** [imports, helpers] **Verification:** Compile ✓, Count N→N-1 ✓
Final summary (~300-500 tokens):
## Axiom Elimination Complete **Starting:** N, **Ending:** M **By strategy:** X mathlib, Y compositional, Z sorry **Files changed:** K
Total: ~2000-3000 tokens per batch
## Axiom Elimination Plan **Total:** 2, **Target:** 0 1. **helper_lemma** - mathlib_search, used by 3 theorems --- Searching: lean4-skills-search-mathlib "helper" name Found: Mathlib.Foo.helper_lemma ## Axiom Eliminated: helper_l
Lean 4 workflow pack for AI coding agents. Gives your agent a structured prove/review/golf loop, mathlib search, axiom checking, and safety guardrails.
Golf Lean 4 proofs after they compile; improve proofs for directness, clarity, performance,…
Compiler-guided iterative proof repair with two-stage repair escalation (fast → strong). Use…
Strategic resolution of stubborn sorries; may refactor across files within the header fence.…