Skip to content

Remove constructors from merge functions#796

Open
saulshanabrook wants to merge 4 commits into
mainfrom
codex/remove-merge-constructors
Open

Remove constructors from merge functions#796
saulshanabrook wants to merge 4 commits into
mainfrom
codex/remove-merge-constructors

Conversation

@saulshanabrook

@saulshanabrook saulshanabrook commented Jun 5, 2026

Copy link
Copy Markdown
Member

This removes constructor-producing encodings from merge functions so merge results are eager values selected from the existing inputs, which is needed for proof mode and for avoiding merge-driven e-node growth.

Stack

PR against Oliver's oflatt-latest-egglog branch.

This now depends on:

The Cargo manifest points at the experimental PR branch, and Cargo.lock pins that branch plus the combined egglog branch.

What changed

  • TermAndCost is now a Pair Term i64.
  • ExtractedExpr uses pair-min-by-second-i64, which returns one of the existing pair values directly.
  • interval Bound is now Maybe (Either i64 bool).
  • Lower/upper bound merges use maybe-either-i64-bool-max and maybe-either-i64-bool-min.
  • Eggcc-specific aliases like IntB, BoolB, Dead, bound-int, and bound-bool were removed; eggcc now spells the generic container representation directly.
  • IVTRes is now Pair IVTPayload i64, with merges using pair-min-by-second-i64.
  • Rules that consume pair-backed values use pair-first and pair-second instead of matching on pair-shaped LHS terms.
  • --run-mode egglog emits the generated egglog program for direct use with the experimental CLI.

Validation

Passed locally:

cargo check --locked
cargo test -p dag_in_context interval_analysis
cargo test -p dag_in_context optimizations::ivt
cargo test -p dag_in_context optimizations::memory
cargo test -p dag_in_context optimizations::switch_rewrites
cargo run --release -- --run-mode egglog --stop-after-n-passes 1 benchmarks/passing/polybench/linear-algebra/kernels/2mm.bril > .tmp/proof-profile/2mm-pass1-current.egg
/Users/saul/p/wt/egglog-experimental/eggcc-proof-baseline-pr927/target/release/egglog-experimental .tmp/proof-profile/2mm-pass1-current.egg

Current composed-stack validation:

# eggcc, after lockfile repin
cargo check
cargo check --locked

# egglog-experimental PR #56, release CLI against full checked-in 2mm export
target/release/egglog-experimental --proofs tests/fixtures/eggcc-2mm-pass1-merge-old.egg

The full 2mm pass-1 export is checked into egglog-experimental PR #56 as tests/fixtures/eggcc-2mm-pass1-merge-old.egg; it contains no :no-merge and runs successfully in proof mode with the release CLI. The default experimental test suite keeps the full-export canary ignored because debug-profile proof execution was too slow for CI.

Performance

Earlier local 2mm export runs for the constructor encoding vs eager encoding showed the eager encoding faster (about 13% on that run). I did not rerun the 5x benchmark after replacing eggcc-specific aliases with direct generic container forms.

@oflatt oflatt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments from our discussion last time

Comment thread Cargo.toml Outdated
Comment thread dag_in_context/src/utility/terms.egg Outdated
Base automatically changed from oflatt-latest-egglog to main June 29, 2026 20:42
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.

2 participants