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 class #
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
Tags #
preorder, order, partial order, poset, linear order, chain
Alias of lt_of_le_of_lt
.
Alias of le_antisymm
.
Alias of ge_antisymm
.
Alias of lt_of_le_of_ne
.
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 le_of_le_of_eq
.
Alias of lt_of_lt_of_eq
.
Alias of le_of_eq_of_le
.
Alias of lt_of_eq_of_lt
.
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_or_gt_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 := _}
Subtype of an order #
Equations
Equations
Equations
- subtype.decidable_le = λ (a b : subtype p), decidable_of_iff (↑a ≤ ↑b) _
Equations
- subtype.decidable_lt = λ (a b : subtype p), decidable_of_iff (↑a < ↑b) _
A subtype of a linear order is a linear order. We explicitly give the proofs of decidable equality and decidable order in order to ensure the decidability instances are all 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 := subtype.decidable_le p, decidable_eq := subtype.decidable_eq (λ (a b : α), eq.decidable a b), decidable_lt := subtype.decidable_lt p, 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 α ×ₗ β = α × β
.
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 α ×ₗ β = α × β
.)
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 #
An order is dense if there is an element between any pair of distinct elements.
Instances
- linear_ordered_field.to_densely_ordered
- order_dual.densely_ordered
- with_bot.densely_ordered
- with_top.densely_ordered
- set.densely_ordered
- sum.densely_ordered
- sum.lex.densely_ordered_of_no_max_order
- sum.lex.densely_ordered_of_no_min_order
- nonneg.densely_ordered
- nnreal.densely_ordered
- ennreal.densely_ordered
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 := _}