src/HOL/Algebra/Group.thy
 author haftmann Mon Mar 01 13:40:23 2010 +0100 (2010-03-01) changeset 35416 d8d7d1b785af parent 33057 764547b68538 child 35847 19f1f7066917 permissions -rw-r--r--
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
     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 definition DirProd :: "_ \<Rightarrow> _ \<Rightarrow> ('a \<times> 'b) monoid" (infixr "\<times>\<times>" 80) where

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

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

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

   485

   486 lemma DirProd_monoid:

   487   assumes "monoid G" and "monoid H"

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

   489 proof -

   490   interpret G: monoid G by fact

   491   interpret H: monoid H by fact

   492   from assms

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

   494 qed

   495

   496

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

   498 lemma DirProd_group:

   499   assumes "group G" and "group H"

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

   501 proof -

   502   interpret G: group G by fact

   503   interpret H: group H by fact

   504   show ?thesis by (rule groupI)

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

   506            simp add: DirProd_def)

   507 qed

   508

   509 lemma carrier_DirProd [simp]:

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

   511   by (simp add: DirProd_def)

   512

   513 lemma one_DirProd [simp]:

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

   515   by (simp add: DirProd_def)

   516

   517 lemma mult_DirProd [simp]:

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

   519   by (simp add: DirProd_def)

   520

   521 lemma inv_DirProd [simp]:

   522   assumes "group G" and "group H"

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

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

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

   526 proof -

   527   interpret G: group G by fact

   528   interpret H: group H by fact

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

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

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

   532 qed

   533

   534

   535 subsection {* Homomorphisms and Isomorphisms *}

   536

   537 constdefs (structure G and H)

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

   539   "hom G H ==

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

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

   542

   543 lemma (in group) hom_compose:

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

   545 by (fastsimp simp add: hom_def compose_def)

   546

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

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

   549

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

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

   552

   553 lemma (in group) iso_sym:

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

   555 apply (simp add: iso_def bij_betw_inv_into)

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

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

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

   559 done

   560

   561 lemma (in group) iso_trans:

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

   563 by (auto simp add: iso_def hom_compose bij_betw_compose)

   564

   565 lemma DirProd_commute_iso:

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

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

   568

   569 lemma DirProd_assoc_iso:

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

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

   572

   573

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

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

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

   577   fixes h

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

   579

   580 lemma (in group_hom) hom_mult [simp]:

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

   582 proof -

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

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

   585 qed

   586

   587 lemma (in group_hom) hom_closed [simp]:

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

   589 proof -

   590   assume "x \<in> carrier G"

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

   592 qed

   593

   594 lemma (in group_hom) one_closed [simp]:

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

   596   by simp

   597

   598 lemma (in group_hom) hom_one [simp]:

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

   600 proof -

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

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

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

   604 qed

   605

   606 lemma (in group_hom) inv_closed [simp]:

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

   608   by simp

   609

   610 lemma (in group_hom) hom_inv [simp]:

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

   612 proof -

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

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

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

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

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

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

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

   620 qed

   621

   622

   623 subsection {* Commutative Structures *}

   624

   625 text {*

   626   Naming convention: multiplicative structures that are commutative

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

   628   \emph{Abelian}.

   629 *}

   630

   631 locale comm_monoid = monoid +

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

   633

   634 lemma (in comm_monoid) m_lcomm:

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

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

   637 proof -

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

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

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

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

   642   finally show ?thesis .

   643 qed

   644

   645 lemmas (in comm_monoid) m_ac = m_assoc m_comm m_lcomm

   646

   647 lemma comm_monoidI:

   648   fixes G (structure)

   649   assumes m_closed:

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

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

   652     and m_assoc:

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

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

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

   656     and m_comm:

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

   658   shows "comm_monoid G"

   659   using l_one

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

   661              intro: assms simp: m_closed one_closed m_comm)

   662

   663 lemma (in monoid) monoid_comm_monoidI:

   664   assumes m_comm:

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

   666   shows "comm_monoid G"

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

   668

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

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

   671 proof -

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

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

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

   675   finally show ?thesis .

   676 qed*)

   677

   678 lemma (in comm_monoid) nat_pow_distr:

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

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

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

   682

   683 locale comm_group = comm_monoid + group

   684

   685 lemma (in group) group_comm_groupI:

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

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

   688   shows "comm_group G"

   689   proof qed (simp_all add: m_comm)

   690

   691 lemma comm_groupI:

   692   fixes G (structure)

   693   assumes m_closed:

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

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

   696     and m_assoc:

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

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

   699     and m_comm:

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

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

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

   703   shows "comm_group G"

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

   705

   706 lemma (in comm_group) inv_mult:

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

   708   by (simp add: m_ac inv_mult_group)

   709

   710

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

   712

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

   714

   715 theorem (in group) subgroups_partial_order:

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

   717   proof qed simp_all

   718

   719 lemma (in group) subgroup_self:

   720   "subgroup (carrier G) G"

   721   by (rule subgroupI) auto

   722

   723 lemma (in group) subgroup_imp_group:

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

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

   726

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

   728   "monoid G"

   729   by (auto intro: monoid.intro m_assoc)

   730

   731 lemma (in group) subgroup_inv_equality:

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

   733 apply (rule_tac inv_equality [THEN sym])

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

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

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

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

   738 done

   739

   740 theorem (in group) subgroups_Inter:

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

   742     and not_empty: "A ~= {}"

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

   744 proof (rule subgroupI)

   745   from subgr [THEN subgroup.subset] and not_empty

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

   747 next

   748   from subgr [THEN subgroup.one_closed]

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

   750 next

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

   752   with subgr [THEN subgroup.m_inv_closed]

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

   754 next

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

   756   with subgr [THEN subgroup.m_closed]

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

   758 qed

   759

   760 theorem (in group) subgroups_complete_lattice:

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

   762     (is "complete_lattice ?L")

   763 proof (rule partial_order.complete_lattice_criterion1)

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

   765 next

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

   767   proof

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

   769       by (unfold greatest_def)

   770         (simp add: subgroup.subset subgroup_self)

   771   qed

   772 next

   773   fix A

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

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

   776     by (fastsimp intro: subgroups_Inter)

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

   778   proof

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

   780       (is "greatest _ ?Int _")

   781     proof (rule greatest_LowerI)

   782       fix H

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

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

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

   786         by (rule subgroup_imp_group)

   787       from groupH have monoidH: "monoid ?H"

   788         by (rule group.is_monoid)

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

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

   791     next

   792       fix H

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

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

   795         by (fastsimp simp: Lower_def intro: Inter_greatest)

   796     next

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

   798     next

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

   800     qed

   801   qed

   802 qed

   803

   804 end