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.

BOOST
From plugin
lean4-skills
4484 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

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).

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. Two distinct commands: `lake lean <path/to/File.lean>` (the dependency-aware file gate — builds the imports, then elaborates this exact file; use it once this refactor edited an imported module, since `lake env lean` reads stale `.olean`s — [File Gate Scope](../skills/lean4/references/cycle-engine.md#file-gate-scope)) and plain `lake build` (project-wide; reserve for the final/project gate)
  • Fail closed on file baselines: whenever a `run-contract/v1` dispatch carries `owned_files`, its `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

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

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_l
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
Stats
449
Stars
47
Forks
Active
Maintenance
Python
Language
MIT
License
17h ago
Last commit
11mo ago
Created

Repo: cameronfreer/lean4-skills

Other agents on lean4-skills.