agentleFS
r-irber-irbe/proof-skills/skills/lean-computational-reflection/SKILL.md

lean-computational-reflection

Skill3 starsChanged 13 days agoApache-2.0View on GitHub

USE FOR: CPDT Ch. 15 / FRAP computational reflection (`denote (compile e) = denote e`), Section 1/2/3 Duality (`KERNEL-LAW-22`, `-31`), `@[csimp]` twins, and proof compression. DO NOT USE FOR: ordinary proof refactoring (`@lean-proof-refactor`) or raw low-level SWAR bitboard tuning (`@lean-unboxed-limbs-swar`). TRIGGERS: computational reflection, CPDT, denote compile, Section 1/2/3, zero Prop leakage, csimp twin, kernel_decide.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Stop immediately if any Prop witness, Fin proof field, or Classical.choice branch enters Section 2's transitive call cone (KernelLawAuditor …

    line 54
  2. Very specific:

    Never use native_decide or bv_decide on kernel-scored reflective obligations.

    line 56

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Computational Reflection & Section 1/2/3 Duality (KERNEL-LAW-22, KERNEL-LAW-31)

Replace bloated tactical proof scripts over fixed schedules, circuits, and normal forms with certified computational decision procedures checked once in Lean 4's kernel (rfl), isolated via the Section 1/2/3 Duality split.

Routing

  • USE FOR: reifying arithmetic/boolean/schedule syntax (Expr, denote), writing reflective simplifiers proved sound once (∀ e, denote (simplify e) = denote e), splitting cold specs/proofs from monomorphic runtime defs (KERNEL-LAW-31), and pairing inductive specs with fast @[csimp] twins (KERNEL-LAW-07).
  • DO NOT USE FOR: general lemma extraction without reflection (@lean-proof-refactor) or e-graph solver search (@lean-egraph-cpsat-superopt).

Workflow

  1. Isolate Section 1 (Cold Syntax & Spec) -- Define inductive ASTs (Expr, BitCircuit), abbrev bit masks, and clean mathematical denote semantics completely outside the hot runtime cone (KERNEL-LAW-25B).
  2. Implement Section 2 (Zero-Prop Kernel Evaluator) -- Write monomorphic concrete def simplify/impl over unboxed Nat/Bool with zero Prop, Fin, Subtype, or typeclass dictionaries (KERNEL-LAW-22, KERNEL-LAW-23).
  3. Prove Section 3 (Reflective Soundness & @[csimp]) -- Prove generic soundness ∀ e, denote (simplify e) = denote e and bridge concrete instantiations (fast = spec) via rfl (<= 1% overhead, avoiding the 1,600x..3,345x penalty).
  4. Discharge Ground Goals via kernel_decide -- Close concrete evaluations with rfl | decide +kernel | omega, strictly within [propext, Classical.choice, Quot.sound].

Recovery & STOP

  • Stop immediately if any Prop witness, Fin proof field, or Classical.choice branch enters Section 2's transitive call cone (KernelLawAuditor Law 22 / KERNEL-LAW-22).
  • Never use native_decide or bv_decide on kernel-scored reflective obligations.

Handoffs

  • Predecessors: lean-proof, lean-proof-refactor.
  • Successors: lean-kernel-optimization, lean-proof-review, lean-verification-gate.

Detailed reference

  • Fast lookup card: ../../references/cards/lean-computational-reflection-tables.md
  • Full handbook: ../../references/handbooks/lean-computational-reflection-handbook.md
  • Template: ../../templates/core/Template_Section123_Reflection.md

See also

  • ../lean-proof-refactor/SKILL.md -- General proof refactoring and AltProof.Closers
  • ../lean-kernel-optimization/SKILL.md -- Full KERNEL-LAW-01..31 kernel cost model

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.