Skip to content

Commit 85f94ab

Browse files
authored
feat: helper theorems (leanprover#7783)
This PR adds helper theorems for equality propagation.
1 parent 2979830 commit 85f94ab

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/Init/Data/Int/Linear.lean

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,29 @@ theorem of_not_dvd (a b : Int) : a != 0 → ¬ (a ∣ b) → b % a > 0 := by
17961796
simp [h₁] at h₂
17971797
assumption
17981798

1799+
def le_of_le_cert (p q : Poly) (k : Nat) : Bool :=
1800+
q == p.addConst (- k)
1801+
1802+
theorem le_of_le (ctx : Context) (p q : Poly) (k : Nat)
1803+
: le_of_le_cert p q k → p.denote' ctx ≤ 0 → q.denote' ctx ≤ 0 := by
1804+
simp [le_of_le_cert]; intro; subst q; simp
1805+
intro h
1806+
simp [Lean.Omega.Int.add_le_zero_iff_le_neg']
1807+
exact Int.le_trans h (Int.ofNat_zero_le _)
1808+
1809+
def not_le_of_le_cert (p q : Poly) (k : Nat) : Bool :=
1810+
q == (p.mul (-1)).addConst (1 + k)
1811+
1812+
theorem not_le_of_le (ctx : Context) (p q : Poly) (k : Nat)
1813+
: not_le_of_le_cert p q k → p.denote' ctx ≤ 0 → ¬ q.denote' ctx ≤ 0 := by
1814+
simp [not_le_of_le_cert]; intro; subst q
1815+
intro h
1816+
apply Int.pos_of_neg_neg
1817+
apply Int.lt_of_add_one_le
1818+
simp [Int.neg_add, Int.neg_sub]
1819+
rw [← Int.add_assoc, ← Int.add_assoc, Int.add_neg_cancel_right, Lean.Omega.Int.add_le_zero_iff_le_neg']
1820+
simp; exact Int.le_trans h (Int.ofNat_zero_le _)
1821+
17991822
end Int.Linear
18001823

18011824
theorem Int.not_le_eq (a b : Int) : (¬a ≤ b) = (b + 1 ≤ a) := by

0 commit comments

Comments
 (0)