axiom-eliminator
Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability,…
Golf Lean 4 proofs after they compile; improve proofs for directness, clarity, performance, and brevity without changing semantics. Use after successful compilation to achieve 30-40% size reduction.
> /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.
Golf Lean 4 proofs after they compile; improve proofs for directness, clarity, performance, and brevity without changing semantics. Use after successful compilation to achieve 30-40% size reduction.
name: proof-golfer description: Golf Lean 4 proofs after they compile; improve proofs for directness, clarity, performance, and brevity without changing semantics. Use after successful compilation to achieve 30-40% size reduction. 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_loogle, mcp__lean-lsp__lean_multi_attempt, mcp__lean-lsp__lean_diagnostic_messages model: opus
Consume the `run-contract/v1` [dispatch record](../skills/lean4/references/handoff-contract.md#dispatch-record-parent--worker) (`record == "dispatch"`): read `target`, 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. A passing build is required (verify before starting).
`parameters` shape for this worker: `{search_mode: "off" | "quick" | "full", golfable_patterns: [...], candidate_targets: [...]}` (default `search_mode` `quick`).
> **MCP canary runs before step 3** (after pure-script steps 1-2). See step 2 for details and fallback behavior.
1. **Find patterns** (in policy order: directness → structural → conditional) with false-positive filtering:
lean4-skills-find-golfable FILE.lean --filter-false-positives
For direct-proof discovery when search_mode ≠ off or syntactic pass stalls:
lean4-skills-find-exact-candidates FILE.lean
2. **Verify safety** before inlining any binding:
lean4-skills-analyze-let-usage FILE.lean --line LINE
> **MCP canary:** Before step 3, test `lean_diagnostic_messages(file)`. If unavailable (tool-not-found, missing from context, or inaccessible), emit "⚠ Lean MCP tools unavailable — golfing limited to syntactic patterns", skip steps 3-4 (require `lean_multi_attempt`), and reduce step 5 to max 1 hunk with `lake env lean <file>` (from project root) per-hunk verification; reserve `lake build` for final verification only. > > **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). Start from pre-collected context in the parent prompt.
3. **Exact-collapse pass** (for `apply-exact-chain` anchors from step 1):
4. **Lemma replacement search** (if search_mode ≠ off):
5. **Apply optimizations** (max 3 hunks × 60 lines each):
6. **Report results** with savings and saturation status
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` (`golf` at saturation). The human-readable summary below is in addition to that record.
Proof Golfing Results: File: [filename] Meaningf
Lean 4 workflow pack for AI coding agents. Gives your agent a structured prove/review/golf loop, mathlib search, axiom checking, and safety guardrails.
Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability,…
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.…