src/HOL/Algebra/Group.thy
 author ballarin Thu Nov 06 14:18:05 2003 +0100 (2003-11-06) changeset 14254 342634f38451 parent 13975 c8e9a89883ce child 14286 0ae66ffb9784 permissions -rw-r--r--
Isar/Locales: <loc>.intro and <loc>.axioms no longer intro? and elim? by
default.
     1 (*

     2   Title:  HOL/Algebra/Group.thy

     3   Id:     $Id$

     4   Author: Clemens Ballarin, started 4 February 2003

     5

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

     7 *)

     8

     9 header {* Groups *}

    10

    11 theory Group = FuncSet:

    12

    13 section {* From Magmas to Groups *}

    14

    15 text {*

    16   Definitions follow Jacobson, Basic Algebra I, Freeman, 1985; with

    17   the exception of \emph{magma} which, following Bourbaki, is a set

    18   together with a binary, closed operation.

    19 *}

    20

    21 subsection {* Definitions *}

    22

    23 record 'a semigroup =

    24   carrier :: "'a set"

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

    26

    27 record 'a monoid = "'a semigroup" +

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

    29

    30 constdefs

    31   m_inv :: "[('a, 'm) monoid_scheme, 'a] => 'a" ("inv\<index> _"  80)

    32   "m_inv G x == (THE y. y \<in> carrier G &

    33                   mult G x y = one G & mult G y x = one G)"

    34

    35   Units :: "('a, 'm) monoid_scheme => 'a set"

    36   "Units G == {y. y \<in> carrier G &

    37                   (EX x : carrier G. mult G x y = one G & mult G y x = one G)}"

    38

    39 consts

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

    41

    42 defs (overloaded)

    43   nat_pow_def: "pow G a n == nat_rec (one G) (%u b. mult G b a) n"

    44   int_pow_def: "pow G a z ==

    45     let p = nat_rec (one G) (%u b. mult G b a)

    46     in if neg z then m_inv G (p (nat (-z))) else p (nat z)"

    47

    48 locale magma = struct G +

    49   assumes m_closed [intro, simp]:

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

    51

    52 locale semigroup = magma +

    53   assumes m_assoc:

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

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

    56

    57 locale monoid = semigroup +

    58   assumes one_closed [intro, simp]: "\<one> \<in> carrier G"

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

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

    61

    62 lemma monoidI:

    63   assumes m_closed:

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

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

    66     and m_assoc:

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

    68       mult G (mult G x y) z = mult G x (mult G y z)"

    69     and l_one: "!!x. x \<in> carrier G ==> mult G (one G) x = x"

    70     and r_one: "!!x. x \<in> carrier G ==> mult G x (one G) = x"

    71   shows "monoid G"

    72   by (fast intro!: monoid.intro magma.intro semigroup_axioms.intro

    73     semigroup.intro monoid_axioms.intro

    74     intro: prems)

    75

    76 lemma (in monoid) Units_closed [dest]:

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

    78   by (unfold Units_def) fast

    79

    80 lemma (in monoid) inv_unique:

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

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

    83   shows "y = y'"

    84 proof -

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

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

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

    88   finally show ?thesis .

    89 qed

    90

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

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

    93   by (unfold Units_def) auto

    94

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

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

    97   apply (unfold Units_def m_inv_def, auto)

    98   apply (rule theI2, fast)

    99    apply (fast intro: inv_unique, fast)

   100   done

   101

   102 lemma (in monoid) Units_l_inv:

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

   104   apply (unfold Units_def m_inv_def, auto)

   105   apply (rule theI2, fast)

   106    apply (fast intro: inv_unique, fast)

   107   done

   108

   109 lemma (in monoid) Units_r_inv:

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

   111   apply (unfold Units_def m_inv_def, auto)

   112   apply (rule theI2, fast)

   113    apply (fast intro: inv_unique, fast)

   114   done

   115

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

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

   118 proof -

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

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

   121     by (auto simp add: Units_def

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

   123 qed

   124

   125 lemma (in monoid) Units_l_cancel [simp]:

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

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

   128 proof

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

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

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

   132     by (simp add: m_assoc Units_closed)

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

   134 next

   135   assume eq: "y = z"

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

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

   138 qed

   139

   140 lemma (in monoid) Units_inv_inv [simp]:

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

   142 proof -

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

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

   145     by (simp add: Units_l_inv Units_r_inv)

   146   with x show ?thesis by (simp add: Units_closed)

   147 qed

   148

   149 lemma (in monoid) inv_inj_on_Units:

   150   "inj_on (m_inv G) (Units G)"

   151 proof (rule inj_onI)

   152   fix x y

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

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

   155   with G show "x = y" by simp

   156 qed

   157

   158 lemma (in monoid) Units_inv_comm:

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

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

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

   162 proof -

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

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

   165 qed

   166

   167 text {* Power *}

   168

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

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

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

   172

   173 lemma (in monoid) nat_pow_0 [simp]:

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

   175   by (simp add: nat_pow_def)

   176

   177 lemma (in monoid) nat_pow_Suc [simp]:

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

   179   by (simp add: nat_pow_def)

   180

   181 lemma (in monoid) nat_pow_one [simp]:

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

   183   by (induct n) simp_all

   184

   185 lemma (in monoid) nat_pow_mult:

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

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

   188

   189 lemma (in monoid) nat_pow_pow:

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

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

   192

   193 text {*

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

   195 *}

   196

   197 locale group = monoid +

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

   199

   200 theorem groupI:

   201   assumes m_closed [simp]:

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

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

   204     and m_assoc:

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

   206       mult G (mult G x y) z = mult G x (mult G y z)"

   207     and l_one [simp]: "!!x. x \<in> carrier G ==> mult G (one G) x = x"

   208     and l_inv_ex: "!!x. x \<in> carrier G ==> EX y : carrier G. mult G y x = one G"

   209   shows "group G"

   210 proof -

   211   have l_cancel [simp]:

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

   213     (mult G x y = mult G x z) = (y = z)"

   214   proof

   215     fix x y z

   216     assume eq: "mult G x y = mult G x z"

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

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

   219       and l_inv: "mult G x_inv x = one G" by fast

   220     from G eq xG have "mult G (mult G x_inv x) y = mult G (mult G x_inv x) z"

   221       by (simp add: m_assoc)

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

   223   next

   224     fix x y z

   225     assume eq: "y = z"

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

   227     then show "mult G x y = mult G x z" by simp

   228   qed

   229   have r_one:

   230     "!!x. x \<in> carrier G ==> mult G x (one G) = x"

   231   proof -

   232     fix x

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

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

   235       and l_inv: "mult G x_inv x = one G" by fast

   236     from x xG have "mult G x_inv (mult G x (one G)) = mult G x_inv x"

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

   238     with x xG show "mult G x (one G) = x" by simp

   239   qed

   240   have inv_ex:

   241     "!!x. x \<in> carrier G ==> EX y : carrier G. mult G y x = one G &

   242       mult G x y = one G"

   243   proof -

   244     fix x

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

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

   247       and l_inv: "mult G y x = one G" by fast

   248     from x y have "mult G y (mult G x y) = mult G y (one G)"

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

   250     with x y have r_inv: "mult G x y = one G"

   251       by simp

   252     from x y show "EX y : carrier G. mult G y x = one G &

   253       mult G x y = one G"

   254       by (fast intro: l_inv r_inv)

   255   qed

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

   257     by (unfold Units_def) fast

   258   show ?thesis

   259     by (fast intro!: group.intro magma.intro semigroup_axioms.intro

   260       semigroup.intro monoid_axioms.intro group_axioms.intro

   261       carrier_subset_Units intro: prems r_one)

   262 qed

   263

   264 lemma (in monoid) monoid_groupI:

   265   assumes l_inv_ex:

   266     "!!x. x \<in> carrier G ==> EX y : carrier G. mult G y x = one G"

   267   shows "group G"

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

   269

   270 lemma (in group) Units_eq [simp]:

   271   "Units G = carrier G"

   272 proof

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

   274 next

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

   276 qed

   277

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

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

   280   using Units_inv_closed by simp

   281

   282 lemma (in group) l_inv:

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

   284   using Units_l_inv by simp

   285

   286 subsection {* Cancellation Laws and Basic Properties *}

   287

   288 lemma (in group) l_cancel [simp]:

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

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

   291   using Units_l_inv by simp

   292

   293 lemma (in group) r_inv:

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

   295 proof -

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

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

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

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

   300 qed

   301

   302 lemma (in group) r_cancel [simp]:

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

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

   305 proof

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

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

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

   309     by (simp add: m_assoc [symmetric])

   310   with G show "y = z" by (simp add: r_inv)

   311 next

   312   assume eq: "y = z"

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

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

   315 qed

   316

   317 lemma (in group) inv_one [simp]:

   318   "inv \<one> = \<one>"

   319 proof -

   320   have "inv \<one> = \<one> \<otimes> (inv \<one>)" by simp

   321   moreover have "... = \<one>" by (simp add: r_inv)

   322   finally show ?thesis .

   323 qed

   324

   325 lemma (in group) inv_inv [simp]:

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

   327   using Units_inv_inv by simp

   328

   329 lemma (in group) inv_inj:

   330   "inj_on (m_inv G) (carrier G)"

   331   using inv_inj_on_Units by simp

   332

   333 lemma (in group) inv_mult_group:

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

   335 proof -

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

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

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

   339   with G show ?thesis by simp

   340 qed

   341

   342 lemma (in group) inv_comm:

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

   344   by (rule Units_inv_comm) auto

   345

   346 lemma (in group) inv_equality:

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

   348 apply (simp add: m_inv_def)

   349 apply (rule the_equality)

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

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

   352 done

   353

   354 text {* Power *}

   355

   356 lemma (in group) int_pow_def2:

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

   358   by (simp add: int_pow_def nat_pow_def Let_def)

   359

   360 lemma (in group) int_pow_0 [simp]:

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

   362   by (simp add: int_pow_def2)

   363

   364 lemma (in group) int_pow_one [simp]:

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

   366   by (simp add: int_pow_def2)

   367

   368 subsection {* Substructures *}

   369

   370 locale submagma = var H + struct G +

   371   assumes subset [intro, simp]: "H \<subseteq> carrier G"

   372     and m_closed [intro, simp]: "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"

   373

   374 declare (in submagma) magma.intro [intro] semigroup.intro [intro]

   375   semigroup_axioms.intro [intro]

   376 (*

   377 alternative definition of submagma

   378

   379 locale submagma = var H + struct G +

   380   assumes subset [intro, simp]: "carrier H \<subseteq> carrier G"

   381     and m_equal [simp]: "mult H = mult G"

   382     and m_closed [intro, simp]:

   383       "[| x \<in> carrier H; y \<in> carrier H |] ==> x \<otimes> y \<in> carrier H"

   384 *)

   385

   386 lemma submagma_imp_subset:

   387   "submagma H G ==> H \<subseteq> carrier G"

   388   by (rule submagma.subset)

   389

   390 lemma (in submagma) subsetD [dest, simp]:

   391   "x \<in> H ==> x \<in> carrier G"

   392   using subset by blast

   393

   394 lemma (in submagma) magmaI [intro]:

   395   includes magma G

   396   shows "magma (G(| carrier := H |))"

   397   by rule simp

   398

   399 lemma (in submagma) semigroup_axiomsI [intro]:

   400   includes semigroup G

   401   shows "semigroup_axioms (G(| carrier := H |))"

   402     by rule (simp add: m_assoc)

   403

   404 lemma (in submagma) semigroupI [intro]:

   405   includes semigroup G

   406   shows "semigroup (G(| carrier := H |))"

   407   using prems by fast

   408

   409 locale subgroup = submagma H G +

   410   assumes one_closed [intro, simp]: "\<one> \<in> H"

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

   412

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

   414

   415 lemma (in subgroup) group_axiomsI [intro]:

   416   includes group G

   417   shows "group_axioms (G(| carrier := H |))"

   418   by (rule group_axioms.intro) (auto intro: l_inv r_inv simp add: Units_def)

   419

   420 lemma (in subgroup) groupI [intro]:

   421   includes group G

   422   shows "group (G(| carrier := H |))"

   423   by (rule groupI) (auto intro: m_assoc l_inv)

   424

   425 text {*

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

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

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

   429 *}

   430

   431 lemma (in group) one_in_subset:

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

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

   434 by (force simp add: l_inv)

   435

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

   437

   438 lemma (in group) subgroupI:

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

   440     and inv: "!!a. a \<in> H ==> inv a \<in> H"

   441     and mult: "!!a b. [|a \<in> H; b \<in> H|] ==> a \<otimes> b \<in> H"

   442   shows "subgroup H G"

   443 proof (rule subgroup.intro)

   444   from subset and mult show "submagma H G" by (rule submagma.intro)

   445 next

   446   have "\<one> \<in> H" by (rule one_in_subset) (auto simp only: prems)

   447   with inv show "subgroup_axioms H G"

   448     by (intro subgroup_axioms.intro) simp_all

   449 qed

   450

   451 text {*

   452   Repeat facts of submagmas for subgroups.  Necessary???

   453 *}

   454

   455 lemma (in subgroup) subset:

   456   "H \<subseteq> carrier G"

   457   ..

   458

   459 lemma (in subgroup) m_closed:

   460   "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"

   461   ..

   462

   463 declare magma.m_closed [simp]

   464

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

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

   467

   468 lemma subgroup_nonempty:

   469   "~ subgroup {} G"

   470   by (blast dest: subgroup.one_closed)

   471

   472 lemma (in subgroup) finite_imp_card_positive:

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

   474 proof (rule classical)

   475   have sub: "subgroup H G" using prems by (rule subgroup.intro)

   476   assume fin: "finite (carrier G)"

   477     and zero: "~ 0 < card H"

   478   then have "finite H" by (blast intro: finite_subset dest: subset)

   479   with zero sub have "subgroup {} G" by simp

   480   with subgroup_nonempty show ?thesis by contradiction

   481 qed

   482

   483 (*

   484 lemma (in monoid) Units_subgroup:

   485   "subgroup (Units G) G"

   486 *)

   487

   488 subsection {* Direct Products *}

   489

   490 constdefs

   491   DirProdSemigroup ::

   492     "[('a, 'm) semigroup_scheme, ('b, 'n) semigroup_scheme]

   493     => ('a \<times> 'b) semigroup"

   494     (infixr "\<times>\<^sub>s" 80)

   495   "G \<times>\<^sub>s H == (| carrier = carrier G \<times> carrier H,

   496     mult = (%(xg, xh) (yg, yh). (mult G xg yg, mult H xh yh)) |)"

   497

   498   DirProdGroup ::

   499     "[('a, 'm) monoid_scheme, ('b, 'n) monoid_scheme] => ('a \<times> 'b) monoid"

   500     (infixr "\<times>\<^sub>g" 80)

   501   "G \<times>\<^sub>g H == (| carrier = carrier (G \<times>\<^sub>s H),

   502     mult = mult (G \<times>\<^sub>s H),

   503     one = (one G, one H) |)"

   504

   505 lemma DirProdSemigroup_magma:

   506   includes magma G + magma H

   507   shows "magma (G \<times>\<^sub>s H)"

   508   by (rule magma.intro) (auto simp add: DirProdSemigroup_def)

   509

   510 lemma DirProdSemigroup_semigroup_axioms:

   511   includes semigroup G + semigroup H

   512   shows "semigroup_axioms (G \<times>\<^sub>s H)"

   513   by (rule semigroup_axioms.intro)

   514     (auto simp add: DirProdSemigroup_def G.m_assoc H.m_assoc)

   515

   516 lemma DirProdSemigroup_semigroup:

   517   includes semigroup G + semigroup H

   518   shows "semigroup (G \<times>\<^sub>s H)"

   519   using prems

   520   by (fast intro: semigroup.intro

   521     DirProdSemigroup_magma DirProdSemigroup_semigroup_axioms)

   522

   523 lemma DirProdGroup_magma:

   524   includes magma G + magma H

   525   shows "magma (G \<times>\<^sub>g H)"

   526   by (rule magma.intro)

   527     (auto simp add: DirProdGroup_def DirProdSemigroup_def)

   528

   529 lemma DirProdGroup_semigroup_axioms:

   530   includes semigroup G + semigroup H

   531   shows "semigroup_axioms (G \<times>\<^sub>g H)"

   532   by (rule semigroup_axioms.intro)

   533     (auto simp add: DirProdGroup_def DirProdSemigroup_def

   534       G.m_assoc H.m_assoc)

   535

   536 lemma DirProdGroup_semigroup:

   537   includes semigroup G + semigroup H

   538   shows "semigroup (G \<times>\<^sub>g H)"

   539   using prems

   540   by (fast intro: semigroup.intro

   541     DirProdGroup_magma DirProdGroup_semigroup_axioms)

   542

   543 (* ... and further lemmas for group ... *)

   544

   545 lemma DirProdGroup_group:

   546   includes group G + group H

   547   shows "group (G \<times>\<^sub>g H)"

   548   by (rule groupI)

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

   550       simp add: DirProdGroup_def DirProdSemigroup_def)

   551

   552 lemma carrier_DirProdGroup [simp]:

   553      "carrier (G \<times>\<^sub>g H) = carrier G \<times> carrier H"

   554   by (simp add: DirProdGroup_def DirProdSemigroup_def)

   555

   556 lemma one_DirProdGroup [simp]:

   557      "one (G \<times>\<^sub>g H) = (one G, one H)"

   558   by (simp add: DirProdGroup_def DirProdSemigroup_def);

   559

   560 lemma mult_DirProdGroup [simp]:

   561      "mult (G \<times>\<^sub>g H) (g, h) (g', h') = (mult G g g', mult H h h')"

   562   by (simp add: DirProdGroup_def DirProdSemigroup_def)

   563

   564 lemma inv_DirProdGroup [simp]:

   565   includes group G + group H

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

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

   568   shows "m_inv (G \<times>\<^sub>g H) (g, h) = (m_inv G g, m_inv H h)"

   569   apply (rule group.inv_equality [OF DirProdGroup_group])

   570   apply (simp_all add: prems group_def group.l_inv)

   571   done

   572

   573 subsection {* Homomorphisms *}

   574

   575 constdefs

   576   hom :: "[('a, 'c) semigroup_scheme, ('b, 'd) semigroup_scheme]

   577     => ('a => 'b)set"

   578   "hom G H ==

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

   580       (\<forall>x \<in> carrier G. \<forall>y \<in> carrier G. h (mult G x y) = mult H (h x) (h y))}"

   581

   582 lemma (in semigroup) hom:

   583   includes semigroup G

   584   shows "semigroup (| carrier = hom G G, mult = op o |)"

   585 proof (rule semigroup.intro)

   586   show "magma (| carrier = hom G G, mult = op o |)"

   587     by (rule magma.intro) (simp add: Pi_def hom_def)

   588 next

   589   show "semigroup_axioms (| carrier = hom G G, mult = op o |)"

   590     by (rule semigroup_axioms.intro) (simp add: o_assoc)

   591 qed

   592

   593 lemma hom_mult:

   594   "[| h \<in> hom G H; x \<in> carrier G; y \<in> carrier G |]

   595    ==> h (mult G x y) = mult H (h x) (h y)"

   596   by (simp add: hom_def)

   597

   598 lemma hom_closed:

   599   "[| h \<in> hom G H; x \<in> carrier G |] ==> h x \<in> carrier H"

   600   by (auto simp add: hom_def funcset_mem)

   601

   602 lemma compose_hom:

   603      "[|group G; h \<in> hom G G; h' \<in> hom G G; h' \<in> carrier G -> carrier G|]

   604       ==> compose (carrier G) h h' \<in> hom G G"

   605 apply (simp (no_asm_simp) add: hom_def)

   606 apply (intro conjI)

   607  apply (force simp add: funcset_compose hom_def)

   608 apply (simp add: compose_def group.axioms hom_mult funcset_mem)

   609 done

   610

   611 locale group_hom = group G + group H + var h +

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

   613   notes hom_mult [simp] = hom_mult [OF homh]

   614     and hom_closed [simp] = hom_closed [OF homh]

   615

   616 lemma (in group_hom) one_closed [simp]:

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

   618   by simp

   619

   620 lemma (in group_hom) hom_one [simp]:

   621   "h \<one> = \<one>\<^sub>2"

   622 proof -

   623   have "h \<one> \<otimes>\<^sub>2 \<one>\<^sub>2 = h \<one> \<otimes>\<^sub>2 h \<one>"

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

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

   626 qed

   627

   628 lemma (in group_hom) inv_closed [simp]:

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

   630   by simp

   631

   632 lemma (in group_hom) hom_inv [simp]:

   633   "x \<in> carrier G ==> h (inv x) = inv\<^sub>2 (h x)"

   634 proof -

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

   636   then have "h x \<otimes>\<^sub>2 h (inv x) = \<one>\<^sub>2"

   637     by (simp add: hom_mult [symmetric] G.r_inv del: hom_mult)

   638   also from x have "... = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)"

   639     by (simp add: hom_mult [symmetric] H.r_inv del: hom_mult)

   640   finally have "h x \<otimes>\<^sub>2 h (inv x) = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)" .

   641   with x show ?thesis by simp

   642 qed

   643

   644 subsection {* Commutative Structures *}

   645

   646 text {*

   647   Naming convention: multiplicative structures that are commutative

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

   649   \emph{Abelian}.

   650 *}

   651

   652 subsection {* Definition *}

   653

   654 locale comm_semigroup = semigroup +

   655   assumes m_comm: "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"

   656

   657 lemma (in comm_semigroup) m_lcomm:

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

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

   660 proof -

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

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

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

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

   665   finally show ?thesis .

   666 qed

   667

   668 lemmas (in comm_semigroup) m_ac = m_assoc m_comm m_lcomm

   669

   670 locale comm_monoid = comm_semigroup + monoid

   671

   672 lemma comm_monoidI:

   673   assumes m_closed:

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

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

   676     and m_assoc:

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

   678       mult G (mult G x y) z = mult G x (mult G y z)"

   679     and l_one: "!!x. x \<in> carrier G ==> mult G (one G) x = x"

   680     and m_comm:

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

   682   shows "comm_monoid G"

   683   using l_one

   684   by (auto intro!: comm_monoid.intro magma.intro semigroup_axioms.intro

   685     comm_semigroup_axioms.intro monoid_axioms.intro

   686     intro: prems simp: m_closed one_closed m_comm)

   687

   688 lemma (in monoid) monoid_comm_monoidI:

   689   assumes m_comm:

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

   691   shows "comm_monoid G"

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

   693 (*

   694 lemma (in comm_monoid) r_one [simp]:

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

   696 proof -

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

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

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

   700   finally show ?thesis .

   701 qed

   702 *)

   703

   704 lemma (in comm_monoid) nat_pow_distr:

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

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

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

   708

   709 locale comm_group = comm_monoid + group

   710

   711 lemma (in group) group_comm_groupI:

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

   713       mult G x y = mult G y x"

   714   shows "comm_group G"

   715   by (fast intro: comm_group.intro comm_semigroup_axioms.intro

   716     group.axioms prems)

   717

   718 lemma comm_groupI:

   719   assumes m_closed:

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

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

   722     and m_assoc:

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

   724       mult G (mult G x y) z = mult G x (mult G y z)"

   725     and m_comm:

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

   727     and l_one: "!!x. x \<in> carrier G ==> mult G (one G) x = x"

   728     and l_inv_ex: "!!x. x \<in> carrier G ==> EX y : carrier G. mult G y x = one G"

   729   shows "comm_group G"

   730   by (fast intro: group.group_comm_groupI groupI prems)

   731

   732 lemma (in comm_group) inv_mult:

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

   734   by (simp add: m_ac inv_mult_group)

   735

   736 end