Library Coq.Structures.OrdersEx

Examples of Ordered Type structures.

Ordered Type for nat, Positive, N, Z with the usual order.
An OrderedType can now directly be seen as a DecidableType

Module OT_as_DT (O:OrderedType) <: DecidableType := O.

(Usual) Decidable Type for nat, positive, N, Z
From two ordered types, we can build a new OrderedType over their cartesian product, using the lexicographic order.

Module PairOrderedType(O1 O2:OrderedType) <: OrderedType.
 Include PairDecidableType O1 O2.

 Definition lt :=
   (relation_disjunction (O1.lt @@1) (O1.eq * O2.lt))%signature.

 Instance lt_strorder : StrictOrder lt.

 Instance lt_compat : Proper (eq==>eq==>iff) lt.

 Definition compare x y :=
  match O1.compare (fst x) (fst y) with
   | Eq => O2.compare (snd x) (snd y)
   | Lt => Lt
   | Gt => Gt
  end.

 Lemma compare_spec : forall x y, CompSpec eq lt x y (compare x y).

End PairOrderedType.