From mathcomp.ssreflect
From fcsl
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
(**********)
(* Posets *)
(**********)
Module Poset.
Section RawMixin.
Record mixin_of (T : Type) := Mixin {
mx_leq : T -> T -> Prop;
_ : forall x, mx_leq x x;
_ : forall x y, mx_leq x y -> mx_leq y x -> x = y;
_ : forall x y z, mx_leq x y -> mx_leq y z -> mx_leq x z}.
End RawMixin.
Section ClassDef.
Record class_of T := Class {mixin : mixin_of T}.
Structure type : Type := Pack {sort : Type; _ : class_of sort; _ : Type}.
Local Coercion sort : type >-> Sortclass.
Variables (T : Type) (cT : type).
Definition class := let: Pack _ c _ as cT' := cT return class_of cT' in c.
Definition clone c of phant_id class c := @Pack T c T.
(* produce a poset type out of the mixin *)
(* equalize m0 and m by means of a phantom *)
Definition pack (m0 : mixin_of T) :=
fun m & phant_id m0 m => Pack (@Class T m) T.
Definition leq := mx_leq (mixin class).
End ClassDef.
Module Exports.
Coercion sort : type >-> Sortclass.
Notation poset := Poset.type.
Notation PosetMixin := Poset.Mixin.
Notation Poset T m := (@pack T _ m id).
Notation "[ 'poset' 'of' T 'for' cT ]" := (@clone T cT _ id)
(at level 0, format "[ 'poset'  'of'  T  'for'  cT ]") : form_scope.
Notation "[ 'poset' 'of' T ]" := (@clone T _ _ id)
(at level 0, format "[ 'poset'  'of'  T ]") : form_scope.
Notation "x <== y" := (Poset.leq x y) (at level 70).
(* re-state lattice properties using the exported notation *)
Section Laws.
Variable T : poset.

Lemma poset_refl (x : T) : x <== x.