Skip to content

Commit 68377ba

Browse files
committed
feat: normalize Int lt
1 parent 7429773 commit 68377ba

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Lean/Meta/Tactic/Grind/Order/Assert.lean

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,14 @@ def assertIneqFalse (c : Cnstr NodeId) (e : Expr) (he : Expr) : OrderM Unit := d
239239
else
240240
``Grind.Order.lt_of_not_le_k
241241
let h' ← mkLinearOrdRingPrefix declName
242-
let k' := -c.k
243-
let h := mkApp6 h' (← getExpr c.u) (← getExpr c.v) (toExpr c.k) (toExpr k') eagerReflBoolTrue h
244-
addEdge c.v c.u { k := k', strict := c.kind matches .le } h
242+
let mut k' := -c.k
243+
let mut h := mkApp6 h' (← getExpr c.u) (← getExpr c.v) (toExpr c.k) (toExpr k') eagerReflBoolTrue h
244+
let mut strict := c.kind matches .le
245+
if (← isInt) && strict then
246+
h := mkApp6 (mkConst ``Grind.Order.int_lt) (← getExpr c.v) (← getExpr c.u) (toExpr k') (toExpr (k'-1)) eagerReflBoolTrue h
247+
k' := k' - 1
248+
strict := !strict
249+
addEdge c.v c.u { k := k', strict } h
245250
else if c.kind matches .lt then
246251
let h' ← mkLeLtLinearPrefix ``Grind.Order.le_of_not_lt
247252
let h := mkApp3 h' (← getExpr c.u) (← getExpr c.v) h

src/Lean/Meta/Tactic/Grind/Order/OrderM.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ def isLinearPreorder : OrderM Bool :=
6666
def hasLt : OrderM Bool :=
6767
return (← getStruct).lawfulOrderLTInst?.isSome
6868

69+
def isInt : OrderM Bool :=
70+
return isSameExpr (← getStruct).type (← getIntExpr)
71+
6972
end Lean.Meta.Grind.Order

tests/lean/run/grind_order_3.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ example [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearPreorder α] [CommRi
1515
example [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearPreorder α] [CommRing α] [OrderedRing α]
1616
(a b c d : α) : a - b ≤ 5 → ¬ (c < b) → ¬ (d ≤ c + 2) → d ≤ a - 8 → False := by
1717
grind -linarith (splits := 0)
18+
19+
example (p : Prop) (a b c : Int) : (p ↔ b ≤ a) → (p ↔ c ≤ b) → ¬ p → c ≤ a + 1 → False := by
20+
grind -linarith -cutsat (splits := 0)

0 commit comments

Comments
 (0)