Skip to content

fix: canonicalize literals when creating grind patterns - #14618

Merged
leodemoura merged 1 commit into
masterfrom
grind_bv_lit_canon
Jul 31, 2026
Merged

fix: canonicalize literals when creating grind patterns#14618
leodemoura merged 1 commit into
masterfrom
grind_bv_lit_canon

Conversation

@leodemoura

Copy link
Copy Markdown
Member

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.

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 leodemoura added the changelog-tactics User facing tactics label Jul 31, 2026
@leodemoura
leodemoura enabled auto-merge July 31, 2026 13:13
@leodemoura
leodemoura added this pull request to the merge queue Jul 31, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jul 31, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 17dbc815cf3055e73a9e37d854b8427dc1e9c46c --onto 5b8d06c1764fa367a1e27b3e89f64667eac425af. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-31 13:42:35)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 17dbc815cf3055e73a9e37d854b8427dc1e9c46c --onto a39eab69e1eee9ad38f4efe507907b1026a77808. You can force reference manual CI using the force-manual-ci label. (2026-07-31 13:42:37)

Merged via the queue into master with commit 02a57df Jul 31, 2026
24 of 25 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants