2014-11-17 20:19:46 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Authors: Jeremy Avigad
|
|
|
|
|
2015-06-29 03:59:34 +00:00
|
|
|
Partially ordered additive groups, modeled on Isabelle's library. These classes can be refined
|
|
|
|
if necessary.
|
2014-11-17 20:19:46 +00:00
|
|
|
-/
|
2014-12-01 04:34:12 +00:00
|
|
|
import logic.eq data.unit data.sigma data.prod
|
2015-07-06 14:29:56 +00:00
|
|
|
import algebra.binary algebra.group algebra.order
|
2014-11-17 20:19:46 +00:00
|
|
|
open eq eq.ops -- note: ⁻¹ will be overloaded
|
|
|
|
|
|
|
|
namespace algebra
|
|
|
|
|
|
|
|
variable {A : Type}
|
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
/- partially ordered monoids, such as the natural numbers -/
|
|
|
|
|
2014-11-17 20:19:46 +00:00
|
|
|
structure ordered_cancel_comm_monoid [class] (A : Type) extends add_comm_monoid A,
|
2014-11-30 13:31:34 +00:00
|
|
|
add_left_cancel_semigroup A, add_right_cancel_semigroup A, order_pair A :=
|
2014-12-12 23:22:19 +00:00
|
|
|
(add_le_add_left : ∀a b, le a b → ∀c, le (add c a) (add c b))
|
|
|
|
(le_of_add_le_add_left : ∀a b c, le (add a b) (add a c) → le b c)
|
2015-05-29 03:33:45 +00:00
|
|
|
(add_lt_add_left : ∀a b, lt a b → ∀c, lt (add c a) (add c b))
|
|
|
|
(lt_of_add_lt_add_left : ∀a b c, lt (add a b) (add a c) → lt b c)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
|
|
|
section
|
2014-12-26 21:25:05 +00:00
|
|
|
variables [s : ordered_cancel_comm_monoid A]
|
|
|
|
variables {a b c d e : A}
|
2014-11-17 20:19:46 +00:00
|
|
|
include s
|
|
|
|
|
2015-05-29 03:33:45 +00:00
|
|
|
theorem add_lt_add_left (H : a < b) (c : A) : c + a < c + b :=
|
|
|
|
!ordered_cancel_comm_monoid.add_lt_add_left H c
|
|
|
|
|
|
|
|
theorem add_lt_add_right (H : a < b) (c : A) : a + c < b + c :=
|
|
|
|
begin
|
|
|
|
rewrite [add.comm, {b + _}add.comm],
|
|
|
|
exact (add_lt_add_left H c)
|
|
|
|
end
|
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_le_add_left (H : a ≤ b) (c : A) : c + a ≤ c + b :=
|
2014-12-12 23:22:19 +00:00
|
|
|
!ordered_cancel_comm_monoid.add_le_add_left H c
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_le_add_right (H : a ≤ b) (c : A) : a + c ≤ b + c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
(add.comm c a) ▸ (add.comm c b) ▸ (add_le_add_left H c)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_le_add (Hab : a ≤ b) (Hcd : c ≤ d) : a + c ≤ b + d :=
|
2014-11-30 13:31:34 +00:00
|
|
|
le.trans (add_le_add_right Hab c) (add_le_add_left Hcd b)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem le_add_of_nonneg_right (H : b ≥ 0) : a ≤ a + b :=
|
2015-03-01 19:38:27 +00:00
|
|
|
begin
|
|
|
|
have H1 : a + b ≥ a + 0, from add_le_add_left H a,
|
|
|
|
rewrite add_zero at H1,
|
|
|
|
exact H1
|
|
|
|
end
|
2014-12-26 21:25:05 +00:00
|
|
|
|
|
|
|
theorem le_add_of_nonneg_left (H : b ≥ 0) : a ≤ b + a :=
|
2015-03-01 19:38:27 +00:00
|
|
|
begin
|
|
|
|
have H1 : 0 + a ≤ b + a, from add_le_add_right H a,
|
|
|
|
rewrite zero_add at H1,
|
|
|
|
exact H1
|
|
|
|
end
|
2014-12-26 21:25:05 +00:00
|
|
|
|
|
|
|
theorem add_lt_add (Hab : a < b) (Hcd : c < d) : a + c < b + d :=
|
2014-11-30 13:31:34 +00:00
|
|
|
lt.trans (add_lt_add_right Hab c) (add_lt_add_left Hcd b)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_add_of_le_of_lt (Hab : a ≤ b) (Hcd : c < d) : a + c < b + d :=
|
2014-11-30 13:31:34 +00:00
|
|
|
lt_of_le_of_lt (add_le_add_right Hab c) (add_lt_add_left Hcd b)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_add_of_lt_of_le (Hab : a < b) (Hcd : c ≤ d) : a + c < b + d :=
|
2014-11-30 13:31:34 +00:00
|
|
|
lt_of_lt_of_le (add_lt_add_right Hab c) (add_le_add_left Hcd b)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_add_of_pos_right (H : b > 0) : a < a + b := !add_zero ▸ add_lt_add_left H a
|
|
|
|
|
|
|
|
theorem lt_add_of_pos_left (H : b > 0) : a < b + a := !zero_add ▸ add_lt_add_right H a
|
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
-- here we start using le_of_add_le_add_left.
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem le_of_add_le_add_left (H : a + b ≤ a + c) : b ≤ c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
!ordered_cancel_comm_monoid.le_of_add_le_add_left H
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem le_of_add_le_add_right (H : a + b ≤ c + b) : a ≤ c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
le_of_add_le_add_left (show b + a ≤ b + c, begin rewrite [add.comm, {b + _}add.comm], exact H end)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_of_add_lt_add_left (H : a + b < a + c) : b < c :=
|
2015-05-29 03:33:45 +00:00
|
|
|
!ordered_cancel_comm_monoid.lt_of_add_lt_add_left H
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_of_add_lt_add_right (H : a + b < c + b) : a < c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
lt_of_add_lt_add_left ((add.comm a b) ▸ (add.comm c b) ▸ H)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_le_add_left_iff (a b c : A) : a + b ≤ a + c ↔ b ≤ c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
iff.intro le_of_add_le_add_left (assume H, add_le_add_left H _)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_le_add_right_iff (a b c : A) : a + b ≤ c + b ↔ a ≤ c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
iff.intro le_of_add_le_add_right (assume H, add_le_add_right H _)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_add_left_iff (a b c : A) : a + b < a + c ↔ b < c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
iff.intro lt_of_add_lt_add_left (assume H, add_lt_add_left H _)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_add_right_iff (a b c : A) : a + b < c + b ↔ a < c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
iff.intro lt_of_add_lt_add_right (assume H, add_lt_add_right H _)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
|
|
|
-- here we start using properties of zero.
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_nonneg (Ha : 0 ≤ a) (Hb : 0 ≤ b) : 0 ≤ a + b :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_le_add Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_pos (Ha : 0 < a) (Hb : 0 < b) : 0 < a + b :=
|
|
|
|
!zero_add ▸ (add_lt_add Ha Hb)
|
|
|
|
|
|
|
|
theorem add_pos_of_pos_of_nonneg (Ha : 0 < a) (Hb : 0 ≤ b) : 0 < a + b :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_lt_add_of_lt_of_le Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_pos_of_nonneg_of_pos (Ha : 0 ≤ a) (Hb : 0 < b) : 0 < a + b :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_lt_add_of_le_of_lt Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_nonpos (Ha : a ≤ 0) (Hb : b ≤ 0) : a + b ≤ 0 :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_le_add Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_neg (Ha : a < 0) (Hb : b < 0) : a + b < 0 :=
|
|
|
|
!zero_add ▸ (add_lt_add Ha Hb)
|
|
|
|
|
|
|
|
theorem add_neg_of_neg_of_nonpos (Ha : a < 0) (Hb : b ≤ 0) : a + b < 0 :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_lt_add_of_lt_of_le Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_neg_of_nonpos_of_neg (Ha : a ≤ 0) (Hb : b < 0) : a + b < 0 :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ (add_lt_add_of_le_of_lt Ha Hb)
|
2014-11-17 20:19:46 +00:00
|
|
|
|
|
|
|
-- TODO: add nonpos version (will be easier with simplifier)
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_eq_zero_iff_eq_zero_and_eq_zero_of_nonneg_of_nonneg
|
2014-11-30 13:31:34 +00:00
|
|
|
(Ha : 0 ≤ a) (Hb : 0 ≤ b) : a + b = 0 ↔ a = 0 ∧ b = 0 :=
|
2014-11-17 20:19:46 +00:00
|
|
|
iff.intro
|
|
|
|
(assume Hab : a + b = 0,
|
|
|
|
have Ha' : a ≤ 0, from
|
|
|
|
calc
|
2015-03-01 19:38:27 +00:00
|
|
|
a = a + 0 : by rewrite add_zero
|
2014-11-30 13:31:34 +00:00
|
|
|
... ≤ a + b : add_le_add_left Hb
|
2015-03-01 19:38:27 +00:00
|
|
|
... = 0 : Hab,
|
2014-12-26 21:25:05 +00:00
|
|
|
have Haz : a = 0, from le.antisymm Ha' Ha,
|
2014-11-17 20:19:46 +00:00
|
|
|
have Hb' : b ≤ 0, from
|
|
|
|
calc
|
2015-03-01 19:38:27 +00:00
|
|
|
b = 0 + b : by rewrite zero_add
|
2014-11-30 13:31:34 +00:00
|
|
|
... ≤ a + b : add_le_add_right Ha
|
2015-03-01 19:38:27 +00:00
|
|
|
... = 0 : Hab,
|
2014-12-26 21:25:05 +00:00
|
|
|
have Hbz : b = 0, from le.antisymm Hb' Hb,
|
2014-11-17 20:19:46 +00:00
|
|
|
and.intro Haz Hbz)
|
|
|
|
(assume Hab : a = 0 ∧ b = 0,
|
2015-05-06 17:34:43 +00:00
|
|
|
obtain Ha' Hb', from Hab,
|
|
|
|
by rewrite [Ha', Hb', add_zero])
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem le_add_of_nonneg_of_le (Ha : 0 ≤ a) (Hbc : b ≤ c) : b ≤ a + c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_le_add Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem le_add_of_le_of_nonneg (Hbc : b ≤ c) (Ha : 0 ≤ a) : b ≤ c + a :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_le_add Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_pos_of_le (Ha : 0 < a) (Hbc : b ≤ c) : b < a + c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_lt_add_of_lt_of_le Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_le_of_pos (Hbc : b ≤ c) (Ha : 0 < a) : b < c + a :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_lt_add_of_le_of_lt Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_le_of_nonpos_of_le (Ha : a ≤ 0) (Hbc : b ≤ c) : a + b ≤ c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_le_add Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_le_of_le_of_nonpos (Hbc : b ≤ c) (Ha : a ≤ 0) : b + a ≤ c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_le_add Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_neg_of_le (Ha : a < 0) (Hbc : b ≤ c) : a + b < c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_lt_add_of_lt_of_le Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_le_of_neg (Hbc : b ≤ c) (Ha : a < 0) : b + a < c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_lt_add_of_le_of_lt Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_nonneg_of_lt (Ha : 0 ≤ a) (Hbc : b < c) : b < a + c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_lt_add_of_le_of_lt Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_lt_of_nonneg (Hbc : b < c) (Ha : 0 ≤ a) : b < c + a :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_lt_add_of_lt_of_le Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_pos_of_lt (Ha : 0 < a) (Hbc : b < c) : b < a + c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
!zero_add ▸ add_lt_add Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem lt_add_of_lt_of_pos (Hbc : b < c) (Ha : 0 < a) : b < c + a :=
|
2014-12-26 21:25:05 +00:00
|
|
|
!add_zero ▸ add_lt_add Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_nonpos_of_lt (Ha : a ≤ 0) (Hbc : b < c) : a + b < c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!zero_add ▸ add_lt_add_of_le_of_lt Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_lt_of_nonpos (Hbc : b < c) (Ha : a ≤ 0) : b + a < c :=
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_zero ▸ add_lt_add_of_lt_of_le Hbc Ha
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_neg_of_lt (Ha : a < 0) (Hbc : b < c) : a + b < c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
!zero_add ▸ add_lt_add Ha Hbc
|
2014-11-30 13:31:34 +00:00
|
|
|
|
|
|
|
theorem add_lt_of_lt_of_neg (Hbc : b < c) (Ha : a < 0) : b + a < c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
!add_zero ▸ add_lt_add Hbc Ha
|
2014-11-17 20:19:46 +00:00
|
|
|
end
|
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
/- partially ordered groups -/
|
2014-11-17 20:19:46 +00:00
|
|
|
|
|
|
|
structure ordered_comm_group [class] (A : Type) extends add_comm_group A, order_pair A :=
|
2014-12-12 23:22:19 +00:00
|
|
|
(add_le_add_left : ∀a b, le a b → ∀c, le (add c a) (add c b))
|
2015-05-29 03:33:45 +00:00
|
|
|
(add_lt_add_left : ∀a b, lt a b → ∀ c, lt (add c a) (add c b))
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2015-01-19 21:00:24 +00:00
|
|
|
theorem ordered_comm_group.le_of_add_le_add_left [s : ordered_comm_group A] {a b c : A} (H : a + b ≤ a + c) : b ≤ c :=
|
2015-02-25 22:30:42 +00:00
|
|
|
assert H' : -a + (a + b) ≤ -a + (a + c), from ordered_comm_group.add_le_add_left _ _ H _,
|
2015-02-09 01:35:28 +00:00
|
|
|
by rewrite *neg_add_cancel_left at H'; exact H'
|
2015-01-19 21:00:24 +00:00
|
|
|
|
2015-05-29 03:33:45 +00:00
|
|
|
theorem ordered_comm_group.lt_of_add_lt_add_left [s : ordered_comm_group A] {a b c : A} (H : a + b < a + c) : b < c :=
|
|
|
|
assert H' : -a + (a + b) < -a + (a + c), from ordered_comm_group.add_lt_add_left _ _ H _,
|
|
|
|
by rewrite *neg_add_cancel_left at H'; exact H'
|
|
|
|
|
2015-06-21 19:36:43 +00:00
|
|
|
definition ordered_comm_group.to_ordered_cancel_comm_monoid [trans-instance] [coercion] [reducible]
|
2014-11-17 20:19:46 +00:00
|
|
|
[s : ordered_comm_group A] : ordered_cancel_comm_monoid A :=
|
2015-01-17 17:38:10 +00:00
|
|
|
⦃ ordered_cancel_comm_monoid, s,
|
2015-01-19 21:00:24 +00:00
|
|
|
add_left_cancel := @add.left_cancel A s,
|
|
|
|
add_right_cancel := @add.right_cancel A s,
|
2015-05-29 03:33:45 +00:00
|
|
|
le_of_add_le_add_left := @ordered_comm_group.le_of_add_le_add_left A s,
|
|
|
|
lt_of_add_lt_add_left := @ordered_comm_group.lt_of_add_lt_add_left A s⦄
|
2014-11-17 20:19:46 +00:00
|
|
|
|
2014-11-26 23:08:23 +00:00
|
|
|
section
|
|
|
|
variables [s : ordered_comm_group A] (a b c d e : A)
|
|
|
|
include s
|
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem neg_le_neg {a b : A} (H : a ≤ b) : -b ≤ -a :=
|
2014-11-30 13:31:34 +00:00
|
|
|
have H1 : 0 ≤ -a + b, from !add.left_inv ▸ !(add_le_add_left H),
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_neg_cancel_right ▸ !zero_add ▸ add_le_add_right H1 (-b)
|
2015-01-20 21:22:47 +00:00
|
|
|
|
|
|
|
theorem le_of_neg_le_neg {a b : A} (H : -b ≤ -a) : a ≤ b :=
|
|
|
|
neg_neg a ▸ neg_neg b ▸ neg_le_neg H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_le_neg_iff_le : -a ≤ -b ↔ b ≤ a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro le_of_neg_le_neg neg_le_neg
|
|
|
|
|
|
|
|
theorem nonneg_of_neg_nonpos {a : A} (H : -a ≤ 0) : 0 ≤ a :=
|
|
|
|
le_of_neg_le_neg (neg_zero⁻¹ ▸ H)
|
|
|
|
|
|
|
|
theorem neg_nonpos_of_nonneg {a : A} (H : 0 ≤ a) : -a ≤ 0 :=
|
|
|
|
neg_zero ▸ neg_le_neg H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_nonpos_iff_nonneg : -a ≤ 0 ↔ 0 ≤ a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro nonneg_of_neg_nonpos neg_nonpos_of_nonneg
|
|
|
|
|
|
|
|
theorem nonpos_of_neg_nonneg {a : A} (H : 0 ≤ -a) : a ≤ 0 :=
|
|
|
|
le_of_neg_le_neg (neg_zero⁻¹ ▸ H)
|
|
|
|
|
|
|
|
theorem neg_nonneg_of_nonpos {a : A} (H : a ≤ 0) : 0 ≤ -a :=
|
|
|
|
neg_zero ▸ neg_le_neg H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_nonneg_iff_nonpos : 0 ≤ -a ↔ a ≤ 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro nonpos_of_neg_nonneg neg_nonneg_of_nonpos
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem neg_lt_neg {a b : A} (H : a < b) : -b < -a :=
|
2014-11-30 13:31:34 +00:00
|
|
|
have H1 : 0 < -a + b, from !add.left_inv ▸ !(add_lt_add_left H),
|
2014-12-24 02:14:19 +00:00
|
|
|
!add_neg_cancel_right ▸ !zero_add ▸ add_lt_add_right H1 (-b)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2015-01-20 21:22:47 +00:00
|
|
|
theorem lt_of_neg_lt_neg {a b : A} (H : -b < -a) : a < b :=
|
|
|
|
neg_neg a ▸ neg_neg b ▸ neg_lt_neg H
|
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_lt_neg_iff_lt : -a < -b ↔ b < a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro lt_of_neg_lt_neg neg_lt_neg
|
|
|
|
|
|
|
|
theorem pos_of_neg_neg {a : A} (H : -a < 0) : 0 < a :=
|
|
|
|
lt_of_neg_lt_neg (neg_zero⁻¹ ▸ H)
|
|
|
|
|
|
|
|
theorem neg_neg_of_pos {a : A} (H : 0 < a) : -a < 0 :=
|
|
|
|
neg_zero ▸ neg_lt_neg H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_neg_iff_pos : -a < 0 ↔ 0 < a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro pos_of_neg_neg neg_neg_of_pos
|
|
|
|
|
|
|
|
theorem neg_of_neg_pos {a : A} (H : 0 < -a) : a < 0 :=
|
|
|
|
lt_of_neg_lt_neg (neg_zero⁻¹ ▸ H)
|
|
|
|
|
|
|
|
theorem neg_pos_of_neg {a : A} (H : a < 0) : 0 < -a :=
|
|
|
|
neg_zero ▸ neg_lt_neg H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem neg_pos_iff_neg : 0 < -a ↔ a < 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro neg_of_neg_pos neg_pos_of_neg
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-17 18:32:38 +00:00
|
|
|
theorem le_neg_iff_le_neg : a ≤ -b ↔ b ≤ -a := !neg_neg ▸ !neg_le_neg_iff_le
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-17 18:32:38 +00:00
|
|
|
theorem neg_le_iff_neg_le : -a ≤ b ↔ -b ≤ a := !neg_neg ▸ !neg_le_neg_iff_le
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-17 18:32:38 +00:00
|
|
|
theorem lt_neg_iff_lt_neg : a < -b ↔ b < -a := !neg_neg ▸ !neg_lt_neg_iff_lt
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-17 18:32:38 +00:00
|
|
|
theorem neg_lt_iff_neg_lt : -a < b ↔ -b < a := !neg_neg ▸ !neg_lt_neg_iff_lt
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_nonneg_iff_le : 0 ≤ a - b ↔ b ≤ a := !sub_self ▸ !add_le_add_right_iff
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_nonpos_iff_le : a - b ≤ 0 ↔ a ≤ b := !sub_self ▸ !add_le_add_right_iff
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_pos_iff_lt : 0 < a - b ↔ b < a := !sub_self ▸ !add_lt_add_right_iff
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_neg_iff_lt : a - b < 0 ↔ a < b := !sub_self ▸ !add_lt_add_right_iff
|
2014-11-26 23:08:23 +00:00
|
|
|
|
|
|
|
theorem add_le_iff_le_neg_add : a + b ≤ c ↔ b ≤ -a + c :=
|
2014-11-30 13:31:34 +00:00
|
|
|
have H: a + b ≤ c ↔ -a + (a + b) ≤ -a + c, from iff.symm (!add_le_add_left_iff),
|
2014-11-26 23:08:23 +00:00
|
|
|
!neg_add_cancel_left ▸ H
|
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem add_le_iff_le_sub_left : a + b ≤ c ↔ b ≤ c - a :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite [sub_eq_add_neg, {c+_}add.comm]; apply add_le_iff_le_neg_add
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem add_le_iff_le_sub_right : a + b ≤ c ↔ a ≤ c - b :=
|
|
|
|
have H: a + b ≤ c ↔ a + b - b ≤ c - b, from iff.symm (!add_le_add_right_iff),
|
2014-11-26 23:08:23 +00:00
|
|
|
!add_neg_cancel_right ▸ H
|
|
|
|
|
|
|
|
theorem le_add_iff_neg_add_le : a ≤ b + c ↔ -b + a ≤ c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H: a ≤ b + c ↔ -b + a ≤ -b + (b + c), from iff.symm (!add_le_add_left_iff),
|
|
|
|
by rewrite neg_add_cancel_left at H; exact H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem le_add_iff_sub_left_le : a ≤ b + c ↔ a - b ≤ c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite [sub_eq_add_neg, {a+_}add.comm]; apply le_add_iff_neg_add_le
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem le_add_iff_sub_right_le : a ≤ b + c ↔ a - c ≤ b :=
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H: a ≤ b + c ↔ a - c ≤ b + c - c, from iff.symm (!add_le_add_right_iff),
|
|
|
|
by rewrite add_neg_cancel_right at H; exact H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2015-06-09 06:14:21 +00:00
|
|
|
theorem le_add_iff_neg_add_le_left : a ≤ b + c ↔ -b + a ≤ c :=
|
|
|
|
assert H: a ≤ b + c ↔ -b + a ≤ -b + (b + c), from iff.symm (!add_le_add_left_iff),
|
|
|
|
by rewrite neg_add_cancel_left at H; exact H
|
|
|
|
|
|
|
|
theorem le_add_iff_neg_add_le_right : a ≤ b + c ↔ -c + a ≤ b :=
|
|
|
|
by rewrite add.comm; apply le_add_iff_neg_add_le_left
|
|
|
|
|
|
|
|
theorem le_add_iff_neg_le_sub_left : c ≤ a + b ↔ -a ≤ b - c :=
|
|
|
|
assert H : c ≤ a + b ↔ -a + c ≤ b, from !le_add_iff_neg_add_le,
|
|
|
|
assert H' : -a + c ≤ b ↔ -a ≤ b - c, from !add_le_iff_le_sub_right,
|
|
|
|
iff.trans H H'
|
|
|
|
|
|
|
|
theorem le_add_iff_neg_le_sub_right : c ≤ a + b ↔ -b ≤ a - c :=
|
|
|
|
by rewrite add.comm; apply le_add_iff_neg_le_sub_left
|
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_iff_lt_neg_add_left : a + b < c ↔ b < -a + c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H: a + b < c ↔ -a + (a + b) < -a + c, from iff.symm (!add_lt_add_left_iff),
|
|
|
|
begin rewrite neg_add_cancel_left at H, exact H end
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem add_lt_iff_lt_neg_add_right : a + b < c ↔ a < -b + c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite add.comm; apply add_lt_iff_lt_neg_add_left
|
2014-12-26 21:25:05 +00:00
|
|
|
|
|
|
|
theorem add_lt_iff_lt_sub_left : a + b < c ↔ b < c - a :=
|
2015-03-01 19:38:27 +00:00
|
|
|
begin
|
|
|
|
rewrite [sub_eq_add_neg, {c+_}add.comm],
|
|
|
|
apply add_lt_iff_lt_neg_add_left
|
|
|
|
end
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem add_lt_add_iff_lt_sub_right : a + b < c ↔ a < c - b :=
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H: a + b < c ↔ a + b - b < c - b, from iff.symm (!add_lt_add_right_iff),
|
|
|
|
by rewrite add_neg_cancel_right at H; exact H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_add_iff_neg_add_lt_left : a < b + c ↔ -b + a < c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H: a < b + c ↔ -b + a < -b + (b + c), from iff.symm (!add_lt_add_left_iff),
|
|
|
|
by rewrite neg_add_cancel_left at H; exact H
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_add_iff_neg_add_lt_right : a < b + c ↔ -c + a < b :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite add.comm; apply lt_add_iff_neg_add_lt_left
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem lt_add_iff_sub_lt_left : a < b + c ↔ a - b < c :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite [sub_eq_add_neg, {a + _}add.comm]; apply lt_add_iff_neg_add_lt_left
|
2014-12-26 21:25:05 +00:00
|
|
|
|
|
|
|
theorem lt_add_iff_sub_lt_right : a < b + c ↔ a - c < b :=
|
2015-03-01 19:38:27 +00:00
|
|
|
by rewrite add.comm; apply lt_add_iff_sub_lt_left
|
2014-11-26 23:08:23 +00:00
|
|
|
|
|
|
|
-- TODO: the Isabelle library has varations on a + b ≤ b ↔ a ≤ 0
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem le_iff_le_of_sub_eq_sub {a b c d : A} (H : a - b = c - d) : a ≤ b ↔ c ≤ d :=
|
2014-11-26 23:08:23 +00:00
|
|
|
calc
|
2015-03-01 18:09:46 +00:00
|
|
|
a ≤ b ↔ a - b ≤ 0 : iff.symm (sub_nonpos_iff_le a b)
|
2015-03-01 19:38:27 +00:00
|
|
|
... = (c - d ≤ 0) : by rewrite H
|
2015-03-01 18:09:46 +00:00
|
|
|
... ↔ c ≤ d : sub_nonpos_iff_le c d
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem lt_iff_lt_of_sub_eq_sub {a b c d : A} (H : a - b = c - d) : a < b ↔ c < d :=
|
2014-11-26 23:08:23 +00:00
|
|
|
calc
|
2015-03-01 18:09:46 +00:00
|
|
|
a < b ↔ a - b < 0 : iff.symm (sub_neg_iff_lt a b)
|
2015-03-01 19:38:27 +00:00
|
|
|
... = (c - d < 0) : by rewrite H
|
2015-03-01 18:09:46 +00:00
|
|
|
... ↔ c < d : sub_neg_iff_lt c d
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_le_sub_left {a b : A} (H : a ≤ b) (c : A) : c - b ≤ c - a :=
|
2014-12-26 21:25:05 +00:00
|
|
|
add_le_add_left (neg_le_neg H) c
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_le_sub_right {a b : A} (H : a ≤ b) (c : A) : a - c ≤ b - c := add_le_add_right H (-c)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_le_sub {a b c d : A} (Hab : a ≤ b) (Hcd : c ≤ d) : a - d ≤ b - c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
add_le_add Hab (neg_le_neg Hcd)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_lt_sub_left {a b : A} (H : a < b) (c : A) : c - b < c - a :=
|
2014-12-26 21:25:05 +00:00
|
|
|
add_lt_add_left (neg_lt_neg H) c
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_lt_sub_right {a b : A} (H : a < b) (c : A) : a - c < b - c := add_lt_add_right H (-c)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-12-26 21:25:05 +00:00
|
|
|
theorem sub_lt_sub {a b c d : A} (Hab : a < b) (Hcd : c < d) : a - d < b - c :=
|
|
|
|
add_lt_add Hab (neg_lt_neg Hcd)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_lt_sub_of_le_of_lt {a b c d : A} (Hab : a ≤ b) (Hcd : c < d) : a - d < b - c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
add_lt_add_of_le_of_lt Hab (neg_lt_neg Hcd)
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-30 13:31:34 +00:00
|
|
|
theorem sub_lt_sub_of_lt_of_le {a b c d : A} (Hab : a < b) (Hcd : c ≤ d) : a - d < b - c :=
|
2014-12-26 21:25:05 +00:00
|
|
|
add_lt_add_of_lt_of_le Hab (neg_le_neg Hcd)
|
2015-02-25 19:14:57 +00:00
|
|
|
|
|
|
|
theorem sub_le_self (a : A) {b : A} (H : b ≥ 0) : a - b ≤ a :=
|
|
|
|
calc
|
|
|
|
a - b = a + -b : rfl
|
|
|
|
... ≤ a + 0 : add_le_add_left (neg_nonpos_of_nonneg H)
|
2015-03-01 19:38:27 +00:00
|
|
|
... = a : by rewrite add_zero
|
2015-02-25 19:14:57 +00:00
|
|
|
|
|
|
|
theorem sub_lt_self (a : A) {b : A} (H : b > 0) : a - b < a :=
|
|
|
|
calc
|
|
|
|
a - b = a + -b : rfl
|
|
|
|
... < a + 0 : add_lt_add_left (neg_neg_of_pos H)
|
2015-03-01 19:38:27 +00:00
|
|
|
... = a : by rewrite add_zero
|
2015-06-09 06:14:21 +00:00
|
|
|
|
|
|
|
theorem add_le_add_three {a b c d e f : A} (H1 : a ≤ d) (H2 : b ≤ e) (H3 : c ≤ f) :
|
2015-06-16 08:32:53 +00:00
|
|
|
a + b + c ≤ d + e + f :=
|
2015-06-09 06:14:21 +00:00
|
|
|
begin
|
|
|
|
apply le.trans,
|
|
|
|
apply add_le_add,
|
|
|
|
apply add_le_add,
|
|
|
|
repeat assumption,
|
|
|
|
apply le.refl
|
|
|
|
end
|
|
|
|
|
2015-06-16 08:32:53 +00:00
|
|
|
theorem sub_le_of_nonneg (H : b ≥ 0) : a - b ≤ a :=
|
|
|
|
add_le_of_le_of_nonpos (le.refl a) (neg_nonpos_of_nonneg H)
|
2015-08-03 19:01:32 +00:00
|
|
|
|
|
|
|
theorem neg_add_neg_le_neg_of_pos {a : A} (H : a > 0) : -a + -a ≤ -a :=
|
|
|
|
!neg_add ▸ neg_le_neg (le_add_of_nonneg_left (le_of_lt H))
|
2014-11-26 23:08:23 +00:00
|
|
|
end
|
|
|
|
|
2015-06-29 03:59:34 +00:00
|
|
|
/- partially ordered groups with min and max -/
|
|
|
|
|
|
|
|
structure lattice_ordered_comm_group [class] (A : Type)
|
|
|
|
extends ordered_comm_group A, lattice A
|
|
|
|
|
|
|
|
section
|
|
|
|
variables [s : lattice_ordered_comm_group A]
|
|
|
|
variables (a b c : A)
|
|
|
|
include s
|
|
|
|
|
|
|
|
theorem min_add_add_left : min (a + b) (a + c) = a + min b c :=
|
|
|
|
eq.symm (eq_min
|
|
|
|
(show a + min b c ≤ a + b, from add_le_add_left !min_le_left _)
|
|
|
|
(show a + min b c ≤ a + c, from add_le_add_left !min_le_right _)
|
|
|
|
(take d,
|
|
|
|
assume H₁ : d ≤ a + b,
|
|
|
|
assume H₂ : d ≤ a + c,
|
|
|
|
have H : d - a ≤ min b c,
|
|
|
|
from le_min (iff.mp !le_add_iff_sub_left_le H₁) (iff.mp !le_add_iff_sub_left_le H₂),
|
2015-07-18 09:28:53 +00:00
|
|
|
show d ≤ a + min b c, from iff.mpr !le_add_iff_sub_left_le H))
|
2015-06-29 03:59:34 +00:00
|
|
|
|
|
|
|
theorem min_add_add_right : min (a + c) (b + c) = min a b + c :=
|
|
|
|
by rewrite [add.comm a c, add.comm b c, add.comm _ c]; apply min_add_add_left
|
|
|
|
|
|
|
|
theorem max_add_add_left : max (a + b) (a + c) = a + max b c :=
|
|
|
|
eq.symm (eq_max
|
|
|
|
(add_le_add_left !le_max_left _)
|
|
|
|
(add_le_add_left !le_max_right _)
|
|
|
|
(λ d H₁ H₂,
|
|
|
|
have H : max b c ≤ d - a,
|
|
|
|
from max_le (iff.mp !add_le_iff_le_sub_left H₁) (iff.mp !add_le_iff_le_sub_left H₂),
|
2015-07-18 09:28:53 +00:00
|
|
|
show a + max b c ≤ d, from iff.mpr !add_le_iff_le_sub_left H))
|
2015-06-29 03:59:34 +00:00
|
|
|
|
|
|
|
theorem max_add_add_right : max (a + c) (b + c) = max a b + c :=
|
|
|
|
by rewrite [add.comm a c, add.comm b c, add.comm _ c]; apply max_add_add_left
|
|
|
|
|
|
|
|
theorem max_neg_neg : max (-a) (-b) = - min a b :=
|
|
|
|
eq.symm (eq_max
|
|
|
|
(show -a ≤ -(min a b), from neg_le_neg !min_le_left)
|
|
|
|
(show -b ≤ -(min a b), from neg_le_neg !min_le_right)
|
|
|
|
(take d,
|
|
|
|
assume H₁ : -a ≤ d,
|
|
|
|
assume H₂ : -b ≤ d,
|
|
|
|
have H : -d ≤ min a b,
|
|
|
|
from le_min (!iff.mp !neg_le_iff_neg_le H₁) (!iff.mp !neg_le_iff_neg_le H₂),
|
|
|
|
show -(min a b) ≤ d, from !iff.mp !neg_le_iff_neg_le H))
|
|
|
|
|
|
|
|
theorem min_eq_neg_max_neg_neg : min a b = - max (-a) (-b) :=
|
|
|
|
by rewrite [max_neg_neg, neg_neg]
|
|
|
|
|
|
|
|
theorem min_neg_neg : min (-a) (-b) = - max a b :=
|
|
|
|
by rewrite [min_eq_neg_max_neg_neg, *neg_neg]
|
|
|
|
|
|
|
|
theorem max_eq_neg_min_neg_neg : max a b = - min (-a) (-b) :=
|
|
|
|
by rewrite [min_neg_neg, neg_neg]
|
2015-06-29 04:39:36 +00:00
|
|
|
|
|
|
|
/- absolute value -/
|
|
|
|
variables {a b c}
|
|
|
|
|
|
|
|
definition abs (a : A) : A := max a (-a)
|
|
|
|
|
|
|
|
theorem abs_of_nonneg (H : a ≥ 0) : abs a = a :=
|
|
|
|
have H' : -a ≤ a, from le.trans (neg_nonpos_of_nonneg H) H,
|
|
|
|
max_eq_left H'
|
|
|
|
|
|
|
|
theorem abs_of_pos (H : a > 0) : abs a = a :=
|
|
|
|
abs_of_nonneg (le_of_lt H)
|
|
|
|
|
|
|
|
theorem abs_of_nonpos (H : a ≤ 0) : abs a = -a :=
|
|
|
|
have H' : a ≤ -a, from le.trans H (neg_nonneg_of_nonpos H),
|
|
|
|
max_eq_right H'
|
|
|
|
|
|
|
|
theorem abs_of_neg (H : a < 0) : abs a = -a := abs_of_nonpos (le_of_lt H)
|
|
|
|
|
|
|
|
theorem abs_zero : abs 0 = (0:A) := abs_of_nonneg (le.refl _)
|
|
|
|
|
|
|
|
theorem abs_neg (a : A) : abs (-a) = abs a :=
|
|
|
|
by rewrite [↑abs, max.comm, neg_neg]
|
|
|
|
|
|
|
|
theorem abs_pos_of_pos (H : a > 0) : abs a > 0 :=
|
|
|
|
by rewrite (abs_of_pos H); exact H
|
|
|
|
|
|
|
|
theorem abs_pos_of_neg (H : a < 0) : abs a > 0 :=
|
|
|
|
!abs_neg ▸ abs_pos_of_pos (neg_pos_of_neg H)
|
|
|
|
|
|
|
|
theorem abs_sub (a b : A) : abs (a - b) = abs (b - a) :=
|
|
|
|
by rewrite [-neg_sub, abs_neg]
|
|
|
|
|
|
|
|
theorem ne_zero_of_abs_ne_zero {a : A} (H : abs a ≠ 0) : a ≠ 0 :=
|
|
|
|
assume Ha, H (Ha⁻¹ ▸ abs_zero)
|
2015-06-29 03:59:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
/- linear ordered group with decidable order -/
|
|
|
|
|
2015-01-20 21:22:47 +00:00
|
|
|
structure decidable_linear_ordered_comm_group [class] (A : Type)
|
2015-05-29 03:33:45 +00:00
|
|
|
extends add_comm_group A, decidable_linear_order A :=
|
|
|
|
(add_le_add_left : ∀ a b, le a b → ∀ c, le (add c a) (add c b))
|
|
|
|
(add_lt_add_left : ∀ a b, lt a b → ∀ c, lt (add c a) (add c b))
|
|
|
|
|
|
|
|
private theorem add_le_add_left' (A : Type) (s : decidable_linear_ordered_comm_group A) (a b : A) :
|
|
|
|
a ≤ b → (∀ c : A, c + a ≤ c + b) :=
|
|
|
|
decidable_linear_ordered_comm_group.add_le_add_left a b
|
|
|
|
|
2015-06-29 03:59:34 +00:00
|
|
|
definition decidable_linear_ordered_comm_group.to_lattice_ordered_comm_group
|
|
|
|
[trans-instance] [reducible] [coercion]
|
|
|
|
(A : Type) [s : decidable_linear_ordered_comm_group A] : lattice_ordered_comm_group A :=
|
|
|
|
⦃ lattice_ordered_comm_group, s, decidable_linear_order.to_lattice,
|
|
|
|
le_of_lt := @le_of_lt A s,
|
|
|
|
add_le_add_left := add_le_add_left' A s,
|
|
|
|
lt_of_le_of_lt := @lt_of_le_of_lt A s,
|
|
|
|
lt_of_lt_of_le := @lt_of_lt_of_le A s ⦄
|
2015-01-20 21:22:47 +00:00
|
|
|
|
|
|
|
section
|
|
|
|
variables [s : decidable_linear_ordered_comm_group A]
|
|
|
|
variables {a b c d e : A}
|
|
|
|
include s
|
|
|
|
|
|
|
|
theorem eq_zero_of_neg_eq (H : -a = a) : a = 0 :=
|
|
|
|
lt.by_cases
|
|
|
|
(assume H1 : a < 0,
|
|
|
|
have H2: a > 0, from H ▸ neg_pos_of_neg H1,
|
|
|
|
absurd H1 (lt.asymm H2))
|
|
|
|
(assume H1 : a = 0, H1)
|
|
|
|
(assume H1 : a > 0,
|
|
|
|
have H2: a < 0, from H ▸ neg_neg_of_pos H1,
|
|
|
|
absurd H1 (lt.asymm H2))
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_nonneg (a : A) : abs a ≥ 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (le.total 0 a)
|
2015-02-07 02:34:41 +00:00
|
|
|
(assume H : 0 ≤ a, by rewrite (abs_of_nonneg H); exact H)
|
2015-01-20 21:22:47 +00:00
|
|
|
(assume H : a ≤ 0,
|
|
|
|
calc
|
2015-02-25 23:18:21 +00:00
|
|
|
0 ≤ -a : neg_nonneg_of_nonpos H
|
|
|
|
... = abs a : abs_of_nonpos H)
|
2015-01-20 21:22:47 +00:00
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_abs (a : A) : abs (abs a) = abs a := abs_of_nonneg !abs_nonneg
|
2015-01-20 21:22:47 +00:00
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem le_abs_self (a : A) : a ≤ abs a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (le.total 0 a)
|
|
|
|
(assume H : 0 ≤ a, abs_of_nonneg H ▸ !le.refl)
|
|
|
|
(assume H : a ≤ 0, le.trans H !abs_nonneg)
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem neg_le_abs_self (a : A) : -a ≤ abs a :=
|
2015-01-20 21:22:47 +00:00
|
|
|
!abs_neg ▸ !le_abs_self
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem eq_zero_of_abs_eq_zero (H : abs a = 0) : a = 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
have H1 : a ≤ 0, from H ▸ le_abs_self a,
|
|
|
|
have H2 : -a ≤ 0, from H ▸ abs_neg a ▸ le_abs_self (-a),
|
|
|
|
le.antisymm H1 (nonneg_of_neg_nonpos H2)
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_eq_zero_iff_eq_zero (a : A) : abs a = 0 ↔ a = 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
iff.intro eq_zero_of_abs_eq_zero (assume H, congr_arg abs H ⬝ !abs_zero)
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_pos_of_ne_zero (H : a ≠ 0) : abs a > 0 :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (lt_or_gt_of_ne H) abs_pos_of_neg abs_pos_of_pos
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs.by_cases {P : A → Prop} {a : A} (H1 : P a) (H2 : P (-a)) : P (abs a) :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (le.total 0 a)
|
|
|
|
(assume H : 0 ≤ a, (abs_of_nonneg H)⁻¹ ▸ H1)
|
|
|
|
(assume H : a ≤ 0, (abs_of_nonpos H)⁻¹ ▸ H2)
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_le_of_le_of_neg_le (H1 : a ≤ b) (H2 : -a ≤ b) : abs a ≤ b :=
|
2015-01-20 21:22:47 +00:00
|
|
|
abs.by_cases H1 H2
|
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_lt_of_lt_of_neg_lt (H1 : a < b) (H2 : -a < b) : abs a < b :=
|
2015-01-20 21:22:47 +00:00
|
|
|
abs.by_cases H1 H2
|
|
|
|
|
|
|
|
-- the triangle inequality
|
2015-04-22 02:13:19 +00:00
|
|
|
section
|
2015-02-25 23:18:21 +00:00
|
|
|
private lemma aux1 {a b : A} (H1 : a + b ≥ 0) (H2 : a ≥ 0) : abs (a + b) ≤ abs a + abs b :=
|
2015-01-20 21:22:47 +00:00
|
|
|
decidable.by_cases
|
|
|
|
(assume H3 : b ≥ 0,
|
|
|
|
calc
|
2015-02-25 23:18:21 +00:00
|
|
|
abs (a + b) ≤ abs (a + b) : le.refl
|
2015-03-01 19:38:27 +00:00
|
|
|
... = a + b : by rewrite (abs_of_nonneg H1)
|
|
|
|
... = abs a + b : by rewrite (abs_of_nonneg H2)
|
|
|
|
... = abs a + abs b : by rewrite (abs_of_nonneg H3))
|
2015-01-20 21:22:47 +00:00
|
|
|
(assume H3 : ¬ b ≥ 0,
|
2015-05-25 09:48:07 +00:00
|
|
|
assert H4 : b ≤ 0, from le_of_lt (lt_of_not_ge H3),
|
2015-01-20 21:22:47 +00:00
|
|
|
calc
|
2015-03-01 19:38:27 +00:00
|
|
|
abs (a + b) = a + b : by rewrite (abs_of_nonneg H1)
|
|
|
|
... = abs a + b : by rewrite (abs_of_nonneg H2)
|
2015-02-25 23:18:21 +00:00
|
|
|
... ≤ abs a + 0 : add_le_add_left H4
|
|
|
|
... ≤ abs a + -b : add_le_add_left (neg_nonneg_of_nonpos H4)
|
2015-03-01 19:38:27 +00:00
|
|
|
... = abs a + abs b : by rewrite (abs_of_nonpos H4))
|
2015-02-07 02:34:41 +00:00
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
private lemma aux2 {a b : A} (H1 : a + b ≥ 0) : abs (a + b) ≤ abs a + abs b :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (le.total b 0)
|
|
|
|
(assume H2 : b ≤ 0,
|
2015-02-07 02:34:41 +00:00
|
|
|
have H3 : ¬ a < 0, from
|
2015-01-20 21:22:47 +00:00
|
|
|
assume H4 : a < 0,
|
|
|
|
have H5 : a + b < 0, from !add_zero ▸ add_lt_add_of_lt_of_le H4 H2,
|
2015-05-25 09:48:07 +00:00
|
|
|
not_lt_of_ge H1 H5,
|
|
|
|
aux1 H1 (le_of_not_gt H3))
|
2015-01-20 21:22:47 +00:00
|
|
|
(assume H2 : 0 ≤ b,
|
2015-03-01 19:38:27 +00:00
|
|
|
begin
|
|
|
|
have H3 : abs (b + a) ≤ abs b + abs a,
|
|
|
|
begin
|
|
|
|
rewrite add.comm at H1,
|
2015-04-29 21:39:59 +00:00
|
|
|
exact aux1 H1 H2
|
2015-03-01 19:38:27 +00:00
|
|
|
end,
|
|
|
|
rewrite [add.comm, {abs a + _}add.comm],
|
|
|
|
exact H3
|
|
|
|
end)
|
2015-02-07 02:34:41 +00:00
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_add_le_abs_add_abs (a b : A) : abs (a + b) ≤ abs a + abs b :=
|
2015-01-20 21:22:47 +00:00
|
|
|
or.elim (le.total 0 (a + b))
|
|
|
|
(assume H2 : 0 ≤ a + b, aux2 H2)
|
|
|
|
(assume H2 : a + b ≤ 0,
|
2015-03-01 19:38:27 +00:00
|
|
|
assert H3 : -a + -b = -(a + b), by rewrite neg_add,
|
2015-07-18 09:28:53 +00:00
|
|
|
assert H4 : -(a + b) ≥ 0, from iff.mpr (neg_nonneg_iff_nonpos (a+b)) H2,
|
2015-03-01 19:38:27 +00:00
|
|
|
have H5 : -a + -b ≥ 0, begin rewrite -H3 at H4, exact H4 end,
|
2015-01-20 21:22:47 +00:00
|
|
|
calc
|
2015-02-25 23:18:21 +00:00
|
|
|
abs (a + b) = abs (-a + -b) : by rewrite [-abs_neg, neg_add]
|
2015-03-01 19:38:27 +00:00
|
|
|
... ≤ abs (-a) + abs (-b) : aux2 H5
|
2015-02-25 23:18:21 +00:00
|
|
|
... = abs a + abs b : by rewrite *abs_neg)
|
2015-01-20 21:22:47 +00:00
|
|
|
|
2015-02-25 23:18:21 +00:00
|
|
|
theorem abs_sub_abs_le_abs_sub (a b : A) : abs a - abs b ≤ abs (a - b) :=
|
|
|
|
have H1 : abs a - abs b + abs b ≤ abs (a - b) + abs b, from
|
2015-01-20 21:22:47 +00:00
|
|
|
calc
|
2015-03-01 19:38:27 +00:00
|
|
|
abs a - abs b + abs b = abs a : by rewrite sub_add_cancel
|
|
|
|
... = abs (a - b + b) : by rewrite sub_add_cancel
|
|
|
|
... ≤ abs (a - b) + abs b : abs_add_le_abs_add_abs,
|
2015-01-20 21:22:47 +00:00
|
|
|
algebra.le_of_add_le_add_right H1
|
2015-06-09 06:14:21 +00:00
|
|
|
|
2015-06-16 08:32:53 +00:00
|
|
|
theorem abs_add_three (a b c : A) : abs (a + b + c) ≤ abs a + abs b + abs c :=
|
2015-06-09 06:14:21 +00:00
|
|
|
begin
|
|
|
|
apply le.trans,
|
|
|
|
apply abs_add_le_abs_add_abs,
|
|
|
|
apply le.trans,
|
|
|
|
apply add_le_add_right,
|
|
|
|
apply abs_add_le_abs_add_abs,
|
|
|
|
apply le.refl
|
|
|
|
end
|
2015-07-28 04:49:51 +00:00
|
|
|
|
|
|
|
theorem dist_bdd_within_interval {a b lb ub : A} (H : lb < ub) (Hal : lb ≤ a) (Hau : a ≤ ub)
|
|
|
|
(Hbl : lb ≤ b) (Hbu : b ≤ ub) : abs (a - b) ≤ ub - lb :=
|
|
|
|
begin
|
|
|
|
cases (decidable.em (b ≤ a)) with [Hba, Hba],
|
|
|
|
rewrite (abs_of_nonneg (iff.mpr !sub_nonneg_iff_le Hba)),
|
|
|
|
apply sub_le_sub,
|
|
|
|
apply Hau,
|
|
|
|
apply Hbl,
|
|
|
|
rewrite [abs_of_neg (iff.mpr !sub_neg_iff_lt (lt_of_not_ge Hba)), neg_sub],
|
|
|
|
apply sub_le_sub,
|
|
|
|
apply Hbu,
|
|
|
|
apply Hal
|
|
|
|
end
|
|
|
|
|
2015-06-09 06:14:21 +00:00
|
|
|
end
|
2015-06-29 04:39:36 +00:00
|
|
|
end
|
2014-11-26 23:08:23 +00:00
|
|
|
|
2014-11-17 20:19:46 +00:00
|
|
|
end algebra
|