(* 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                                                     *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(* ---                        monoid.v                                  --- *)
(*                                                                          *)
(* Author: Pierre Casteran.                                                 *)
(*    LABRI, URA CNRS 1304,                                                 *)
(*    Departement d'Informatique, Universite Bordeaux I,                    *)
(*    33405 Talence CEDEX,                                                  *)
(*    e-mail:  casteran@labri.u-bordeaux.fr                                 *)
(* A monoid on some M:Set is a structure composed of a binary associative operation o:M->M->M, and a neutral element u:M for o. *)
Section monoid_def.
Variable M : Set.
Record monoid : Set := mkmonoid
{u : M;
o : M -> M -> M;
point_assoc : forall a b c : M, o a (o b c) = o (o a b) c;
u_neutral_l : forall a : M, o u a = a;
u_neutral_r : forall a : M, o a u = a}.
Hint Resolve point_assoc u_neutral_r u_neutral_l: arith.
Variable MO : monoid.
Let u' := u MO.
Let o' := o MO.
Remark o'_assoc : forall a b c : M, o' a (o' b c) = o' (o' a b) c.
exact (point_assoc MO).
Qed.
Hint Resolve o'_assoc: arith.
Remark u'_neutral_l : forall a : M, o' u' a = a.
exact (u_neutral_l MO).
Qed.
Hint Resolve u'_neutral_l: arith.
Remark u'_neutral_r : forall a : M, o' a u' = a.
exact (u_neutral_r MO).
Qed.
Hint Resolve u'_neutral_r: arith.
(* powering ************)
Fixpoint power (x : M) (n : nat) {struct n} : M :=
match n with
| O => u'
| S n => o' x (power x n)
end.
(* some lemmas on powering *)
(***************************)

(* Specifications: *)
Lemma power_u : forall m : nat, power u' m = u'.
Hint Resolve power_u: arith.