(* 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                                                     *)


Set Implicit Arguments.
Unset Strict Implicit.
Require Export Group_util.
Section Free_group_def.
Variable V : SET.

Inductive FG : Type :=
  | Var : V -> FG
  | Law : FG -> FG -> FG
  | Unit : FG
  | Inv : FG -> FG.

Inductive eqFG : FG -> FG -> Prop :=
  | eqFG_Var : forall x y : V, Equal x y -> (eqFG (Var x) (Var y):Prop)
  | eqFG_law :
      forall x x' y y' : FG,
      eqFG x x' -> eqFG y y' -> (eqFG (Law x y) (Law x' y'):Prop)
  | eqFG_law_assoc :
      forall x y z : FG, eqFG (Law (Law x y) z) (Law x (Law y z)):Prop
  | eqFG_law0r : forall x : FG, eqFG (Law x Unit) x:Prop
  | eqFG_inv : forall x y : FG, eqFG x y -> eqFG (Inv x) (Inv y)
  | eqFG_invr : forall x : FG, eqFG (Law x (Inv x)) Unit
  | eqFG_refl : forall x : FG, eqFG x x:Prop
  | eqFG_sym : forall x y : FG, eqFG x y -> (eqFG y x:Prop)
  | eqFG_trans : forall x y z : FG, eqFG x y -> eqFG y z -> (eqFG x z:Prop).
Hint Resolve eqFG_Var eqFG_law eqFG_law_assoc eqFG_law0r eqFG_invr eqFG_refl:
  algebra.
Hint Immediate eqFG_sym: algebra.

Lemma eqFG_Equiv : equivalence eqFG.
(* Goal: @Map_eq V (sgroup_set (monoid_sgroup (group_monoid G))) f (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x y : FG) (H' : eqFG x y) => @eqFG_ind (fun x0 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (fun (x0 y0 : Carrier V) (H : @Equal V x0 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x0 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x0 x' y0 y' : FG) (_ : eqFG x0 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x0 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z)) (fun x0 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun x0 : FG => @GROUP_inverse_r G (FG_lift_fun x0)) (fun x0 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun (x0 y0 z : FG) (_ : eqFG x0 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x y H')) FG_var) *)
red in |- *.
(* Goal: and (@transitive FG eqFG) (@symmetric FG eqFG) *)
split; [ try assumption | idtac ].
(* Goal: @reflexive FG eqFG *)
(* Goal: @partial_equivalence FG eqFG *)
exact eqFG_refl.
(* Goal: @Map_eq V (sgroup_set (monoid_sgroup (group_monoid G))) f (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x y : FG) (H' : eqFG x y) => @eqFG_ind (fun x0 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (fun (x0 y0 : Carrier V) (H : @Equal V x0 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x0 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x0 x' y0 y' : FG) (_ : eqFG x0 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x0 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z)) (fun x0 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun x0 : FG => @GROUP_inverse_r G (FG_lift_fun x0)) (fun x0 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun (x0 y0 z : FG) (_ : eqFG x0 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x y H')) FG_var) *)
red in |- *.
(* Goal: and (@transitive FG eqFG) (@symmetric FG eqFG) *)
split; [ try assumption | idtac ].
(* Goal: @transitive FG eqFG *)
(* Goal: @symmetric FG eqFG *)
exact eqFG_trans.
(* Goal: @symmetric FG eqFG *)
exact eqFG_sym.
Qed.

Definition FG_set := Build_Setoid eqFG_Equiv.

Definition FreeGroup : GROUP.
(* Goal: Ob GROUP *)
apply (BUILD_GROUP (E:=FG_set) (genlaw:=Law) (e:=Unit) (geninv:=Inv)).
(* Goal: forall (x x' y y' : Carrier FG_set) (_ : @Equal FG_set x x') (_ : @Equal FG_set y y'), @Equal FG_set (Law x y) (Law x' y') *)
(* Goal: forall x y z : Carrier FG_set, @Equal FG_set (Law (Law x y) z) (Law x (Law y z)) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x Unit) x *)
(* Goal: forall (x y : Carrier FG_set) (_ : @Equal FG_set x y), @Equal FG_set (Inv x) (Inv y) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x (Inv x)) Unit *)
exact eqFG_law.
(* Goal: forall x y z : Carrier FG_set, @Equal FG_set (Law (Law x y) z) (Law x (Law y z)) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x Unit) x *)
(* Goal: forall (x y : Carrier FG_set) (_ : @Equal FG_set x y), @Equal FG_set (Inv x) (Inv y) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x (Inv x)) Unit *)
exact eqFG_law_assoc.
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x Unit) x *)
(* Goal: forall (x y : Carrier FG_set) (_ : @Equal FG_set x y), @Equal FG_set (Inv x) (Inv y) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x (Inv x)) Unit *)
exact eqFG_law0r.
(* Goal: forall (x y : Carrier FG_set) (_ : @Equal FG_set x y), @Equal FG_set (Inv x) (Inv y) *)
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x (Inv x)) Unit *)
exact eqFG_inv.
(* Goal: forall x : Carrier FG_set, @Equal FG_set (Law x (Inv x)) Unit *)
exact eqFG_invr.
Defined.
Section Universal_prop.
Variable G : GROUP.
Variable f : Hom V G.

Fixpoint FG_lift_fun (p : FreeGroup) : G :=
  match p with
  | Var v => f v
  | Law p1 p2 => sgroup_law _ (FG_lift_fun p1) (FG_lift_fun p2)
  | Unit => monoid_unit G
  | Inv p1 => group_inverse G (FG_lift_fun p1)
  end.

Definition FG_lift : Hom FreeGroup G.
(* Goal: Carrier (@Hom GROUP FreeGroup G) *)
apply (BUILD_HOM_GROUP (G:=FreeGroup) (G':=G) (ff:=FG_lift_fun)).
(* Goal: forall (x y : Carrier (sgroup_set (monoid_sgroup (group_monoid FreeGroup)))) (_ : @Equal (sgroup_set (monoid_sgroup (group_monoid FreeGroup))) x y), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x) (FG_lift_fun y) *)
(* Goal: forall x y : Carrier (sgroup_set (monoid_sgroup (group_monoid FreeGroup))), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (sgroup_law (monoid_sgroup (group_monoid FreeGroup)) x y)) (sgroup_law (monoid_sgroup (group_monoid G)) (FG_lift_fun x) (FG_lift_fun y)) *)
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (@monoid_unit (monoid_sgroup (group_monoid FreeGroup)) (monoid_on_def (group_monoid FreeGroup)))) (@monoid_unit (monoid_sgroup (group_monoid G)) (monoid_on_def (group_monoid G))) *)
intros x y H'; try assumption.
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x) (FG_lift_fun y) *)
(* Goal: forall x y : Carrier (sgroup_set (monoid_sgroup (group_monoid FreeGroup))), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (sgroup_law (monoid_sgroup (group_monoid FreeGroup)) x y)) (sgroup_law (monoid_sgroup (group_monoid G)) (FG_lift_fun x) (FG_lift_fun y)) *)
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (@monoid_unit (monoid_sgroup (group_monoid FreeGroup)) (monoid_on_def (group_monoid FreeGroup)))) (@monoid_unit (monoid_sgroup (group_monoid G)) (monoid_on_def (group_monoid G))) *)
elim H'; simpl in |- *; auto with algebra.
(* Goal: forall (x y z : FG) (_ : eqFG x y) (_ : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x) (FG_lift_fun y)) (_ : eqFG y z) (_ : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y) (FG_lift_fun z)), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x) (FG_lift_fun z) *)
(* Goal: forall x y : Carrier (sgroup_set (monoid_sgroup (group_monoid FreeGroup))), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (sgroup_law (monoid_sgroup (group_monoid FreeGroup)) x y)) (sgroup_law (monoid_sgroup (group_monoid G)) (FG_lift_fun x) (FG_lift_fun y)) *)
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (@monoid_unit (monoid_sgroup (group_monoid FreeGroup)) (monoid_on_def (group_monoid FreeGroup)))) (@monoid_unit (monoid_sgroup (group_monoid G)) (monoid_on_def (group_monoid G))) *)
intros x0 y0 z H'0 H'1 H'2 H'3; try assumption.
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun z) *)
(* Goal: forall x y : Carrier (sgroup_set (monoid_sgroup (group_monoid FreeGroup))), @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (sgroup_law (monoid_sgroup (group_monoid FreeGroup)) x y)) (sgroup_law (monoid_sgroup (group_monoid G)) (FG_lift_fun x) (FG_lift_fun y)) *)
(* Goal: @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun (@monoid_unit (monoid_sgroup (group_monoid FreeGroup)) (monoid_on_def (group_monoid FreeGroup)))) (@monoid_unit (monoid_sgroup (group_monoid G)) (monoid_on_def (group_monoid G))) *)
apply Trans with (FG_lift_fun y0); auto with algebra.
(* Goal: forall (x y : Carrier V) (_ : @Equal V x y), @Equal (sgroup_set (monoid_sgroup (group_monoid FreeGroup))) (Var x) (Var y) *)
simpl in |- *; auto with algebra.
(* Goal: forall (x y : Carrier V) (_ : @Equal V x y), @Equal (sgroup_set (monoid_sgroup (group_monoid FreeGroup))) (Var x) (Var y) *)
simpl in |- *; auto with algebra.
Defined.

Definition FG_var : Hom V FreeGroup.
(* Goal: Carrier (@Hom SET V (sgroup_set (monoid_sgroup (group_monoid FreeGroup)))) *)
apply (Build_Map (A:=V) (B:=FreeGroup) (Ap:=Var)).
(* Goal: @Map_eq V (sgroup_set (monoid_sgroup (group_monoid G))) f (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x y : FG) (H' : eqFG x y) => @eqFG_ind (fun x0 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (fun (x0 y0 : Carrier V) (H : @Equal V x0 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x0 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x0 x' y0 y' : FG) (_ : eqFG x0 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x0 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z)) (fun x0 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun x0 : FG => @GROUP_inverse_r G (FG_lift_fun x0)) (fun x0 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun (x0 y0 z : FG) (_ : eqFG x0 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x y H')) FG_var) *)
red in |- *.
(* Goal: forall (x y : Carrier V) (_ : @Equal V x y), @Equal (sgroup_set (monoid_sgroup (group_monoid FreeGroup))) (Var x) (Var y) *)
simpl in |- *; auto with algebra.
Defined.

Lemma FG_comp_prop :
 Equal f (comp_hom (FG_lift:Hom (FreeGroup:SET) G) FG_var).
(* Goal: forall x : Carrier V, @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) f x) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x0 y : FG) (H' : eqFG x0 y) => @eqFG_ind (fun x1 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) (fun (x1 y0 : Carrier V) (H : @Equal V x1 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x1 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x1 x' y0 y' : FG) (_ : eqFG x1 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x1) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x1 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x1) (FG_lift_fun y0) (FG_lift_fun z)) (fun x1 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x1)) (fun (x1 y0 : FG) (_ : eqFG x1 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x1) (FG_lift_fun y0) H0) (fun x1 : FG => @GROUP_inverse_r G (FG_lift_fun x1)) (fun x1 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1)) (fun (x1 y0 : FG) (_ : eqFG x1 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0) H0) (fun (x1 y0 z : FG) (_ : eqFG x1 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x0 y H')) FG_var) x) *)
simpl in |- *.
(* Goal: @Map_eq V (sgroup_set (monoid_sgroup (group_monoid G))) f (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x y : FG) (H' : eqFG x y) => @eqFG_ind (fun x0 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (fun (x0 y0 : Carrier V) (H : @Equal V x0 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x0 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x0 x' y0 y' : FG) (_ : eqFG x0 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x0 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z)) (fun x0 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun x0 : FG => @GROUP_inverse_r G (FG_lift_fun x0)) (fun x0 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0)) (fun (x0 y0 : FG) (_ : eqFG x0 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) H0) (fun (x0 y0 z : FG) (_ : eqFG x0 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x0) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x y H')) FG_var) *)
red in |- *.
(* Goal: forall x : Carrier V, @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) f x) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) (@comp_hom SET V FG_set (sgroup_set (monoid_sgroup (group_monoid G))) (@f2 FreeGroup G FG_lift_fun (fun (x0 y : FG) (H' : eqFG x0 y) => @eqFG_ind (fun x1 y0 : FG => @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) (fun (x1 y0 : Carrier V) (H : @Equal V x1 y0) => @Ap_comp V (sgroup_set (monoid_sgroup (group_monoid G))) f f x1 y0 H (@Refl (MAP V (sgroup_set (monoid_sgroup (group_monoid G)))) f)) (fun (x1 x' y0 y' : FG) (_ : eqFG x1 x') (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun x')) (_ : eqFG y0 y') (H2 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun y')) => @SGROUP_comp (monoid_sgroup (group_monoid G)) (FG_lift_fun x1) (FG_lift_fun x') (FG_lift_fun y0) (FG_lift_fun y') H0 H2) (fun x1 y0 z : FG => @SGROUP_assoc (monoid_sgroup (group_monoid G)) (FG_lift_fun x1) (FG_lift_fun y0) (FG_lift_fun z)) (fun x1 : FG => @MONOID_unit_r (group_monoid G) (FG_lift_fun x1)) (fun (x1 y0 : FG) (_ : eqFG x1 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) => @GROUP_comp G (FG_lift_fun x1) (FG_lift_fun y0) H0) (fun x1 : FG => @GROUP_inverse_r G (FG_lift_fun x1)) (fun x1 : FG => @Refl (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1)) (fun (x1 y0 : FG) (_ : eqFG x1 y0) (H0 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) => @Sym (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0) H0) (fun (x1 y0 z : FG) (_ : eqFG x1 y0) (H'1 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0)) (_ : eqFG y0 z) (H'3 : @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun y0) (FG_lift_fun z)) => @Trans (sgroup_set (monoid_sgroup (group_monoid G))) (FG_lift_fun x1) (FG_lift_fun y0) (FG_lift_fun z) H'1 H'3) x0 y H')) FG_var) x) *)
simpl in |- *.
(* Goal: forall x : Carrier V, @Equal (sgroup_set (monoid_sgroup (group_monoid G))) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) f x) (@Ap V (sgroup_set (monoid_sgroup (group_monoid G))) f x) *)
auto with algebra.
Qed.
End Universal_prop.
End Free_group_def.
Hint Resolve FG_comp_prop: algebra.
