(* $Id: Setoid_ex.v,v 1.2 1999/10/05 10:35:40 boulme Exp $ *)
Set Implicit Arguments.
Unset Strict Implicit.

Require Import Records.
Require Import Build.

Inductive Label : Set :=
  | T : Label
  | EQ : Label
  | EQ_refl : Label
  | EQ_sym : Label
  | EQ_trans : Label
  | AP : Label
  | AP_EQ : Label
  | OP : Label
  | OP_EQ_l : Label
  | OP_EQ_r : Label
  | OP_ass : Label
  | INF : Label
  | INF_trans : Label
  | INF_refl : Label
  | OP_INF_l : Label
  | OP_INF_r : Label.


Lemma eqLabel_dec : forall x y : Label, {x = y} + {x <> y}.
  intros x y; case x; case y; auto; right; discriminate.
Defined.


Definition setoid_sig : sign eqLabel_dec.
  refine
   (Build_sign _
      ( T -: Type  ;;
        EQ -: T -> T -> Prop ;;
        EQ_refl -: forall x : T, EQ x x ;;
        EQ_sym  -:  forall x y : T, EQ x y -> EQ y x ;;
        EQ_trans -: forall x y z : T, EQ x y -> EQ y z -> EQ x z ;; )).
  exact I.
Defined.

Definition setoid := Drecord setoid_sig.
Identity Coercion setoid_Drecord: setoid >-> Drecord. 

Definition carrier (s : setoid) : Type := s @ T.
Coercion carrier : setoid >-> Sortclass.

Definition Build_setoid := Build setoid_sig.

Definition Type_setoid : setoid :=
  Build_setoid (refl_equal (A:=Type)) (sym_eq (A:=Type)) (trans_eq (A:=Type)).
