Skip to content

feat(opt): ægraph pipeline integration (v1.0.5 Track 1) + #48 prep survey (Track 4)#130

Merged
avrabe merged 1 commit into
mainfrom
release/v1.0.5-track4-rocq-prep
May 19, 2026
Merged

feat(opt): ægraph pipeline integration (v1.0.5 Track 1) + #48 prep survey (Track 4)#130
avrabe merged 1 commit into
mainfrom
release/v1.0.5-track4-rocq-prep

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 19, 2026

Combined: egraph_optimize pass (opt-in) + 4 tests + rocq-roundtrip-prep.md.

🤖 Generated with Claude Code

…rvey (Track 4)

## Track 1: ægraph pipeline integration

New `pub fn egraph_optimize(module: &mut Module) -> Result<()>` in
the optimize module. Feeds each function's straight-line maximal
(0→1)-net-stack-effect expression trees through the v1.0.4 Track C
ægraph engine, saturates with the 3 identity rules, and extracts the
smaller form when one exists.

### Tree builder

`try_build_egraph_tree(instructions, start)` greedily walks
consecutive instructions, building the e-graph by stack simulation:
each egraph-supported op pops its operands and pushes its result.
Bails on control flow / unsupported ops / stack underflow. Returns
a tree iff the final symbolic stack has exactly 1 entry (a
(0→1)-net-effect expression).

### Extraction workaround

The v1.0.4 substrate's `extract()` always emits the node originally
stored at the requested class id, ignoring union-find merges. To
get the smaller representative after a rule fire, the pipeline pass
scans all class ids in the same union-find root and picks the
shortest extraction. A v1.0.6 follow-up should move this into
`egraph::extract()` as proper cost-driven extraction.

### CLI wiring

New CLI pass `egraph`. Opt-in via `--passes egraph,…` (NOT
included in the default pipeline yet — the candidate set is tiny
and v1.0.6 will widen op coverage before flipping the default).

### Tests (4 new)

- test_egraph_optimize_folds_x_plus_zero: positive (x+0 → x).
- test_egraph_optimize_no_op_on_plain_function: non-identity
  function is byte-for-byte unchanged.
- test_egraph_optimize_skips_across_call: a Call breaks the tree,
  but the post-call identity tree still folds.
- test_egraph_optimize_recurses_into_blocks: block-nested
  identity must fold.

All 4 pass.

## Track 4: #48 prep survey

New doc docs/research/v1.0.5/rocq-roundtrip-prep.md (~700 words).
Surveys the proofs/ tree's Admitted state (4 remaining: 3 in
placeholder files Roundtrip.v / TermBijection.v / StackSignature.v,
1 in the real partial-composition lemma). Recommends Path A for
v1.1.0 (close #48 properly, ~1400 LOC Rocq + 150 LOC Rust subset
extraction) or Path B for v1.0.5 cleanup (signal-noise reduction).

Trace: REQ-1, REQ-3, REQ-7, REQ-14
@avrabe avrabe merged commit fce5219 into main May 19, 2026
6 of 15 checks passed
@avrabe avrabe deleted the release/v1.0.5-track4-rocq-prep branch May 19, 2026 05:24
@avrabe avrabe mentioned this pull request May 19, 2026
avrabe added a commit that referenced this pull request May 19, 2026
…#68 fused + Rocq prep) (#133)

Four v1.0.4 infrastructure pieces grew real consumers:

  #130  Track 1+4  ægraph pipeline integration + Rocq Roundtrip prep doc
  #131  Track 2    #70 six-pass chain composition + task.return shim peephole
  #132  Track 3    #68 Tier-1.1 scalar adapter inlining + Tier-2.2 body dedup

+18 tests, 400+ total. Code-section bytes unchanged on the current
corpus — Track 3 agent flagged 4 pre-existing observations worth
tracking for v1.0.6+.
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.

1 participant