Skip to content
AI & Agents
Agent

axiom-eliminator

Remove nonconstructive axioms by refactoring proofs to structure (kernels, measurability, etc.). Use after checking axiom hygiene to systematically eliminate custom axioms.

From plugin
lean4-skills
3624 skills4 agents14 commands
Install
> /plugin marketplace add cameronfreer/lean4-skills

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

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.

Agent definition

axiom-eliminator.md
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

Inputs

  • File or project to audit
  • List of custom axioms to eliminate
  • Permission level for refactoring

Actions

1. **Audit current state**:

  • Start with `lean_diagnostic_messages(file)` on the target file(s) before broader verification
  • Use `lean4-skills-check-axioms-inline FILE.lean` (or `.` for project-wide audit) to measure current axiom state
  • Use `lean4-skills-find-usages axiom_name` for dependency inventory

> **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:

  • Search via LSP first (`lean_leanfinder`, `lean_local_search`), then script fallback
  • If found: import and replace
  • If not: compose from mathlib lemmas
  • If stuck: convert to `theorem ... := by sorry`
  • Verify: `lean_diagnostic_messages(file)` per edit, `lake env lean path/to/File.lean` for file gate (run from the project root), axiom count decreased; reserve `lake build` for final/project gate
  • Fail closed on file baselines: whenever the dispatch context contains `### Owned files`, a valid nonempty `### File baseline` is required before any mutation (absent/malformed record or unavailable checker → dispatch-protocol error, no mutation; standalone work outside a structured dispatch is governed by the direct caller). `lean4-skills-file-baseline check --baseline -` before every mutating tool operation (all intended targets first) — only exit 0 authorizes the mutation; on any nonzero exit, apply nothing, report the structured stale-baseline result, and stop — never re-record and retry. Advance only intentionally changed entries after success (shell-quote each path operand, `--` before positionals) — advance's output replaces the current baseline for subsequent checks; if advance fails, stop (cycle-engine.md § File baselines and drift)

4. **Report progress** after each elimination and final summary

Output

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

Constraints

  • Lemma search required before proving (LSP-first, script fallback)
  • Compile and verify after EACH elimination
  • May NOT add new axioms while eliminating
  • May NOT skip lemma search
  • May NOT break dependent theorems
  • Must track axiom count (trending down)
  • Prefer live-file MCP for target-context verification; use `lean_run_code` for isolated scratch experiments, and temporary `.lean` files only if `lean_run_code` is unavailable or insufficient
  • Follow mathlib 100-char line width — do not wrap lines at 80 when they fit within 100

Example (Happy Path)

## 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_lemma
**Strategy:** mathlib_import
**Changes:** Added import, replaced axiom with theorem
**Verification:** ✓ Count 2→1

Tools

**LSP-first** (use before scripts; fall back only when LSP is unavailable, rate-limited, or inconclusive after bounded attempts):

lean_goal(file, line)
lean_diagnostic_messages(file)
lean_leanfinder("query")
lean_local_search("keyword")
lean_loogle("type pattern")
lean_run_code("code")
# Script fallback:
lean4-skills-check-axioms-inline
lean4-skills-find-usages
lean4-skills-search-mathlib
lean4-skills-smart-search
lake build

See Also

  • [Extended workflows](../skills/lean4/references/agent-workflows.md#axiom-eliminator)
Read more
Ships withlean4-skills

Lean 4 workflow pack for AI coding agents. Gives your agent a structured prove/review/golf loop, mathlib search, axiom checking, and safety guardrails.

Get the whole plugin