Comparison #
This file provides basic results about orderings and comparison in linear orders.
Definitions #
CmpLE
: AnOrdering
from≤
.Ordering.Compares
: Turns anOrdering
into<
and=
propositions.linearOrderOfCompares
: Constructs aLinearOrder
instance from the fact that any two elements that are not one strictly less than the other either way are equal.
Like cmp
, but uses a ≤
on the type instead of <
. Given two elements x
and y
, returns a
three-way comparison result Ordering
.
Equations
- cmpLE x y = if x ≤ y then if y ≤ x then Ordering.eq else Ordering.lt else Ordering.gt
Instances For
theorem
cmpLE_swap
{α : Type u_3}
[LE α]
[IsTotal α fun x x_1 => x ≤ x_1]
[DecidableRel fun x x_1 => x ≤ x_1]
(x : α)
(y : α)
:
Ordering.swap (cmpLE x y) = cmpLE y x
theorem
cmpLE_eq_cmp
{α : Type u_3}
[Preorder α]
[IsTotal α fun x x_1 => x ≤ x_1]
[DecidableRel fun x x_1 => x ≤ x_1]
[DecidableRel fun x x_1 => x < x_1]
(x : α)
(y : α)
:
Compares o a b
means that a
and b
have the ordering relation o
between them, assuming
that the relation a < b
is defined.
Equations
- Ordering.Compares x x x = match x, x, x with | Ordering.lt, a, b => a < b | Ordering.eq, a, b => a = b | Ordering.gt, a, b => a > b
Instances For
@[simp]
theorem
Ordering.compares_lt
{α : Type u_1}
[LT α]
(a : α)
(b : α)
:
Ordering.Compares Ordering.lt a b = (a < b)
@[simp]
theorem
Ordering.compares_eq
{α : Type u_1}
[LT α]
(a : α)
(b : α)
:
Ordering.Compares Ordering.eq a b = (a = b)
@[simp]
theorem
Ordering.compares_gt
{α : Type u_1}
[LT α]
(a : α)
(b : α)
:
Ordering.Compares Ordering.gt a b = (a > b)
theorem
Ordering.compares_swap
{α : Type u_1}
[LT α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares (Ordering.swap o) a b ↔ Ordering.Compares o b a
theorem
Ordering.Compares.swap
{α : Type u_1}
[LT α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares o b a → Ordering.Compares (Ordering.swap o) a b
Alias of the reverse direction of Ordering.compares_swap
.
theorem
Ordering.Compares.of_swap
{α : Type u_1}
[LT α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares (Ordering.swap o) a b → Ordering.Compares o b a
Alias of the forward direction of Ordering.compares_swap
.
theorem
Ordering.swap_eq_iff_eq_swap
{o : Ordering}
{o' : Ordering}
:
Ordering.swap o = o' ↔ o = Ordering.swap o'
theorem
Ordering.Compares.eq_lt
{α : Type u_1}
[Preorder α]
{o : Ordering}
{a : α}
{b : α}
:
Ordering.Compares o a b → (o = Ordering.lt ↔ a < b)
theorem
Ordering.Compares.ne_lt
{α : Type u_1}
[Preorder α]
{o : Ordering}
{a : α}
{b : α}
:
Ordering.Compares o a b → (o ≠ Ordering.lt ↔ b ≤ a)
theorem
Ordering.Compares.eq_eq
{α : Type u_1}
[Preorder α]
{o : Ordering}
{a : α}
{b : α}
:
Ordering.Compares o a b → (o = Ordering.eq ↔ a = b)
theorem
Ordering.Compares.eq_gt
{α : Type u_1}
[Preorder α]
{o : Ordering}
{a : α}
{b : α}
(h : Ordering.Compares o a b)
:
o = Ordering.gt ↔ b < a
theorem
Ordering.Compares.ne_gt
{α : Type u_1}
[Preorder α]
{o : Ordering}
{a : α}
{b : α}
(h : Ordering.Compares o a b)
:
o ≠ Ordering.gt ↔ a ≤ b
theorem
Ordering.Compares.le_total
{α : Type u_1}
[Preorder α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares o a b → a ≤ b ∨ b ≤ a
theorem
Ordering.Compares.le_antisymm
{α : Type u_1}
[Preorder α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares o a b → a ≤ b → b ≤ a → a = b
theorem
Ordering.Compares.inj
{α : Type u_1}
[Preorder α]
{o₁ : Ordering}
{o₂ : Ordering}
{a : α}
{b : α}
:
Ordering.Compares o₁ a b → Ordering.Compares o₂ a b → o₁ = o₂
theorem
Ordering.compares_iff_of_compares_impl
{α : Type u_1}
{β : Type u_2}
[LinearOrder α]
[Preorder β]
{a : α}
{b : α}
{a' : β}
{b' : β}
(h : ∀ {o : Ordering}, Ordering.Compares o a b → Ordering.Compares o a' b')
(o : Ordering)
:
Ordering.Compares o a b ↔ Ordering.Compares o a' b'
theorem
Ordering.swap_orElse
(o₁ : Ordering)
(o₂ : Ordering)
:
Ordering.swap (Ordering.orElse o₁ o₂) = Ordering.orElse (Ordering.swap o₁) (Ordering.swap o₂)
theorem
Ordering.orElse_eq_lt
(o₁ : Ordering)
(o₂ : Ordering)
:
Ordering.orElse o₁ o₂ = Ordering.lt ↔ o₁ = Ordering.lt ∨ o₁ = Ordering.eq ∧ o₂ = Ordering.lt
@[simp]
theorem
toDual_compares_toDual
{α : Type u_1}
[LT α]
{a : α}
{b : α}
{o : Ordering}
:
Ordering.Compares o (↑OrderDual.toDual a) (↑OrderDual.toDual b) ↔ Ordering.Compares o b a
@[simp]
theorem
ofDual_compares_ofDual
{α : Type u_1}
[LT α]
{a : αᵒᵈ}
{b : αᵒᵈ}
{o : Ordering}
:
Ordering.Compares o (↑OrderDual.ofDual a) (↑OrderDual.ofDual b) ↔ Ordering.Compares o b a
theorem
cmp_compares
{α : Type u_1}
[LinearOrder α]
(a : α)
(b : α)
:
Ordering.Compares (cmp a b) a b
theorem
Ordering.Compares.cmp_eq
{α : Type u_1}
[LinearOrder α]
{a : α}
{b : α}
{o : Ordering}
(h : Ordering.Compares o a b)
:
@[simp]
theorem
cmp_swap
{α : Type u_1}
[Preorder α]
[DecidableRel fun x x_1 => x < x_1]
(a : α)
(b : α)
:
Ordering.swap (cmp a b) = cmp b a
@[simp]
@[simp]
def
linearOrderOfCompares
{α : Type u_1}
[Preorder α]
(cmp : α → α → Ordering)
(h : ∀ (a b : α), Ordering.Compares (cmp a b) a b)
:
Generate a linear order structure from a preorder and cmp
function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem
cmp_eq_lt_iff
{α : Type u_1}
[LinearOrder α]
(x : α)
(y : α)
:
cmp x y = Ordering.lt ↔ x < y
@[simp]
@[simp]
theorem
cmp_eq_gt_iff
{α : Type u_1}
[LinearOrder α]
(x : α)
(y : α)
:
cmp x y = Ordering.gt ↔ y < x
theorem
cmp_eq_cmp_symm
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
{β : Type u_3}
[LinearOrder β]
{x' : β}
{y' : β}
:
theorem
lt_iff_lt_of_cmp_eq_cmp
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
{β : Type u_3}
[LinearOrder β]
{x' : β}
{y' : β}
(h : cmp x y = cmp x' y')
:
theorem
le_iff_le_of_cmp_eq_cmp
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
{β : Type u_3}
[LinearOrder β]
{x' : β}
{y' : β}
(h : cmp x y = cmp x' y')
:
theorem
eq_iff_eq_of_cmp_eq_cmp
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
{β : Type u_3}
[LinearOrder β]
{x' : β}
{y' : β}
(h : cmp x y = cmp x' y')
:
theorem
LT.lt.cmp_eq_lt
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
(h : x < y)
:
cmp x y = Ordering.lt
theorem
LT.lt.cmp_eq_gt
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
(h : x < y)
:
cmp y x = Ordering.gt
theorem
Eq.cmp_eq_eq
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
(h : x = y)
:
cmp x y = Ordering.eq
theorem
Eq.cmp_eq_eq'
{α : Type u_1}
[LinearOrder α]
{x : α}
{y : α}
(h : x = y)
:
cmp y x = Ordering.eq