(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA                        ENS-CNRS                *)
(*              Rocquencourt                        Lyon                    *)
(*                                                                          *)
(*                                 Coq V6.1                                 *)
(*                               Oct 1st 1996                               *)
(*                                                                          *)
(****************************************************************************)
(*                                 Monoid.v                                 *)
(****************************************************************************)
Require Export Map2.
Set Implicit Arguments.
Unset Strict Implicit.
SubClass BinOp (A : Setoid) := Map2 A A A.
Section monoid_laws.
Variables (A : Setoid) (op : BinOp A) (e : A).
Let Ap_op (x y : A) := op x y.
Infix "+_M" := Ap_op (at level 40, left associativity).
Definition Monoid_ass := forall x y z : A, x +_M (y +_M z) =_S x +_M y +_M z.
Definition Monoid_idl := forall x : A, e +_M x =_S x.
Definition Monoid_idr := forall x : A, x =_S x +_M e.
End monoid_laws.
Structure Monoid : Type :=
{Mcarrier :> Setoid;
Mop : BinOp Mcarrier;
Munit : Mcarrier;
Prf_monoid_ass : Monoid_ass Mop;
Prf_monoid_idl : Monoid_idl Mop Munit;
Prf_monoid_idr : Monoid_idr Mop Munit}.
Definition ApMop (m : Monoid) (x y : m) := Mop m x y.
Infix "+_M" := ApMop (at level 40, left associativity).
(*** rewrite rules ***)

Lemma Midr : forall (M : Monoid) (x : M), x =_S x +_M Munit M.