HoldFastPlayground

Slotted e-graphs and independent minimal-CIC kernel diversity

Design for binder-aware equality saturation and an independent checker for the minimal CIC fragment.

Scope and boundary

Slotted e-graphs extend the existing congruence-closure prover with bounded reasoning under binders. The mathematical elaborator uses a guarded fallback for lambda and beta equalities. Existing certificates · Qualification record

The independent minimal-CIC checker addresses bugs that rocq c and rocqchk could share because both use Rocq's OCaml implementation. The Python checker can recheck selected Gallina units alongside Rocq through check-minicic --dual. Local package replay uses the declared Gallina subset.

Slotted e-graphs for binder-aware equality saturation

HoldFast's slotted e-graph represents bound variables by their binder depth in slot nodes. Canonical binder names make alpha-equivalent terms share an e-class, while free variables retain their spelling.

  • fun x => f x and fun y => f y have the same canonical form, so inserting either reuses the same e-class without an alpha-rewrite rule.
  • push_version and pop_version isolate branch-local equations. Separate caps bound nodes, merges and saturation iterations.
  • saturate_and_explain(lhs, rhs) finds a shortest path through recorded equality edges and emits a Gallina certificate for Rocq replay. slotted_cert_sound relates the checked certificate to the modeled equality. A negative control checks that fun x => x differs from fun x => y where y is free.

Independent minimal-CIC second proof checker

The standalone Python checker implements a subset of Gallina without sharing Rocq code. Its checks include the following features.

  • Enforced minimal-CIC boundary: Refuses SProp, universe/sort polymorphism (Polymorphic, Cumulative, NonCumulative), CoInductive/CoFixpoint, Module Type, primitive Register/Primitive, vm_cast_no_check, native_cast_no_check, native_compute, Admitted/admit, Type in Type, Unset Guard/Unset Positivity, and Axiom, Parameter or Conjecture declarations before parsing.
  • Core trusted checking algorithms:
    1. Predicative universe checking: Prop : Type(0), Type(i) : Type(i+1), Prod(_, Prop) : Prop, and Prod(Type(i), Type(j)) : Type(max(i, j)) with strict prohibition of Type(i) : Type(i) cycles (no_type_in_type), plus inductive constructor universe predicativity (ctor_arg_fits, large_inductive_rejected).
    2. Strict positivity & Prop elimination checking: Every inductive constructor domain checks delta-normalized (whnf) strict positivity (strictly_positive_arg), rejecting negative occurrences even behind transparent definitions, and restricts Prop -> Type large elimination to empty or single-constructor prop-argument inductives (prop_elim_allowed).
    3. Structural fixpoint guard checking: Every recursive Fix call must apply a strict structural subterm of the inductive rec_arg parameter at argument position rec_arg (fix_call_guarded, fix_wrong_arg_rejected), rejecting diverging Fix f (n : nat) := f n and argument-swapping exploits.
    4. Fuel-bounded conversion (whnf / convertible) checks alpha, beta, delta, iota, zeta and eta conversion, including constructor-indexed Match branches and dependent motives. Exhausted fuel leaves the check unresolved.

Dual-kernel acceptance requires both the independent checker and Rocq (rocq c and rocqchk) to accept the same inputs with empty assumption sets.

Local Gallina packages

Supply a root .v unit and its reachable local units with repeated --dependency arguments. Each filename stem names a unique unit. Leading Require declarations resolve qualified references, and Require Import also exposes the unit's top-level declarations unqualified. The checker resolves the dependency graph before checking declarations in each unit. Missing units, cycles, unreachable inputs and assumption declarations fail.

Console
python tools/run.py holdfast-parser check-minicic Consumer.v --dependency Support.v --dual

The package check accepts up to 64 units of 65,536 bytes each and reports the SHA-256 of each exact input and a digest of the ordered closure. With --dual, Rocq compiles the same bytes in a fresh directory with scrubbed search paths, and rocqchk checks the closure with an empty assumption allowance. The package input uses the minimal-CIC Gallina subset. The ordinary mathematical package emitter's library imports, Gallina prelude and tactics require a wider checker or a compatible proof-term producer. Locked mathematical packages

Proof obligations

Obligation Required artifact and refusal predicate
SE-alpha Give alpha-equivalent terms one canonical form. Keep bound slot nodes distinct from free variables, including "$slot_0".
SE-cert-sound Prove check_cert_sound and slotted_cert_sound over explicit de Bruijn terms (SEquiv) and replay reconstructed SlottedCert Gallina proofs in Rocq; refuse unproved rewrites and budget overruns.
SE-capture-avoid Prove eval_subst_sound and beta_eval_sound and reject variable-capture rewrites such as lam x. x = lam x. y.
MC-universes Prove no_type_in_type, prod_sort_predicative, and large_inductive_rejected; reject Type : Type, impredicative large inductives, SProp, and Polymorphic.
MC-positivity Prove strict-positivity refusal of negative recursive inductives (strict_positivity_rejects_negative_rec, strict_positivity_rejects_nested_negative) even behind delta definitions, plus prop_or_elim_to_type_rejected.
MC-guard Enforce fix_call_guarded (fix_wrong_arg_rejected) rejecting unguarded or wrong-argument recursive Fix definitions while accepting structurally decreasing functions (myadd).
MC-dual-check Cross-verify identical minimal-CIC Gallina modules in both Rocq 9.3.0 (rocqchk) and minicic_checker with empty assumption sets.

Qualification and implementation artifacts

Component Artifact Role
Rocq slotted soundness proof slotted_egraph_soundness.v Zero-axiom SlottedEGraphSoundness β/λ-congruence and certificate checker soundness (rocqchk)
Slotted e-graph prototype slotted_egraph.py Canonical-slot α-hash-consing, versioned saturation, shortest-path explanations and Gallina emission
Rocq minimal-CIC spec minicic_spec.v Zero-axiom MiniCicSpec universe non-circularity and negative-inductive refusal specification (rocqchk)
Independent second kernel minicic_checker.py Standalone minimal-CIC typechecker, Gallina parser, positivity/guard checker, and SHA-256 verdicts
Qualification records Q25ev · Q25ew Slotted e-graph and independent kernel diversity tracks