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

Require Import Setoid_ex.
Require Import Records.
Require Import Build.

(**** semigroups ****)

Definition semigroup_on (s : setoid) :=
  (OP -: s @ T -> s @ T -> s @ T  ;;
   OP_EQ_l -: forall x y z : s @ T,
                 (s @ EQ) x y -> (s @ EQ) (OP x z) (OP y z) ;;
   OP_EQ_r -: forall x y z : (s @ T),
                 (s @ EQ) x y -> (s @ EQ) (OP z x) (OP z y)  ;;
   OP_ass  -: forall x y z : (s @ T),
                 (s @ EQ) (OP (OP x y) z) (OP x (OP y z)) ;;). 

Definition semigroup_sig : sign eqLabel_dec.
 refine (flatsign _ _ (fun s => semigroup_on s)); simpl in |- *; auto.
Defined.

Definition semigroup := Drecord semigroup_sig.
 
Definition semigroup_setoid : semigroup -> setoid. 
  refine (coerce (flatsign_subsign _ _ (fun s => semigroup_on s)));
   simpl in |- *; auto.
Defined.

Coercion semigroup_setoid : semigroup >-> setoid.
