The areas / V04. Order and lattices
Mathlib.Order.Defs.LinearOrder
92 declarations. Mathlib docs · Source
Orders
Defines classes for linear orders and proves some basic lemmas about them.
We intentionally avoid using grind in this fundamental file to keep the proofs understandable,
rather than hiding the reasoning behind automation.
Definition of LinearOrder and lemmas about types with a linear order
theorem Ordering.Compares.match_1.congr_eq_1 E1 #
∀ {α : Type u_2} (motive : Ordering → α → α → Sort u_1) (x : Ordering) (x_1 x_2 : α)
(h_1 : (a b : α) → motive Ordering.lt a b) (h_2 : (a b : α) → motive Ordering.eq a b)
(h_3 : (a b : α) → motive Ordering.gt a b) (a b : α),
x = Ordering.lt →
x_1 = a →
x_2 = b →
(match x, x_1, x_2 with
| Ordering.lt, a, b => h_1 a b
| Ordering.eq, a, b => h_2 a b
| Ordering.gt, a, b => h_3 a b) ≍
h_1 a b
def LinearOrder.ctorIdx E1 #
{α : Type u_2} → LinearOrder α → ℕ
theorem Ordering.Compares.match_1.congr_eq_3 E1 #
∀ {α : Type u_2} (motive : Ordering → α → α → Sort u_1) (x : Ordering) (x_1 x_2 : α)
(h_1 : (a b : α) → motive Ordering.lt a b) (h_2 : (a b : α) → motive Ordering.eq a b)
(h_3 : (a b : α) → motive Ordering.gt a b) (a b : α),
x = Ordering.gt →
x_1 = a →
x_2 = b →
(match x, x_1, x_2 with
| Ordering.lt, a, b => h_1 a b
| Ordering.eq, a, b => h_2 a b
| Ordering.gt, a, b => h_3 a b) ≍
h_3 a b
theorem Ordering.Compares.match_1.congr_eq_2 E1 #
∀ {α : Type u_2} (motive : Ordering → α → α → Sort u_1) (x : Ordering) (x_1 x_2 : α)
(h_1 : (a b : α) → motive Ordering.lt a b) (h_2 : (a b : α) → motive Ordering.eq a b)
(h_3 : (a b : α) → motive Ordering.gt a b) (a b : α),
x = Ordering.eq →
x_1 = a →
x_2 = b →
(match x, x_1, x_2 with
| Ordering.lt, a, b => h_1 a b
| Ordering.eq, a, b => h_2 a b
| Ordering.gt, a, b => h_3 a b) ≍
h_2 a b
theorem LinOrd.of.injEq E0 #
∀ (carrier : Type u_2) [str : LinearOrder carrier] (carrier_1 : Type u_2) (str_1 : LinearOrder carrier_1),
(↧carrier = ↧carrier_1) = (carrier = carrier_1 ∧ str ≍ str_1)
theorem LinOrd.of.inj E1 #
∀ {carrier : Type u_2} {str : LinearOrder carrier} {carrier_1 : Type u_2} {str_1 : LinearOrder carrier_1},
↧carrier = ↧carrier_1 → carrier = carrier_1 ∧ str ≍ str_1
def LinOrd.ctorIdx E1 #
LinOrd → ℕ
def maxDefault E1 #
{α : Type u_1} → [inst : LE α] → [DecidableLE α] → α → α → α
Default definition of max.
def minDefault E1 #
{α : Type u_1} → [inst : LE α] → [DecidableLE α] → α → α → α
Default definition of min.
def tacticCompareOfLessAndEq_rfl E1 #
Lean.ParserDescr
This attempts to prove that a given instance of compare is equal to compareOfLessAndEq by
introducing the arguments and trying the following approaches in order:
- seeing if
rflworks - seeing if the
compareat hand is nonetheless essentiallycompareOfLessAndEq, but, because of implicit arguments, requires us to unfold the defs and split theifs in the definition ofcompareOfLessAndEq - seeing if we can split by cases on the arguments, then see if the defs work themselves out
(useful when
compareis defined via amatchstatement, as it is forBool)
class LinearOrder E3 #
Type u_2 → Type u_2
A linear order is reflexive, transitive, antisymmetric and total relation ≤.
We assume that every linear ordered type has decidable (≤), (<), and (=).
instance LinearOrder.toOrd E0 #
{α : Type u_2} → [self : LinearOrder α] → Ord α
instance LinearOrder.toMax E0 #
{α : Type u_2} → [self : LinearOrder α] → Max α
ctor LinearOrder.mk E0 #
{α : Type u_2} →
[toPartialOrder : PartialOrder α] →
[toMin : Min α] →
[toMax : Max α] →
[toOrd : Ord α] →
(∀ (a b : α), a ≤ b ∨ b ≤ a) →
(toDecidableLE : DecidableLE α) →
(toDecidableEq : DecidableEq α) →
(toDecidableLT : DecidableLT α) →
autoParam (∀ (a b : α), a ⊓ b = if a ≤ b then a else b) LinearOrder.min_def._autoParam →
autoParam (∀ (a b : α), a ⊔ b = if a ≤ b then b else a) LinearOrder.max_def._autoParam →
autoParam (∀ (a b : α), compare a b = compareOfLessAndEq a b)
LinearOrder.compare_eq_compareOfLessAndEq._autoParam →
LinearOrder α
instance LinearOrder.toMin E0 #
{α : Type u_2} → [self : LinearOrder α] → Min α
instance LinearOrder.toPartialOrder E0 #
{α : Type u_2} → [self : LinearOrder α] → PartialOrder α
theorem LinearOrder.le_total E2 #
∀ {α : Type u_2} [self : LinearOrder α] (a b : α), a ≤ b ∨ b ≤ a
A linear order is total.
instance LinearOrder.toDecidableLE E0 #
{α : Type u_2} → [self : LinearOrder α] → DecidableLE α
In a linearly ordered type, we assume the order relations are all decidable.
instance LinearOrder.toDecidableEq E0 #
{α : Type u_2} → [self : LinearOrder α] → DecidableEq α
In a linearly ordered type, we assume the order relations are all decidable.
instance LinearOrder.toDecidableLT E0 #
{α : Type u_2} → [self : LinearOrder α] → DecidableLT α
In a linearly ordered type, we assume the order relations are all decidable.
theorem LinearOrder.min_def E0 #
∀ {α : Type u_2} [self : LinearOrder α] (a b : α), min a b = if a ≤ b then a else b
The minimum function is equivalent to the one you get from minOfLe.
theorem LinearOrder.max_def E0 #
∀ {α : Type u_2} [self : LinearOrder α] (a b : α), max a b = if a ≤ b then b else a
The minimum function is equivalent to the one you get from maxOfLe.
theorem LinearOrder.compare_eq_compareOfLessAndEq E2 #
∀ {α : Type u_2} [self : LinearOrder α] (a b : α), compare a b = compareOfLessAndEq a b
Comparison via compare is equal to the canonical comparison given decidable < and =.
instance instIsLinearOrder_mathlib E0 #
∀ {α : Type u_1} [inst : LinearOrder α], Std.IsLinearOrder α
theorem le_total E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), a ≤ b ∨ b ≤ a
theorem le_of_not_ge E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, ¬a ≤ b → b ≤ a
theorem lt_of_not_ge E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, ¬b ≤ a → a < b
theorem lt_or_ge E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), a < b ∨ b ≤ a
theorem le_or_gt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), a ≤ b ∨ b < a
theorem gt_trichotomy E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), b < a ∨ a = b ∨ a < b
theorem lt_trichotomy E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), a < b ∨ a = b ∨ b < a
theorem le_of_not_gt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, ¬b < a → a ≤ b
theorem lt_or_gt_of_ne E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≠ b → a < b ∨ b < a
theorem gt_or_lt_of_ne E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≠ b → b < a ∨ a < b
theorem ne_iff_lt_or_gt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≠ b ↔ a < b ∨ b < a
theorem ne_iff_gt_or_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≠ b ↔ b < a ∨ a < b
theorem lt_iff_not_ge E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a < b ↔ ¬b ≤ a
theorem not_lt E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, ¬a < b ↔ b ≤ a
theorem not_le E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, ¬a ≤ b ↔ b < a
theorem le_imp_le_of_lt_imp_lt E1 #
∀ {α : Type u_2} {β : Type u_3} [inst : Preorder α] [inst_1 : LinearOrder β] {a b : α} {c d : β},
(d < c → b < a) → a ≤ b → c ≤ d
theorem min_def E0 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), min a b = if a ≤ b then a else b
theorem max_def E0 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), max a b = if a ≤ b then b else a
theorem min_ind E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α} {motive : α → Prop},
(a ≤ b → motive a) → (b ≤ a → motive b) → motive (min a b)
theorem max_ind E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α} {motive : α → Prop},
(b ≤ a → motive a) → (a ≤ b → motive b) → motive (max a b)
theorem max_le_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, max a b ≤ c ↔ a ≤ c ∧ b ≤ c
theorem le_min_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, c ≤ min a b ↔ c ≤ a ∧ c ≤ b
theorem min_le_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, min a b ≤ c ↔ a ≤ c ∨ b ≤ c
theorem le_max_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, c ≤ max a b ↔ c ≤ a ∨ c ≤ b
theorem max_lt_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, max a b < c ↔ a < c ∧ b < c
theorem lt_min_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, c < min a b ↔ c < a ∧ c < b
theorem min_lt_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, min a b < c ↔ a < c ∨ b < c
theorem lt_max_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, c < max a b ↔ c < a ∨ c < b
theorem min_le_left E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), min a b ≤ a
theorem le_max_left E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), a ≤ max a b
theorem le_max_right E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), b ≤ max a b
theorem min_le_right E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), min a b ≤ b
theorem le_min E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, c ≤ a → c ≤ b → c ≤ min a b
theorem max_le E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, a ≤ c → b ≤ c → max a b ≤ c
theorem min_comm E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), min a b = min b a
theorem max_comm E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), max a b = max b a
theorem min_def' E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), min a b = if b ≤ a then b else a
theorem max_def' E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), max a b = if b ≤ a then a else b
theorem min_assoc E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b c : α), min (min a b) c = min a (min b c)
theorem max_assoc E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b c : α), max (max a b) c = max a (max b c)
theorem max_left_comm E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b c : α), max a (max b c) = max b (max a c)
theorem min_left_comm E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b c : α), min a (min b c) = min b (min a c)
theorem min_self E0 #
∀ {α : Type u_1} [inst : LinearOrder α] (a : α), min a a = a
theorem max_self E0 #
∀ {α : Type u_1} [inst : LinearOrder α] (a : α), max a a = a
theorem max_eq_left E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, b ≤ a → max a b = a
theorem min_eq_left E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≤ b → min a b = a
theorem min_eq_right E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, b ≤ a → min a b = b
theorem max_eq_right E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a ≤ b → max a b = b
theorem min_eq_left_of_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a < b → min a b = a
theorem max_eq_left_of_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, b < a → max a b = a
theorem max_eq_right_of_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, a < b → max a b = b
theorem min_eq_right_of_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, b < a → min a b = b
theorem lt_min E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, a < b → a < c → a < min b c
theorem max_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b c : α}, b < a → c < a → max b c < a
theorem compare_lt_iff_lt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, compare a b = Ordering.lt ↔ a < b
theorem compare_eq_iff_eq E0 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, compare a b = Ordering.eq ↔ a = b
theorem compare_gt_iff_gt E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, compare a b = Ordering.gt ↔ b < a
theorem compare_le_iff_le E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, compare a b ≠ Ordering.gt ↔ a ≤ b
theorem compare_ge_iff_ge E1 #
∀ {α : Type u_1} [inst : LinearOrder α] {a b : α}, compare a b ≠ Ordering.lt ↔ b ≤ a
theorem compare_iff E0 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α) {o : Ordering}, compare a b = o ↔ o.Compares a b
theorem cmp_eq_compare E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), cmp a b = compare a b
theorem cmp_eq_compareOfLessAndEq E1 #
∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), cmp a b = compareOfLessAndEq a b
instance instLawfulBCmpCompare_mathlib E0 #
∀ {α : Type u_1} [inst : LinearOrder α], Std.LawfulBCmp compare
structure LinOrd E1 #
Type (u_2 + 1)
The category of linear orders.
This will get reused to define OrderType.
ctor LinOrd.of E0 #
(carrier : Type u_2) → [str : LinearOrder carrier] → LinOrd
Construct a bundled LinOrd from the underlying type and typeclass.
abbrev LinOrd.carrier E1 #
LinOrd → Type u_2
The underlying linearly ordered type.
instance LinOrd.str E0 #
(self : LinOrd) → LinearOrder ↑self
instance LinOrd.instCoeSortType E0 #
CoeSort LinOrd (Type u_2)