fix: canonicalize literals when creating grind patterns - #14618
Merged
Conversation
This PR fixes a `grind` regression on goals that use a bit-vector literal written with `#` syntax under a quantifier, such as `example (f g : Nat → BitVec 2) (h : ∀ n, f n = g n ||| 1#2) : f 0 = g 0 ||| 1#2 := by grind`. The tactic failed with a kernel error instead of closing the goal. Ground subterms of e-matching patterns are internalized after `preprocessLight` only, which does not put literals in `grind` normal form. A `1#2` reaching the E-graph as `BitVec.ofNat` rather than `OfNat.ofNat` produces two interpreted nodes for one value, and merging them looks like a `valueInconsistency` to `addEqStep`, which then closes the goal with an ill-typed proof term. Ground patterns are now canonicalized when they are created. This is a stopgap: the normalizer should do it, once `Sym.dsimp` has been ported to `grind`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
leodemoura
enabled auto-merge
July 31, 2026 13:13
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
Garmelon
pushed a commit
that referenced
this pull request
Aug 3, 2026
This PR fixes a `grind` regression on goals that use a bit-vector literal written with `#` syntax under a quantifier, such as `example (f g : Nat → BitVec 2) (h : ∀ n, f n = g n ||| 1#2) : f 0 = g 0 ||| 1#2 := by grind`. The tactic failed with a kernel error instead of closing the goal. Ground subterms of e-matching patterns are internalized after `preprocessLight` only, which does not put literals in `grind` normal form. A `1#2` reaching the E-graph as `BitVec.ofNat` rather than `OfNat.ofNat` produces two interpreted nodes for one value, and merging them looks like a `valueInconsistency` to `addEqStep`, which then closes the goal with an ill-typed proof term. Ground patterns are now canonicalized when they are created. This is a stopgap: the normalizer should do it, once `Sym.dsimp` has been ported to `grind`. Co-authored-by: Claude Fable 5 <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 fixes a
grindregression on goals that use a bit-vector literal written with#syntax under a quantifier, such asexample (f g : Nat → BitVec 2) (h : ∀ n, f n = g n ||| 1#2) : f 0 = g 0 ||| 1#2 := by grind. The tactic failed with a kernel error instead of closing the goal.Ground subterms of e-matching patterns are internalized after
preprocessLightonly, which does not put literals ingrindnormal form. A1#2reaching the E-graph asBitVec.ofNatrather thanOfNat.ofNatproduces two interpreted nodes for one value, and merging them looks like avalueInconsistencytoaddEqStep, which then closes the goal with an ill-typed proof term.Ground patterns are now canonicalized when they are created. This is a stopgap: the normalizer should do it, once
Sym.dsimphas been ported togrind.