Theory Group_ZF_4

(* 
    This file is a part of IsarMathLib - 
    a library of formalized mathematics written for Isabelle/Isar.

    Copyright (C) 2013  Daniel de la Concepcion

    This program is free software; Redistribution and use in source and binary forms, 
    with or without modification, are permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation and/or 
   other materials provided with the distribution.
   3. The name of the author may not be used to endorse or promote products 
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)

section Groups 4

theory Group_ZF_4 imports Group_ZF_1 Group_ZF_2 Finite_ZF Cardinal_ZF

begin

textThis theory file deals with normal subgroup test and some finite group theory.
Then we define group homomorphisms and prove that the set of endomorphisms
forms a ring with unity and we also prove the first isomorphism theorem.

subsectionConjugation of subgroups

textFirst we show some properties of conjugation

textThe conjugate of a subgroup is a subgroup.

theorem (in group0) conj_group_is_group:
  assumes "IsAsubgroup(H,P)" "gG"
  shows "IsAsubgroup({g(hg¯). hH},P)"
proof-
  have sub:"HG" using assms(1) group0_3_L2 by auto
  from assms(2) have "g¯G" using inverse_in_group by auto
  {
    fix r assume "r{g(hg¯). hH}"
    then  obtain h where h:"hH" "r=g(h(g¯))" by auto
    from h(1) have "h¯H" using group0_3_T3A assms(1) by auto
    from h(1) sub have "hG" by auto
    then have "h¯G" using inverse_in_group by auto
    with g¯G have "((h¯)(g)¯)G" using group_op_closed by auto
    from h(2) have "r¯=(g(h(g¯)))¯" by auto moreover
    from hG g¯G have s:"h(g¯)G" using group_op_closed by blast
    ultimately have "r¯=(h(g¯))¯(g)¯" using group_inv_of_two assms(2) by auto
    moreover
    from hG g¯G have "(h(g¯))¯=(g¯)¯h¯" using group_inv_of_two by auto
    moreover have "(g¯)¯=g" using group_inv_of_inv assms(2) by auto
    ultimately have "r¯=(g(h¯))(g)¯" by auto
    with h¯Gg¯G have "r¯=g((h¯)(g)¯)" using group_oper_assoc assms(2) by auto
    moreover from s assms(2) h(2) have "rG" using group_op_closed by auto
    moreover note h¯H ultimately have "r¯{g(hg¯). hH}" "rG" by auto
  }
  then have "r{g(hg¯). hH}. r¯{g(hg¯). hH}" and "{g(hg¯). hH}G" by auto moreover
  {
    fix s t assume s:"s{g(hg¯). hH}" and t:"t{g(hg¯). hH}"
    then obtain hs ht where hs:"hsH" "s=g(hs(g¯))" and ht:"htH" "t=g(ht(g¯))" by auto
    from hs(1) have "hsG" using sub by auto
    then have "ghsG" using group_op_closed assms(2) by auto
    then have "(ghs)¯G" using inverse_in_group by auto
    from ht(1) have "htG" using sub by auto
    with g¯:G have "ht(g¯)G" using group_op_closed by auto
    from hs(2) ht(2) have "st=(g(hs(g¯)))(g(ht(g¯)))" by auto
    moreover from hsG have "hsht = hs𝟭ht" using group0_2_L2 by auto
    then have "hsht = hs(g¯g)ht" using group0_2_L6 assms(2) by auto
    then have "g(hsht) = g(hs(g¯g)ht)" by auto
    with hsG have "g(hsht) = g((hsg¯g)ht)" using group_oper_assoc
      assms(2) inverse_in_group by auto
    with hsG htG have "g(hsht) = g(hsg¯(ght))" using group_oper_assoc
      assms(2) inverse_in_group group_op_closed by auto
    with hsG htG have "g(hsht) = g(hsg¯)(ght)" using group_oper_assoc
      assms(2) inverse_in_group group_op_closed by auto
    then have "g(hsht)g¯ = g(hsg¯)(ght)g¯" by auto
    with hsG htG have "g((hsht)g¯) = g(hsg¯)(ght)g¯" using group_oper_assoc
      inverse_in_group assms(2) group_op_closed by auto
    with hsG htG have "g((hsht)g¯) = (g(hsg¯))(g(htg¯))" using group_oper_assoc
      inverse_in_group assms(2) group_op_closed by auto
    ultimately have "st=g((hsht)(g¯))" by auto moreover
    from hs(1) ht(1) have "hshtH" using assms(1) group0_3_L6 by auto
    ultimately have "st{g(hg¯). hH}" by auto
  }
  then have "{g(hg¯). hH} {is closed under}P" unfolding IsOpClosed_def by auto moreover
  from assms(1) have "𝟭H" using group0_3_L5 by auto
  then have "g(𝟭g¯){g(hg¯). hH}" by auto
  then have "{g(hg¯). hH}0" by auto ultimately
  show ?thesis using group0_3_T3 by auto
qed

textEvery set is equipollent with its conjugates.

theorem (in group0) conj_set_is_eqpoll:
  assumes "HG" "gG"
  shows "H{g(hg¯). hH}"
proof-
  have fun:"{h,g(hg¯). hH}:H{g(hg¯). hH}" unfolding Pi_def function_def domain_def by auto
  {
    fix h1 h2 assume "h1H""h2H""{h,g(hg¯). hH}`h1={h,g(hg¯). hH}`h2"
    with fun have "g(h1g¯)=g(h2g¯)""h1g¯G""h2g¯G""h1G""h2G" using apply_equality assms(1)
      group_op_closed inverse_in_group assms(2) by auto
    then have "h1g¯=h2g¯" using group0_2_L19(2) assms(2) by auto
    with h1G h2G have "h1=h2" using group0_2_L19(1) inverse_in_group assms(2) by auto
  }
  then have "h1H. h2H. {h,g(hg¯). hH}`h1={h,g(hg¯). hH}`h2  h1=h2" by auto
  with fun have "{h,g(hg¯). hH}inj(H,{g(hg¯). hH})" unfolding inj_def by auto moreover
  {
    fix ghg assume "ghg{g(hg¯). hH}"
    then obtain h where "hH" "ghg=g(hg¯)" by auto
    then have "h,ghg{h,g(hg¯). hH}" by auto
    then have "{h,g(hg¯). hH}`h=ghg" using apply_equality fun by auto
    with hH have "hH. {h,g(hg¯). hH}`h=ghg" by auto
  }
  with fun have "{h,g(hg¯). hH}surj(H,{g(hg¯). hH})" unfolding surj_def by auto
  ultimately have "{h,g(hg¯). hH}bij(H,{g(hg¯). hH})" unfolding bij_def by auto
  then show ?thesis unfolding eqpoll_def by auto
qed

textEvery normal subgroup contains its conjugate subgroups.

theorem (in group0) norm_group_cont_conj:
  assumes "IsAnormalSubgroup(G,P,H)" "gG"
  shows "{g(hg¯). hH}H"
proof-
  {
    fix r assume "r{g(hg¯). hH}"
    then obtain h where h:"r=g(hg¯)" "hH" by auto moreover
    from h(2) have "hG" using group0_3_L2 assms(1) unfolding IsAnormalSubgroup_def by auto moreover
    from assms(2) have "g¯G" using inverse_in_group by auto
    ultimately have "r=ghg¯" "hH" using group_oper_assoc assms(2) by auto
    then have "rH" using assms unfolding IsAnormalSubgroup_def by auto
  }
  then show "{g(hg¯). hH}H" by auto
qed

textIf a subgroup contains all its conjugate subgroups, then it is normal.

theorem (in group0) cont_conj_is_normal:
  assumes "IsAsubgroup(H,P)" "gG. {g(hg¯). hH}H"
  shows "IsAnormalSubgroup(G,P,H)"
proof-
  {
    fix h g assume "hH" "gG"
    with assms(2) have "g(hg¯)H" by auto
    moreover from gGhH have "hG" "g¯G" "gG" using group0_3_L2 assms(1) inverse_in_group by auto
    ultimately have "ghg¯H" using group_oper_assoc by auto
  }
  then show ?thesis using assms(1) unfolding IsAnormalSubgroup_def by auto
qed

textIf a group has only one subgroup of a given order, then this subgroup is normal.

corollary (in group0) only_one_equipoll_sub:
  assumes "IsAsubgroup(H,P)" "M. IsAsubgroup(M,P) HM  M=H"
  shows "IsAnormalSubgroup(G,P,H)"
proof-
  {
    fix g assume g:"gG"
    with assms(1) have "IsAsubgroup({g(hg¯). hH},P)" using conj_group_is_group by auto
    moreover
    from assms(1) g have "H{g(hg¯). hH}" using conj_set_is_eqpoll group0_3_L2 by auto
    ultimately have "{g(hg¯). hH}=H" using assms(2) by auto
    then have "{g(hg¯). hH}H" by auto
  }
  then show ?thesis using cont_conj_is_normal assms(1) by auto
qed

textThe trivial subgroup is then a normal subgroup.

corollary (in group0) trivial_normal_subgroup:
  shows "IsAnormalSubgroup(G,P,{𝟭})"
proof-
  have "{𝟭}G" using group0_2_L2 by auto
  moreover have "{𝟭}0" by auto moreover
  {
    fix a b assume "a{𝟭}""b{𝟭}"
    then have "a=𝟭""b=𝟭" by auto
    then have "P`a,b=𝟭𝟭" by auto
    then have "P`a,b=𝟭" using group0_2_L2 by auto
    then have "P`a,b{𝟭}" by auto
  }
  then have "{𝟭}{is closed under}P" unfolding IsOpClosed_def by auto
  moreover
  {
    fix a assume "a{𝟭}"
    then have "a=𝟭" by auto
    then have "a¯=𝟭¯" by auto
    then have "a¯=𝟭" using group_inv_of_one by auto
    then have "a¯{𝟭}" by auto
  }
  then have "a{𝟭}. a¯{𝟭}" by auto ultimately
  have "IsAsubgroup({𝟭},P)" using group0_3_T3 by auto moreover
  {
    fix M assume M:"IsAsubgroup(M,P)" "{𝟭}M"
    then have one:"𝟭M" "M{𝟭}" using eqpoll_sym group0_3_L5 by auto
    then obtain f where "fbij(M,{𝟭})" unfolding eqpoll_def by auto
    then have inj:"finj(M,{𝟭})" unfolding bij_def by auto
    then have fun:"f:M{𝟭}" unfolding inj_def by auto
    {
      fix b assume b:"bM" "b𝟭"
      with 𝟭M have "f`bf`𝟭" using inj unfolding inj_def by auto
      moreover from fun b(1) have "f`b{𝟭}" by (rule apply_type)
      moreover from fun one(1) have "f`𝟭{𝟭}" by (rule apply_type)
      ultimately have "False" by auto
    }
    with 𝟭M have "M={𝟭}" by auto
  }
  ultimately show ?thesis using only_one_equipoll_sub by auto
qed

textThe whole group is normal as a subgroup

lemma (in group0) whole_normal_subgroup:
  shows "IsAnormalSubgroup(G,P,G)"
proof-
  have "GG" by auto moreover
  have "xG. x¯G" using inverse_in_group by auto moreover
  have "G0" using group0_2_L2 by auto moreover
  have "G{is closed under}P" using group_op_closed
    unfolding IsOpClosed_def by auto ultimately
  have "IsAsubgroup(G,P)" using group0_3_T3 by auto
  moreover
  {
    fix n g assume ng:"nG" "gG"
    then have "P ` P ` g, n, GroupInv(G, P) ` g  G"
      using group_op_closed inverse_in_group by auto
  }
  ultimately show ?thesis unfolding IsAnormalSubgroup_def by auto
qed

subsectionSimple groups

textIn this subsection we study the groups that build the rest of
the groups: the simple groups.

textSince the whole group and the trivial subgroup are always normal,
it is natural to define simplicity of groups in the following way:

definition
  IsSimple ("[_,_]{is a simple group}" 89)
  where "[G,f]{is a simple group}  IsAgroup(G,f)  (M. IsAnormalSubgroup(G,f,M)  M=GM={TheNeutralElement(G,f)})"

textFrom the definition follows that if a group has no subgroups,
then it is simple.

corollary (in group0) noSubgroup_imp_simple:
  assumes "H. IsAsubgroup(H,P) H=GH={𝟭}"
  shows "[G,P]{is a simple group}"
proof-
  have "IsAgroup(G,P)" using groupAssum by auto moreover
  {
    fix M assume "IsAnormalSubgroup(G,P,M)"
    then have "IsAsubgroup(M,P)" unfolding IsAnormalSubgroup_def by auto
    with assms have "M=GM={𝟭}" by auto
  }
  ultimately show ?thesis unfolding IsSimple_def by auto
qed

textWe add a context for an abelian group

locale abelian_group = group0 +
  assumes isAbelian: "P {is commutative on} G"

textSince every subgroup is normal in abelian
groups, it follows that commutative simple groups
do not have subgroups.

corollary (in abelian_group) abelian_simple_noSubgroups:
  assumes "[G,P]{is a simple group}"
  shows "H. IsAsubgroup(H,P) H=GH={𝟭}"
proof-
  {
    fix H assume A:"IsAsubgroup(H,P)""H  {𝟭}"
    then have "IsAnormalSubgroup(G,P,H)" using Group_ZF_2_4_L6(1) groupAssum isAbelian
      by auto
    with assms(1) A have "H=G" unfolding IsSimple_def by auto
  }
  then show ?thesis by auto
qed

subsectionFinite groups

textThis subsection deals with finite groups and their structure

textThe subgroup of a finite group is finite.

lemma (in group0) finite_subgroup:
  assumes "Finite(G)" "IsAsubgroup(H,P)"
  shows "Finite(H)"
  using group0_3_L2 subset_Finite assms by force

textThe space of cosets is also finite. In particular, quotient groups.

lemma (in group0) finite_cosets:
  assumes "Finite(G)" "IsAsubgroup(H,P)"
  defines "r  QuotientGroupRel(G,P,H)"
  shows "Finite(G//r)"
proof- 
  have fun:"{g,r``{g}. gG}:G(G//r)" unfolding Pi_def function_def domain_def by auto
  {
    fix C assume C:"CG//r"
    have equiv:"equiv(G,r)" using Group_ZF_2_4_L3 assms(2) unfolding r_def by auto
    then have "refl(G,r)" unfolding equiv_def by auto
    with C have "C0" using EquivClass_1_L5 by auto
    then obtain c where c:"cC" by auto
    with C have "r``{c}=C" using EquivClass_1_L2 equiv by auto
    with c C have "c,C{g,r``{g}. gG}" using EquivClass_1_L1 equiv by auto
    then have "{g,r``{g}. gG}`c=C" "cG" using apply_equality fun by auto
    then have "cG. {g,r``{g}. gG}`c=C" by auto
  }
  with fun have surj:"{g,r``{g}. gG}surj(G,G//r)" unfolding surj_def by auto
  from assms(1) obtain n where "nnat" "Gn" unfolding Finite_def by auto
  then have G:"Gn" "Ord(n)" using eqpoll_imp_lepoll by auto
  then have "G//rG" using surj_fun_inv_2 surj by auto
  with G(1) have "G//rn" using lepoll_trans by blast
  with nnat show "Finite(G//r)" using lepoll_nat_imp_Finite by auto
qed

textAll the cosets are equipollent.

lemma (in group0) cosets_equipoll:
  assumes "IsAsubgroup(H,P)" "g1G""g2G"
  defines "r  QuotientGroupRel(G,P,H)"
  shows "r``{g1}  r``{g2}"
proof-
  have equiv:"equiv(G,r)" using Group_ZF_2_4_L3 assms(1) unfolding r_def by auto
  from assms(3,2) have GG:"(g1¯)g2G" using inverse_in_group group_op_closed by auto
  then have bij:"RightTranslation(G,P,(g1¯)g2)bij(G,G)" using trans_bij(1) by auto
  have "r``{g2}G//r" using assms(3) unfolding quotient_def by auto
  then have sub2:"r``{g2}G" using EquivClass_1_L1 equiv
      assms(3) by blast
  have "r``{g1}G//r" using assms(2) unfolding quotient_def by auto
  then have sub:"r``{g1}G" using EquivClass_1_L1 equiv assms(2) by blast
  with bij have "restrict(RightTranslation(G,P,(g1¯)g2),r``{g1})bij(r``{g1},RightTranslation(G,P,(g1¯)g2)``(r``{g1}))"
    using restrict_bij unfolding bij_def by auto
  then have "r``{g1}RightTranslation(G,P,(g1¯)g2)``(r``{g1})" unfolding eqpoll_def by auto
  with GG sub have A0:"r``{g1}{RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}"
    using func_imagedef group0_5_L1(1) by force
  {
    fix t assume "t{RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}"
    then obtain q where q:"t=RightTranslation(G,P,(g1¯)g2)`q" "qr``{g1}" by auto
    then have "g1,qr" "qG" using image_iff sub by auto
    then have "g1(q¯)H" "q¯G" using inverse_in_group unfolding r_def QuotientGroupRel_def by auto
    from GG q sub have t:"t=q((g1¯)g2)" using group0_5_L2(1) by auto
    then have "g2t¯=g2(q((g1¯)g2))¯" by auto
    with qG GG have "g2t¯=g2(((g1¯)g2)¯q¯)" using group_inv_of_two by auto
    then have "g2t¯=g2(((g2¯)g1¯¯)q¯)" using group_inv_of_two inverse_in_group assms(2)
      assms(3) by auto
    then have "g2t¯=g2(((g2¯)g1)q¯)" using group_inv_of_inv assms(2) by auto moreover
    have "(g2¯)g1G" using assms(2) inverse_in_group assms(3) group_op_closed by auto
    with assms(3) q¯G have "g2(((g2¯)g1)q¯)=g2((g2¯)g1)q¯" using group_oper_assoc by auto
    moreover have "g2((g2¯)g1)=g2(g2¯)g1" using assms(2) inverse_in_group assms(3)
      group_oper_assoc by auto
    then have "g2((g2¯)g1)=g1" using group0_2_L6 assms(3) group0_2_L2 assms(2) by auto ultimately
    have "g2t¯=g1q¯" by auto
    with g1(q¯)H have "g2t¯H" by auto moreover
    from t qG g2G have "tG" using inverse_in_group assms(2) group_op_closed by auto
    ultimately have "g2,tr" unfolding QuotientGroupRel_def r_def using assms(3) by auto
    then have "tr``{g2}" using image_iff assms(4) by auto
  }
  then have A1:"{RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}r``{g2}" by auto
  {
    fix t assume "tr``{g2}"
    then have "g2,tr" "tG" using sub2 image_iff by auto
    then have H:"g2t¯H" unfolding QuotientGroupRel_def r_def by auto
    then have G:"g2t¯G" using group0_3_L2 assms(1) by auto
    then have "g1(g1¯(g2t¯))=g1g1¯(g2t¯)" using group_oper_assoc
        assms(2) inverse_in_group by auto
    with G have "g1(g1¯(g2t¯))=g2t¯" using group0_2_L6 assms(2) group0_2_L2 by auto
    with H have HH:"g1(g1¯(g2t¯))H" by auto
    from tG have GGG:"tg2¯G" using inverse_in_group assms(3) group_op_closed by auto
    from tG have "(tg2¯)¯=g2¯¯t¯" using group_inv_of_two inverse_in_group assms(3) by auto
    also have "=g2t¯" using group_inv_of_inv assms(3) by auto
    finally have "(tg2¯)¯=g2t¯" by auto
    then have "g1¯(tg2¯)¯=g1¯(g2t¯)" by auto
    then have "((tg2¯)g1)¯=g1¯(g2t¯)" using group_inv_of_two GGG assms(2) by auto
    then have HHH:"g1((tg2¯)g1)¯H" using HH by auto
    from tG have "(tg2¯)g1G" using assms(2) inverse_in_group assms(3) group_op_closed by auto
    with HHH have "g1,(tg2¯)g1r" using assms(2) unfolding r_def QuotientGroupRel_def by auto
    then have rg1:"tg2¯g1r``{g1}" using image_iff by auto
    from assms(3) have "g2¯:G" using inverse_in_group by auto
    from tG have "tg2¯g1((g1¯)g2)=t(g2¯g1)((g1¯)g2)" using group_oper_assoc inverse_in_group assms(3) assms(2)
      by auto
    also from tG have "=t((g2¯g1)((g1¯)g2))" using group_oper_assoc group_op_closed inverse_in_group assms(3) assms(2)
      by auto
    also from GG g2¯:G have "=t(g2¯(g1((g1¯)g2)))" using group_oper_assoc
      assms(2) by auto
    also have "=t(g2¯(g1(g1¯)g2))" using group_oper_assoc assms(2) inverse_in_group assms(3) by auto
    also from tG have "=t" using group0_2_L6 assms(3) group0_2_L6 assms(2) group0_2_L2 assms(3) by auto
    finally have "tg2¯g1((g1¯)g2)=t" by auto
    with (tg2¯)g1G GG have "RightTranslation(G,P,(g1¯)g2)`(tg2¯g1)=t" using group0_5_L2(1) by auto
    then have "t{RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}" using rg1 by force
  }
  then have "r``{g2}{RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}" by blast
  with A1 have "r``{g2}={RightTranslation(G,P,(g1¯)g2)`t. tr``{g1}}" by auto
  with A0 show ?thesis by auto
qed

textThe order of a subgroup multiplied by the order of the space of cosets is the order of
the group. We only prove the theorem for finite groups.

theorem (in group0) Lagrange:
  assumes "Finite(G)" "IsAsubgroup(H,P)"
  defines "r  QuotientGroupRel(G,P,H)"
  shows "|G|=|H| #* |G//r|"
proof-
  have equiv:"equiv(G,r)" using Group_ZF_2_4_L3 assms(2) unfolding r_def by auto
  have "r``{𝟭} G" unfolding r_def QuotientGroupRel_def by auto

  have "aaG. aaH  aa,𝟭r" using Group_ZF_2_4_L5C unfolding r_def by auto
  then have "aaG. aaH  𝟭,aar" using equiv unfolding sym_def equiv_def
    by auto
  then have "aaG. aaH  aar``{𝟭}" using image_iff by auto
  with r``{𝟭} G have H:"H=r``{𝟭}" using group0_3_L2 assms(2) by blast
  {
    fix c assume "c(G//r)"
    then obtain g where "gG" "c=r``{g}" unfolding quotient_def by auto
    then have "cr``{𝟭}" using cosets_equipoll assms(2) group0_2_L2 unfolding r_def by auto
    then have "|c|=|H|" using H cardinal_cong by auto
  }
  then have "c(G//r). |c|=|H|" by auto moreover
  have "Finite(G//r)" using assms finite_cosets by auto moreover
  have "(G//r)=G" using Union_quotient Group_ZF_2_4_L3 assms(2,3) by auto moreover
  from (G//r)=G have "Finite((G//r))" using assms(1) by auto moreover
  have "c1(G//r). c2(G//r). c1c2  c1c2=0" using quotient_disj
      equiv by blast ultimately
  show ?thesis using card_partition by auto
qed

subsectionSubgroups generated by sets

textIn this section we study the minimal subgroup containing a set

textSince G› is always a group containing the set, we may take
the intersection of all subgroups bigger than the set; and hence
the result is the subgroup we searched.

definition (in group0)
  SubgroupGenerated ("_G" 80)
  where "XG  XG  {HPow(G). XH  IsAsubgroup(H,P)}"

textEvery generated subgroup is a subgroup

theorem (in group0) subgroupGen_is_subgroup:
  assumes "XG"
  shows "IsAsubgroup(XG,P)"
proof-
  have "restrict(P,G×G)=P" using group_oper_fun restrict_idem unfolding Pi_def by auto
  then have "IsAsubgroup(G,P)" unfolding IsAsubgroup_def using groupAssum by auto
  with assms have "G{HPow(G). XH  IsAsubgroup(H,P)}" by auto
  then have "{HPow(G). XH  IsAsubgroup(H,P)}0" by auto
  then show ?thesis using subgroup_inter SubgroupGenerated_def assms by auto
qed

textThe generated subgroup contains the original set

theorem (in group0) subgroupGen_contains_set:
  assumes "XG"
  shows "X  XG"
proof-
  have "restrict(P,G×G)=P" using group_oper_fun restrict_idem unfolding Pi_def by auto
  then have "IsAsubgroup(G,P)" unfolding IsAsubgroup_def using groupAssum by auto
  with assms have "G{HPow(G). XH  IsAsubgroup(H,P)}" by auto
  then have "{HPow(G). XH  IsAsubgroup(H,P)}0" by auto
  then show ?thesis using subgroup_inter SubgroupGenerated_def assms by auto
qed

textGiven a subgroup that contains a set, the generated subgroup
from that set is smaller than this subgroup

theorem (in group0) subgroupGen_minimal:
  assumes "IsAsubgroup(H,P)" "XH"
  shows "XG  H"
proof-
  from assms have sub:"XG" using group0_3_L2 by auto
  from assms have "H{HPow(G). XH  IsAsubgroup(H,P)}" using group0_3_L2 by auto
  then show ?thesis using sub subgroup_inter SubgroupGenerated_def assms by auto
qed

end