Emit supplemental-graph adjacency constraints lazily - #72
Conversation
The supplemental-graph adjacency constraints (exact-path/distance-2, distance-3 and --k4 shape graphs) are derived in the PBP, not in the OPB. They were all emitted up front during model building, but most are never used: a supplemental for antecedent (p,t) is needed only when x_p_t's value is decided by adjacency during search -- assigned true (forward-checking use) or removed from dom(p) by forward-checking (the branch-consequence a later Hall-set confinement cites) -- plus the root degree/NDS reads. Supplementals for (p,t) eliminated at the root (a kept unit suffices) or only removed by all-different (justified by a Hall pol) are never needed. Make them lazy: create_*_graphs now register a pending derivation keyed by (g,p,q,t) and indexed by antecedent (p,t); materialise_adjacency_for runs them on first use, driven from guessing/unit_propagating (assignment) and the searcher's propagate_adjacency_constraints (per removed value), with the degree/NDS readers materialising before their pol. The OPB is byte-identical and the search tree is unchanged; only PBP logging differs. The searcher's per-removal bookkeeping is gated on has_pending_supplementals(), so it costs nothing once everything has been materialised or when there are no supplementals. Mid-search materialisation needs care with proof levels: wiplvl N wipes every level >= N (that is how forget_level discards a subtree), and search uses levels depth+2, so a derivation scratches at active_level+1 (its wiplvl clears only the scratch), emits the persistent @Label at level 0, and the batch restores active_level once. This typically defers ~40-70% of supplemental derivations; on the search-light distance-3 instances that previously dominated the proof it is a ~60% reduction in PBP lines. Verified: ctest 48/48 (release and sanitize, incl proof_*, cake_* and random_proof_sweep); a 300-instance distance-3/locally-injective/counting sweep all verify; OPB byte-identical to the eager version. (Pre-existing and unaffected: directed distance-3 proofs throw at model build, and labelled proofs are explicitly unsupported.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
77adc7a to
de80b1e
Compare
|
Closing as won't-fix on The lazy supplemental-adjacency work is landing on the This standalone |
The supplemental-graph adjacency constraints (exact-path/distance-2, distance-3,
--k4shape graphs) are derived in the PBP, not in the OPB, and were all emitted up front during model building. Most are never used. This makes them lazy — emitted only on first use — leaving the OPB byte-identical and the search tree unchanged (only PBP logging differs).When is a supplemental needed?
A supplemental for antecedent
(p,t)is needed exactly whenx_p_t's value is decided by adjacency during search:guessing/unit_propagating);dom(p)by forward-checking — the branch-consequence a later Hall-set confinement cites in its RUP (triggered per removed value from the searcher'spropagate_adjacency_constraints);plus the root degree/NDS reads (materialised before their
pol). Supplementals for(p,t)eliminated at the root (a kept unit suffices) or only removed by all-different (justified by a Hallpol) are never emitted.This was established empirically first: keeping supplementals only for assigned
(p,t)fails--distance3proofs (the checker's RUP reconstructs a Hall confinement via the removed vertices' adjacency, in the reverse direction), whereas keeping assigned ∪ removed verifies across a 720-instance probe with 0 failures, deferring ~46% on average.Implementation
create_*_graphsregister a pending derivation keyed by(g,p,q,t)and indexed by antecedent(p,t);materialise_adjacency_forruns them on first use.Mid-search materialisation needs care with proof levels:
wiplvl Nwipes every level ≥ N (that's howforget_leveldiscards a subtree), and search uses levelsdepth+2, so a derivation scratches atactive_level + 1(itswiplvlclears only the scratch), emits the persistent@labelat level 0, and the batch restoresactive_levelonce.Results
proof_*, thecake_*verified-pipeline, andrandom_proof_sweep.🤖 Generated with Claude Code