(* Copyright 2012-2015 by Adam Petcher.				* * Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
(* Type classes and theory for groups, including finite cyclic groups. *)
Set Implicit Arguments.
Class Group_op(A : Set) := groupOp : A -> A -> A.
Infix "*" := groupOp : group_scope.
Delimit Scope group_scope with group.
Local Open Scope group_scope.
Class Group
(GroupElement : Set)
(groupOp : Group_op GroupElement)
(ident : GroupElement)
(inverse : GroupElement -> GroupElement)
:={
associativity :
forall (x y z : GroupElement),
(x * y) * z = x * (y * z);
left_identity :
forall (a : GroupElement),
ident * a = a;
right_identity :
forall (a : GroupElement),
a * ident = a;
left_inverse :
forall (a : GroupElement),
(inverse a) * a = ident;
right_inverse :
forall (a : GroupElement),
a * (inverse a) = ident
}.
Fixpoint groupExp`{G : Group}(a : GroupElement)(n : nat) : GroupElement :=
match n with
| 0 => ident
| S n' => groupOp a (groupExp a n')
end.
Infix "^" := groupExp : group_scope.
Section GroupProperties.
Context `{G : Group}.

Lemma groupExp_identity : forall n,
ident^n = ident.