src/ZF/ex/Group.thy
changeset 46953 2b6e55924af3
parent 46822 95f1e700b712
child 49755 b286e8f47560
equal deleted inserted replaced
46952:5e1bcfdcb175 46953:2b6e55924af3
     9 
     9 
    10 
    10 
    11 subsection {* Monoids *}
    11 subsection {* Monoids *}
    12 
    12 
    13 (*First, we must simulate a record declaration:
    13 (*First, we must simulate a record declaration:
    14 record monoid = 
    14 record monoid =
    15   carrier :: i
    15   carrier :: i
    16   mult :: "[i,i] => i" (infixl "\<cdot>\<index>" 70)
    16   mult :: "[i,i] => i" (infixl "\<cdot>\<index>" 70)
    17   one :: i ("\<one>\<index>")
    17   one :: i ("\<one>\<index>")
    18 *)
    18 *)
    19 
    19 
    39 
    39 
    40 locale monoid = fixes G (structure)
    40 locale monoid = fixes G (structure)
    41   assumes m_closed [intro, simp]:
    41   assumes m_closed [intro, simp]:
    42          "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> x \<cdot> y \<in> carrier(G)"
    42          "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> x \<cdot> y \<in> carrier(G)"
    43       and m_assoc:
    43       and m_assoc:
    44          "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G); z \<in> carrier(G)\<rbrakk> 
    44          "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G); z \<in> carrier(G)\<rbrakk>
    45           \<Longrightarrow> (x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)"
    45           \<Longrightarrow> (x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)"
    46       and one_closed [intro, simp]: "\<one> \<in> carrier(G)"
    46       and one_closed [intro, simp]: "\<one> \<in> carrier(G)"
    47       and l_one [simp]: "x \<in> carrier(G) \<Longrightarrow> \<one> \<cdot> x = x"
    47       and l_one [simp]: "x \<in> carrier(G) \<Longrightarrow> \<one> \<cdot> x = x"
    48       and r_one [simp]: "x \<in> carrier(G) \<Longrightarrow> x \<cdot> \<one> = x"
    48       and r_one [simp]: "x \<in> carrier(G) \<Longrightarrow> x \<cdot> \<one> = x"
    49 
    49 
    59 
    59 
    60 lemma update_carrier_eq [simp]: "update_carrier(<A,Z>,B) = <B,Z>"
    60 lemma update_carrier_eq [simp]: "update_carrier(<A,Z>,B) = <B,Z>"
    61   by (simp add: update_carrier_def)
    61   by (simp add: update_carrier_def)
    62 
    62 
    63 lemma carrier_update_carrier [simp]: "carrier(update_carrier(M,B)) = B"
    63 lemma carrier_update_carrier [simp]: "carrier(update_carrier(M,B)) = B"
    64   by (simp add: update_carrier_def) 
    64   by (simp add: update_carrier_def)
    65 
    65 
    66 lemma mult_update_carrier [simp]: "mmult(update_carrier(M,B),x,y) = mmult(M,x,y)"
    66 lemma mult_update_carrier [simp]: "mmult(update_carrier(M,B),x,y) = mmult(M,x,y)"
    67   by (simp add: update_carrier_def mmult_def) 
    67   by (simp add: update_carrier_def mmult_def)
    68 
    68 
    69 lemma one_update_carrier [simp]: "one(update_carrier(M,B)) = one(M)"
    69 lemma one_update_carrier [simp]: "one(update_carrier(M,B)) = one(M)"
    70   by (simp add: update_carrier_def one_def) 
    70   by (simp add: update_carrier_def one_def)
    71 
    71 
    72 
    72 
    73 lemma (in monoid) inv_unique:
    73 lemma (in monoid) inv_unique:
    74   assumes eq: "y \<cdot> x = \<one>"  "x \<cdot> y' = \<one>"
    74   assumes eq: "y \<cdot> x = \<one>"  "x \<cdot> y' = \<one>"
    75     and G: "x \<in> carrier(G)"  "y \<in> carrier(G)"  "y' \<in> carrier(G)"
    75     and G: "x \<in> carrier(G)"  "y \<in> carrier(G)"  "y' \<in> carrier(G)"
   107     "\<And>x y z. \<lbrakk>x \<in> carrier(G); y \<in> carrier(G); z \<in> carrier(G)\<rbrakk> \<Longrightarrow>
   107     "\<And>x y z. \<lbrakk>x \<in> carrier(G); y \<in> carrier(G); z \<in> carrier(G)\<rbrakk> \<Longrightarrow>
   108     (x \<cdot> y = x \<cdot> z) \<longleftrightarrow> (y = z)"
   108     (x \<cdot> y = x \<cdot> z) \<longleftrightarrow> (y = z)"
   109   proof
   109   proof
   110     fix x y z
   110     fix x y z
   111     assume G: "x \<in> carrier(G)"  "y \<in> carrier(G)"  "z \<in> carrier(G)"
   111     assume G: "x \<in> carrier(G)"  "y \<in> carrier(G)"  "z \<in> carrier(G)"
   112     { 
   112     {
   113       assume eq: "x \<cdot> y = x \<cdot> z"
   113       assume eq: "x \<cdot> y = x \<cdot> z"
   114       with G l_inv_ex obtain x_inv where xG: "x_inv \<in> carrier(G)"
   114       with G l_inv_ex obtain x_inv where xG: "x_inv \<in> carrier(G)"
   115         and l_inv: "x_inv \<cdot> x = \<one>" by fast
   115         and l_inv: "x_inv \<cdot> x = \<one>" by fast
   116       from G eq xG have "(x_inv \<cdot> x) \<cdot> y = (x_inv \<cdot> x) \<cdot> z"
   116       from G eq xG have "(x_inv \<cdot> x) \<cdot> y = (x_inv \<cdot> x) \<cdot> z"
   117         by (simp add: m_assoc)
   117         by (simp add: m_assoc)
   145       by simp
   145       by simp
   146     from x y show "\<exists>y \<in> carrier(G). y \<cdot> x = \<one> & x \<cdot> y = \<one>"
   146     from x y show "\<exists>y \<in> carrier(G). y \<cdot> x = \<one> & x \<cdot> y = \<one>"
   147       by (fast intro: l_inv r_inv)
   147       by (fast intro: l_inv r_inv)
   148   qed
   148   qed
   149   show ?thesis
   149   show ?thesis
   150     by (blast intro: group.intro monoid.intro group_axioms.intro 
   150     by (blast intro: group.intro monoid.intro group_axioms.intro
   151                      assms r_one inv_ex)
   151                      assms r_one inv_ex)
   152 qed
   152 qed
   153 
   153 
   154 lemma (in group) inv [simp]:
   154 lemma (in group) inv [simp]:
   155   "x \<in> carrier(G) \<Longrightarrow> inv x \<in> carrier(G) & inv x \<cdot> x = \<one> & x \<cdot> inv x = \<one>"
   155   "x \<in> carrier(G) \<Longrightarrow> inv x \<in> carrier(G) & inv x \<cdot> x = \<one> & x \<cdot> inv x = \<one>"
   156   apply (frule inv_ex) 
   156   apply (frule inv_ex)
   157   apply (unfold Bex_def m_inv_def)
   157   apply (unfold Bex_def m_inv_def)
   158   apply (erule exE) 
   158   apply (erule exE)
   159   apply (rule theI)
   159   apply (rule theI)
   160   apply (rule ex1I, assumption)
   160   apply (rule ex1I, assumption)
   161    apply (blast intro: inv_unique)
   161    apply (blast intro: inv_unique)
   162   done
   162   done
   163 
   163 
   219 apply (rule r_cancel [THEN iffD1], auto)
   219 apply (rule r_cancel [THEN iffD1], auto)
   220 done
   220 done
   221 
   221 
   222 lemma (in group) inv_one [simp]:
   222 lemma (in group) inv_one [simp]:
   223   "inv \<one> = \<one>"
   223   "inv \<one> = \<one>"
   224   by (auto intro: inv_equality) 
   224   by (auto intro: inv_equality)
   225 
   225 
   226 lemma (in group) inv_inv [simp]: "x \<in> carrier(G) \<Longrightarrow> inv (inv x) = x"
   226 lemma (in group) inv_inv [simp]: "x \<in> carrier(G) \<Longrightarrow> inv (inv x) = x"
   227   by (auto intro: inv_equality) 
   227   by (auto intro: inv_equality)
   228 
   228 
   229 text{*This proof is by cancellation*}
   229 text{*This proof is by cancellation*}
   230 lemma (in group) inv_mult_group:
   230 lemma (in group) inv_mult_group:
   231   "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> inv (x \<cdot> y) = inv y \<cdot> inv x"
   231   "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> inv (x \<cdot> y) = inv y \<cdot> inv x"
   232 proof -
   232 proof -
   358   "\<lbrakk>h \<in> hom(G,H); x \<in> carrier(G)\<rbrakk> \<Longrightarrow> h ` x \<in> carrier(H)"
   358   "\<lbrakk>h \<in> hom(G,H); x \<in> carrier(G)\<rbrakk> \<Longrightarrow> h ` x \<in> carrier(H)"
   359   by (auto simp add: hom_def)
   359   by (auto simp add: hom_def)
   360 
   360 
   361 lemma (in group) hom_compose:
   361 lemma (in group) hom_compose:
   362      "\<lbrakk>h \<in> hom(G,H); i \<in> hom(H,I)\<rbrakk> \<Longrightarrow> i O h \<in> hom(G,I)"
   362      "\<lbrakk>h \<in> hom(G,H); i \<in> hom(H,I)\<rbrakk> \<Longrightarrow> i O h \<in> hom(G,I)"
   363 by (force simp add: hom_def comp_fun) 
   363 by (force simp add: hom_def comp_fun)
   364 
   364 
   365 lemma hom_is_fun:
   365 lemma hom_is_fun:
   366   "h \<in> hom(G,H) \<Longrightarrow> h \<in> carrier(G) -> carrier(H)"
   366   "h \<in> hom(G,H) \<Longrightarrow> h \<in> carrier(G) -> carrier(H)"
   367   by (simp add: hom_def)
   367   by (simp add: hom_def)
   368 
   368 
   372 definition
   372 definition
   373   iso :: "[i,i] => i"  (infixr "\<cong>" 60) where
   373   iso :: "[i,i] => i"  (infixr "\<cong>" 60) where
   374   "G \<cong> H == hom(G,H) \<inter> bij(carrier(G), carrier(H))"
   374   "G \<cong> H == hom(G,H) \<inter> bij(carrier(G), carrier(H))"
   375 
   375 
   376 lemma (in group) iso_refl: "id(carrier(G)) \<in> G \<cong> G"
   376 lemma (in group) iso_refl: "id(carrier(G)) \<in> G \<cong> G"
   377   by (simp add: iso_def hom_def id_type id_bij) 
   377   by (simp add: iso_def hom_def id_type id_bij)
   378 
   378 
   379 
   379 
   380 lemma (in group) iso_sym:
   380 lemma (in group) iso_sym:
   381      "h \<in> G \<cong> H \<Longrightarrow> converse(h) \<in> H \<cong> G"
   381      "h \<in> G \<cong> H \<Longrightarrow> converse(h) \<in> H \<cong> G"
   382 apply (simp add: iso_def bij_converse_bij, clarify) 
   382 apply (simp add: iso_def bij_converse_bij, clarify)
   383 apply (subgoal_tac "converse(h) \<in> carrier(H) \<rightarrow> carrier(G)") 
   383 apply (subgoal_tac "converse(h) \<in> carrier(H) \<rightarrow> carrier(G)")
   384  prefer 2 apply (simp add: bij_converse_bij bij_is_fun) 
   384  prefer 2 apply (simp add: bij_converse_bij bij_is_fun)
   385 apply (auto intro: left_inverse_eq [of _ "carrier(G)" "carrier(H)"] 
   385 apply (auto intro: left_inverse_eq [of _ "carrier(G)" "carrier(H)"]
   386             simp add: hom_def bij_is_inj right_inverse_bij); 
   386             simp add: hom_def bij_is_inj right_inverse_bij);
   387 done
   387 done
   388 
   388 
   389 lemma (in group) iso_trans: 
   389 lemma (in group) iso_trans:
   390      "\<lbrakk>h \<in> G \<cong> H; i \<in> H \<cong> I\<rbrakk> \<Longrightarrow> i O h \<in> G \<cong> I"
   390      "\<lbrakk>h \<in> G \<cong> H; i \<in> H \<cong> I\<rbrakk> \<Longrightarrow> i O h \<in> G \<cong> I"
   391   by (auto simp add: iso_def hom_compose comp_bij)
   391   by (auto simp add: iso_def hom_compose comp_bij)
   392 
   392 
   393 lemma DirProdGroup_commute_iso:
   393 lemma DirProdGroup_commute_iso:
   394   assumes "group(G)" and "group(H)"
   394   assumes "group(G)" and "group(H)"
   406 proof -
   406 proof -
   407   interpret group G by fact
   407   interpret group G by fact
   408   interpret group H by fact
   408   interpret group H by fact
   409   interpret group I by fact
   409   interpret group I by fact
   410   show ?thesis
   410   show ?thesis
   411     by (auto intro: lam_type simp add: iso_def hom_def inj_def surj_def bij_def) 
   411     by (auto intro: lam_type simp add: iso_def hom_def inj_def surj_def bij_def)
   412 qed
   412 qed
   413 
   413 
   414 text{*Basis for homomorphism proofs: we assume two groups @{term G} and
   414 text{*Basis for homomorphism proofs: we assume two groups @{term G} and
   415   @{term H}, with a homomorphism @{term h} between them*}
   415   @{term H}, with a homomorphism @{term h} between them*}
   416 locale group_hom = G: group G + H: group H
   416 locale group_hom = G: group G + H: group H
   480   "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> inv (x \<cdot> y) = inv x \<cdot> inv y"
   480   "\<lbrakk>x \<in> carrier(G); y \<in> carrier(G)\<rbrakk> \<Longrightarrow> inv (x \<cdot> y) = inv x \<cdot> inv y"
   481   by (simp add: m_ac inv_mult_group)
   481   by (simp add: m_ac inv_mult_group)
   482 
   482 
   483 
   483 
   484 lemma (in group) subgroup_self: "subgroup (carrier(G),G)"
   484 lemma (in group) subgroup_self: "subgroup (carrier(G),G)"
   485 by (simp add: subgroup_def) 
   485 by (simp add: subgroup_def)
   486 
   486 
   487 lemma (in group) subgroup_imp_group:
   487 lemma (in group) subgroup_imp_group:
   488   "subgroup(H,G) \<Longrightarrow> group (update_carrier(G,H))"
   488   "subgroup(H,G) \<Longrightarrow> group (update_carrier(G,H))"
   489 by (simp add: subgroup.is_group)
   489 by (simp add: subgroup.is_group)
   490 
   490 
   510 
   510 
   511 subsection {*Bijections Form a Group *}
   511 subsection {*Bijections Form a Group *}
   512 
   512 
   513 theorem group_BijGroup: "group(BijGroup(S))"
   513 theorem group_BijGroup: "group(BijGroup(S))"
   514 apply (simp add: BijGroup_def)
   514 apply (simp add: BijGroup_def)
   515 apply (rule groupI) 
   515 apply (rule groupI)
   516     apply (simp_all add: id_bij comp_bij comp_assoc) 
   516     apply (simp_all add: id_bij comp_bij comp_assoc)
   517  apply (simp add: id_bij bij_is_fun left_comp_id [of _ S S] fun_is_rel)
   517  apply (simp add: id_bij bij_is_fun left_comp_id [of _ S S] fun_is_rel)
   518 apply (blast intro: left_comp_inverse bij_is_inj bij_converse_bij)
   518 apply (blast intro: left_comp_inverse bij_is_inj bij_converse_bij)
   519 done
   519 done
   520 
   520 
   521 
   521 
   522 subsection{*Automorphisms Form a Group*}
   522 subsection{*Automorphisms Form a Group*}
   523 
   523 
   524 lemma Bij_Inv_mem: "\<lbrakk>f \<in> bij(S,S);  x \<in> S\<rbrakk> \<Longrightarrow> converse(f) ` x \<in> S" 
   524 lemma Bij_Inv_mem: "\<lbrakk>f \<in> bij(S,S);  x \<in> S\<rbrakk> \<Longrightarrow> converse(f) ` x \<in> S"
   525 by (blast intro: apply_funtype bij_is_fun bij_converse_bij)
   525 by (blast intro: apply_funtype bij_is_fun bij_converse_bij)
   526 
   526 
   527 lemma inv_BijGroup: "f \<in> bij(S,S) \<Longrightarrow> m_inv (BijGroup(S), f) = converse(f)"
   527 lemma inv_BijGroup: "f \<in> bij(S,S) \<Longrightarrow> m_inv (BijGroup(S), f) = converse(f)"
   528 apply (rule group.inv_equality)
   528 apply (rule group.inv_equality)
   529 apply (rule group_BijGroup)
   529 apply (rule group_BijGroup)
   530 apply (simp_all add: BijGroup_def bij_converse_bij 
   530 apply (simp_all add: BijGroup_def bij_converse_bij
   531           left_comp_inverse [OF bij_is_inj]) 
   531           left_comp_inverse [OF bij_is_inj])
   532 done
   532 done
   533 
   533 
   534 lemma iso_is_bij: "h \<in> G \<cong> H ==> h \<in> bij(carrier(G), carrier(H))"
   534 lemma iso_is_bij: "h \<in> G \<cong> H ==> h \<in> bij(carrier(G), carrier(H))"
   535 by (simp add: iso_def)
   535 by (simp add: iso_def)
   536 
   536 
   552 proof (rule subgroup.intro)
   552 proof (rule subgroup.intro)
   553   show "auto(G) \<subseteq> carrier (BijGroup (carrier(G)))"
   553   show "auto(G) \<subseteq> carrier (BijGroup (carrier(G)))"
   554     by (auto simp add: auto_def BijGroup_def iso_def)
   554     by (auto simp add: auto_def BijGroup_def iso_def)
   555 next
   555 next
   556   fix x y
   556   fix x y
   557   assume "x \<in> auto(G)" "y \<in> auto(G)" 
   557   assume "x \<in> auto(G)" "y \<in> auto(G)"
   558   thus "x \<cdot>\<^bsub>BijGroup (carrier(G))\<^esub> y \<in> auto(G)"
   558   thus "x \<cdot>\<^bsub>BijGroup (carrier(G))\<^esub> y \<in> auto(G)"
   559     by (auto simp add: BijGroup_def auto_def iso_def bij_is_fun 
   559     by (auto simp add: BijGroup_def auto_def iso_def bij_is_fun
   560                        group.hom_compose comp_bij)
   560                        group.hom_compose comp_bij)
   561 next
   561 next
   562   show "\<one>\<^bsub>BijGroup (carrier(G))\<^esub> \<in> auto(G)" by (simp add:  BijGroup_def id_in_auto)
   562   show "\<one>\<^bsub>BijGroup (carrier(G))\<^esub> \<in> auto(G)" by (simp add:  BijGroup_def id_in_auto)
   563 next
   563 next
   564   fix x 
   564   fix x
   565   assume "x \<in> auto(G)" 
   565   assume "x \<in> auto(G)"
   566   thus "inv\<^bsub>BijGroup (carrier(G))\<^esub> x \<in> auto(G)"
   566   thus "inv\<^bsub>BijGroup (carrier(G))\<^esub> x \<in> auto(G)"
   567     by (simp add: auto_def inv_BijGroup iso_is_bij iso_sym) 
   567     by (simp add: auto_def inv_BijGroup iso_is_bij iso_sym)
   568 qed
   568 qed
   569 
   569 
   570 theorem (in group) AutoGroup: "group (AutoGroup(G))"
   570 theorem (in group) AutoGroup: "group (AutoGroup(G))"
   571 by (simp add: AutoGroup_def subgroup.is_group subgroup_auto group_BijGroup)
   571 by (simp add: AutoGroup_def subgroup.is_group subgroup_auto group_BijGroup)
   572 
   572 
   654 subsection {* Normal subgroups *}
   654 subsection {* Normal subgroups *}
   655 
   655 
   656 lemma normal_imp_subgroup: "H \<lhd> G ==> subgroup(H,G)"
   656 lemma normal_imp_subgroup: "H \<lhd> G ==> subgroup(H,G)"
   657   by (simp add: normal_def subgroup_def)
   657   by (simp add: normal_def subgroup_def)
   658 
   658 
   659 lemma (in group) normalI: 
   659 lemma (in group) normalI:
   660   "subgroup(H,G) \<Longrightarrow> (\<forall>x \<in> carrier(G). H #> x = x <# H) \<Longrightarrow> H \<lhd> G";
   660   "subgroup(H,G) \<Longrightarrow> (\<forall>x \<in> carrier(G). H #> x = x <# H) \<Longrightarrow> H \<lhd> G";
   661   by (simp add: normal_def normal_axioms_def)
   661   by (simp add: normal_def normal_axioms_def)
   662 
   662 
   663 lemma (in normal) inv_op_closed1:
   663 lemma (in normal) inv_op_closed1:
   664      "\<lbrakk>x \<in> carrier(G); h \<in> H\<rbrakk> \<Longrightarrow> (inv x) \<cdot> h \<cdot> x \<in> H"
   664      "\<lbrakk>x \<in> carrier(G); h \<in> H\<rbrakk> \<Longrightarrow> (inv x) \<cdot> h \<cdot> x \<in> H"
   665 apply (insert coset_eq) 
   665 apply (insert coset_eq)
   666 apply (auto simp add: l_coset_def r_coset_def)
   666 apply (auto simp add: l_coset_def r_coset_def)
   667 apply (drule bspec, assumption)
   667 apply (drule bspec, assumption)
   668 apply (drule equalityD1 [THEN subsetD], blast, clarify)
   668 apply (drule equalityD1 [THEN subsetD], blast, clarify)
   669 apply (simp add: m_assoc)
   669 apply (simp add: m_assoc)
   670 apply (simp add: m_assoc [symmetric])
   670 apply (simp add: m_assoc [symmetric])
   671 done
   671 done
   672 
   672 
   673 lemma (in normal) inv_op_closed2:
   673 lemma (in normal) inv_op_closed2:
   674      "\<lbrakk>x \<in> carrier(G); h \<in> H\<rbrakk> \<Longrightarrow> x \<cdot> h \<cdot> (inv x) \<in> H"
   674      "\<lbrakk>x \<in> carrier(G); h \<in> H\<rbrakk> \<Longrightarrow> x \<cdot> h \<cdot> (inv x) \<in> H"
   675 apply (subgoal_tac "inv (inv x) \<cdot> h \<cdot> (inv x) \<in> H") 
   675 apply (subgoal_tac "inv (inv x) \<cdot> h \<cdot> (inv x) \<in> H")
   676 apply simp 
   676 apply simp
   677 apply (blast intro: inv_op_closed1) 
   677 apply (blast intro: inv_op_closed1)
   678 done
   678 done
   679 
   679 
   680 text{*Alternative characterization of normal subgroups*}
   680 text{*Alternative characterization of normal subgroups*}
   681 lemma (in group) normal_inv_iff:
   681 lemma (in group) normal_inv_iff:
   682      "(N \<lhd> G) \<longleftrightarrow>
   682      "(N \<lhd> G) \<longleftrightarrow>
   683       (subgroup(N,G) & (\<forall>x \<in> carrier(G). \<forall>h \<in> N. x \<cdot> h \<cdot> (inv x) \<in> N))"
   683       (subgroup(N,G) & (\<forall>x \<in> carrier(G). \<forall>h \<in> N. x \<cdot> h \<cdot> (inv x) \<in> N))"
   684       (is "_ \<longleftrightarrow> ?rhs")
   684       (is "_ \<longleftrightarrow> ?rhs")
   685 proof
   685 proof
   686   assume N: "N \<lhd> G"
   686   assume N: "N \<lhd> G"
   687   show ?rhs
   687   show ?rhs
   688     by (blast intro: N normal.inv_op_closed2 normal_imp_subgroup) 
   688     by (blast intro: N normal.inv_op_closed2 normal_imp_subgroup)
   689 next
   689 next
   690   assume ?rhs
   690   assume ?rhs
   691   hence sg: "subgroup(N,G)" 
   691   hence sg: "subgroup(N,G)"
   692     and closed: "\<And>x. x\<in>carrier(G) \<Longrightarrow> \<forall>h\<in>N. x \<cdot> h \<cdot> inv x \<in> N" by auto
   692     and closed: "\<And>x. x\<in>carrier(G) \<Longrightarrow> \<forall>h\<in>N. x \<cdot> h \<cdot> inv x \<in> N" by auto
   693   hence sb: "N \<subseteq> carrier(G)" by (simp add: subgroup.subset) 
   693   hence sb: "N \<subseteq> carrier(G)" by (simp add: subgroup.subset)
   694   show "N \<lhd> G"
   694   show "N \<lhd> G"
   695   proof (intro normalI [OF sg], simp add: l_coset_def r_coset_def, clarify)
   695   proof (intro normalI [OF sg], simp add: l_coset_def r_coset_def, clarify)
   696     fix x
   696     fix x
   697     assume x: "x \<in> carrier(G)"
   697     assume x: "x \<in> carrier(G)"
   698     show "(\<Union>h\<in>N. {h \<cdot> x}) = (\<Union>h\<in>N. {x \<cdot> h})"
   698     show "(\<Union>h\<in>N. {h \<cdot> x}) = (\<Union>h\<in>N. {x \<cdot> h})"
   699     proof
   699     proof
   700       show "(\<Union>h\<in>N. {h \<cdot> x}) \<subseteq> (\<Union>h\<in>N. {x \<cdot> h})"
   700       show "(\<Union>h\<in>N. {h \<cdot> x}) \<subseteq> (\<Union>h\<in>N. {x \<cdot> h})"
   701       proof clarify
   701       proof clarify
   702         fix n
   702         fix n
   703         assume n: "n \<in> N" 
   703         assume n: "n \<in> N"
   704         show "n \<cdot> x \<in> (\<Union>h\<in>N. {x \<cdot> h})"
   704         show "n \<cdot> x \<in> (\<Union>h\<in>N. {x \<cdot> h})"
   705         proof (rule UN_I) 
   705         proof (rule UN_I)
   706           from closed [of "inv x"]
   706           from closed [of "inv x"]
   707           show "inv x \<cdot> n \<cdot> x \<in> N" by (simp add: x n)
   707           show "inv x \<cdot> n \<cdot> x \<in> N" by (simp add: x n)
   708           show "n \<cdot> x \<in> {x \<cdot> (inv x \<cdot> n \<cdot> x)}"
   708           show "n \<cdot> x \<in> {x \<cdot> (inv x \<cdot> n \<cdot> x)}"
   709             by (simp add: x n m_assoc [symmetric] sb [THEN subsetD])
   709             by (simp add: x n m_assoc [symmetric] sb [THEN subsetD])
   710         qed
   710         qed
   711       qed
   711       qed
   712     next
   712     next
   713       show "(\<Union>h\<in>N. {x \<cdot> h}) \<subseteq> (\<Union>h\<in>N. {h \<cdot> x})"
   713       show "(\<Union>h\<in>N. {x \<cdot> h}) \<subseteq> (\<Union>h\<in>N. {h \<cdot> x})"
   714       proof clarify
   714       proof clarify
   715         fix n
   715         fix n
   716         assume n: "n \<in> N" 
   716         assume n: "n \<in> N"
   717         show "x \<cdot> n \<in> (\<Union>h\<in>N. {h \<cdot> x})"
   717         show "x \<cdot> n \<in> (\<Union>h\<in>N. {h \<cdot> x})"
   718         proof (rule UN_I) 
   718         proof (rule UN_I)
   719           show "x \<cdot> n \<cdot> inv x \<in> N" by (simp add: x n closed)
   719           show "x \<cdot> n \<cdot> inv x \<in> N" by (simp add: x n closed)
   720           show "x \<cdot> n \<in> {x \<cdot> n \<cdot> inv x \<cdot> x}"
   720           show "x \<cdot> n \<in> {x \<cdot> n \<cdot> inv x \<cdot> x}"
   721             by (simp add: x n m_assoc sb [THEN subsetD])
   721             by (simp add: x n m_assoc sb [THEN subsetD])
   722         qed
   722         qed
   723       qed
   723       qed
   777 lemma (in group) setmult_subset_G:
   777 lemma (in group) setmult_subset_G:
   778      "\<lbrakk>H \<subseteq> carrier(G); K \<subseteq> carrier(G)\<rbrakk> \<Longrightarrow> H <#> K \<subseteq> carrier(G)"
   778      "\<lbrakk>H \<subseteq> carrier(G); K \<subseteq> carrier(G)\<rbrakk> \<Longrightarrow> H <#> K \<subseteq> carrier(G)"
   779 by (auto simp add: set_mult_def subsetD)
   779 by (auto simp add: set_mult_def subsetD)
   780 
   780 
   781 lemma (in group) subgroup_mult_id: "subgroup(H,G) \<Longrightarrow> H <#> H = H"
   781 lemma (in group) subgroup_mult_id: "subgroup(H,G) \<Longrightarrow> H <#> H = H"
   782 apply (rule equalityI) 
   782 apply (rule equalityI)
   783 apply (auto simp add: subgroup.m_closed set_mult_def Sigma_def image_def)
   783 apply (auto simp add: subgroup.m_closed set_mult_def Sigma_def image_def)
   784 apply (rule_tac x = x in bexI)
   784 apply (rule_tac x = x in bexI)
   785 apply (rule bexI [of _ "\<one>"])
   785 apply (rule bexI [of _ "\<one>"])
   786 apply (auto simp add: subgroup.one_closed subgroup.subset [THEN subsetD])
   786 apply (auto simp add: subgroup.one_closed subgroup.subset [THEN subsetD])
   787 done
   787 done
   868    shows "equiv (carrier(G), rcong H)"
   868    shows "equiv (carrier(G), rcong H)"
   869 proof -
   869 proof -
   870   interpret group G by fact
   870   interpret group G by fact
   871   show ?thesis proof (simp add: equiv_def, intro conjI)
   871   show ?thesis proof (simp add: equiv_def, intro conjI)
   872     show "rcong H \<subseteq> carrier(G) \<times> carrier(G)"
   872     show "rcong H \<subseteq> carrier(G) \<times> carrier(G)"
   873       by (auto simp add: r_congruent_def) 
   873       by (auto simp add: r_congruent_def)
   874   next
   874   next
   875     show "refl (carrier(G), rcong H)"
   875     show "refl (carrier(G), rcong H)"
   876       by (auto simp add: r_congruent_def refl_def) 
   876       by (auto simp add: r_congruent_def refl_def)
   877   next
   877   next
   878     show "sym (rcong H)"
   878     show "sym (rcong H)"
   879     proof (simp add: r_congruent_def sym_def, clarify)
   879     proof (simp add: r_congruent_def sym_def, clarify)
   880       fix x y
   880       fix x y
   881       assume [simp]: "x \<in> carrier(G)" "y \<in> carrier(G)" 
   881       assume [simp]: "x \<in> carrier(G)" "y \<in> carrier(G)"
   882         and "inv x \<cdot> y \<in> H"
   882         and "inv x \<cdot> y \<in> H"
   883       hence "inv (inv x \<cdot> y) \<in> H" by simp
   883       hence "inv (inv x \<cdot> y) \<in> H" by simp
   884       thus "inv y \<cdot> x \<in> H" by (simp add: inv_mult_group)
   884       thus "inv y \<cdot> x \<in> H" by (simp add: inv_mult_group)
   885     qed
   885     qed
   886   next
   886   next
   888     proof (simp add: r_congruent_def trans_def, clarify)
   888     proof (simp add: r_congruent_def trans_def, clarify)
   889       fix x y z
   889       fix x y z
   890       assume [simp]: "x \<in> carrier(G)" "y \<in> carrier(G)" "z \<in> carrier(G)"
   890       assume [simp]: "x \<in> carrier(G)" "y \<in> carrier(G)" "z \<in> carrier(G)"
   891         and "inv x \<cdot> y \<in> H" and "inv y \<cdot> z \<in> H"
   891         and "inv x \<cdot> y \<in> H" and "inv y \<cdot> z \<in> H"
   892       hence "(inv x \<cdot> y) \<cdot> (inv y \<cdot> z) \<in> H" by simp
   892       hence "(inv x \<cdot> y) \<cdot> (inv y \<cdot> z) \<in> H" by simp
   893       hence "inv x \<cdot> (y \<cdot> inv y) \<cdot> z \<in> H" by (simp add: m_assoc del: inv) 
   893       hence "inv x \<cdot> (y \<cdot> inv y) \<cdot> z \<in> H" by (simp add: m_assoc del: inv)
   894       thus "inv x \<cdot> z \<in> H" by simp
   894       thus "inv x \<cdot> z \<in> H" by simp
   895     qed
   895     qed
   896   qed
   896   qed
   897 qed
   897 qed
   898 
   898 
   900   Was there a mistake in the definitions? I'd have expected them to
   900   Was there a mistake in the definitions? I'd have expected them to
   901   correspond to right cosets.*}
   901   correspond to right cosets.*}
   902 lemma (in subgroup) l_coset_eq_rcong:
   902 lemma (in subgroup) l_coset_eq_rcong:
   903   assumes "group(G)"
   903   assumes "group(G)"
   904   assumes a: "a \<in> carrier(G)"
   904   assumes a: "a \<in> carrier(G)"
   905   shows "a <# H = (rcong H) `` {a}" 
   905   shows "a <# H = (rcong H) `` {a}"
   906 proof -
   906 proof -
   907   interpret group G by fact
   907   interpret group G by fact
   908   show ?thesis
   908   show ?thesis
   909     by (force simp add: r_congruent_def l_coset_def m_assoc [symmetric] a
   909     by (force simp add: r_congruent_def l_coset_def m_assoc [symmetric] a
   910       Collect_image_eq) 
   910       Collect_image_eq)
   911 qed
   911 qed
   912 
   912 
   913 lemma (in group) rcos_equation:
   913 lemma (in group) rcos_equation:
   914   assumes "subgroup(H, G)"
   914   assumes "subgroup(H, G)"
   915   shows
   915   shows
   916      "\<lbrakk>ha \<cdot> a = h \<cdot> b; a \<in> carrier(G);  b \<in> carrier(G);  
   916      "\<lbrakk>ha \<cdot> a = h \<cdot> b; a \<in> carrier(G);  b \<in> carrier(G);
   917         h \<in> H;  ha \<in> H;  hb \<in> H\<rbrakk>
   917         h \<in> H;  ha \<in> H;  hb \<in> H\<rbrakk>
   918       \<Longrightarrow> hb \<cdot> a \<in> (\<Union>h\<in>H. {h \<cdot> b})" (is "PROP ?P")
   918       \<Longrightarrow> hb \<cdot> a \<in> (\<Union>h\<in>H. {h \<cdot> b})" (is "PROP ?P")
   919 proof -
   919 proof -
   920   interpret subgroup H G by fact
   920   interpret subgroup H G by fact
   921   show "PROP ?P"
   921   show "PROP ?P"
   980   fix a
   980   fix a
   981   assume a: "a \<in> carrier(G)"
   981   assume a: "a \<in> carrier(G)"
   982   show "|H #> a| = |H|"
   982   show "|H #> a| = |H|"
   983   proof (rule eqpollI [THEN cardinal_cong])
   983   proof (rule eqpollI [THEN cardinal_cong])
   984     show "H #> a \<lesssim> H"
   984     show "H #> a \<lesssim> H"
   985     proof (simp add: lepoll_def, intro exI) 
   985     proof (simp add: lepoll_def, intro exI)
   986       show "(\<lambda>y \<in> H#>a. y \<cdot> inv a) \<in> inj(H #> a, H)"
   986       show "(\<lambda>y \<in> H#>a. y \<cdot> inv a) \<in> inj(H #> a, H)"
   987         by (auto intro: lam_type 
   987         by (auto intro: lam_type
   988                  simp add: inj_def r_coset_def m_assoc subsetD [OF H] a)
   988                  simp add: inj_def r_coset_def m_assoc subsetD [OF H] a)
   989     qed
   989     qed
   990     show "H \<lesssim> H #> a"
   990     show "H \<lesssim> H #> a"
   991     proof (simp add: lepoll_def, intro exI) 
   991     proof (simp add: lepoll_def, intro exI)
   992       show "(\<lambda>y\<in> H. y \<cdot> a) \<in> inj(H, H #> a)"
   992       show "(\<lambda>y\<in> H. y \<cdot> a) \<in> inj(H, H #> a)"
   993         by (auto intro: lam_type 
   993         by (auto intro: lam_type
   994                  simp add: inj_def r_coset_def  subsetD [OF H] a)
   994                  simp add: inj_def r_coset_def  subsetD [OF H] a)
   995     qed
   995     qed
   996   qed
   996   qed
   997 qed
   997 qed
   998 
   998 
  1019 subsection {*Quotient Groups: Factorization of a Group*}
  1019 subsection {*Quotient Groups: Factorization of a Group*}
  1020 
  1020 
  1021 definition
  1021 definition
  1022   FactGroup :: "[i,i] => i" (infixl "Mod" 65) where
  1022   FactGroup :: "[i,i] => i" (infixl "Mod" 65) where
  1023     --{*Actually defined for groups rather than monoids*}
  1023     --{*Actually defined for groups rather than monoids*}
  1024   "G Mod H == 
  1024   "G Mod H ==
  1025      <rcosets\<^bsub>G\<^esub> H, \<lambda><K1,K2> \<in> (rcosets\<^bsub>G\<^esub> H) \<times> (rcosets\<^bsub>G\<^esub> H). K1 <#>\<^bsub>G\<^esub> K2, H, 0>"
  1025      <rcosets\<^bsub>G\<^esub> H, \<lambda><K1,K2> \<in> (rcosets\<^bsub>G\<^esub> H) \<times> (rcosets\<^bsub>G\<^esub> H). K1 <#>\<^bsub>G\<^esub> K2, H, 0>"
  1026 
  1026 
  1027 lemma (in normal) setmult_closed:
  1027 lemma (in normal) setmult_closed:
  1028      "\<lbrakk>K1 \<in> rcosets H; K2 \<in> rcosets H\<rbrakk> \<Longrightarrow> K1 <#> K2 \<in> rcosets H"
  1028      "\<lbrakk>K1 \<in> rcosets H; K2 \<in> rcosets H\<rbrakk> \<Longrightarrow> K1 <#> K2 \<in> rcosets H"
  1029 by (auto simp add: rcos_sum RCOSETS_def)
  1029 by (auto simp add: rcos_sum RCOSETS_def)
  1064 apply (auto dest: rcosets_inv_mult_group_eq simp add: setinv_closed)
  1064 apply (auto dest: rcosets_inv_mult_group_eq simp add: setinv_closed)
  1065 done
  1065 done
  1066 
  1066 
  1067 lemma (in normal) inv_FactGroup:
  1067 lemma (in normal) inv_FactGroup:
  1068      "X \<in> carrier (G Mod H) \<Longrightarrow> inv\<^bsub>G Mod H\<^esub> X = set_inv X"
  1068      "X \<in> carrier (G Mod H) \<Longrightarrow> inv\<^bsub>G Mod H\<^esub> X = set_inv X"
  1069 apply (rule group.inv_equality [OF factorgroup_is_group]) 
  1069 apply (rule group.inv_equality [OF factorgroup_is_group])
  1070 apply (simp_all add: FactGroup_def setinv_closed rcosets_inv_mult_group_eq)
  1070 apply (simp_all add: FactGroup_def setinv_closed rcosets_inv_mult_group_eq)
  1071 done
  1071 done
  1072 
  1072 
  1073 text{*The coset map is a homomorphism from @{term G} to the quotient group
  1073 text{*The coset map is a homomorphism from @{term G} to the quotient group
  1074   @{term "G Mod H"}*}
  1074   @{term "G Mod H"}*}
  1075 lemma (in normal) r_coset_hom_Mod:
  1075 lemma (in normal) r_coset_hom_Mod:
  1076   "(\<lambda>a \<in> carrier(G). H #> a) \<in> hom(G, G Mod H)"
  1076   "(\<lambda>a \<in> carrier(G). H #> a) \<in> hom(G, G Mod H)"
  1077 by (auto simp add: FactGroup_def RCOSETS_def hom_def rcos_sum intro: lam_type) 
  1077 by (auto simp add: FactGroup_def RCOSETS_def hom_def rcos_sum intro: lam_type)
  1078 
  1078 
  1079 
  1079 
  1080 subsection{*The First Isomorphism Theorem*}
  1080 subsection{*The First Isomorphism Theorem*}
  1081 
  1081 
  1082 text{*The quotient by the kernel of a homomorphism is isomorphic to the 
  1082 text{*The quotient by the kernel of a homomorphism is isomorphic to the
  1083   range of that homomorphism.*}
  1083   range of that homomorphism.*}
  1084 
  1084 
  1085 definition
  1085 definition
  1086   kernel :: "[i,i,i] => i" where
  1086   kernel :: "[i,i,i] => i" where
  1087     --{*the kernel of a homomorphism*}
  1087     --{*the kernel of a homomorphism*}
  1088   "kernel(G,H,h) == {x \<in> carrier(G). h ` x = \<one>\<^bsub>H\<^esub>}";
  1088   "kernel(G,H,h) == {x \<in> carrier(G). h ` x = \<one>\<^bsub>H\<^esub>}";
  1089 
  1089 
  1090 lemma (in group_hom) subgroup_kernel: "subgroup (kernel(G,H,h), G)"
  1090 lemma (in group_hom) subgroup_kernel: "subgroup (kernel(G,H,h), G)"
  1091 apply (rule subgroup.intro) 
  1091 apply (rule subgroup.intro)
  1092 apply (auto simp add: kernel_def group.intro)
  1092 apply (auto simp add: kernel_def group.intro)
  1093 done
  1093 done
  1094 
  1094 
  1095 text{*The kernel of a homomorphism is a normal subgroup*}
  1095 text{*The kernel of a homomorphism is a normal subgroup*}
  1096 lemma (in group_hom) normal_kernel: "(kernel(G,H,h)) \<lhd> G"
  1096 lemma (in group_hom) normal_kernel: "(kernel(G,H,h)) \<lhd> G"
  1097 apply (simp add: group.normal_inv_iff subgroup_kernel group.intro)
  1097 apply (simp add: group.normal_inv_iff subgroup_kernel group.intro)
  1098 apply (simp add: kernel_def)  
  1098 apply (simp add: kernel_def)
  1099 done
  1099 done
  1100 
  1100 
  1101 lemma (in group_hom) FactGroup_nonempty:
  1101 lemma (in group_hom) FactGroup_nonempty:
  1102   assumes X: "X \<in> carrier (G Mod kernel(G,H,h))"
  1102   assumes X: "X \<in> carrier (G Mod kernel(G,H,h))"
  1103   shows "X \<noteq> 0"
  1103   shows "X \<noteq> 0"
  1104 proof -
  1104 proof -
  1105   from X
  1105   from X
  1106   obtain g where "g \<in> carrier(G)" 
  1106   obtain g where "g \<in> carrier(G)"
  1107              and "X = kernel(G,H,h) #> g"
  1107              and "X = kernel(G,H,h) #> g"
  1108     by (auto simp add: FactGroup_def RCOSETS_def)
  1108     by (auto simp add: FactGroup_def RCOSETS_def)
  1109   thus ?thesis 
  1109   thus ?thesis
  1110    by (auto simp add: kernel_def r_coset_def image_def intro: hom_one)
  1110    by (auto simp add: kernel_def r_coset_def image_def intro: hom_one)
  1111 qed
  1111 qed
  1112 
  1112 
  1113 
  1113 
  1114 lemma (in group_hom) FactGroup_contents_mem:
  1114 lemma (in group_hom) FactGroup_contents_mem:
  1115   assumes X: "X \<in> carrier (G Mod (kernel(G,H,h)))"
  1115   assumes X: "X \<in> carrier (G Mod (kernel(G,H,h)))"
  1116   shows "contents (h``X) \<in> carrier(H)"
  1116   shows "contents (h``X) \<in> carrier(H)"
  1117 proof -
  1117 proof -
  1118   from X
  1118   from X
  1119   obtain g where g: "g \<in> carrier(G)" 
  1119   obtain g where g: "g \<in> carrier(G)"
  1120              and "X = kernel(G,H,h) #> g"
  1120              and "X = kernel(G,H,h) #> g"
  1121     by (auto simp add: FactGroup_def RCOSETS_def)
  1121     by (auto simp add: FactGroup_def RCOSETS_def)
  1122   hence "h `` X = {h ` g}"
  1122   hence "h `` X = {h ` g}"
  1123     by (auto simp add: kernel_def r_coset_def image_UN 
  1123     by (auto simp add: kernel_def r_coset_def image_UN
  1124                        image_eq_UN [OF hom_is_fun] g)
  1124                        image_eq_UN [OF hom_is_fun] g)
  1125   thus ?thesis by (auto simp add: g)
  1125   thus ?thesis by (auto simp add: g)
  1126 qed
  1126 qed
  1127 
  1127 
  1128 lemma mult_FactGroup:
  1128 lemma mult_FactGroup:
  1129      "[|X \<in> carrier(G Mod H); X' \<in> carrier(G Mod H)|] 
  1129      "[|X \<in> carrier(G Mod H); X' \<in> carrier(G Mod H)|]
  1130       ==> X \<cdot>\<^bsub>(G Mod H)\<^esub> X' = X <#>\<^bsub>G\<^esub> X'"
  1130       ==> X \<cdot>\<^bsub>(G Mod H)\<^esub> X' = X <#>\<^bsub>G\<^esub> X'"
  1131 by (simp add: FactGroup_def) 
  1131 by (simp add: FactGroup_def)
  1132 
  1132 
  1133 lemma (in normal) FactGroup_m_closed:
  1133 lemma (in normal) FactGroup_m_closed:
  1134      "[|X \<in> carrier(G Mod H); X' \<in> carrier(G Mod H)|] 
  1134      "[|X \<in> carrier(G Mod H); X' \<in> carrier(G Mod H)|]
  1135       ==> X <#>\<^bsub>G\<^esub> X' \<in> carrier(G Mod H)"
  1135       ==> X <#>\<^bsub>G\<^esub> X' \<in> carrier(G Mod H)"
  1136 by (simp add: FactGroup_def setmult_closed) 
  1136 by (simp add: FactGroup_def setmult_closed)
  1137 
  1137 
  1138 lemma (in group_hom) FactGroup_hom:
  1138 lemma (in group_hom) FactGroup_hom:
  1139      "(\<lambda>X \<in> carrier(G Mod (kernel(G,H,h))). contents (h``X))
  1139      "(\<lambda>X \<in> carrier(G Mod (kernel(G,H,h))). contents (h``X))
  1140       \<in> hom (G Mod (kernel(G,H,h)), H)" 
  1140       \<in> hom (G Mod (kernel(G,H,h)), H)"
  1141 proof (simp add: hom_def FactGroup_contents_mem lam_type mult_FactGroup normal.FactGroup_m_closed [OF normal_kernel], intro ballI)  
  1141 proof (simp add: hom_def FactGroup_contents_mem lam_type mult_FactGroup normal.FactGroup_m_closed [OF normal_kernel], intro ballI)
  1142   fix X and X'
  1142   fix X and X'
  1143   assume X:  "X  \<in> carrier (G Mod kernel(G,H,h))"
  1143   assume X:  "X  \<in> carrier (G Mod kernel(G,H,h))"
  1144      and X': "X' \<in> carrier (G Mod kernel(G,H,h))"
  1144      and X': "X' \<in> carrier (G Mod kernel(G,H,h))"
  1145   then
  1145   then
  1146   obtain g and g'
  1146   obtain g and g'
  1147            where "g \<in> carrier(G)" and "g' \<in> carrier(G)" 
  1147            where "g \<in> carrier(G)" and "g' \<in> carrier(G)"
  1148              and "X = kernel(G,H,h) #> g" and "X' = kernel(G,H,h) #> g'"
  1148              and "X = kernel(G,H,h) #> g" and "X' = kernel(G,H,h) #> g'"
  1149     by (auto simp add: FactGroup_def RCOSETS_def)
  1149     by (auto simp add: FactGroup_def RCOSETS_def)
  1150   hence all: "\<forall>x\<in>X. h ` x = h ` g" "\<forall>x\<in>X'. h ` x = h ` g'" 
  1150   hence all: "\<forall>x\<in>X. h ` x = h ` g" "\<forall>x\<in>X'. h ` x = h ` g'"
  1151     and Xsub: "X \<subseteq> carrier(G)" and X'sub: "X' \<subseteq> carrier(G)"
  1151     and Xsub: "X \<subseteq> carrier(G)" and X'sub: "X' \<subseteq> carrier(G)"
  1152     by (force simp add: kernel_def r_coset_def image_def)+
  1152     by (force simp add: kernel_def r_coset_def image_def)+
  1153   hence "h `` (X <#> X') = {h ` g \<cdot>\<^bsub>H\<^esub> h ` g'}" using X X'
  1153   hence "h `` (X <#> X') = {h ` g \<cdot>\<^bsub>H\<^esub> h ` g'}" using X X'
  1154     by (auto dest!: FactGroup_nonempty
  1154     by (auto dest!: FactGroup_nonempty
  1155              simp add: set_mult_def image_eq_UN [OF hom_is_fun] image_UN
  1155              simp add: set_mult_def image_eq_UN [OF hom_is_fun] image_UN
  1156                        subsetD [OF Xsub] subsetD [OF X'sub]) 
  1156                        subsetD [OF Xsub] subsetD [OF X'sub])
  1157   thus "contents (h `` (X <#> X')) = contents (h `` X) \<cdot>\<^bsub>H\<^esub> contents (h `` X')"
  1157   thus "contents (h `` (X <#> X')) = contents (h `` X) \<cdot>\<^bsub>H\<^esub> contents (h `` X')"
  1158     by (simp add: all image_eq_UN [OF hom_is_fun] FactGroup_nonempty 
  1158     by (simp add: all image_eq_UN [OF hom_is_fun] FactGroup_nonempty
  1159                   X X' Xsub X'sub)
  1159                   X X' Xsub X'sub)
  1160 qed
  1160 qed
  1161 
  1161 
  1162 
  1162 
  1163 text{*Lemma for the following injectivity result*}
  1163 text{*Lemma for the following injectivity result*}
  1164 lemma (in group_hom) FactGroup_subset:
  1164 lemma (in group_hom) FactGroup_subset:
  1165      "\<lbrakk>g \<in> carrier(G); g' \<in> carrier(G); h ` g = h ` g'\<rbrakk>
  1165      "\<lbrakk>g \<in> carrier(G); g' \<in> carrier(G); h ` g = h ` g'\<rbrakk>
  1166       \<Longrightarrow>  kernel(G,H,h) #> g \<subseteq> kernel(G,H,h) #> g'"
  1166       \<Longrightarrow>  kernel(G,H,h) #> g \<subseteq> kernel(G,H,h) #> g'"
  1167 apply (clarsimp simp add: kernel_def r_coset_def image_def)
  1167 apply (clarsimp simp add: kernel_def r_coset_def image_def)
  1168 apply (rename_tac y)  
  1168 apply (rename_tac y)
  1169 apply (rule_tac x="y \<cdot> g \<cdot> inv g'" in bexI) 
  1169 apply (rule_tac x="y \<cdot> g \<cdot> inv g'" in bexI)
  1170 apply (simp_all add: G.m_assoc) 
  1170 apply (simp_all add: G.m_assoc)
  1171 done
  1171 done
  1172 
  1172 
  1173 lemma (in group_hom) FactGroup_inj:
  1173 lemma (in group_hom) FactGroup_inj:
  1174      "(\<lambda>X\<in>carrier (G Mod kernel(G,H,h)). contents (h `` X))
  1174      "(\<lambda>X\<in>carrier (G Mod kernel(G,H,h)). contents (h `` X))
  1175       \<in> inj(carrier (G Mod kernel(G,H,h)), carrier(H))"
  1175       \<in> inj(carrier (G Mod kernel(G,H,h)), carrier(H))"
  1176 proof (simp add: inj_def FactGroup_contents_mem lam_type, clarify) 
  1176 proof (simp add: inj_def FactGroup_contents_mem lam_type, clarify)
  1177   fix X and X'
  1177   fix X and X'
  1178   assume X:  "X  \<in> carrier (G Mod kernel(G,H,h))"
  1178   assume X:  "X  \<in> carrier (G Mod kernel(G,H,h))"
  1179      and X': "X' \<in> carrier (G Mod kernel(G,H,h))"
  1179      and X': "X' \<in> carrier (G Mod kernel(G,H,h))"
  1180   then
  1180   then
  1181   obtain g and g'
  1181   obtain g and g'
  1182            where gX: "g \<in> carrier(G)"  "g' \<in> carrier(G)" 
  1182            where gX: "g \<in> carrier(G)"  "g' \<in> carrier(G)"
  1183               "X = kernel(G,H,h) #> g" "X' = kernel(G,H,h) #> g'"
  1183               "X = kernel(G,H,h) #> g" "X' = kernel(G,H,h) #> g'"
  1184     by (auto simp add: FactGroup_def RCOSETS_def)
  1184     by (auto simp add: FactGroup_def RCOSETS_def)
  1185   hence all: "\<forall>x\<in>X. h ` x = h ` g" "\<forall>x\<in>X'. h ` x = h ` g'"
  1185   hence all: "\<forall>x\<in>X. h ` x = h ` g" "\<forall>x\<in>X'. h ` x = h ` g'"
  1186     and Xsub: "X \<subseteq> carrier(G)" and X'sub: "X' \<subseteq> carrier(G)"
  1186     and Xsub: "X \<subseteq> carrier(G)" and X'sub: "X' \<subseteq> carrier(G)"
  1187     by (force simp add: kernel_def r_coset_def image_def)+
  1187     by (force simp add: kernel_def r_coset_def image_def)+
  1188   assume "contents (h `` X) = contents (h `` X')"
  1188   assume "contents (h `` X) = contents (h `` X')"
  1189   hence h: "h ` g = h ` g'"
  1189   hence h: "h ` g = h ` g'"
  1190     by (simp add: all image_eq_UN [OF hom_is_fun] FactGroup_nonempty 
  1190     by (simp add: all image_eq_UN [OF hom_is_fun] FactGroup_nonempty
  1191                   X X' Xsub X'sub)
  1191                   X X' Xsub X'sub)
  1192   show "X=X'" by (rule equalityI) (simp_all add: FactGroup_subset h gX) 
  1192   show "X=X'" by (rule equalityI) (simp_all add: FactGroup_subset h gX)
  1193 qed
  1193 qed
  1194 
  1194 
  1195 
  1195 
  1196 lemma (in group_hom) kernel_rcoset_subset:
  1196 lemma (in group_hom) kernel_rcoset_subset:
  1197   assumes g: "g \<in> carrier(G)"
  1197   assumes g: "g \<in> carrier(G)"
  1198   shows "kernel(G,H,h) #> g \<subseteq> carrier (G)"
  1198   shows "kernel(G,H,h) #> g \<subseteq> carrier (G)"
  1199     by (auto simp add: g kernel_def r_coset_def) 
  1199     by (auto simp add: g kernel_def r_coset_def)
  1200 
  1200 
  1201 
  1201 
  1202 
  1202 
  1203 text{*If the homomorphism @{term h} is onto @{term H}, then so is the
  1203 text{*If the homomorphism @{term h} is onto @{term H}, then so is the
  1204 homomorphism from the quotient group*}
  1204 homomorphism from the quotient group*}
  1208          \<in> surj(carrier (G Mod kernel(G,H,h)), carrier(H))"
  1208          \<in> surj(carrier (G Mod kernel(G,H,h)), carrier(H))"
  1209 proof (simp add: surj_def FactGroup_contents_mem lam_type, clarify)
  1209 proof (simp add: surj_def FactGroup_contents_mem lam_type, clarify)
  1210   fix y
  1210   fix y
  1211   assume y: "y \<in> carrier(H)"
  1211   assume y: "y \<in> carrier(H)"
  1212   with h obtain g where g: "g \<in> carrier(G)" "h ` g = y"
  1212   with h obtain g where g: "g \<in> carrier(G)" "h ` g = y"
  1213     by (auto simp add: surj_def) 
  1213     by (auto simp add: surj_def)
  1214   hence "(\<Union>x\<in>kernel(G,H,h) #> g. {h ` x}) = {y}" 
  1214   hence "(\<Union>x\<in>kernel(G,H,h) #> g. {h ` x}) = {y}"
  1215     by (auto simp add: y kernel_def r_coset_def) 
  1215     by (auto simp add: y kernel_def r_coset_def)
  1216   with g show "\<exists>x\<in>carrier(G Mod kernel(G, H, h)). contents(h `` x) = y"
  1216   with g show "\<exists>x\<in>carrier(G Mod kernel(G, H, h)). contents(h `` x) = y"
  1217         --{*The witness is @{term "kernel(G,H,h) #> g"}*}
  1217         --{*The witness is @{term "kernel(G,H,h) #> g"}*}
  1218     by (force simp add: FactGroup_def RCOSETS_def 
  1218     by (force simp add: FactGroup_def RCOSETS_def
  1219            image_eq_UN [OF hom_is_fun] kernel_rcoset_subset)
  1219            image_eq_UN [OF hom_is_fun] kernel_rcoset_subset)
  1220 qed
  1220 qed
  1221 
  1221 
  1222 
  1222 
  1223 text{*If @{term h} is a homomorphism from @{term G} onto @{term H}, then the
  1223 text{*If @{term h} is a homomorphism from @{term G} onto @{term H}, then the
  1224  quotient group @{term "G Mod (kernel(G,H,h))"} is isomorphic to @{term H}.*}
  1224  quotient group @{term "G Mod (kernel(G,H,h))"} is isomorphic to @{term H}.*}
  1225 theorem (in group_hom) FactGroup_iso:
  1225 theorem (in group_hom) FactGroup_iso:
  1226   "h \<in> surj(carrier(G), carrier(H))
  1226   "h \<in> surj(carrier(G), carrier(H))
  1227    \<Longrightarrow> (\<lambda>X\<in>carrier (G Mod kernel(G,H,h)). contents (h``X)) \<in> (G Mod (kernel(G,H,h))) \<cong> H"
  1227    \<Longrightarrow> (\<lambda>X\<in>carrier (G Mod kernel(G,H,h)). contents (h``X)) \<in> (G Mod (kernel(G,H,h))) \<cong> H"
  1228 by (simp add: iso_def FactGroup_hom FactGroup_inj bij_def FactGroup_surj)
  1228 by (simp add: iso_def FactGroup_hom FactGroup_inj bij_def FactGroup_surj)
  1229  
  1229 
  1230 end
  1230 end