/proof-skills:proof-simplifyfrom Proof Skills
Uses verified TLA+ specs and Lean proofs to safely simplify code by deleting defensive checks, redundant locks, dead branches, and flags that invariants make unnecessary. Re-verifies every change before applying it.
Ships in Proof Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A proof tells you what is always true of the system. Code written without that knowledge defends against states that cannot happen: guards that never fail, locks that protect nothing, retries that never fire, flags that duplicate other state. Each piece costs reading time, test time, and latency, and each is a place for new bugs.
This skill turns proven facts into deletions. It proves every deletion safe before making it, then re-verifies afterwards.
The standard of evidence: a simplification is justified only by a property the model proved, under assumptions the code actually enforces. Anything less is a guess dressed up in proof vocabulary.
You need all four of these; without them there is nothing to justify a deletion. If any is
missing, run formal-verify (W1) first:
check_trust.sh clean);Properties.tla / Properties.lean);CORRESPONDENCE.md, including its Assumptions list.Harvest candidates. Read the model and the code side by side. Use
references/catalog.md for the eight kinds of candidate and how to spot each:
List each candidate with its code location, the model element it maps to, and the fact that would justify it.
Prove each candidate in the model before touching code. Techniques, from cheapest to
strongest (references/equivalence.md):
Enabled_A_without_G => G as an invariant.INSTANCE … WITH checked as a PROPERTY, or a Lean simulation theorem. All safety
properties then transfer automatically. Liveness must be re-checked.reach_iff). The two versions reach exactly the
same states. This is the strongest form.theorem simple_eq : ∀ x, simple x = current x). Use it for
replacing an algorithm.Audit assumptions. For each candidate, list which Assumptions from CORRESPONDENCE.md the proof relies on, then decide:
Apply one simplification at a time. For each accepted candidate:
Use one commit per simplification, whose message names the property that justifies it.
Report. Add simplifications[] to formal/findings.json, then publish the Artifact
report (formal-verify/references/report-artifact.md, section "Simplifications"). For
each change it shows:
Also include the candidates you rejected, with the reason. They are useful knowledge ("the lock looks redundant but protects the cron path, which is not modeled").
TLA+: a lock that does nothing. assets/tla/CancelOrder.tla models a cancel handler
that takes a row lock and uses a conditional UPDATE, while the payment webhook never
takes the lock.
MC_current.cfg and MC_cas_only.cfg pass.MC_lock_only.cfg fails (exit 13): the lock alone never prevented paid → cancelled.CancelOrderSimple.tla removes the lock, and MC_refines.cfg proves it refines the
current spec under a mapping that reconstructs the lock.Decision: remove the lock, keep the CAS, and write the model's finding into the code comment.
Lean: a defensive guard the invariant makes dead.
lean-model/assets/lean-patterns/ProofPatterns/RedundantGuard.lean:
guard_implied: the k ∉ applied re-check follows from the idempotency invariant.reach_iff: with or without it, exactly the same states are reachable.Decision: delete it, citing applied_nodup.
Run them:
T=${CLAUDE_SKILL_DIR}/../tlaplus-model/scripts/tlc.sh
for c in MC_current MC_cas_only MC_lock_only; do $T ${CLAUDE_SKILL_DIR}/assets/tla/CancelOrder.tla --config $c.cfg; done
$T ${CLAUDE_SKILL_DIR}/assets/tla/CancelOrderSimple.tla --config MC_refines.cfg
references/catalog.md — the eight candidate kinds: how to spot them, how to justify them in TLA+ and Lean, and the typical code change.references/equivalence.md — re-check, guard implication, refinement mappings, reachable-state equivalence, and function equality, with verified templates.assets/tla/CancelOrder.tla (opens in a new tab)assets/tla/CancelOrderSimple.tla (opens in a new tab)assets/tla/MC_cas_only.cfg (opens in a new tab)assets/tla/MC_current.cfg (opens in a new tab)assets/tla/MC_lock_only.cfg (opens in a new tab)assets/tla/MC_refines.cfg (opens in a new tab)references/catalog.md (opens in a new tab)references/equivalence.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
formal-verification, tla-plus, lean, code-simplification, refactoring
4 skills in this plugin
/formal-verifyEnd-to-end formal-methods bug hunting for real codebases in any language — scope a risky concern, model it in TLA+ and/or Lean 4, check it, turn every counterexample into a failing test, fix the code, re-verify, and publish the results as an Artifact report. Use this skill whenever the user wants to find race conditions, lost updates, deadlocks, stale caches, double-applied retries, broken idempotency, message reordering or loss bugs, state-machine violations, dataflow/pipeline loss or duplication, or graph/DAG/scheduler bugs; whenever they say "formally verify", "model check", "prove", "TLA+", "Lean", "invariant", "spec this out", "is this thread-safe", "can this race", or ask for a concurrency/async/distributed review of a module or PR — even if they never name a formal-methods tool. Also the entry point for keeping specs in CI and detecting spec/code drift. Routes to tlaplus-model, lean-model, and proof-simplify for the tool-specific work./lean-modelUse this skill to prove or refute properties of real software in Lean 4. The target is the user's own code, not textbook math. It covers state machines, concurrency and interleavings, async handlers, retries and idempotency, queues, batching pipelines, and graph algorithms such as topological order, acyclicity and DAG scheduling. Trigger it when the user wants a guarantee for every input or size ("holds for all N"), beyond what TLC, tests or a model checker showed. Also trigger it for invariant proofs by induction, a concrete counterexample trace, an executable reference model for differential testing, or setting up a Lean/lake project to model code. Also use it to audit a Lean development's trust base: sorry, axioms, native_decide. Do NOT use it for pure mathematics such as analysis, algebra or Mathlib coursework and homework. Do NOT use it to translate code into Lean syntax, or for other provers like Dafny, Coq or Isabelle. Pairs with formal-verify for bug hunts and tlaplus-model for protocol exploration./tlaplus-modelTLA+/TLC model-checking skill. Use it whenever TLA+, PlusCal, Quint, Apalache, TLC, a .tla/.cfg file, or model-checker output appears. That includes a pasted TLC error, "Invariant X is violated", or a State 1/State 2… counterexample trace the user wants explained or triaged (real bug, model artifact, or too-strong property), even if it looks answerable by reading alone. Also use it to write, run, scale, or fix specs; debug slow or exploding TLC runs; check invariants, liveness, and fairness; replay production logs against a spec; or "model"/"exhaustively check" concurrent code, protocols, queues, caches, schedulers, leases, retries, and state machines for races, lost updates, double-spends, deadlocks, and ordering bugs, even for a design with no code yet. Not for runtime race detectors, Jepsen, Alloy, Lean/Coq proofs, or UI state-machine libraries. Pair with formal-verify for the full bug-hunt loop.proof-skills@opum is listed by opum-ai/opum-marketplace — review the source before installing
npx claudepluginhub opum-ai/opum-marketplace --plugin proof-skillsOther plugins' skills for the same job