Comparison #
This file provides basic results about orderings and comparison in linear orders.
Definitions #
cmp_le
: Anordering
from≤
.ordering.compares
: Turns anordering
into<
and=
propositions.linear_order_of_compares
: Constructs alinear_order
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
- cmp_le x y = ite (x ≤ y) (ite (y ≤ x) ordering.eq ordering.lt) ordering.gt
theorem
cmp_le_eq_cmp
{α : Type u_1}
[preorder α]
[is_total α has_le.le]
[decidable_rel has_le.le]
[decidable_rel has_lt.lt]
(x y : α) :
@[simp]
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.gt.compares a b = (a > b)
- ordering.eq.compares a b = (a = b)
- ordering.lt.compares a b = (a < b)
theorem
ordering.compares.eq_lt
{α : Type u_1}
[preorder α]
{o : ordering}
{a b : α} :
o.compares a b → (o = ordering.lt ↔ a < b)
theorem
ordering.compares.ne_lt
{α : Type u_1}
[preorder α]
{o : ordering}
{a b : α} :
o.compares a b → (o ≠ ordering.lt ↔ b ≤ a)
theorem
ordering.compares.eq_eq
{α : Type u_1}
[preorder α]
{o : ordering}
{a b : α} :
o.compares a b → (o = ordering.eq ↔ a = b)
theorem
ordering.compares.eq_gt
{α : Type u_1}
[preorder α]
{o : ordering}
{a b : α}
(h : o.compares a b) :
o = ordering.gt ↔ b < a
theorem
ordering.compares.ne_gt
{α : Type u_1}
[preorder α]
{o : ordering}
{a b : α}
(h : o.compares a b) :
o ≠ ordering.gt ↔ a ≤ b
theorem
ordering.or_else_eq_lt
(o₁ o₂ : ordering) :
o₁.or_else o₂ = ordering.lt ↔ o₁ = ordering.lt ∨ o₁ = ordering.eq ∧ o₂ = ordering.lt
def
linear_order_of_compares
{α : Type u_1}
[preorder α]
(cmp : α → α → ordering)
(h : ∀ (a b : α), (cmp a b).compares a b) :
Generate a linear order structure from a preorder and cmp
function.
Equations
- linear_order_of_compares cmp h = {le := preorder.le _inst_1, lt := preorder.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := λ (a b : α), decidable_of_iff (cmp a b ≠ ordering.gt) _, decidable_eq := λ (a b : α), decidable_of_iff (cmp a b = ordering.eq) _, decidable_lt := λ (a b : α), decidable_of_iff (cmp a b = ordering.lt) _, max := max_default (λ (a b : α), decidable_of_iff (cmp a b ≠ ordering.gt) _), max_def := _, min := min_default (λ (a b : α), decidable_of_iff (cmp a b ≠ ordering.gt) _), min_def := _}
@[simp]
@[simp]
@[simp]
@[simp]
theorem
cmp_eq_cmp_symm
{α : Type u_1}
[linear_order α]
{x y : α}
{β : Type u_2}
[linear_order β]
{x' y' : β} :
theorem
lt_iff_lt_of_cmp_eq_cmp
{α : Type u_1}
[linear_order α]
{x y : α}
{β : Type u_2}
[linear_order β]
{x' y' : β}
(h : cmp x y = cmp x' y') :
theorem
le_iff_le_of_cmp_eq_cmp
{α : Type u_1}
[linear_order α]
{x y : α}
{β : Type u_2}
[linear_order β]
{x' y' : β}
(h : cmp x y = cmp x' y') :