chore: audit and standardize grind E-graph internalization entry points#12402
Draft
chore: audit and standardize grind E-graph internalization entry points#12402
Conversation
Add `preprocessAndInternalize` as the preferred entry point for adding newly constructed terms to the E-graph, combining full preprocessing with internalization. Mark 12 ad-hoc sites across 10 files where complex synthesized terms bypass the full normalization pipeline with TODO comments for future investigation. This is preparatory work for the grind simplification sets design, which requires that every term in the E-graph has been through the full preprocessing pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace generic TODO markers with specific explanations of why these sites cannot easily use preprocessAndInternalize. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ensureInternalized now returns Simp.Result so that callers can compose preprocessing proofs with E-graph equality proofs. This ensures correctness when full preprocessing produces terms that are only propositionally (not definitionally) equal to the originals. In abstractGroundMismatches?, the original subterms are pushed into the lhss/rhss arrays (needed for definitional equality with the lambda abstraction), while the preprocessed versions are used only for the isEqv check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Linear/DenoteExpr and CommRing/EqCnstr conversions broke 15 tests because the arithmetic solvers' proof reconstruction is tightly coupled with the exact form of internalized expressions. Full preprocessing changes expressions in ways that cause type mismatches in solver proofs. These sites now have explanatory comments alongside Proj.lean and Cutsat/EqCnstr.lean as sites that cannot use preprocessAndInternalize. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0492bd1 to
73639ef
Compare
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
Full preprocessing (via preprocessAndInternalize) runs simp, which can normalize terms into forms that break congruence closure. For example, `i < (a :: l).length` becomes `i + 1 ≤ (a :: l).length`, preventing CC from proving equality with `0 < (a :: l).length` when `i` and `0` are in the same equivalence class. This caused 6 test failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a preferred entry point
preprocessAndInternalizefor adding newly constructedterms to the E-graph, and converts ad-hoc internalization sites to use it. This is preparatory
work for the grind simplification sets design, which requires every term in the E-graph to have
been through the full preprocessing pipeline.
A new function
preprocessAndInternalizeinSimp.leancomposespreprocessandinternalizeinto a single call. Eight sites that previously used
preprocessLight+internalizeor bareinternalizeare converted to use it, with proof adjustments where needed (e.g. composingSimp.Result.proof?viamkEqTrans/mkHEqTrans).Four sites are intentionally not converted, with explanations:
Proj.lean: preprocessing would reduceproj_i (ctor ...)to the field value, breaking thecongruence closure connection mechanism
Cutsat/EqCnstr.lean(3 sites): terms are tightly coupled with the cutsat polynomial solverand
mkVarregistration🤖 Prepared with Claude Code