The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V04. Order and lattices

Mathlib.Algebra.Order.Sub.Defs

66 declarations. Mathlib docs · Source

Ordered Subtraction

This file proves lemmas relating (truncated) subtraction with an order. We provide a class OrderedSub stating that a - b ≤ c ↔ a ≤ c + b.

The subtraction discussed here could both be normal subtraction in an additive group or truncated subtraction on a canonically ordered monoid (ℕ, Multiset, ENNReal, ...)

Implementation notes

OrderedSub is a mixin type-class, so that we can use the results in this file even in cases where we don't have a CanonicallyOrderedAdd instance (even though that is our main focus). Conversely, this means we can use CanonicallyOrderedAdd without necessarily having to define a subtraction.

The results in this file are ordered by the type-class assumption needed to prove it. This means that similar results might not be close to each other. Furthermore, we don't prove implications if a bi-implication can be proven under the same assumptions.

Lemmas using this class are named using tsub instead of sub (short for "truncated subtraction"). This is to avoid naming conflicts with similar lemmas about ordered groups.

We provide a second version of most results that require [AddLeftReflectLE α]. In the second version we replace this type-class assumption by explicit AddLECancellable assumptions.

TODO: maybe we should make a multiplicative version of this, so that we can replace some identical lemmas about subtraction/division in Ordered[Add]CommGroup with these.

TODO: generalize Nat.le_of_le_of_sub_le_sub_right, Nat.sub_le_sub_right_iff, Nat.mul_self_sub_mul_self_eq

Preorder

Lemmas that assume that an element is AddLECancellable

Lemmas where addition is order-reflecting

Partial order

Lemmas that assume that an element is AddLECancellable.

Lemmas where addition is order-reflecting.

Lemmas in a linearly ordered monoid.

class OrderedSub E1 #

(α : Type u_2) → [LE α] → [Add α] → [Sub α] → Prop

OrderedSub α means that α has a subtraction characterized by a - b ≤ c ↔ a ≤ c + b. In other words, a - b is the least c such that a ≤ b + c.

This is satisfied both by the subtraction in additive ordered groups and by truncated subtraction in canonically ordered monoids on many specific types.

ctor OrderedSub.mk E0 #

∀ {α : Type u_2} [inst : LE α] [inst_1 : Add α] [inst_2 : Sub α], (∀ (a b c : α), a - b ≤ c ↔ a ≤ c + b) → OrderedSub α

theorem OrderedSub.tsub_le_iff_right E1 #

∀ {α : Type u_2} {inst : LE α} {inst_1 : Add α} {inst_2 : Sub α} [self : OrderedSub α] (a b c : α),
  a - b ≤ c ↔ a ≤ c + b

a - b provides a lower bound on c such that a ≤ c + b.

theorem tsub_le_iff_right E0 #

∀ {α : Type u_1} [inst : LE α] [inst_1 : Add α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}, a - b ≤ c ↔ a ≤ c + b

theorem add_tsub_le_right E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : Add α] [inst_2 : Sub α] [OrderedSub α] {a b : α}, a + b - b ≤ a

See add_tsub_cancel_right for the equality if AddLeftReflectLE α.

theorem le_tsub_add E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : Add α] [inst_2 : Sub α] [OrderedSub α] {a b : α}, b ≤ b - a + a

theorem tsub_le_iff_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  a - b ≤ c ↔ a ≤ b + c

theorem le_add_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  a ≤ b + (a - b)

theorem add_tsub_le_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  a + b - a ≤ b

See add_tsub_cancel_left for the equality if AddLeftReflectLE α.

theorem tsub_le_tsub_right E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  a ≤ b → ∀ (c : α), a - c ≤ b - c

theorem tsub_le_iff_tsub_le E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  a - b ≤ c ↔ a - c ≤ b

theorem tsub_tsub_le E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  b - (b - a) ≤ a

See tsub_tsub_cancel_of_le for the equality.

theorem tsub_le_tsub_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α}
  [AddLeftMono α], a ≤ b → ∀ (c : α), c - b ≤ c - a

theorem tsub_le_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c d : α}
  [AddLeftMono α], a ≤ b → c ≤ d → a - d ≤ b - c

theorem antitone_const_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {c : α}
  [AddLeftMono α], Antitone fun x ↦ c - x

theorem add_tsub_le_assoc E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + b - c ≤ a + (b - c)

See add_tsub_assoc_of_le for the equality.

theorem add_tsub_le_tsub_add E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + b - c ≤ a - c + b

See tsub_add_eq_add_tsub for the equality.

theorem add_le_add_add_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + b ≤ a + c + (b - c)

theorem le_tsub_add_add E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + b ≤ a - c + (b + c)

theorem tsub_le_tsub_add_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a - c ≤ a - b + (b - c)

theorem tsub_tsub_tsub_le_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], c - a - (c - b) ≤ b - a

theorem tsub_tsub_le_tsub_add E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] [AddLeftMono α]
  {a b c : α}, a - (b - c) ≤ a - b + c

theorem add_tsub_add_le_tsub_add_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c d : α}
  [AddLeftMono α], a + b - (c + d) ≤ a - c + (b - d)

See tsub_add_tsub_comm for the equality.

theorem add_tsub_add_le_tsub_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + b - (a + c) ≤ b - c

See add_tsub_add_eq_tsub_left for the equality.

theorem add_tsub_add_le_tsub_right E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], a + c - (b + c) ≤ a - b

See add_tsub_add_eq_tsub_right for the equality.

theorem AddLECancellable.le_add_tsub_swap E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  AddLECancellable b → a ≤ b + a - b

theorem AddLECancellable.le_add_tsub E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  AddLECancellable b → a ≤ a + b - b

theorem AddLECancellable.le_tsub_of_add_le_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable a → a + b ≤ c → b ≤ c - a

theorem AddLECancellable.le_tsub_of_add_le_right E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable b → a + b ≤ c → a ≤ c - b

theorem le_add_tsub_swap E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α}
  [AddLeftReflectLE α], a ≤ b + a - b

theorem le_add_tsub' E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α}
  [AddLeftReflectLE α], a ≤ a + b - b

theorem le_tsub_of_add_le_left E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a + b ≤ c → b ≤ c - a

theorem le_tsub_of_add_le_right E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a + b ≤ c → a ≤ c - b

theorem tsub_nonpos E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommMonoid α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  a - b ≤ 0 ↔ a ≤ b

theorem tsub_nonpos_of_le E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : AddCommMonoid α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  a ≤ b → a - b ≤ 0

Alias of the reverse direction of tsub_nonpos.

theorem tsub_tsub E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] (b a c : α),
  b - a - c = b - (a + c)

theorem tsub_add_eq_tsub_tsub E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] (a b c : α),
  a - (b + c) = a - b - c

theorem tsub_add_eq_tsub_tsub_swap E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] (a b c : α),
  a - (b + c) = a - c - b

theorem tsub_right_comm E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  a - b - c = a - c - b

theorem AddLECancellable.tsub_eq_of_eq_add E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable b → a = c + b → a - b = c

See AddLECancellable.tsub_eq_of_eq_add' for a version assuming that a = c + b itself is cancellable rather than b.

theorem AddLECancellable.tsub_eq_of_eq_add' E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], AddLECancellable a → a = c + b → a - b = c

Weaker version of AddLECancellable.tsub_eq_of_eq_add assuming that a = c + b itself is cancellable rather than b.

theorem AddLECancellable.tsub_eq_of_eq_add_rev E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable b → a = b + c → a - b = c

See AddLECancellable.tsub_eq_of_eq_add_rev' for a version assuming that a = b + c itself is cancellable rather than b.

theorem AddLECancellable.tsub_eq_of_eq_add_rev' E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftMono α], AddLECancellable a → a = b + c → a - b = c

Weaker version of AddLECancellable.tsub_eq_of_eq_add_rev assuming that a = b + c itself is cancellable rather than b.

theorem AddLECancellable.add_tsub_cancel_right E0 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  AddLECancellable b → a + b - b = a

theorem AddLECancellable.add_tsub_cancel_left E0 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b : α},
  AddLECancellable a → a + b - a = b

theorem AddLECancellable.lt_add_of_tsub_lt_left E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable b → a - b < c → a < b + c

theorem AddLECancellable.lt_add_of_tsub_lt_right E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable c → a - c < b → a < b + c

theorem AddLECancellable.lt_tsub_of_add_lt_right E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable c → a + c < b → a < b - c

theorem AddLECancellable.lt_tsub_of_add_lt_left E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α},
  AddLECancellable a → a + c < b → c < b - a

theorem tsub_eq_of_eq_add E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a = c + b → a - b = c

theorem tsub_eq_of_eq_add_rev E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a = b + c → a - b = c

theorem add_tsub_cancel_right E0 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α]
  [AddLeftReflectLE α] (a b : α), a + b - b = a

theorem add_tsub_cancel_left E0 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α]
  [AddLeftReflectLE α] (a b : α), a + b - a = b

theorem tsub_eq_tsub_of_add_eq_add E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c d : α}
  [AddLeftReflectLE α], a + d = c + b → a - b = c - d

A more general version of the reverse direction of sub_eq_sub_iff_add_eq_add

theorem lt_add_of_tsub_lt_left E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a - b < c → a < b + c

theorem lt_add_of_tsub_lt_right E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a - c < b → a < b + c

theorem lt_tsub_of_add_lt_left E2 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a + c < b → c < b - a

This lemma (and some of its corollaries) also holds for ENNReal, but this proof doesn't work for it. Maybe we should add this lemma as field to OrderedSub?

theorem lt_tsub_of_add_lt_right E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] {a b c : α}
  [AddLeftReflectLE α], a + c < b → a < b - c

theorem add_tsub_add_eq_tsub_right E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] [AddLeftMono α]
  [AddLeftReflectLE α] (a c b : α), a + c - (b + c) = a - b

theorem add_tsub_add_eq_tsub_left E1 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α] [AddLeftMono α]
  [AddLeftReflectLE α] (a b c : α), a + b - (a + c) = b - c

theorem lt_of_tsub_lt_tsub_right E1 #

∀ {α : Type u_1} {a b c : α} [inst : LinearOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α],
  a - c < b - c → a < b

See lt_of_tsub_lt_tsub_right_of_le for a weaker statement in a partial order.

theorem lt_tsub_iff_right E1 #

∀ {α : Type u_1} {a b c : α} [inst : LinearOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α],
  a < b - c ↔ a + c < b

See lt_tsub_iff_right_of_le for a weaker statement in a partial order.

theorem lt_tsub_iff_left E1 #

∀ {α : Type u_1} {a b c : α} [inst : LinearOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α],
  a < b - c ↔ c + a < b

See lt_tsub_iff_left_of_le for a weaker statement in a partial order.

theorem lt_tsub_comm E1 #

∀ {α : Type u_1} {a b c : α} [inst : LinearOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α],
  a < b - c ↔ c < b - a

theorem lt_of_tsub_lt_tsub_left E1 #

∀ {α : Type u_1} {a b c : α} [inst : LinearOrder α] [inst_1 : AddCommSemigroup α] [inst_2 : Sub α] [OrderedSub α]
  [AddLeftMono α], a - b < a - c → c < b

See lt_of_tsub_lt_tsub_left_of_le for a weaker statement in a partial order.

theorem tsub_zero E0 #

∀ {α : Type u_1} [inst : PartialOrder α] [inst_1 : AddCommMonoid α] [inst_2 : Sub α] [OrderedSub α] (a : α), a - 0 = a