(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(* Finite sets library. * Authors: Pierre Letouzey and Jean-Christophe Filliâtre * Institution: LRI, CNRS UMR 8623 - Université Paris Sud *              91405 Orsay, France *)
Set Implicit Arguments.
(** * Some alternative (but equivalent) presentations for an Ordered Type inferface. *)
(** ** The original interface *)
Module Type OrderedTypeOrig := OrderedType.OrderedType.
(** ** An interface based on compare *)
Module Type OrderedTypeAlt.
Parameter t : Type.
Parameter compare : t -> t -> comparison.
Infix "?=" := compare (at level 70, no associativity).
Parameter compare_sym :
forall x y, (y?=x) = CompOpp (x?=y).
Parameter compare_trans :
forall c x y z, (x?=y) = c -> (y?=z) = c -> (x?=z) = c.
End OrderedTypeAlt.
(** ** From OrderedTypeOrig to OrderedType. *)
Module Update_OT (O:OrderedTypeOrig) <: OrderedType.
Include Update_DT O.  (* Provides : t eq eq_equiv eq_dec *)
Definition lt := O.lt.
#[global]
Instance lt_strorder : StrictOrder lt.
#[global]
Instance lt_compat : Proper (eq==>eq==>iff) lt.
Definition compare x y :=
match O.compare x y with
| EQ _ => Eq
| LT _ => Lt
| GT _ => Gt
end.

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