Skip to content

Commit ff6eb56

Browse files
authored
fix: natCast in grind cutsat (#8776)
This PR ensures that user provided `natCast` application are properly internalized in the grind cutsat module.
1 parent 4b7ea26 commit ff6eb56

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/Lean/Meta/Tactic/Grind/Arith/Cutsat/EqCnstr.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def processNewDiseqImpl (a b : Expr) : GoalM Unit := do
290290

291291
/-- Different kinds of terms internalized by this module. -/
292292
private inductive SupportedTermKind where
293-
| add | mul | num | div | mod | sub | pow | natAbs | toNat
293+
| add | mul | num | div | mod | sub | pow | natAbs | toNat | natCast
294294
deriving BEq
295295

296296
private def getKindAndType? (e : Expr) : Option (SupportedTermKind × Expr) :=
@@ -307,6 +307,7 @@ private def getKindAndType? (e : Expr) : Option (SupportedTermKind × Expr) :=
307307
some (.num, α)
308308
| Int.natAbs _ => some (.natAbs, Nat.mkType)
309309
| Int.toNat _ => some (.toNat, Nat.mkType)
310+
| NatCast.natCast α _ _ => some (.natCast, α)
310311
| _ => none
311312

312313
private def isForbiddenParent (parent? : Option Expr) (k : SupportedTermKind) : Bool := Id.run do
@@ -315,7 +316,7 @@ private def isForbiddenParent (parent? : Option Expr) (k : SupportedTermKind) :
315316
-- TODO: document `NatCast.natCast` case.
316317
-- Remark: we added it to prevent natCast_sub from being expanded twice.
317318
if declName == ``NatCast.natCast then return true
318-
if k matches .div | .mod | .sub | .pow | .natAbs | .toNat then return false
319+
if k matches .div | .mod | .sub | .pow | .natAbs | .toNat | .natCast then return false
319320
if declName == ``HAdd.hAdd || declName == ``LE.le || declName == ``Dvd.dvd then return true
320321
match k with
321322
| .add => return false

tests/lean/grind/omega_regressions.lean

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/lean/run/grind_cutsat_nat_le.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ example (a b : Int) : a + b = Int.ofNat 2 → a - 2 = -b := by
2727
grind
2828

2929
/--
30-
trace: [grind.cutsat.assert] -1*「↑a * ↑b」 ≤ 0
30+
trace: [grind.cutsat.assert] -1*↑a ≤ 0
31+
[grind.cutsat.assert] -1*↑b ≤ 0
32+
[grind.cutsat.assert] -1*「↑a * ↑b」 ≤ 0
3133
[grind.cutsat.assert] -1*↑c ≤ 0
3234
[grind.cutsat.assert] -1*↑c + 「↑a * ↑b」 + 1 ≤ 0
3335
[grind.cutsat.assert] -1*↑0 = 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example (n : Int) (n0 : ¬0 ≤ n) (a : Nat) : n ≠ (a : Int) := by
2+
grind

0 commit comments

Comments
 (0)