Basic definitions about ≤
and <
#
This file proves basic results about orders, provides extensive dot notation, defines useful order classes and allows to transfer order instances.
Type synonyms #
order_dual α
: A type synonym reversing the meaning of all inequalities.as_linear_order α
: A type synonym to promotepartial_order α
tolinear_order α
usingis_total α (≤)
.
Transfering orders #
order.preimage
,preorder.lift
: Transfers a (pre)order onβ
to an order onα
using a functionf : α → β
.partial_order.lift
,linear_order.lift
: Transfers a partial (resp., linear) order onβ
to a partial (resp., linear) order onα
using an injective functionf
.
Extra classes #
no_top_order
,no_bot_order
: An order without a maximal/minimal element.densely_ordered
: An order with no gap, i.e. for any two elementsa < b
there existsc
such thata < c < b
.
Notes #
≤
and <
are highly favored over ≥
and >
in mathlib. The reason is that we can formulate all
lemmas using ≤
/<
, and rw
has trouble unifying ≤
and ≥
. Hence choosing one direction spares
us useless duplication. This is enforced by a linter. See Note [nolint_ge] for more infos.
Dot notation is particularly useful on ≤
(has_le.le
) and <
(has_lt.lt
). To that end, we
provide many aliases to dot notation-less lemmas. For example, le_trans
is aliased with
has_le.le.trans
and can be used to construct hab.trans hbc : a ≤ c
when hab : a ≤ b
,
hbc : b ≤ c
, lt_of_le_of_lt
is aliased as has_le.le.trans_lt
and can be used to construct
hab.trans hbc : a < c
when hab : a ≤ b
, hbc : b < c
.
TODO #
- expand module docs
- automatic construction of dual definitions / theorems
See also #
algebra.order.basic
for basic lemmas about orders, and projection notation for orders
Tags #
preorder, order, partial order, poset, linear order, chain
Alias of lt_of_le_of_lt
.
Alias of le_antisymm
.
Alias of lt_of_le_of_ne
.
Alias of lt_of_le_not_le
.
Alias of lt_or_eq_of_le
.
Alias of decidable.lt_or_eq_of_le
.
Alias of lt_of_lt_of_le
.
Alias of not_le_of_lt
.
Alias of not_lt_of_le
.
Alias of decidable.eq_or_lt_of_le
.
Alias of eq_or_lt_of_le
.
Alias of eq_of_le_of_not_lt
.
Alias of eq_of_ge_of_not_gt
.
A version of ne_iff_lt_or_gt
with LHS and RHS reversed.
Given a relation R
on β
and a function f : α → β
, the preimage relation on α
is defined
by x ≤ y ↔ f x ≤ f y
. It is the unique relation on α
making f
a rel_embedding
(assuming f
is injective).
The preimage of a decidable order is decidable.
Equations
- order.preimage.decidable f s = λ (x y : α), H (f x) (f y)
Order dual #
Type synonym to equip a type with the dual order: ≤
means ≥
and <
means >
.
Equations
- order_dual α = α
Equations
- order_dual.has_le α = {le := λ (x y : α), y ≤ x}
Equations
- order_dual.has_lt α = {lt := λ (x y : α), y < x}
Equations
- order_dual.has_zero α = {zero := 0}
Equations
- order_dual.preorder α = {le := has_le.le (order_dual.has_le α), lt := has_lt.lt (order_dual.has_lt α), le_refl := _, le_trans := _, lt_iff_le_not_le := _}
Equations
- order_dual.partial_order α = {le := preorder.le (order_dual.preorder α), lt := preorder.lt (order_dual.preorder α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _}
Equations
- order_dual.linear_order α = {le := partial_order.le (order_dual.partial_order α), lt := partial_order.lt (order_dual.partial_order α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := infer_instance (λ (a b : α), has_le.le.decidable b a), decidable_eq := decidable_eq_of_decidable_le infer_instance, decidable_lt := infer_instance (λ (a b : α), has_lt.lt.decidable b a), max := min _inst_1, max_def := _, min := max _inst_1, min_def := _}
Equations
Order instances on the function space #
Equations
- pi.partial_order = {le := preorder.le pi.preorder, lt := preorder.lt pi.preorder, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _}
Lifts of order instances #
Transfer a partial_order
on β
to a partial_order
on α
using an injective
function f : α → β
. See note [reducible non-instances].
Equations
- partial_order.lift f inj = {le := preorder.le (preorder.lift f), lt := preorder.lt (preorder.lift f), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _}
Transfer a linear_order
on β
to a linear_order
on α
using an injective
function f : α → β
. See note [reducible non-instances].
Equations
- linear_order.lift f inj = {le := partial_order.le (partial_order.lift f inj), lt := partial_order.lt (partial_order.lift f inj), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := λ (x y : α), infer_instance, decidable_eq := λ (x y : α), decidable_of_iff (f x = f y) _, decidable_lt := λ (x y : α), infer_instance, max := max_default (λ (a b : α), infer_instance), max_def := _, min := min_default (λ (a b : α), infer_instance), min_def := _}
Equations
Equations
A subtype of a linear order is a linear order. We explicitly give the proof of decidable equality as the existing instance, in order to not have two instances of decidable equality that are not definitionally equal.
Equations
- subtype.linear_order p = {le := linear_order.le (linear_order.lift coe subtype.coe_injective), lt := linear_order.lt (linear_order.lift coe subtype.coe_injective), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := linear_order.decidable_le (linear_order.lift coe subtype.coe_injective), decidable_eq := subtype.decidable_eq (λ (a b : α), eq.decidable a b), decidable_lt := linear_order.decidable_lt (linear_order.lift coe subtype.coe_injective), max := max (linear_order.lift coe subtype.coe_injective), max_def := _, min := min (linear_order.lift coe subtype.coe_injective), min_def := _}
Pointwise order on α × β
#
The lexicographic order is defined in order.lexicographic
, and the instances are available via the
type synonym lex α β = α × β
.
The pointwise partial order on a product.
(The lexicographic ordering is defined in order/lexicographic.lean, and the instances are
available via the type synonym lex α β = α × β
.)
Equations
- prod.partial_order α β = {le := preorder.le (prod.preorder α β), lt := preorder.lt (prod.preorder α β), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _}
Additional order classes #
- no_top : ∀ (a : α), ∃ (a' : α), a < a'
Order without a maximal element. Sometimes called cofinal.
a : α
is a top element of α
if it is greater than or equal to any other element of α
.
This predicate is useful, e.g., to make some statements and proofs work in both cases
[order_top α]
and [no_top_order α]
.
- no_bot : ∀ (a : α), ∃ (a' : α), a' < a
Order without a minimal element. Sometimes called coinitial or dense.
a : α
is a bottom element of α
if it is less than or equal to any other element of α
.
This predicate is useful, e.g., to make some statements and proofs work in both cases
[order_bot α]
and [no_bot_order α]
.
An order is dense if there is an element between any pair of distinct elements.
Linear order from a total partial order #
Type synonym to create an instance of linear_order
from a partial_order
and
is_total α (≤)
Equations
- as_linear_order α = α
Equations
- as_linear_order.inhabited = {default := default α _inst_1}
Equations
- as_linear_order.linear_order = {le := partial_order.le _inst_1, lt := partial_order.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := classical.dec_rel has_le.le, decidable_eq := decidable_eq_of_decidable_le (classical.dec_rel has_le.le), decidable_lt := decidable_lt_of_decidable_le (classical.dec_rel has_le.le), max := max_default (λ (a b : as_linear_order α), classical.dec_rel has_le.le a b), max_def := _, min := min_default (λ (a b : as_linear_order α), classical.dec_rel has_le.le a b), min_def := _}