(* 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)                    *)
(****************************************************************************)
(* Revised and adapted to use Coq V6.1 features by the author               *)
(* February 1997                                                            *)
(****************************************************************************)
(*   script coq V5.8.3                                                      *)
(*                                                                          *)
(*                                                                          *)
(*   An exercise on groups                                                  *)
(*                                                                          *)
(*                                                                          *)
(*   Pierre Casteran.                                                       *)
(*   LaBRI [casteran@labri.u-bordeaux.fr]                                   *)
(*                                                                          *)
(*                                                                          *)
(*  This file presents a development in Coq of the following lemma:         *)
(*  "Let E be a non-empty set, o an associative law on E,                   *)
(*   such that for each x:E, the functions [y:E](o x y) and                 *)
(*   [y:E](o y x) are onto.                                                 *)
(*   Then E is a group"                                                     *)
(*                                                                          *)
(*  See groups.ps.gz in this directory                                      *)
(*                                                                          *)
(****************************************************************************)
(*                                 Groups.v                                 *)
(****************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Section General_definitions.
Variable E : Set.
Definition onto (f : E -> E) := forall y : E, {x : E | f x = y}.
Variable o : E -> E -> E.
Variable e : E.
Variable s : E -> E.
Definition associative := forall x y z : E, o x (o y z) = o (o x y) z.
Definition left_neutral := forall x : E, o e x = x.
Definition right_neutral := forall x : E, o x e = x.
Definition left_symmetric := forall x : E, o (s x) x = e.
Definition right_symmetric := forall x : E, o x (s x) = e.
End General_definitions.
(* what is a group on E ? *)
Record group (E : Set) : Set := mkgroup
{group_law : E -> E -> E;
(* composition law *)
group_assoc : associative group_law;
group_neutral : E;
(* neutral element *)
group_sym : E -> E;
(* symmetric *)
group_l_neutral : left_neutral group_law group_neutral;
group_r_neutral : right_neutral group_law group_neutral;
group_l_sym : left_symmetric group_law group_neutral group_sym;
group_r_sym : right_symmetric group_law group_neutral group_sym}.
Section some_properties_of_groups.
Variable E : Set.
Variable G : group E.
Let o := group_law G.
Let s := group_sym G.
Let e := group_neutral G.
Let assoc := group_assoc G.
Let l_neutral := group_l_neutral G.
Let r_neutral := group_r_neutral G.
Let l_sym := group_l_sym G.
Let r_sym := group_r_sym G.
Hint Resolve assoc l_sym l_neutral r_sym r_neutral.
Hint Unfold o s e.

(**************************************************)
Lemma solve_equation : forall x y : E, o x y = e -> y = s x.
Hint Resolve solve_equation.