fix: grind congruence-table invariant for lazy ite branches#13624
Merged
Conversation
Collaborator
|
Reference manual CI status:
|
This PR fixes a `grind` equivalence-class invariant violation that could panic when an `ite`/`dite` branch was internalized lazily (after the condition became `True` or `False`) and that branch's equivalence class was later merged with another. `applyCongrFun` already passed the parent to `internalize` (so satellite solvers see it) but never called `registerParent`, so the lazily internalized branch had no record of the `ite` as one of its parents. Subsequent merges then skipped re-hashing the `ite` in the congruence table, leaving an orphaned entry whose `congr` chain no longer matched the table's representative. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Mathlib CI status (docs):
|
6d06f1d to
2370329
Compare
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 fixes a
grindcongruence-table invariant violation that could panicwhen an
itebranch was internalized lazily (after the condition becameTrueor
False) and that branch's equivalence class was later merged with another.Internalize.leanhas a special case foritethat internalizes only thecondition; the
then/elsebranches are skipped and only internalized lateron demand by
propagateIte. The on-demand path (applyCongrFun) calledinternalizefor the branch but never calledregisterParentto add theparent
iteto the branch's parent set in the e-graph. Subsequent merges ofthe branch's equivalence class then skipped re-hashing the
itein thecongruence table, leaving an orphan entry whose
congrchain no longer matchedthe table's representative.
The fix adds the explicit
registerParent e rhsthat the standardfor arg in argsloop inInternalize.leanwould have made for an ordinaryapplication argument; we are simply mirroring that pattern lazily. The same
helper is reused by
propagateDIte, but with parent registration disabled(controlled by a new
ite : Boolparameter): forditetherhspropagatedupwards is a constructed reduction (built via
mkAppfrome's children,possibly post-
preprocess), not a structural argument ofe, so registeringeas its parent would be incorrect. The lambda branches of aditearealready eagerly internalized as parents of
ebyInternalize.lean, so thiscase does not need the fix.