mathlib documentation

order.compare

Comparison #

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

Definitions #

def cmp_le {α : Type u_1} [has_le α] [decidable_rel has_le.le] (x y : α) :

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

Equations
theorem cmp_le_swap {α : Type u_1} [has_le α] [is_total α has_le.le] [decidable_rel has_le.le] (x y : α) :
(cmp_le x y).swap = cmp_le y x
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 : α) :
cmp_le x y = cmp x y
@[simp]
def ordering.compares {α : Type u_1} [has_lt α] :
orderingα → α → Prop

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
theorem ordering.compares_swap {α : Type u_1} [has_lt α] {a b : α} {o : ordering} :
theorem ordering.compares.of_swap {α : Type u_1} [has_lt α] {a b : α} {o : ordering} :
o.swap.compares a bo.compares b a

Alias of compares_swap.

theorem ordering.compares.swap {α : Type u_1} [has_lt α] {a b : α} {o : ordering} :
o.compares b ao.swap.compares a b

Alias of compares_swap.

theorem ordering.swap_eq_iff_eq_swap {o o' : ordering} :
o.swap = o' o = o'.swap
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) :
theorem ordering.compares.ne_gt {α : Type u_1} [preorder α] {o : ordering} {a b : α} (h : o.compares a b) :
theorem ordering.compares.le_total {α : Type u_1} [preorder α] {a b : α} {o : ordering} :
o.compares a ba b b a
theorem ordering.compares.le_antisymm {α : Type u_1} [preorder α] {a b : α} {o : ordering} :
o.compares a ba bb aa = b
theorem ordering.compares.inj {α : Type u_1} [preorder α] {o₁ o₂ : ordering} {a b : α} :
o₁.compares a bo₂.compares a bo₁ = o₂
theorem ordering.compares_iff_of_compares_impl {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β] {a b : α} {a' b' : β} (h : ∀ {o : ordering}, o.compares a bo.compares a' b') (o : ordering) :
o.compares a b o.compares a' b'
theorem ordering.swap_or_else (o₁ o₂ : ordering) :
(o₁.or_else o₂).swap = o₁.swap.or_else o₂.swap
theorem order_dual.dual_compares {α : Type u_1} [has_lt α] {a b : α} {o : ordering} :
o.compares a b o.compares b a
theorem cmp_compares {α : Type u_1} [linear_order α] (a b : α) :
(cmp a b).compares a b
theorem cmp_swap {α : Type u_1} [preorder α] [decidable_rel has_lt.lt] (a b : α) :
(cmp a b).swap = cmp b a
theorem order_dual.cmp_le_flip {α : Type u_1} [has_le α] [decidable_rel has_le.le] (x y : α) :
cmp_le x y = cmp_le y x
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
@[simp]
theorem cmp_eq_lt_iff {α : Type u_1} [linear_order α] (x y : α) :
@[simp]
theorem cmp_eq_eq_iff {α : Type u_1} [linear_order α] (x y : α) :
@[simp]
theorem cmp_eq_gt_iff {α : Type u_1} [linear_order α] (x y : α) :
@[simp]
theorem cmp_self_eq_eq {α : Type u_1} [linear_order α] (x : α) :
theorem cmp_eq_cmp_symm {α : Type u_1} [linear_order α] {x y : α} {β : Type u_2} [linear_order β] {x' y' : β} :
cmp x y = cmp x' y' cmp y x = cmp y' x'
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') :
x < y 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') :
x y x' y'
theorem has_lt.lt.cmp_eq_lt {α : Type u_1} [linear_order α] {x y : α} (h : x < y) :
theorem has_lt.lt.cmp_eq_gt {α : Type u_1} [linear_order α] {x y : α} (h : x < y) :
theorem eq.cmp_eq_eq {α : Type u_1} [linear_order α] {x y : α} (h : x = y) :
theorem eq.cmp_eq_eq' {α : Type u_1} [linear_order α] {x y : α} (h : x = y) :