src/HOL/Algebra/Group.thy
 author wenzelm Sun Mar 21 16:51:37 2010 +0100 (2010-03-21) changeset 35848 5443079512ea parent 35847 19f1f7066917 child 35849 b5522b51cb1e permissions -rw-r--r--
slightly more uniform definitions -- eliminated old-style meta-equality;
     1 (*

     2   Title:  HOL/Algebra/Group.thy

     3   Author: Clemens Ballarin, started 4 February 2003

     4

     5 Based on work by Florian Kammueller, L C Paulson and Markus Wenzel.

     6 *)

     7

     8 theory Group

     9 imports Lattice FuncSet

    10 begin

    11

    12

    13 section {* Monoids and Groups *}

    14

    15 subsection {* Definitions *}

    16

    17 text {*

    18   Definitions follow \cite{Jacobson:1985}.

    19 *}

    20

    21 record 'a monoid =  "'a partial_object" +

    22   mult    :: "['a, 'a] \<Rightarrow> 'a" (infixl "\<otimes>\<index>" 70)

    23   one     :: 'a ("\<one>\<index>")

    24

    25 definition

    26   m_inv :: "('a, 'b) monoid_scheme => 'a => 'a" ("inv\<index> _"  80)

    27   where "inv\<^bsub>G\<^esub> x = (THE y. y \<in> carrier G & x \<otimes>\<^bsub>G\<^esub> y = \<one>\<^bsub>G\<^esub> & y \<otimes>\<^bsub>G\<^esub> x = \<one>\<^bsub>G\<^esub>)"

    28

    29 definition

    30   Units :: "_ => 'a set"

    31   --{*The set of invertible elements*}

    32   where "Units G = {y. y \<in> carrier G & (\<exists>x \<in> carrier G. x \<otimes>\<^bsub>G\<^esub> y = \<one>\<^bsub>G\<^esub> & y \<otimes>\<^bsub>G\<^esub> x = \<one>\<^bsub>G\<^esub>)}"

    33

    34 consts

    35   pow :: "[('a, 'm) monoid_scheme, 'a, 'b::number] => 'a" (infixr "'(^')\<index>" 75)

    36

    37 defs (overloaded)

    38   nat_pow_def: "pow G a n == nat_rec \<one>\<^bsub>G\<^esub> (%u b. b \<otimes>\<^bsub>G\<^esub> a) n"

    39   int_pow_def: "pow G a z ==

    40     let p = nat_rec \<one>\<^bsub>G\<^esub> (%u b. b \<otimes>\<^bsub>G\<^esub> a)

    41     in if neg z then inv\<^bsub>G\<^esub> (p (nat (-z))) else p (nat z)"

    42

    43 locale monoid =

    44   fixes G (structure)

    45   assumes m_closed [intro, simp]:

    46          "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x \<otimes> y \<in> carrier G"

    47       and m_assoc:

    48          "\<lbrakk>x \<in> carrier G; y \<in> carrier G; z \<in> carrier G\<rbrakk>

    49           \<Longrightarrow> (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"

    50       and one_closed [intro, simp]: "\<one> \<in> carrier G"

    51       and l_one [simp]: "x \<in> carrier G \<Longrightarrow> \<one> \<otimes> x = x"

    52       and r_one [simp]: "x \<in> carrier G \<Longrightarrow> x \<otimes> \<one> = x"

    53

    54 lemma monoidI:

    55   fixes G (structure)

    56   assumes m_closed:

    57       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"

    58     and one_closed: "\<one> \<in> carrier G"

    59     and m_assoc:

    60       "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

    61       (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"

    62     and l_one: "!!x. x \<in> carrier G ==> \<one> \<otimes> x = x"

    63     and r_one: "!!x. x \<in> carrier G ==> x \<otimes> \<one> = x"

    64   shows "monoid G"

    65   by (fast intro!: monoid.intro intro: assms)

    66

    67 lemma (in monoid) Units_closed [dest]:

    68   "x \<in> Units G ==> x \<in> carrier G"

    69   by (unfold Units_def) fast

    70

    71 lemma (in monoid) inv_unique:

    72   assumes eq: "y \<otimes> x = \<one>"  "x \<otimes> y' = \<one>"

    73     and G: "x \<in> carrier G"  "y \<in> carrier G"  "y' \<in> carrier G"

    74   shows "y = y'"

    75 proof -

    76   from G eq have "y = y \<otimes> (x \<otimes> y')" by simp

    77   also from G have "... = (y \<otimes> x) \<otimes> y'" by (simp add: m_assoc)

    78   also from G eq have "... = y'" by simp

    79   finally show ?thesis .

    80 qed

    81

    82 lemma (in monoid) Units_m_closed [intro, simp]:

    83   assumes x: "x \<in> Units G" and y: "y \<in> Units G"

    84   shows "x \<otimes> y \<in> Units G"

    85 proof -

    86   from x obtain x' where x: "x \<in> carrier G" "x' \<in> carrier G" and xinv: "x \<otimes> x' = \<one>" "x' \<otimes> x = \<one>"

    87     unfolding Units_def by fast

    88   from y obtain y' where y: "y \<in> carrier G" "y' \<in> carrier G" and yinv: "y \<otimes> y' = \<one>" "y' \<otimes> y = \<one>"

    89     unfolding Units_def by fast

    90   from x y xinv yinv have "y' \<otimes> (x' \<otimes> x) \<otimes> y = \<one>" by simp

    91   moreover from x y xinv yinv have "x \<otimes> (y \<otimes> y') \<otimes> x' = \<one>" by simp

    92   moreover note x y

    93   ultimately show ?thesis unfolding Units_def

    94     -- "Must avoid premature use of @{text hyp_subst_tac}."

    95     apply (rule_tac CollectI)

    96     apply (rule)

    97     apply (fast)

    98     apply (rule bexI [where x = "y' \<otimes> x'"])

    99     apply (auto simp: m_assoc)

   100     done

   101 qed

   102

   103 lemma (in monoid) Units_one_closed [intro, simp]:

   104   "\<one> \<in> Units G"

   105   by (unfold Units_def) auto

   106

   107 lemma (in monoid) Units_inv_closed [intro, simp]:

   108   "x \<in> Units G ==> inv x \<in> carrier G"

   109   apply (unfold Units_def m_inv_def, auto)

   110   apply (rule theI2, fast)

   111    apply (fast intro: inv_unique, fast)

   112   done

   113

   114 lemma (in monoid) Units_l_inv_ex:

   115   "x \<in> Units G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"

   116   by (unfold Units_def) auto

   117

   118 lemma (in monoid) Units_r_inv_ex:

   119   "x \<in> Units G ==> \<exists>y \<in> carrier G. x \<otimes> y = \<one>"

   120   by (unfold Units_def) auto

   121

   122 lemma (in monoid) Units_l_inv [simp]:

   123   "x \<in> Units G ==> inv x \<otimes> x = \<one>"

   124   apply (unfold Units_def m_inv_def, auto)

   125   apply (rule theI2, fast)

   126    apply (fast intro: inv_unique, fast)

   127   done

   128

   129 lemma (in monoid) Units_r_inv [simp]:

   130   "x \<in> Units G ==> x \<otimes> inv x = \<one>"

   131   apply (unfold Units_def m_inv_def, auto)

   132   apply (rule theI2, fast)

   133    apply (fast intro: inv_unique, fast)

   134   done

   135

   136 lemma (in monoid) Units_inv_Units [intro, simp]:

   137   "x \<in> Units G ==> inv x \<in> Units G"

   138 proof -

   139   assume x: "x \<in> Units G"

   140   show "inv x \<in> Units G"

   141     by (auto simp add: Units_def

   142       intro: Units_l_inv Units_r_inv x Units_closed [OF x])

   143 qed

   144

   145 lemma (in monoid) Units_l_cancel [simp]:

   146   "[| x \<in> Units G; y \<in> carrier G; z \<in> carrier G |] ==>

   147    (x \<otimes> y = x \<otimes> z) = (y = z)"

   148 proof

   149   assume eq: "x \<otimes> y = x \<otimes> z"

   150     and G: "x \<in> Units G"  "y \<in> carrier G"  "z \<in> carrier G"

   151   then have "(inv x \<otimes> x) \<otimes> y = (inv x \<otimes> x) \<otimes> z"

   152     by (simp add: m_assoc Units_closed del: Units_l_inv)

   153   with G show "y = z" by (simp add: Units_l_inv)

   154 next

   155   assume eq: "y = z"

   156     and G: "x \<in> Units G"  "y \<in> carrier G"  "z \<in> carrier G"

   157   then show "x \<otimes> y = x \<otimes> z" by simp

   158 qed

   159

   160 lemma (in monoid) Units_inv_inv [simp]:

   161   "x \<in> Units G ==> inv (inv x) = x"

   162 proof -

   163   assume x: "x \<in> Units G"

   164   then have "inv x \<otimes> inv (inv x) = inv x \<otimes> x" by simp

   165   with x show ?thesis by (simp add: Units_closed del: Units_l_inv Units_r_inv)

   166 qed

   167

   168 lemma (in monoid) inv_inj_on_Units:

   169   "inj_on (m_inv G) (Units G)"

   170 proof (rule inj_onI)

   171   fix x y

   172   assume G: "x \<in> Units G"  "y \<in> Units G" and eq: "inv x = inv y"

   173   then have "inv (inv x) = inv (inv y)" by simp

   174   with G show "x = y" by simp

   175 qed

   176

   177 lemma (in monoid) Units_inv_comm:

   178   assumes inv: "x \<otimes> y = \<one>"

   179     and G: "x \<in> Units G"  "y \<in> Units G"

   180   shows "y \<otimes> x = \<one>"

   181 proof -

   182   from G have "x \<otimes> y \<otimes> x = x \<otimes> \<one>" by (auto simp add: inv Units_closed)

   183   with G show ?thesis by (simp del: r_one add: m_assoc Units_closed)

   184 qed

   185

   186 text {* Power *}

   187

   188 lemma (in monoid) nat_pow_closed [intro, simp]:

   189   "x \<in> carrier G ==> x (^) (n::nat) \<in> carrier G"

   190   by (induct n) (simp_all add: nat_pow_def)

   191

   192 lemma (in monoid) nat_pow_0 [simp]:

   193   "x (^) (0::nat) = \<one>"

   194   by (simp add: nat_pow_def)

   195

   196 lemma (in monoid) nat_pow_Suc [simp]:

   197   "x (^) (Suc n) = x (^) n \<otimes> x"

   198   by (simp add: nat_pow_def)

   199

   200 lemma (in monoid) nat_pow_one [simp]:

   201   "\<one> (^) (n::nat) = \<one>"

   202   by (induct n) simp_all

   203

   204 lemma (in monoid) nat_pow_mult:

   205   "x \<in> carrier G ==> x (^) (n::nat) \<otimes> x (^) m = x (^) (n + m)"

   206   by (induct m) (simp_all add: m_assoc [THEN sym])

   207

   208 lemma (in monoid) nat_pow_pow:

   209   "x \<in> carrier G ==> (x (^) n) (^) m = x (^) (n * m::nat)"

   210   by (induct m) (simp, simp add: nat_pow_mult add_commute)

   211

   212

   213 (* Jacobson defines submonoid here. *)

   214 (* Jacobson defines the order of a monoid here. *)

   215

   216

   217 subsection {* Groups *}

   218

   219 text {*

   220   A group is a monoid all of whose elements are invertible.

   221 *}

   222

   223 locale group = monoid +

   224   assumes Units: "carrier G <= Units G"

   225

   226 lemma (in group) is_group: "group G" by (rule group_axioms)

   227

   228 theorem groupI:

   229   fixes G (structure)

   230   assumes m_closed [simp]:

   231       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"

   232     and one_closed [simp]: "\<one> \<in> carrier G"

   233     and m_assoc:

   234       "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   235       (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"

   236     and l_one [simp]: "!!x. x \<in> carrier G ==> \<one> \<otimes> x = x"

   237     and l_inv_ex: "!!x. x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"

   238   shows "group G"

   239 proof -

   240   have l_cancel [simp]:

   241     "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   242     (x \<otimes> y = x \<otimes> z) = (y = z)"

   243   proof

   244     fix x y z

   245     assume eq: "x \<otimes> y = x \<otimes> z"

   246       and G: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"

   247     with l_inv_ex obtain x_inv where xG: "x_inv \<in> carrier G"

   248       and l_inv: "x_inv \<otimes> x = \<one>" by fast

   249     from G eq xG have "(x_inv \<otimes> x) \<otimes> y = (x_inv \<otimes> x) \<otimes> z"

   250       by (simp add: m_assoc)

   251     with G show "y = z" by (simp add: l_inv)

   252   next

   253     fix x y z

   254     assume eq: "y = z"

   255       and G: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"

   256     then show "x \<otimes> y = x \<otimes> z" by simp

   257   qed

   258   have r_one:

   259     "!!x. x \<in> carrier G ==> x \<otimes> \<one> = x"

   260   proof -

   261     fix x

   262     assume x: "x \<in> carrier G"

   263     with l_inv_ex obtain x_inv where xG: "x_inv \<in> carrier G"

   264       and l_inv: "x_inv \<otimes> x = \<one>" by fast

   265     from x xG have "x_inv \<otimes> (x \<otimes> \<one>) = x_inv \<otimes> x"

   266       by (simp add: m_assoc [symmetric] l_inv)

   267     with x xG show "x \<otimes> \<one> = x" by simp

   268   qed

   269   have inv_ex:

   270     "!!x. x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one> & x \<otimes> y = \<one>"

   271   proof -

   272     fix x

   273     assume x: "x \<in> carrier G"

   274     with l_inv_ex obtain y where y: "y \<in> carrier G"

   275       and l_inv: "y \<otimes> x = \<one>" by fast

   276     from x y have "y \<otimes> (x \<otimes> y) = y \<otimes> \<one>"

   277       by (simp add: m_assoc [symmetric] l_inv r_one)

   278     with x y have r_inv: "x \<otimes> y = \<one>"

   279       by simp

   280     from x y show "\<exists>y \<in> carrier G. y \<otimes> x = \<one> & x \<otimes> y = \<one>"

   281       by (fast intro: l_inv r_inv)

   282   qed

   283   then have carrier_subset_Units: "carrier G <= Units G"

   284     by (unfold Units_def) fast

   285   show ?thesis proof qed (auto simp: r_one m_assoc carrier_subset_Units)

   286 qed

   287

   288 lemma (in monoid) group_l_invI:

   289   assumes l_inv_ex:

   290     "!!x. x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"

   291   shows "group G"

   292   by (rule groupI) (auto intro: m_assoc l_inv_ex)

   293

   294 lemma (in group) Units_eq [simp]:

   295   "Units G = carrier G"

   296 proof

   297   show "Units G <= carrier G" by fast

   298 next

   299   show "carrier G <= Units G" by (rule Units)

   300 qed

   301

   302 lemma (in group) inv_closed [intro, simp]:

   303   "x \<in> carrier G ==> inv x \<in> carrier G"

   304   using Units_inv_closed by simp

   305

   306 lemma (in group) l_inv_ex [simp]:

   307   "x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"

   308   using Units_l_inv_ex by simp

   309

   310 lemma (in group) r_inv_ex [simp]:

   311   "x \<in> carrier G ==> \<exists>y \<in> carrier G. x \<otimes> y = \<one>"

   312   using Units_r_inv_ex by simp

   313

   314 lemma (in group) l_inv [simp]:

   315   "x \<in> carrier G ==> inv x \<otimes> x = \<one>"

   316   using Units_l_inv by simp

   317

   318

   319 subsection {* Cancellation Laws and Basic Properties *}

   320

   321 lemma (in group) l_cancel [simp]:

   322   "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   323    (x \<otimes> y = x \<otimes> z) = (y = z)"

   324   using Units_l_inv by simp

   325

   326 lemma (in group) r_inv [simp]:

   327   "x \<in> carrier G ==> x \<otimes> inv x = \<one>"

   328 proof -

   329   assume x: "x \<in> carrier G"

   330   then have "inv x \<otimes> (x \<otimes> inv x) = inv x \<otimes> \<one>"

   331     by (simp add: m_assoc [symmetric] l_inv)

   332   with x show ?thesis by (simp del: r_one)

   333 qed

   334

   335 lemma (in group) r_cancel [simp]:

   336   "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   337    (y \<otimes> x = z \<otimes> x) = (y = z)"

   338 proof

   339   assume eq: "y \<otimes> x = z \<otimes> x"

   340     and G: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"

   341   then have "y \<otimes> (x \<otimes> inv x) = z \<otimes> (x \<otimes> inv x)"

   342     by (simp add: m_assoc [symmetric] del: r_inv Units_r_inv)

   343   with G show "y = z" by simp

   344 next

   345   assume eq: "y = z"

   346     and G: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"

   347   then show "y \<otimes> x = z \<otimes> x" by simp

   348 qed

   349

   350 lemma (in group) inv_one [simp]:

   351   "inv \<one> = \<one>"

   352 proof -

   353   have "inv \<one> = \<one> \<otimes> (inv \<one>)" by (simp del: r_inv Units_r_inv)

   354   moreover have "... = \<one>" by simp

   355   finally show ?thesis .

   356 qed

   357

   358 lemma (in group) inv_inv [simp]:

   359   "x \<in> carrier G ==> inv (inv x) = x"

   360   using Units_inv_inv by simp

   361

   362 lemma (in group) inv_inj:

   363   "inj_on (m_inv G) (carrier G)"

   364   using inv_inj_on_Units by simp

   365

   366 lemma (in group) inv_mult_group:

   367   "[| x \<in> carrier G; y \<in> carrier G |] ==> inv (x \<otimes> y) = inv y \<otimes> inv x"

   368 proof -

   369   assume G: "x \<in> carrier G"  "y \<in> carrier G"

   370   then have "inv (x \<otimes> y) \<otimes> (x \<otimes> y) = (inv y \<otimes> inv x) \<otimes> (x \<otimes> y)"

   371     by (simp add: m_assoc l_inv) (simp add: m_assoc [symmetric])

   372   with G show ?thesis by (simp del: l_inv Units_l_inv)

   373 qed

   374

   375 lemma (in group) inv_comm:

   376   "[| x \<otimes> y = \<one>; x \<in> carrier G; y \<in> carrier G |] ==> y \<otimes> x = \<one>"

   377   by (rule Units_inv_comm) auto

   378

   379 lemma (in group) inv_equality:

   380      "[|y \<otimes> x = \<one>; x \<in> carrier G; y \<in> carrier G|] ==> inv x = y"

   381 apply (simp add: m_inv_def)

   382 apply (rule the_equality)

   383  apply (simp add: inv_comm [of y x])

   384 apply (rule r_cancel [THEN iffD1], auto)

   385 done

   386

   387 text {* Power *}

   388

   389 lemma (in group) int_pow_def2:

   390   "a (^) (z::int) = (if neg z then inv (a (^) (nat (-z))) else a (^) (nat z))"

   391   by (simp add: int_pow_def nat_pow_def Let_def)

   392

   393 lemma (in group) int_pow_0 [simp]:

   394   "x (^) (0::int) = \<one>"

   395   by (simp add: int_pow_def2)

   396

   397 lemma (in group) int_pow_one [simp]:

   398   "\<one> (^) (z::int) = \<one>"

   399   by (simp add: int_pow_def2)

   400

   401

   402 subsection {* Subgroups *}

   403

   404 locale subgroup =

   405   fixes H and G (structure)

   406   assumes subset: "H \<subseteq> carrier G"

   407     and m_closed [intro, simp]: "\<lbrakk>x \<in> H; y \<in> H\<rbrakk> \<Longrightarrow> x \<otimes> y \<in> H"

   408     and one_closed [simp]: "\<one> \<in> H"

   409     and m_inv_closed [intro,simp]: "x \<in> H \<Longrightarrow> inv x \<in> H"

   410

   411 lemma (in subgroup) is_subgroup:

   412   "subgroup H G" by (rule subgroup_axioms)

   413

   414 declare (in subgroup) group.intro [intro]

   415

   416 lemma (in subgroup) mem_carrier [simp]:

   417   "x \<in> H \<Longrightarrow> x \<in> carrier G"

   418   using subset by blast

   419

   420 lemma subgroup_imp_subset:

   421   "subgroup H G \<Longrightarrow> H \<subseteq> carrier G"

   422   by (rule subgroup.subset)

   423

   424 lemma (in subgroup) subgroup_is_group [intro]:

   425   assumes "group G"

   426   shows "group (G\<lparr>carrier := H\<rparr>)"

   427 proof -

   428   interpret group G by fact

   429   show ?thesis

   430     apply (rule monoid.group_l_invI)

   431     apply (unfold_locales) 

   432     apply (auto intro: m_assoc l_inv mem_carrier)

   433     done

   434 qed

   435

   436 text {*

   437   Since @{term H} is nonempty, it contains some element @{term x}.  Since

   438   it is closed under inverse, it contains @{text "inv x"}.  Since

   439   it is closed under product, it contains @{text "x \<otimes> inv x = \<one>"}.

   440 *}

   441

   442 lemma (in group) one_in_subset:

   443   "[| H \<subseteq> carrier G; H \<noteq> {}; \<forall>a \<in> H. inv a \<in> H; \<forall>a\<in>H. \<forall>b\<in>H. a \<otimes> b \<in> H |]

   444    ==> \<one> \<in> H"

   445 by (force simp add: l_inv)

   446

   447 text {* A characterization of subgroups: closed, non-empty subset. *}

   448

   449 lemma (in group) subgroupI:

   450   assumes subset: "H \<subseteq> carrier G" and non_empty: "H \<noteq> {}"

   451     and inv: "!!a. a \<in> H \<Longrightarrow> inv a \<in> H"

   452     and mult: "!!a b. \<lbrakk>a \<in> H; b \<in> H\<rbrakk> \<Longrightarrow> a \<otimes> b \<in> H"

   453   shows "subgroup H G"

   454 proof (simp add: subgroup_def assms)

   455   show "\<one> \<in> H" by (rule one_in_subset) (auto simp only: assms)

   456 qed

   457

   458 declare monoid.one_closed [iff] group.inv_closed [simp]

   459   monoid.l_one [simp] monoid.r_one [simp] group.inv_inv [simp]

   460

   461 lemma subgroup_nonempty:

   462   "~ subgroup {} G"

   463   by (blast dest: subgroup.one_closed)

   464

   465 lemma (in subgroup) finite_imp_card_positive:

   466   "finite (carrier G) ==> 0 < card H"

   467 proof (rule classical)

   468   assume "finite (carrier G)" "~ 0 < card H"

   469   then have "finite H" by (blast intro: finite_subset [OF subset])

   470   with prems have "subgroup {} G" by simp

   471   with subgroup_nonempty show ?thesis by contradiction

   472 qed

   473

   474 (*

   475 lemma (in monoid) Units_subgroup:

   476   "subgroup (Units G) G"

   477 *)

   478

   479

   480 subsection {* Direct Products *}

   481

   482 definition

   483   DirProd :: "_ \<Rightarrow> _ \<Rightarrow> ('a \<times> 'b) monoid" (infixr "\<times>\<times>" 80) where

   484   "G \<times>\<times> H =

   485     \<lparr>carrier = carrier G \<times> carrier H,

   486      mult = (\<lambda>(g, h) (g', h'). (g \<otimes>\<^bsub>G\<^esub> g', h \<otimes>\<^bsub>H\<^esub> h')),

   487      one = (\<one>\<^bsub>G\<^esub>, \<one>\<^bsub>H\<^esub>)\<rparr>"

   488

   489 lemma DirProd_monoid:

   490   assumes "monoid G" and "monoid H"

   491   shows "monoid (G \<times>\<times> H)"

   492 proof -

   493   interpret G: monoid G by fact

   494   interpret H: monoid H by fact

   495   from assms

   496   show ?thesis by (unfold monoid_def DirProd_def, auto)

   497 qed

   498

   499

   500 text{*Does not use the previous result because it's easier just to use auto.*}

   501 lemma DirProd_group:

   502   assumes "group G" and "group H"

   503   shows "group (G \<times>\<times> H)"

   504 proof -

   505   interpret G: group G by fact

   506   interpret H: group H by fact

   507   show ?thesis by (rule groupI)

   508      (auto intro: G.m_assoc H.m_assoc G.l_inv H.l_inv

   509            simp add: DirProd_def)

   510 qed

   511

   512 lemma carrier_DirProd [simp]:

   513      "carrier (G \<times>\<times> H) = carrier G \<times> carrier H"

   514   by (simp add: DirProd_def)

   515

   516 lemma one_DirProd [simp]:

   517      "\<one>\<^bsub>G \<times>\<times> H\<^esub> = (\<one>\<^bsub>G\<^esub>, \<one>\<^bsub>H\<^esub>)"

   518   by (simp add: DirProd_def)

   519

   520 lemma mult_DirProd [simp]:

   521      "(g, h) \<otimes>\<^bsub>(G \<times>\<times> H)\<^esub> (g', h') = (g \<otimes>\<^bsub>G\<^esub> g', h \<otimes>\<^bsub>H\<^esub> h')"

   522   by (simp add: DirProd_def)

   523

   524 lemma inv_DirProd [simp]:

   525   assumes "group G" and "group H"

   526   assumes g: "g \<in> carrier G"

   527       and h: "h \<in> carrier H"

   528   shows "m_inv (G \<times>\<times> H) (g, h) = (inv\<^bsub>G\<^esub> g, inv\<^bsub>H\<^esub> h)"

   529 proof -

   530   interpret G: group G by fact

   531   interpret H: group H by fact

   532   interpret Prod: group "G \<times>\<times> H"

   533     by (auto intro: DirProd_group group.intro group.axioms assms)

   534   show ?thesis by (simp add: Prod.inv_equality g h)

   535 qed

   536

   537

   538 subsection {* Homomorphisms and Isomorphisms *}

   539

   540 definition

   541   hom :: "_ => _ => ('a => 'b) set" where

   542   "hom G H =

   543     {h. h \<in> carrier G -> carrier H &

   544       (\<forall>x \<in> carrier G. \<forall>y \<in> carrier G. h (x \<otimes>\<^bsub>G\<^esub> y) = h x \<otimes>\<^bsub>H\<^esub> h y)}"

   545

   546 lemma (in group) hom_compose:

   547   "[|h \<in> hom G H; i \<in> hom H I|] ==> compose (carrier G) i h \<in> hom G I"

   548 by (fastsimp simp add: hom_def compose_def)

   549

   550 definition

   551   iso :: "_ => _ => ('a => 'b) set" (infixr "\<cong>" 60)

   552   where "G \<cong> H = {h. h \<in> hom G H & bij_betw h (carrier G) (carrier H)}"

   553

   554 lemma iso_refl: "(%x. x) \<in> G \<cong> G"

   555 by (simp add: iso_def hom_def inj_on_def bij_betw_def Pi_def)

   556

   557 lemma (in group) iso_sym:

   558      "h \<in> G \<cong> H \<Longrightarrow> inv_into (carrier G) h \<in> H \<cong> G"

   559 apply (simp add: iso_def bij_betw_inv_into)

   560 apply (subgoal_tac "inv_into (carrier G) h \<in> carrier H \<rightarrow> carrier G")

   561  prefer 2 apply (simp add: bij_betw_imp_funcset [OF bij_betw_inv_into])

   562 apply (simp add: hom_def bij_betw_def inv_into_f_eq f_inv_into_f Pi_def)

   563 done

   564

   565 lemma (in group) iso_trans:

   566      "[|h \<in> G \<cong> H; i \<in> H \<cong> I|] ==> (compose (carrier G) i h) \<in> G \<cong> I"

   567 by (auto simp add: iso_def hom_compose bij_betw_compose)

   568

   569 lemma DirProd_commute_iso:

   570   shows "(\<lambda>(x,y). (y,x)) \<in> (G \<times>\<times> H) \<cong> (H \<times>\<times> G)"

   571 by (auto simp add: iso_def hom_def inj_on_def bij_betw_def)

   572

   573 lemma DirProd_assoc_iso:

   574   shows "(\<lambda>(x,y,z). (x,(y,z))) \<in> (G \<times>\<times> H \<times>\<times> I) \<cong> (G \<times>\<times> (H \<times>\<times> I))"

   575 by (auto simp add: iso_def hom_def inj_on_def bij_betw_def)

   576

   577

   578 text{*Basis for homomorphism proofs: we assume two groups @{term G} and

   579   @{term H}, with a homomorphism @{term h} between them*}

   580 locale group_hom = G: group G + H: group H for G (structure) and H (structure) +

   581   fixes h

   582   assumes homh: "h \<in> hom G H"

   583

   584 lemma (in group_hom) hom_mult [simp]:

   585   "[| x \<in> carrier G; y \<in> carrier G |] ==> h (x \<otimes>\<^bsub>G\<^esub> y) = h x \<otimes>\<^bsub>H\<^esub> h y"

   586 proof -

   587   assume "x \<in> carrier G" "y \<in> carrier G"

   588   with homh [unfolded hom_def] show ?thesis by simp

   589 qed

   590

   591 lemma (in group_hom) hom_closed [simp]:

   592   "x \<in> carrier G ==> h x \<in> carrier H"

   593 proof -

   594   assume "x \<in> carrier G"

   595   with homh [unfolded hom_def] show ?thesis by auto

   596 qed

   597

   598 lemma (in group_hom) one_closed [simp]:

   599   "h \<one> \<in> carrier H"

   600   by simp

   601

   602 lemma (in group_hom) hom_one [simp]:

   603   "h \<one> = \<one>\<^bsub>H\<^esub>"

   604 proof -

   605   have "h \<one> \<otimes>\<^bsub>H\<^esub> \<one>\<^bsub>H\<^esub> = h \<one> \<otimes>\<^bsub>H\<^esub> h \<one>"

   606     by (simp add: hom_mult [symmetric] del: hom_mult)

   607   then show ?thesis by (simp del: r_one)

   608 qed

   609

   610 lemma (in group_hom) inv_closed [simp]:

   611   "x \<in> carrier G ==> h (inv x) \<in> carrier H"

   612   by simp

   613

   614 lemma (in group_hom) hom_inv [simp]:

   615   "x \<in> carrier G ==> h (inv x) = inv\<^bsub>H\<^esub> (h x)"

   616 proof -

   617   assume x: "x \<in> carrier G"

   618   then have "h x \<otimes>\<^bsub>H\<^esub> h (inv x) = \<one>\<^bsub>H\<^esub>"

   619     by (simp add: hom_mult [symmetric] del: hom_mult)

   620   also from x have "... = h x \<otimes>\<^bsub>H\<^esub> inv\<^bsub>H\<^esub> (h x)"

   621     by (simp add: hom_mult [symmetric] del: hom_mult)

   622   finally have "h x \<otimes>\<^bsub>H\<^esub> h (inv x) = h x \<otimes>\<^bsub>H\<^esub> inv\<^bsub>H\<^esub> (h x)" .

   623   with x show ?thesis by (simp del: H.r_inv H.Units_r_inv)

   624 qed

   625

   626

   627 subsection {* Commutative Structures *}

   628

   629 text {*

   630   Naming convention: multiplicative structures that are commutative

   631   are called \emph{commutative}, additive structures are called

   632   \emph{Abelian}.

   633 *}

   634

   635 locale comm_monoid = monoid +

   636   assumes m_comm: "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x \<otimes> y = y \<otimes> x"

   637

   638 lemma (in comm_monoid) m_lcomm:

   639   "\<lbrakk>x \<in> carrier G; y \<in> carrier G; z \<in> carrier G\<rbrakk> \<Longrightarrow>

   640    x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)"

   641 proof -

   642   assume xyz: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"

   643   from xyz have "x \<otimes> (y \<otimes> z) = (x \<otimes> y) \<otimes> z" by (simp add: m_assoc)

   644   also from xyz have "... = (y \<otimes> x) \<otimes> z" by (simp add: m_comm)

   645   also from xyz have "... = y \<otimes> (x \<otimes> z)" by (simp add: m_assoc)

   646   finally show ?thesis .

   647 qed

   648

   649 lemmas (in comm_monoid) m_ac = m_assoc m_comm m_lcomm

   650

   651 lemma comm_monoidI:

   652   fixes G (structure)

   653   assumes m_closed:

   654       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"

   655     and one_closed: "\<one> \<in> carrier G"

   656     and m_assoc:

   657       "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   658       (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"

   659     and l_one: "!!x. x \<in> carrier G ==> \<one> \<otimes> x = x"

   660     and m_comm:

   661       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"

   662   shows "comm_monoid G"

   663   using l_one

   664     by (auto intro!: comm_monoid.intro comm_monoid_axioms.intro monoid.intro

   665              intro: assms simp: m_closed one_closed m_comm)

   666

   667 lemma (in monoid) monoid_comm_monoidI:

   668   assumes m_comm:

   669       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"

   670   shows "comm_monoid G"

   671   by (rule comm_monoidI) (auto intro: m_assoc m_comm)

   672

   673 (*lemma (in comm_monoid) r_one [simp]:

   674   "x \<in> carrier G ==> x \<otimes> \<one> = x"

   675 proof -

   676   assume G: "x \<in> carrier G"

   677   then have "x \<otimes> \<one> = \<one> \<otimes> x" by (simp add: m_comm)

   678   also from G have "... = x" by simp

   679   finally show ?thesis .

   680 qed*)

   681

   682 lemma (in comm_monoid) nat_pow_distr:

   683   "[| x \<in> carrier G; y \<in> carrier G |] ==>

   684   (x \<otimes> y) (^) (n::nat) = x (^) n \<otimes> y (^) n"

   685   by (induct n) (simp, simp add: m_ac)

   686

   687 locale comm_group = comm_monoid + group

   688

   689 lemma (in group) group_comm_groupI:

   690   assumes m_comm: "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==>

   691       x \<otimes> y = y \<otimes> x"

   692   shows "comm_group G"

   693   proof qed (simp_all add: m_comm)

   694

   695 lemma comm_groupI:

   696   fixes G (structure)

   697   assumes m_closed:

   698       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"

   699     and one_closed: "\<one> \<in> carrier G"

   700     and m_assoc:

   701       "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>

   702       (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"

   703     and m_comm:

   704       "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"

   705     and l_one: "!!x. x \<in> carrier G ==> \<one> \<otimes> x = x"

   706     and l_inv_ex: "!!x. x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"

   707   shows "comm_group G"

   708   by (fast intro: group.group_comm_groupI groupI assms)

   709

   710 lemma (in comm_group) inv_mult:

   711   "[| x \<in> carrier G; y \<in> carrier G |] ==> inv (x \<otimes> y) = inv x \<otimes> inv y"

   712   by (simp add: m_ac inv_mult_group)

   713

   714

   715 subsection {* The Lattice of Subgroups of a Group *}

   716

   717 text_raw {* \label{sec:subgroup-lattice} *}

   718

   719 theorem (in group) subgroups_partial_order:

   720   "partial_order (| carrier = {H. subgroup H G}, eq = op =, le = op \<subseteq> |)"

   721   proof qed simp_all

   722

   723 lemma (in group) subgroup_self:

   724   "subgroup (carrier G) G"

   725   by (rule subgroupI) auto

   726

   727 lemma (in group) subgroup_imp_group:

   728   "subgroup H G ==> group (G(| carrier := H |))"

   729   by (erule subgroup.subgroup_is_group) (rule group_axioms)

   730

   731 lemma (in group) is_monoid [intro, simp]:

   732   "monoid G"

   733   by (auto intro: monoid.intro m_assoc)

   734

   735 lemma (in group) subgroup_inv_equality:

   736   "[| subgroup H G; x \<in> H |] ==> m_inv (G (| carrier := H |)) x = inv x"

   737 apply (rule_tac inv_equality [THEN sym])

   738   apply (rule group.l_inv [OF subgroup_imp_group, simplified], assumption+)

   739  apply (rule subsetD [OF subgroup.subset], assumption+)

   740 apply (rule subsetD [OF subgroup.subset], assumption)

   741 apply (rule_tac group.inv_closed [OF subgroup_imp_group, simplified], assumption+)

   742 done

   743

   744 theorem (in group) subgroups_Inter:

   745   assumes subgr: "(!!H. H \<in> A ==> subgroup H G)"

   746     and not_empty: "A ~= {}"

   747   shows "subgroup (\<Inter>A) G"

   748 proof (rule subgroupI)

   749   from subgr [THEN subgroup.subset] and not_empty

   750   show "\<Inter>A \<subseteq> carrier G" by blast

   751 next

   752   from subgr [THEN subgroup.one_closed]

   753   show "\<Inter>A ~= {}" by blast

   754 next

   755   fix x assume "x \<in> \<Inter>A"

   756   with subgr [THEN subgroup.m_inv_closed]

   757   show "inv x \<in> \<Inter>A" by blast

   758 next

   759   fix x y assume "x \<in> \<Inter>A" "y \<in> \<Inter>A"

   760   with subgr [THEN subgroup.m_closed]

   761   show "x \<otimes> y \<in> \<Inter>A" by blast

   762 qed

   763

   764 theorem (in group) subgroups_complete_lattice:

   765   "complete_lattice (| carrier = {H. subgroup H G}, eq = op =, le = op \<subseteq> |)"

   766     (is "complete_lattice ?L")

   767 proof (rule partial_order.complete_lattice_criterion1)

   768   show "partial_order ?L" by (rule subgroups_partial_order)

   769 next

   770   show "\<exists>G. greatest ?L G (carrier ?L)"

   771   proof

   772     show "greatest ?L (carrier G) (carrier ?L)"

   773       by (unfold greatest_def)

   774         (simp add: subgroup.subset subgroup_self)

   775   qed

   776 next

   777   fix A

   778   assume L: "A \<subseteq> carrier ?L" and non_empty: "A ~= {}"

   779   then have Int_subgroup: "subgroup (\<Inter>A) G"

   780     by (fastsimp intro: subgroups_Inter)

   781   show "\<exists>I. greatest ?L I (Lower ?L A)"

   782   proof

   783     show "greatest ?L (\<Inter>A) (Lower ?L A)"

   784       (is "greatest _ ?Int _")

   785     proof (rule greatest_LowerI)

   786       fix H

   787       assume H: "H \<in> A"

   788       with L have subgroupH: "subgroup H G" by auto

   789       from subgroupH have groupH: "group (G (| carrier := H |))" (is "group ?H")

   790         by (rule subgroup_imp_group)

   791       from groupH have monoidH: "monoid ?H"

   792         by (rule group.is_monoid)

   793       from H have Int_subset: "?Int \<subseteq> H" by fastsimp

   794       then show "le ?L ?Int H" by simp

   795     next

   796       fix H

   797       assume H: "H \<in> Lower ?L A"

   798       with L Int_subgroup show "le ?L H ?Int"

   799         by (fastsimp simp: Lower_def intro: Inter_greatest)

   800     next

   801       show "A \<subseteq> carrier ?L" by (rule L)

   802     next

   803       show "?Int \<in> carrier ?L" by simp (rule Int_subgroup)

   804     qed

   805   qed

   806 qed

   807

   808 end