lean-egraph-cpsat-superopt
Skill3 starsChanged 13 days agoApache-2.0View on GitHub
USE FOR: e-graph equality saturation, OR-Tools CP-SAT/Z3 sharing-aware DAG extraction (`OptiSat`), Fraction signed BnB, context-fusion replay, and dual-certified `eqsat_rw` in Lean 4. DO NOT USE FOR: routine interactive proving (`@lean-proof`) or leaving `grind`/`bv_decide` inside strict `no-grind` submissions. TRIGGERS: e-graph, eqsat, CP-SAT, OptiSat, signed BnB, context fusion, eqsat_rw, dual-certified rewrite, superoptimizer, SmoothE.
In this repository43 other files it gives its agents.
- AGENTS.mdAGENTS.md
- counterexample-first-provingSkill
- hol-metamath-adapterSkill
- isabelle-isar-adapterSkill
- itp-cross-portingSkill
- lean-ai-formalizationSkill
- lean-asymptotic-algorithmsSkill
- lean-bisectSkill
- lean-blueprintSkill
- lean-buildSkill
- lean-computational-reflectionSkill
- lean-core-onlySkill
- lean-corpus-auditSkill
- lean-dependency-managementSkill
- lean-doc-syncSkill
- lean-gatewaySkill
- lean-kernel-optimizationSkill
- lean-knowledge-formalizationSkill
- lean-math-analysisSkill
- lean-math-discreteSkill
- lean-math-dynamicalSkill
- lean-math-foundationsSkill
- lean-math-optimizationSkill
- lean-math-stochasticSkill
- lean-mweSkill
- lean-pedagogical-expositionSkill
- lean-proof-refactorSkill
- lean-proof-repairSkill
- lean-proof-reviewSkill
- lean-proofSkill
- lean-researchSkill
- lean-retro-methodologySkill
- lean-review-councilSkill
- lean-security-formalizationSkill
- lean-setupSkill
- lean-specificationSkill
- lean-tautology-triageSkill
- lean-unboxed-limbs-swarSkill
- lean-upstream-prSkill
- lean-verification-gateSkill
- lean-worker-wrapper-cpsSkill
- research-councilSkill
- rocq-proof-adapterSkill
The file
Files
Sharing-Aware E-Graph & CP-SAT Superoptimization for Lean 4
Synthesize DAG-optimal kernel expressions and dual-certified algebraic rewrites using equality saturation, exact CP-SAT
ILP or signed Fraction branch-and-bound extraction, and offline discovery (grind/eqsat) separated from no-grind
kernel proofs.
Routing
- USE FOR: running
AltProofe-graph superoptimization (egraph_extractor.py,context_fusion.py,cost_ranker.py), encoding sharing-aware DAG selection (x_n,y_c, topological levelsl_c), fusing consecutive recursor passes, and emitting Lean-checkedeqsat_rw/dual-certifiedrewrites. - DO NOT USE FOR: leaving
grind,native_decide, or solver bindings in finalno-grind/ 3-axiom contest artifacts.
Workflow
- Calibrate Kernel Cost -- Assign DAG weights for
>= 2^63GMP limbs, branch vs ANF gates, step-lambda size (<= 30), and context-fusion trace gains. - Saturate & Extract DAG -- Run eqsat, compact e-classes, and solve CP-SAT ILP (
l_c >= l_c' + 1 - |C|(1 - x_n)) or exactFractionsigned-cost BnB over shared e-classes. - Dual-Certify Rewrites -- Pair
lhs -> rhswith a Lean soundness proof (omega/eqsat_rw) and verified cost drop (TwoAxisEval/real - twinlit). - Harden
no-grindHandoff -- Rungrind/eqsat off-path; materialize explicitkernel_decide/rwproofs for strict 3-axiom targets (KERNEL-LAW-31).
Recovery & STOP
- Reject greedy tree extractors that duplicate shared DAG nodes or permit cyclic extractions.
- Guard
Natsubtraction rewrites (b <= a,SOUND-01).
Handoffs
- Predecessors:
lean-specification,lean-kernel-optimization. - Successors:
lean-kernel-optimization,lean-proof-review,lean-verification-gate.
Detailed reference
- Card:
../../references/cards/lean-egraph-cpsat-superopt-tables.md - Handbook:
../../references/handbooks/lean-egraph-cpsat-superopt-handbook.md - Template:
../../templates/core/Template_Egraph_CPSAT_Superopt.md
See also
../lean-kernel-optimization/SKILL.md--KERNEL-LAW-01..31kernel cost model../lean-worker-wrapper-cps/SKILL.md-- Worker/wrapper unboxing and DAG sharing
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
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.

