src/HOL/Algebra/Group.thy
 author nipkow Mon Jun 22 20:59:12 2009 +0200 (2009-06-22) changeset 31754 b5260f5272a4 parent 31727 2621a957d417 child 32960 69916a850301 child 32988 d1d4d7a08a66 permissions -rw-r--r--
tuned FuncSet
     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 constdefs (structure G)

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

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

    28

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

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

    31   "Units G == {y. y \<in> carrier G & (\<exists>x \<in> carrier G. x \<otimes> y = \<one> & y \<otimes> x = \<one>)}"

    32

    33 consts

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

    35

    36 defs (overloaded)

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

    38   int_pow_def: "pow G a z ==

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

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

    41

    42 locale monoid =

    43   fixes G (structure)

    44   assumes m_closed [intro, simp]:

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

    46       and m_assoc:

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

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

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

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

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

    52

    53 lemma monoidI:

    54   fixes G (structure)

    55   assumes m_closed:

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

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

    58     and m_assoc:

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

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

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

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

    63   shows "monoid G"

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

    65

    66 lemma (in monoid) Units_closed [dest]:

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

    68   by (unfold Units_def) fast

    69

    70 lemma (in monoid) inv_unique:

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

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

    73   shows "y = y'"

    74 proof -

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

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

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

    78   finally show ?thesis .

    79 qed

    80

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

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

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

    84 proof -

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

    86     unfolding Units_def by fast

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

    88     unfolding Units_def by fast

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

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

    91   moreover note x y

    92   ultimately show ?thesis unfolding Units_def

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

    94     apply (rule_tac CollectI)

    95     apply (rule)

    96     apply (fast)

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

    98     apply (auto simp: m_assoc)

    99     done

   100 qed

   101

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

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

   104   by (unfold Units_def) auto

   105

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

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

   108   apply (unfold Units_def m_inv_def, auto)

   109   apply (rule theI2, fast)

   110    apply (fast intro: inv_unique, fast)

   111   done

   112

   113 lemma (in monoid) Units_l_inv_ex:

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

   115   by (unfold Units_def) auto

   116

   117 lemma (in monoid) Units_r_inv_ex:

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

   119   by (unfold Units_def) auto

   120

   121 lemma (in monoid) Units_l_inv [simp]:

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

   123   apply (unfold Units_def m_inv_def, auto)

   124   apply (rule theI2, fast)

   125    apply (fast intro: inv_unique, fast)

   126   done

   127

   128 lemma (in monoid) Units_r_inv [simp]:

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

   130   apply (unfold Units_def m_inv_def, auto)

   131   apply (rule theI2, fast)

   132    apply (fast intro: inv_unique, fast)

   133   done

   134

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

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

   137 proof -

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

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

   140     by (auto simp add: Units_def

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

   142 qed

   143

   144 lemma (in monoid) Units_l_cancel [simp]:

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

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

   147 proof

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

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

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

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

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

   153 next

   154   assume eq: "y = z"

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

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

   157 qed

   158

   159 lemma (in monoid) Units_inv_inv [simp]:

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

   161 proof -

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

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

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

   165 qed

   166

   167 lemma (in monoid) inv_inj_on_Units:

   168   "inj_on (m_inv G) (Units G)"

   169 proof (rule inj_onI)

   170   fix x y

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

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

   173   with G show "x = y" by simp

   174 qed

   175

   176 lemma (in monoid) Units_inv_comm:

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

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

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

   180 proof -

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

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

   183 qed

   184

   185 text {* Power *}

   186

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

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

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

   190

   191 lemma (in monoid) nat_pow_0 [simp]:

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

   193   by (simp add: nat_pow_def)

   194

   195 lemma (in monoid) nat_pow_Suc [simp]:

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

   197   by (simp add: nat_pow_def)

   198

   199 lemma (in monoid) nat_pow_one [simp]:

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

   201   by (induct n) simp_all

   202

   203 lemma (in monoid) nat_pow_mult:

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

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

   206

   207 lemma (in monoid) nat_pow_pow:

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

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

   210

   211

   212 (* Jacobson defines submonoid here. *)

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

   214

   215

   216 subsection {* Groups *}

   217

   218 text {*

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

   220 *}

   221

   222 locale group = monoid +

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

   224

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

   226

   227 theorem groupI:

   228   fixes G (structure)

   229   assumes m_closed [simp]:

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

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

   232     and m_assoc:

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

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

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

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

   237   shows "group G"

   238 proof -

   239   have l_cancel [simp]:

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

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

   242   proof

   243     fix x y z

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

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

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

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

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

   249       by (simp add: m_assoc)

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

   251   next

   252     fix x y z

   253     assume eq: "y = z"

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

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

   256   qed

   257   have r_one:

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

   259   proof -

   260     fix x

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

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

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

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

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

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

   267   qed

   268   have inv_ex:

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

   270   proof -

   271     fix x

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

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

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

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

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

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

   278       by simp

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

   280       by (fast intro: l_inv r_inv)

   281   qed

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

   283     by (unfold Units_def) fast

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

   285 qed

   286

   287 lemma (in monoid) group_l_invI:

   288   assumes l_inv_ex:

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

   290   shows "group G"

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

   292

   293 lemma (in group) Units_eq [simp]:

   294   "Units G = carrier G"

   295 proof

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

   297 next

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

   299 qed

   300

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

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

   303   using Units_inv_closed by simp

   304

   305 lemma (in group) l_inv_ex [simp]:

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

   307   using Units_l_inv_ex by simp

   308

   309 lemma (in group) r_inv_ex [simp]:

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

   311   using Units_r_inv_ex by simp

   312

   313 lemma (in group) l_inv [simp]:

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

   315   using Units_l_inv by simp

   316

   317

   318 subsection {* Cancellation Laws and Basic Properties *}

   319

   320 lemma (in group) l_cancel [simp]:

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

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

   323   using Units_l_inv by simp

   324

   325 lemma (in group) r_inv [simp]:

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

   327 proof -

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

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

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

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

   332 qed

   333

   334 lemma (in group) r_cancel [simp]:

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

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

   337 proof

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

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

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

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

   342   with G show "y = z" by simp

   343 next

   344   assume eq: "y = z"

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

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

   347 qed

   348

   349 lemma (in group) inv_one [simp]:

   350   "inv \<one> = \<one>"

   351 proof -

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

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

   354   finally show ?thesis .

   355 qed

   356

   357 lemma (in group) inv_inv [simp]:

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

   359   using Units_inv_inv by simp

   360

   361 lemma (in group) inv_inj:

   362   "inj_on (m_inv G) (carrier G)"

   363   using inv_inj_on_Units by simp

   364

   365 lemma (in group) inv_mult_group:

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

   367 proof -

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

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

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

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

   372 qed

   373

   374 lemma (in group) inv_comm:

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

   376   by (rule Units_inv_comm) auto

   377

   378 lemma (in group) inv_equality:

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

   380 apply (simp add: m_inv_def)

   381 apply (rule the_equality)

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

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

   384 done

   385

   386 text {* Power *}

   387

   388 lemma (in group) int_pow_def2:

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

   390   by (simp add: int_pow_def nat_pow_def Let_def)

   391

   392 lemma (in group) int_pow_0 [simp]:

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

   394   by (simp add: int_pow_def2)

   395

   396 lemma (in group) int_pow_one [simp]:

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

   398   by (simp add: int_pow_def2)

   399

   400

   401 subsection {* Subgroups *}

   402

   403 locale subgroup =

   404   fixes H and G (structure)

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

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

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

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

   409

   410 lemma (in subgroup) is_subgroup:

   411   "subgroup H G" by (rule subgroup_axioms)

   412

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

   414

   415 lemma (in subgroup) mem_carrier [simp]:

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

   417   using subset by blast

   418

   419 lemma subgroup_imp_subset:

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

   421   by (rule subgroup.subset)

   422

   423 lemma (in subgroup) subgroup_is_group [intro]:

   424   assumes "group G"

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

   426 proof -

   427   interpret group G by fact

   428   show ?thesis

   429     apply (rule monoid.group_l_invI)

   430     apply (unfold_locales) 

   431     apply (auto intro: m_assoc l_inv mem_carrier)

   432     done

   433 qed

   434

   435 text {*

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

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

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

   439 *}

   440

   441 lemma (in group) one_in_subset:

   442   "[| 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 |]

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

   444 by (force simp add: l_inv)

   445

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

   447

   448 lemma (in group) subgroupI:

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

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

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

   452   shows "subgroup H G"

   453 proof (simp add: subgroup_def assms)

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

   455 qed

   456

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

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

   459

   460 lemma subgroup_nonempty:

   461   "~ subgroup {} G"

   462   by (blast dest: subgroup.one_closed)

   463

   464 lemma (in subgroup) finite_imp_card_positive:

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

   466 proof (rule classical)

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

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

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

   470   with subgroup_nonempty show ?thesis by contradiction

   471 qed

   472

   473 (*

   474 lemma (in monoid) Units_subgroup:

   475   "subgroup (Units G) G"

   476 *)

   477

   478

   479 subsection {* Direct Products *}

   480

   481 constdefs

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

   483   "G \<times>\<times> H \<equiv> \<lparr>carrier = carrier G \<times> carrier H,

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

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

   486

   487 lemma DirProd_monoid:

   488   assumes "monoid G" and "monoid H"

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

   490 proof -

   491   interpret G: monoid G by fact

   492   interpret H: monoid H by fact

   493   from assms

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

   495 qed

   496

   497

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

   499 lemma DirProd_group:

   500   assumes "group G" and "group H"

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

   502 proof -

   503   interpret G: group G by fact

   504   interpret H: group H by fact

   505   show ?thesis by (rule groupI)

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

   507            simp add: DirProd_def)

   508 qed

   509

   510 lemma carrier_DirProd [simp]:

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

   512   by (simp add: DirProd_def)

   513

   514 lemma one_DirProd [simp]:

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

   516   by (simp add: DirProd_def)

   517

   518 lemma mult_DirProd [simp]:

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

   520   by (simp add: DirProd_def)

   521

   522 lemma inv_DirProd [simp]:

   523   assumes "group G" and "group H"

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

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

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

   527 proof -

   528   interpret G: group G by fact

   529   interpret H: group H by fact

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

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

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

   533 qed

   534

   535

   536 subsection {* Homomorphisms and Isomorphisms *}

   537

   538 constdefs (structure G and H)

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

   540   "hom G H ==

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

   542       (\<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)}"

   543

   544 lemma (in group) hom_compose:

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

   546 by (fastsimp simp add: hom_def compose_def)

   547

   548 constdefs

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

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

   551

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

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

   554

   555 lemma (in group) iso_sym:

   556      "h \<in> G \<cong> H \<Longrightarrow> Inv (carrier G) h \<in> H \<cong> G"

   557 apply (simp add: iso_def bij_betw_Inv)

   558 apply (subgoal_tac "Inv (carrier G) h \<in> carrier H \<rightarrow> carrier G")

   559  prefer 2 apply (simp add: bij_betw_imp_funcset [OF bij_betw_Inv])

   560 apply (simp add: hom_def bij_betw_def Inv_f_eq f_Inv_f Pi_def)

   561 done

   562

   563 lemma (in group) iso_trans:

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

   565 by (auto simp add: iso_def hom_compose bij_betw_compose)

   566

   567 lemma DirProd_commute_iso:

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

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

   570

   571 lemma DirProd_assoc_iso:

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

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

   574

   575

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

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

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

   579   fixes h

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

   581

   582 lemma (in group_hom) hom_mult [simp]:

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

   584 proof -

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

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

   587 qed

   588

   589 lemma (in group_hom) hom_closed [simp]:

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

   591 proof -

   592   assume "x \<in> carrier G"

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

   594 qed

   595

   596 lemma (in group_hom) one_closed [simp]:

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

   598   by simp

   599

   600 lemma (in group_hom) hom_one [simp]:

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

   602 proof -

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

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

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

   606 qed

   607

   608 lemma (in group_hom) inv_closed [simp]:

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

   610   by simp

   611

   612 lemma (in group_hom) hom_inv [simp]:

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

   614 proof -

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

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

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

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

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

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

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

   622 qed

   623

   624

   625 subsection {* Commutative Structures *}

   626

   627 text {*

   628   Naming convention: multiplicative structures that are commutative

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

   630   \emph{Abelian}.

   631 *}

   632

   633 locale comm_monoid = monoid +

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

   635

   636 lemma (in comm_monoid) m_lcomm:

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

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

   639 proof -

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

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

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

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

   644   finally show ?thesis .

   645 qed

   646

   647 lemmas (in comm_monoid) m_ac = m_assoc m_comm m_lcomm

   648

   649 lemma comm_monoidI:

   650   fixes G (structure)

   651   assumes m_closed:

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

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

   654     and m_assoc:

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

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

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

   658     and m_comm:

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

   660   shows "comm_monoid G"

   661   using l_one

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

   663              intro: assms simp: m_closed one_closed m_comm)

   664

   665 lemma (in monoid) monoid_comm_monoidI:

   666   assumes m_comm:

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

   668   shows "comm_monoid G"

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

   670

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

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

   673 proof -

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

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

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

   677   finally show ?thesis .

   678 qed*)

   679

   680 lemma (in comm_monoid) nat_pow_distr:

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

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

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

   684

   685 locale comm_group = comm_monoid + group

   686

   687 lemma (in group) group_comm_groupI:

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

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

   690   shows "comm_group G"

   691   proof qed (simp_all add: m_comm)

   692

   693 lemma comm_groupI:

   694   fixes G (structure)

   695   assumes m_closed:

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

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

   698     and m_assoc:

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

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

   701     and m_comm:

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

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

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

   705   shows "comm_group G"

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

   707

   708 lemma (in comm_group) inv_mult:

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

   710   by (simp add: m_ac inv_mult_group)

   711

   712

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

   714

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

   716

   717 theorem (in group) subgroups_partial_order:

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

   719   proof qed simp_all

   720

   721 lemma (in group) subgroup_self:

   722   "subgroup (carrier G) G"

   723   by (rule subgroupI) auto

   724

   725 lemma (in group) subgroup_imp_group:

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

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

   728

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

   730   "monoid G"

   731   by (auto intro: monoid.intro m_assoc)

   732

   733 lemma (in group) subgroup_inv_equality:

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

   735 apply (rule_tac inv_equality [THEN sym])

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

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

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

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

   740 done

   741

   742 theorem (in group) subgroups_Inter:

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

   744     and not_empty: "A ~= {}"

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

   746 proof (rule subgroupI)

   747   from subgr [THEN subgroup.subset] and not_empty

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

   749 next

   750   from subgr [THEN subgroup.one_closed]

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

   752 next

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

   754   with subgr [THEN subgroup.m_inv_closed]

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

   756 next

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

   758   with subgr [THEN subgroup.m_closed]

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

   760 qed

   761

   762 theorem (in group) subgroups_complete_lattice:

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

   764     (is "complete_lattice ?L")

   765 proof (rule partial_order.complete_lattice_criterion1)

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

   767 next

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

   769   proof

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

   771       by (unfold greatest_def)

   772         (simp add: subgroup.subset subgroup_self)

   773   qed

   774 next

   775   fix A

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

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

   778     by (fastsimp intro: subgroups_Inter)

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

   780   proof

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

   782       (is "greatest _ ?Int _")

   783     proof (rule greatest_LowerI)

   784       fix H

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

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

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

   788 	by (rule subgroup_imp_group)

   789       from groupH have monoidH: "monoid ?H"

   790 	by (rule group.is_monoid)

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

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

   793     next

   794       fix H

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

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

   797 	by (fastsimp simp: Lower_def intro: Inter_greatest)

   798     next

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

   800     next

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

   802     qed

   803   qed

   804 qed

   805

   806 end