File tree Expand file tree Collapse file tree 4 files changed +33
-1
lines changed
Lean/Meta/Tactic/Grind/Order Expand file tree Collapse file tree 4 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,11 @@ Helper theorem for equality propagation
107107theorem eq_of_le_of_le {α} [LE α] [Std.IsPartialOrder α] {a b : α} : a ≤ b → b ≤ a → a = b :=
108108 Std.IsPartialOrder.le_antisymm _ _
109109
110+ theorem eq_of_le_of_le_0 {α} [LE α] [Std.IsPartialOrder α] [Ring α]
111+ {a b : α} : a ≤ b + Int.cast (R := α) 0 → b ≤ a + Int.cast (R := α) 0 → a = b := by
112+ simp [Ring.intCast_zero, Semiring.add_zero]
113+ apply Std.IsPartialOrder.le_antisymm
114+
110115/-!
111116Transitivity
112117-/
Original file line number Diff line number Diff line change @@ -210,8 +210,19 @@ public def mkUnsatProof (u v : Expr) (k₁ : Weight) (h₁ : Expr) (k₂ : Weigh
210210 else
211211 mkUnsatProofCore u v k₁ h₁ k₂ h₂
212212
213- public def mkEqProofOfLeOfLe (u v : Expr) (h₁ : Expr) (h₂ : Expr) : OrderM Expr := do
213+ public def mkEqProofOfLeOfLeCore (u v : Expr) (h₁ : Expr) (h₂ : Expr) : OrderM Expr := do
214214 let h ← mkLePartialPrefix ``Grind.Order.eq_of_le_of_le
215215 return mkApp4 h u v h₁ h₂
216216
217+ public def mkEqProofOfLeOfLeOffset (u v : Expr) (h₁ : Expr) (h₂ : Expr) : OrderM Expr := do
218+ let h ← mkLePartialPrefix ``Grind.Order.eq_of_le_of_le_0
219+ let h := mkApp h (← getStruct).ringInst?.get!
220+ return mkApp4 h u v h₁ h₂
221+
222+ public def mkEqProofOfLeOfLe (u v : Expr) (h₁ : Expr) (h₂ : Expr) : OrderM Expr := do
223+ if (← isRing) then
224+ mkEqProofOfLeOfLeOffset u v h₁ h₂
225+ else
226+ mkEqProofOfLeOfLeCore u v h₁ h₂
227+
217228end Lean.Meta.Grind.Order
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ structure Cnstr (α : Type) where
3333 k : Int := 0
3434 /-- Denotation of this constraint as an expression. -/
3535 e : Expr
36+ /--
37+ If `h? := some h`, then `h` is proof for that the expression associated with this constraint
38+ is equal to `e`. Recall that the input constraints are normalized. For example, given `x y : Int`,
39+ `x ≤ y` is internally represented as `x ≤ y + 0`
40+ -/
3641 h? : Option Expr := none
3742 deriving Inhabited
3843
Original file line number Diff line number Diff line change 1+ def Int.leastOfBdd {P : Int → Prop } [DecidablePred P] (b : Int) (Hb : ∀ z : Int, P z → b ≤ z)
2+ (Hinh : ∃ z : Int, P z) : { lb : Int // P lb ∧ ∀ z : Int, P z → lb ≤ z } :=
3+ sorry
4+
5+ theorem Int.coe_leastOfBdd_eq {P : Int → Prop } [DecidablePred P] {b b' : Int} (Hb : ∀ z : Int, P z → b ≤ z)
6+ (Hb' : ∀ z : Int, P z → b' ≤ z) (Hinh : ∃ z : Int, P z) :
7+ (leastOfBdd b Hb Hinh : Int) = leastOfBdd b' Hb' Hinh := by
8+ grind
9+
10+ example (f : Int → Int) (x y : Int) : x ≤ y → y ≤ x → f x = f y := by
11+ grind -cutsat -linarith
You can’t perform that action at this time.
0 commit comments