Order-related typeclasses #
This module provides the typeclasses used to state that basic operations on some type α
reflect a certain well-behaved order structure on α.
The basic operations are provided by the typeclasses LE α, LT α, BEq α, Ord α, Min α and
Max α.
All of them describe at least some way to compare elements in α. Usually, any subset of them
is available and one can/must show that these comparisons are well-behaved in some sense.
For example, one could merely require that the available operations reflect a preorder (where the less-or-equal relation only needs to be reflexive and transitive). Alternatively, one could require a full linear order (additionally requiring antisymmetry and totality of the less-or-equal relation).
There are many ways to characterize, say, linear orders:
(· ≤ ·)is reflexive, transitive, antisymmetric and total.(· ≤ ·)is antisymmetric,a < b ↔ ¬ b ≤ aand(· < ·)is irreflexive, transitive and asymmetric.min a bis eitheraorb, is symmetric and satisfies the following property:min c (min a b) = cif and only ifmin c a = candmin c b = c.
It is desirable that lemmas about linear orders state this hypothesis in a canonical way.
Therefore, the classes defining preorders, partial orders, linear preorders and linear orders
are all formulated purely in terms of LE. For other operations, there are
classes for compatibility of LE with other operations. Hence, a lemma may look like:
theorem lt_trans {α : Type u} [LE α] [LT α]
[IsPreorder α] -- The order on `α` induced by `LE α` is, among other things, transitive.
[LawfulOrderLT α] -- `<` is the less-than relation induced by `LE α`.
{a b : α} : a < b → b < c → a < c := by
sorry
This typeclass states that the order structure on α, represented by an LE α instance,
is a preorder. In other words, the less-or-equal relation is reflexive and transitive.
Instances
This typeclass states that the order structure on α, represented by an LE α instance,
is a partial order.
In other words, the less-or-equal relation is reflexive, transitive and antisymmetric.
Instances
This typeclass states that the order structure on α, represented by an LE α instance,
is a linear preorder.
In other words, the less-or-equal relation is reflexive, transitive and total.
Instances
This typeclass states that the order structure on α, represented by an LE α instance,
is a linear order.
In other words, the less-or-equal relation is reflexive, transitive, antisymmetric and total.
Instances
This typeclass states that the synthesized LT α instance is compatible with the LE α
instance. This means that LT.lt a b holds if and only if a is less or equal to b according
to the LE α instance, but b is not less or equal to a.
LawfulOrderLT α automatically entails that LT α is asymmetric: a < b and b < a can never
be true simultaneously.
LT α does not uniquely determine the LE α: There can be only one compatible order data
instance that is total, but there can be others that are not total.
Instances
This typeclass bundles MinEqOr α and LawfulOrderInf α. It characterizes when a Min α
instance reasonably computes minima in some type α that has an LE α instance.
As long as α is a preorder (see IsPreorder α), this typeclass implies that the order on
α is total and that Min.min a b returns either a or b, whichever is less or equal to
the other.
Instances
This typeclass bundles MaxEqOr α and LawfulOrderSup α. It characterizes when a Max α
instance reasonably computes maxima in some type α that has an LE α instance.
As long as α is a preorder (see IsPreorder α), this typeclass implies that the order on
α is total and that Min.min a b returns either a or b, whichever is greater or equal to
the other.