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.Order.Compare

34 declarations. Mathlib docs · Source

Comparison

This file provides basic results about orderings and comparison in linear orders.

Definitions

  • CmpLE: An Ordering from ≤.
  • Ordering.Compares: Turns an Ordering into < and = propositions.
  • linearOrderOfCompares: Constructs a LinearOrder instance from the fact that any two elements that are not one strictly less than the other either way are equal.

def cmpLE E1 #

{α : Type u_3} → [inst : LE α] → [DecidableLE α] → α → α → Ordering

Like cmp, but uses a ≤ on the type instead of <. Given two elements x and y, returns a three-way comparison result Ordering.

theorem cmpLE_swap E1 #

∀ {α : Type u_3} [inst : LE α] [Std.Total fun x1 x2 ↦ x1 ≤ x2] [inst_2 : DecidableLE α] (x y : α),
  (cmpLE x y).swap = cmpLE y x

theorem cmpLE_eq_cmp E1 #

∀ {α : Type u_3} [inst : Preorder α] [Std.Total fun x1 x2 ↦ x1 ≤ x2] [inst_2 : DecidableLE α] [inst_3 : DecidableLT α]
  (x y : α), cmpLE x y = cmp x y

theorem Ordering.compares_swap E1 #

∀ {α : Type u_1} [inst : LT α] {a b : α} {o : Ordering}, o.swap.Compares a b ↔ o.Compares b a

theorem Ordering.Compares.swap E1 #

∀ {α : Type u_1} [inst : LT α] {a b : α} {o : Ordering}, o.Compares b a → o.swap.Compares a b

Alias of the reverse direction of Ordering.compares_swap.

theorem Ordering.Compares.of_swap E1 #

∀ {α : Type u_1} [inst : LT α] {a b : α} {o : Ordering}, o.swap.Compares a b → o.Compares b a

Alias of the forward direction of Ordering.compares_swap.

theorem Ordering.swap_eq_iff_eq_swap E1 #

∀ {o o' : Ordering}, o.swap = o' ↔ o = o'.swap

theorem Ordering.Compares.ne_lt E1 #

∀ {α : Type u_1} [inst : Preorder α] {o : Ordering} {a b : α}, o.Compares a b → (o ≠ Ordering.lt ↔ b ≤ a)

theorem Ordering.Compares.ne_gt E1 #

∀ {α : Type u_1} [inst : Preorder α] {o : Ordering} {a b : α}, o.Compares a b → (o ≠ Ordering.gt ↔ a ≤ b)

theorem Ordering.Compares.le_total E1 #

∀ {α : Type u_1} [inst : Preorder α] {a b : α} {o : Ordering}, o.Compares a b → a ≤ b ∨ b ≤ a

theorem Ordering.Compares.le_antisymm E1 #

∀ {α : Type u_1} [inst : Preorder α] {a b : α} {o : Ordering}, o.Compares a b → a ≤ b → b ≤ a → a = b

theorem Ordering.Compares.inj E1 #

∀ {α : Type u_1} [inst : Preorder α] {o₁ o₂ : Ordering} {a b : α}, o₁.Compares a b → o₂.Compares a b → o₁ = o₂

theorem Ordering.compares_iff_of_compares_impl E1 #

∀ {α : Type u_1} {β : Type u_2} [inst : LinearOrder α] [inst_1 : Preorder β] {a b : α} {a' b' : β},
  (∀ {o : Ordering}, o.Compares a b → o.Compares a' b') → ∀ (o : Ordering), o.Compares a b ↔ o.Compares a' b'

theorem toDual_compares_toDual E0 #

∀ {α : Type u_1} [inst : LT α] {a b : α} {o : Ordering},
  o.Compares (OrderDual.toDual a) (OrderDual.toDual b) ↔ o.Compares b a

theorem ofDual_compares_ofDual E0 #

∀ {α : Type u_1} [inst : LT α] {a b : αᵒᵈ} {o : Ordering},
  o.Compares (OrderDual.ofDual a) (OrderDual.ofDual b) ↔ o.Compares b a

theorem cmp_compares E1 #

∀ {α : Type u_1} [inst : LinearOrder α] (a b : α), (cmp a b).Compares a b

theorem Ordering.Compares.cmp_eq E0 #

∀ {α : Type u_1} [inst : LinearOrder α] {a b : α} {o : Ordering}, o.Compares a b → cmp a b = o

theorem cmp_swap E0 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : DecidableLT α] (a b : α), (cmp a b).swap = cmp b a

theorem cmpLE_toDual E0 #

∀ {α : Type u_1} [inst : LE α] [inst_1 : DecidableLE α] (x y : α),
  cmpLE (OrderDual.toDual x) (OrderDual.toDual y) = cmpLE y x

theorem cmpLE_ofDual E0 #

∀ {α : Type u_1} [inst : LE α] [inst_1 : DecidableLE α] (x y : αᵒᵈ),
  cmpLE (OrderDual.ofDual x) (OrderDual.ofDual y) = cmpLE y x

theorem cmp_toDual E0 #

∀ {α : Type u_1} [inst : LT α] [inst_1 : DecidableLT α] (x y : α),
  cmp (OrderDual.toDual x) (OrderDual.toDual y) = cmp y x

theorem cmp_ofDual E0 #

∀ {α : Type u_1} [inst : LT α] [inst_1 : DecidableLT α] (x y : αᵒᵈ),
  cmp (OrderDual.ofDual x) (OrderDual.ofDual y) = cmp y x

def linearOrderOfCompares E1 #

{α : Type u_1} → [inst : Preorder α] → (cmp : α → α → Ordering) → (∀ (a b : α), (cmp a b).Compares a b) → LinearOrder α

Generate a linear order structure from a preorder and cmp function.

theorem cmp_eq_lt_iff E0 #

∀ {α : Type u_1} [inst : LinearOrder α] (x y : α), cmp x y = Ordering.lt ↔ x < y

theorem cmp_eq_eq_iff E0 #

∀ {α : Type u_1} [inst : LinearOrder α] (x y : α), cmp x y = Ordering.eq ↔ x = y

theorem cmp_eq_gt_iff E0 #

∀ {α : Type u_1} [inst : LinearOrder α] (x y : α), cmp x y = Ordering.gt ↔ y < x

theorem cmp_self_eq_eq E0 #

∀ {α : Type u_1} [inst : LinearOrder α] (x : α), cmp x x = Ordering.eq

theorem cmp_eq_cmp_symm E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α} {β : Type u_3} [inst_1 : LinearOrder β] {x' y' : β},
  cmp x y = cmp x' y' ↔ cmp y x = cmp y' x'

theorem lt_iff_lt_of_cmp_eq_cmp E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α} {β : Type u_3} [inst_1 : LinearOrder β] {x' y' : β},
  cmp x y = cmp x' y' → (x < y ↔ x' < y')

theorem le_iff_le_of_cmp_eq_cmp E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α} {β : Type u_3} [inst_1 : LinearOrder β] {x' y' : β},
  cmp x y = cmp x' y' → (x ≤ y ↔ x' ≤ y')

theorem LT.lt.cmp_eq_lt E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α}, x < y → cmp x y = Ordering.lt

theorem LT.lt.cmp_eq_gt E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α}, x < y → cmp y x = Ordering.gt

theorem Eq.cmp_eq_eq E0 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α}, x = y → cmp x y = Ordering.eq

theorem Eq.cmp_eq_eq' E1 #

∀ {α : Type u_1} [inst : LinearOrder α] {x y : α}, x = y → cmp y x = Ordering.eq