Skip to content

Preserve acyclic LP selections with SCC-local rank constraints - #369

Open
TheDarkLightX wants to merge 1 commit into
egraphs-good:mainfrom
TheDarkLightX:fix/lp-selection-acyclicity
Open

TheDarkLightX wants to merge 1 commit into
egraphs-good:mainfrom
TheDarkLightX:fix/lp-selection-acyclicity

Conversation

@TheDarkLightX

Copy link
Copy Markdown

Fixes #207.

This preserves every acyclic class-consistent selection instead of removing e-nodes using graph-wide cycle breaking. On current main (73975c9), the new three-class back-edge regression returns cost 10 instead of 1; the independent small-graph oracle also finds cost 8 instead of 7 for graph 60. The original issue/comment examples are retained as coverage, but already pass current main on this build.

Encoding

Compute SCCs of the full possible-edge graph with iterative Kosaraju. Direct self-loop nodes are disabled. For a component of size m > 1, each class gets a continuous rank in [0, m − 1]. Every possible intra-component edge has:

rank(parent) − rank(child) − m × selected(node) ≥ 1 − m

When selected, the parent rank is at least one larger. When unselected, M = m makes the constraint redundant even at the extreme bounds. Cross-component edges need no rank constraints; singleton components need no rank variables. Existing activation, root, and one-node-per-active-class constraints remain.

The decoder uses a binary threshold and an explicit visiting stack, so small numerical residues do not select nodes and a cyclic or missing incumbent cannot cause an infinite reconstruction loop.

Formal evidence and its boundary

Optional pinned Lean proof and replay instructions establish:

  • For any finite canonical-class model with a valid full-possible-edge SCC partition, selected edges are acyclic iff the self-loop exclusions and SCC-local bounded-rank constraints are feasible
  • Component sizes are actual subtype cardinalities, and singleton rank variables are genuinely omitted
  • Removing selected nodes cannot increase an additive nonnegative objective

Lean 4.30.0-rc2 and the pinned Mathlib revision check both SCC soundness/completeness theorems. No unfinished proofs or new axioms; reported dependencies are only propext, Classical.choice, and Quot.sound.

This verifies the exact mathematical encoding. Rust model construction, Kosaraju, reconstruction, good_lp/CBC, floating-point tolerances, and solver optimality are tested/reviewed boundaries, not formally verified implementations. The proof also does not claim a complete rooted-objective/RecExpr refinement theorem. Rooted optimality requires finite nonnegative costs and an optimal backend result. Negative costs remain accepted with their existing disconnected-selection limitation documented.

Validation

  • Required make passed: default release, std-clock release, LP, explanations, no-default-features, formatting, all-feature docs, and deadlinks
  • 10 integration tests, including 702 independent solver/brute-force comparisons, pass with LP and LP + deterministic
  • All 512 directed three-vertex graphs checked against an independent reachability SCC oracle; duplicate edges, rebuilt aliases, empty input, and a 20,000-class cycle on a 64 KiB stack pass
  • Three fresh-build mutations are killed: too-small M, too-small rank range, and omitted rank rows
  • Independent final review found no blocking issues

An additional, non-required cargo test --release --all-features run fails the existing pattern::Pattern doctest's order assertion ([1,3] versus [3,1]). The same isolated failure reproduces on untouched main; this PR leaves that unrelated example unchanged.

Performance

Reproducible benchmark fixture, exact lock, protocol, and raw samples are kept on a separate fork evidence branch, outside this PR's diff.

Synthetic Linux/CBC 2.10.12 medians, baseline → SCC:

  • Acyclic chain500: 11.70 → 12.81 ms; duplicate500: 20.57 → 18.56 ms, with unchanged constraint counts
  • Ring128: 5.73 → 11.62 ms, while recovering cost 65 instead of 1000
  • Ring8/16 recover costs 5/9 instead of 1000

These are small synthetic measurements, not application-scale guarantees. In three independent five-second attempts, both variants returned the same suboptimal incumbents for shared100 (63.4 versus optimum 61) and shared500 (361.8 versus 301), all with TimeLimit status. Exact modeling can cost more, and time-limited results need not be optimal.

Assisted-by: OpenAI Codex (implementation, proof development, testing, and write-up).

Replace graph-wide cycle pruning with exact selected-edge acyclicity rows.
Add regression/oracle tests, iterative SCC checks, guarded decoding, and
an optional pinned Lean proof of the abstract encoding.

Assisted-by: OpenAI Codex
@TheDarkLightX
TheDarkLightX marked this pull request as ready for review October 4, 2026 00:27
@egraphs-good egraphs-good deleted a comment from chatgpt-codex-connector Bot Oct 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LpExtractor creates an infeasible problem for CBC

1 participant