src/HOL/Algebra/Group.thy
author ballarin
Thu Feb 27 15:12:29 2003 +0100 (2003-02-27)
changeset 13835 12b2ffbe543a
parent 13817 7e031a968443
child 13854 91c9ab25fece
permissions -rw-r--r--
Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin@13813
     1
(*
ballarin@13813
     2
  Title:  HOL/Algebra/Group.thy
ballarin@13813
     3
  Id:     $Id$
ballarin@13813
     4
  Author: Clemens Ballarin, started 4 February 2003
ballarin@13813
     5
ballarin@13813
     6
Based on work by Florian Kammueller, L C Paulson and Markus Wenzel.
ballarin@13813
     7
*)
ballarin@13813
     8
ballarin@13813
     9
header {* Algebraic Structures up to Abelian Groups *}
ballarin@13813
    10
ballarin@13835
    11
theory Group = FuncSet:
ballarin@13813
    12
ballarin@13813
    13
text {*
ballarin@13813
    14
  Definitions follow Jacobson, Basic Algebra I, Freeman, 1985; with
ballarin@13813
    15
  the exception of \emph{magma} which, following Bourbaki, is a set
ballarin@13813
    16
  together with a binary, closed operation.
ballarin@13813
    17
*}
ballarin@13813
    18
ballarin@13813
    19
section {* From Magmas to Groups *}
ballarin@13813
    20
ballarin@13813
    21
subsection {* Definitions *}
ballarin@13813
    22
ballarin@13835
    23
(* The following may be unnecessary. *)
ballarin@13835
    24
text {*
ballarin@13835
    25
  We write groups additively.  This simplifies notation for rings.
ballarin@13835
    26
  All rings have an additive inverse, only fields have a
ballarin@13835
    27
  multiplicative one.  This definitions reduces the need for
ballarin@13835
    28
  qualifiers.
ballarin@13835
    29
*}
ballarin@13835
    30
ballarin@13817
    31
record 'a semigroup =
ballarin@13813
    32
  carrier :: "'a set"
ballarin@13813
    33
  mult :: "['a, 'a] => 'a" (infixl "\<otimes>\<index>" 70)
ballarin@13813
    34
ballarin@13817
    35
record 'a monoid = "'a semigroup" +
ballarin@13813
    36
  one :: 'a ("\<one>\<index>")
ballarin@13817
    37
ballarin@13817
    38
record 'a group = "'a monoid" +
ballarin@13813
    39
  m_inv :: "'a => 'a" ("inv\<index> _" [81] 80)
ballarin@13813
    40
ballarin@13813
    41
locale magma = struct G +
ballarin@13813
    42
  assumes m_closed [intro, simp]:
ballarin@13813
    43
    "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"
ballarin@13813
    44
ballarin@13813
    45
locale semigroup = magma +
ballarin@13813
    46
  assumes m_assoc:
ballarin@13813
    47
    "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13813
    48
     (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"
ballarin@13813
    49
ballarin@13817
    50
locale l_one = struct G +
ballarin@13813
    51
  assumes one_closed [intro, simp]: "\<one> \<in> carrier G"
ballarin@13813
    52
    and l_one [simp]: "x \<in> carrier G ==> \<one> \<otimes> x = x"
ballarin@13817
    53
ballarin@13817
    54
locale group = semigroup + l_one +
ballarin@13817
    55
  assumes inv_closed [intro, simp]: "x \<in> carrier G ==> inv x \<in> carrier G"
ballarin@13813
    56
    and l_inv: "x \<in> carrier G ==> inv x \<otimes> x = \<one>"
ballarin@13813
    57
ballarin@13813
    58
subsection {* Cancellation Laws and Basic Properties *}
ballarin@13813
    59
ballarin@13813
    60
lemma (in group) l_cancel [simp]:
ballarin@13813
    61
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13813
    62
   (x \<otimes> y = x \<otimes> z) = (y = z)"
ballarin@13813
    63
proof
ballarin@13813
    64
  assume eq: "x \<otimes> y = x \<otimes> z"
ballarin@13813
    65
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
ballarin@13813
    66
  then have "(inv x \<otimes> x) \<otimes> y = (inv x \<otimes> x) \<otimes> z" by (simp add: m_assoc)
ballarin@13813
    67
  with G show "y = z" by (simp add: l_inv)
ballarin@13813
    68
next
ballarin@13813
    69
  assume eq: "y = z"
ballarin@13813
    70
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
ballarin@13813
    71
  then show "x \<otimes> y = x \<otimes> z" by simp
ballarin@13813
    72
qed
ballarin@13813
    73
ballarin@13813
    74
lemma (in group) r_one [simp]:  
ballarin@13813
    75
  "x \<in> carrier G ==> x \<otimes> \<one> = x"
ballarin@13813
    76
proof -
ballarin@13813
    77
  assume x: "x \<in> carrier G"
ballarin@13813
    78
  then have "inv x \<otimes> (x \<otimes> \<one>) = inv x \<otimes> x"
ballarin@13813
    79
    by (simp add: m_assoc [symmetric] l_inv)
ballarin@13813
    80
  with x show ?thesis by simp 
ballarin@13813
    81
qed
ballarin@13813
    82
ballarin@13813
    83
lemma (in group) r_inv:
ballarin@13813
    84
  "x \<in> carrier G ==> x \<otimes> inv x = \<one>"
ballarin@13813
    85
proof -
ballarin@13813
    86
  assume x: "x \<in> carrier G"
ballarin@13813
    87
  then have "inv x \<otimes> (x \<otimes> inv x) = inv x \<otimes> \<one>"
ballarin@13813
    88
    by (simp add: m_assoc [symmetric] l_inv)
ballarin@13813
    89
  with x show ?thesis by (simp del: r_one)
ballarin@13813
    90
qed
ballarin@13813
    91
ballarin@13813
    92
lemma (in group) r_cancel [simp]:
ballarin@13813
    93
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13813
    94
   (y \<otimes> x = z \<otimes> x) = (y = z)"
ballarin@13813
    95
proof
ballarin@13813
    96
  assume eq: "y \<otimes> x = z \<otimes> x"
ballarin@13813
    97
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
ballarin@13813
    98
  then have "y \<otimes> (x \<otimes> inv x) = z \<otimes> (x \<otimes> inv x)"
ballarin@13813
    99
    by (simp add: m_assoc [symmetric])
ballarin@13813
   100
  with G show "y = z" by (simp add: r_inv)
ballarin@13813
   101
next
ballarin@13813
   102
  assume eq: "y = z"
ballarin@13813
   103
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
ballarin@13813
   104
  then show "y \<otimes> x = z \<otimes> x" by simp
ballarin@13813
   105
qed
ballarin@13813
   106
ballarin@13813
   107
lemma (in group) inv_inv [simp]:
ballarin@13813
   108
  "x \<in> carrier G ==> inv (inv x) = x"
ballarin@13813
   109
proof -
ballarin@13813
   110
  assume x: "x \<in> carrier G"
ballarin@13813
   111
  then have "inv x \<otimes> inv (inv x) = inv x \<otimes> x" by (simp add: l_inv r_inv)
ballarin@13813
   112
  with x show ?thesis by simp
ballarin@13813
   113
qed
ballarin@13813
   114
ballarin@13813
   115
lemma (in group) inv_mult:
ballarin@13813
   116
  "[| x \<in> carrier G; y \<in> carrier G |] ==> inv (x \<otimes> y) = inv y \<otimes> inv x"
ballarin@13813
   117
proof -
ballarin@13813
   118
  assume G: "x \<in> carrier G" "y \<in> carrier G"
ballarin@13813
   119
  then have "inv (x \<otimes> y) \<otimes> (x \<otimes> y) = (inv y \<otimes> inv x) \<otimes> (x \<otimes> y)"
ballarin@13813
   120
    by (simp add: m_assoc l_inv) (simp add: m_assoc [symmetric] l_inv)
ballarin@13813
   121
  with G show ?thesis by simp
ballarin@13813
   122
qed
ballarin@13813
   123
ballarin@13813
   124
subsection {* Substructures *}
ballarin@13813
   125
ballarin@13813
   126
locale submagma = var H + struct G +
ballarin@13813
   127
  assumes subset [intro, simp]: "H \<subseteq> carrier G"
ballarin@13813
   128
    and m_closed [intro, simp]: "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"
ballarin@13813
   129
ballarin@13813
   130
declare (in submagma) magma.intro [intro] semigroup.intro [intro]
ballarin@13813
   131
ballarin@13813
   132
(*
ballarin@13813
   133
alternative definition of submagma
ballarin@13813
   134
ballarin@13813
   135
locale submagma = var H + struct G +
ballarin@13813
   136
  assumes subset [intro, simp]: "carrier H \<subseteq> carrier G"
ballarin@13813
   137
    and m_equal [simp]: "mult H = mult G"
ballarin@13813
   138
    and m_closed [intro, simp]:
ballarin@13813
   139
      "[| x \<in> carrier H; y \<in> carrier H |] ==> x \<otimes> y \<in> carrier H"
ballarin@13813
   140
*)
ballarin@13813
   141
ballarin@13813
   142
lemma submagma_imp_subset:
ballarin@13813
   143
  "submagma H G ==> H \<subseteq> carrier G"
ballarin@13813
   144
  by (rule submagma.subset)
ballarin@13813
   145
ballarin@13813
   146
lemma (in submagma) subsetD [dest, simp]:
ballarin@13813
   147
  "x \<in> H ==> x \<in> carrier G"
ballarin@13813
   148
  using subset by blast
ballarin@13813
   149
ballarin@13813
   150
lemma (in submagma) magmaI [intro]:
ballarin@13813
   151
  includes magma G
ballarin@13813
   152
  shows "magma (G(| carrier := H |))"
ballarin@13813
   153
  by rule simp
ballarin@13813
   154
ballarin@13813
   155
lemma (in submagma) semigroup_axiomsI [intro]:
ballarin@13813
   156
  includes semigroup G
ballarin@13813
   157
  shows "semigroup_axioms (G(| carrier := H |))"
ballarin@13813
   158
    by rule (simp add: m_assoc)
ballarin@13813
   159
ballarin@13813
   160
lemma (in submagma) semigroupI [intro]:
ballarin@13813
   161
  includes semigroup G
ballarin@13813
   162
  shows "semigroup (G(| carrier := H |))"
ballarin@13813
   163
  using prems by fast
ballarin@13813
   164
ballarin@13813
   165
locale subgroup = submagma H G +
ballarin@13813
   166
  assumes one_closed [intro, simp]: "\<one> \<in> H"
ballarin@13813
   167
    and m_inv_closed [intro, simp]: "x \<in> H ==> inv x \<in> H"
ballarin@13813
   168
ballarin@13813
   169
declare (in subgroup) group.intro [intro]
ballarin@13813
   170
ballarin@13817
   171
lemma (in subgroup) l_oneI [intro]:
ballarin@13817
   172
  includes l_one G
ballarin@13817
   173
  shows "l_one (G(| carrier := H |))"
ballarin@13817
   174
  by rule simp_all
ballarin@13817
   175
ballarin@13813
   176
lemma (in subgroup) group_axiomsI [intro]:
ballarin@13813
   177
  includes group G
ballarin@13813
   178
  shows "group_axioms (G(| carrier := H |))"
ballarin@13813
   179
  by rule (simp_all add: l_inv)
ballarin@13813
   180
ballarin@13813
   181
lemma (in subgroup) groupI [intro]:
ballarin@13813
   182
  includes group G
ballarin@13813
   183
  shows "group (G(| carrier := H |))"
ballarin@13813
   184
  using prems by fast
ballarin@13813
   185
ballarin@13813
   186
text {*
ballarin@13813
   187
  Since @{term H} is nonempty, it contains some element @{term x}.  Since
ballarin@13813
   188
  it is closed under inverse, it contains @{text "inv x"}.  Since
ballarin@13813
   189
  it is closed under product, it contains @{text "x \<otimes> inv x = \<one>"}.
ballarin@13813
   190
*}
ballarin@13813
   191
ballarin@13813
   192
lemma (in group) one_in_subset:
ballarin@13813
   193
  "[| 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 |]
ballarin@13813
   194
   ==> \<one> \<in> H"
ballarin@13813
   195
by (force simp add: l_inv)
ballarin@13813
   196
ballarin@13813
   197
text {* A characterization of subgroups: closed, non-empty subset. *}
ballarin@13813
   198
ballarin@13813
   199
lemma (in group) subgroupI:
ballarin@13813
   200
  assumes subset: "H \<subseteq> carrier G" and non_empty: "H \<noteq> {}"
ballarin@13813
   201
    and inv: "!!a. a \<in> H ==> inv a \<in> H"
ballarin@13813
   202
    and mult: "!!a b. [|a \<in> H; b \<in> H|] ==> a \<otimes> b \<in> H"
ballarin@13813
   203
  shows "subgroup H G"
ballarin@13813
   204
proof
ballarin@13813
   205
  from subset and mult show "submagma H G" ..
ballarin@13813
   206
next
ballarin@13813
   207
  have "\<one> \<in> H" by (rule one_in_subset) (auto simp only: prems)
ballarin@13813
   208
  with inv show "subgroup_axioms H G"
ballarin@13813
   209
    by (intro subgroup_axioms.intro) simp_all
ballarin@13813
   210
qed
ballarin@13813
   211
ballarin@13813
   212
text {*
ballarin@13813
   213
  Repeat facts of submagmas for subgroups.  Necessary???
ballarin@13813
   214
*}
ballarin@13813
   215
ballarin@13813
   216
lemma (in subgroup) subset:
ballarin@13813
   217
  "H \<subseteq> carrier G"
ballarin@13813
   218
  ..
ballarin@13813
   219
ballarin@13813
   220
lemma (in subgroup) m_closed:
ballarin@13813
   221
  "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"
ballarin@13813
   222
  ..
ballarin@13813
   223
ballarin@13813
   224
declare magma.m_closed [simp]
ballarin@13813
   225
ballarin@13817
   226
declare l_one.one_closed [iff] group.inv_closed [simp]
ballarin@13817
   227
  l_one.l_one [simp] group.r_one [simp] group.inv_inv [simp]
ballarin@13813
   228
ballarin@13813
   229
lemma subgroup_nonempty:
ballarin@13813
   230
  "~ subgroup {} G"
ballarin@13813
   231
  by (blast dest: subgroup.one_closed)
ballarin@13813
   232
ballarin@13813
   233
lemma (in subgroup) finite_imp_card_positive:
ballarin@13813
   234
  "finite (carrier G) ==> 0 < card H"
ballarin@13813
   235
proof (rule classical)
ballarin@13813
   236
  have sub: "subgroup H G" using prems ..
ballarin@13813
   237
  assume fin: "finite (carrier G)"
ballarin@13813
   238
    and zero: "~ 0 < card H"
ballarin@13813
   239
  then have "finite H" by (blast intro: finite_subset dest: subset)
ballarin@13813
   240
  with zero sub have "subgroup {} G" by simp
ballarin@13813
   241
  with subgroup_nonempty show ?thesis by contradiction
ballarin@13813
   242
qed
ballarin@13813
   243
ballarin@13813
   244
subsection {* Direct Products *}
ballarin@13813
   245
ballarin@13813
   246
constdefs
ballarin@13817
   247
  DirProdSemigroup ::
ballarin@13817
   248
    "[('a, 'c) semigroup_scheme, ('b, 'd) semigroup_scheme]
ballarin@13817
   249
    => ('a \<times> 'b) semigroup"
ballarin@13817
   250
    (infixr "\<times>\<^sub>s" 80)
ballarin@13817
   251
  "G \<times>\<^sub>s H == (| carrier = carrier G \<times> carrier H,
ballarin@13817
   252
    mult = (%(xg, xh) (yg, yh). (mult G xg yg, mult H xh yh)) |)"
ballarin@13817
   253
ballarin@13817
   254
  DirProdMonoid ::
ballarin@13817
   255
    "[('a, 'c) monoid_scheme, ('b, 'd) monoid_scheme] => ('a \<times> 'b) monoid"
ballarin@13813
   256
    (infixr "\<times>\<^sub>m" 80)
ballarin@13817
   257
  "G \<times>\<^sub>m H == (| carrier = carrier (G \<times>\<^sub>s H),
ballarin@13817
   258
    mult = mult (G \<times>\<^sub>s H),
ballarin@13817
   259
    one = (one G, one H) |)"
ballarin@13813
   260
ballarin@13813
   261
  DirProdGroup ::
ballarin@13813
   262
    "[('a, 'c) group_scheme, ('b, 'd) group_scheme] => ('a \<times> 'b) group"
ballarin@13813
   263
    (infixr "\<times>\<^sub>g" 80)
ballarin@13813
   264
  "G \<times>\<^sub>g H == (| carrier = carrier (G \<times>\<^sub>m H),
ballarin@13813
   265
    mult = mult (G \<times>\<^sub>m H),
ballarin@13817
   266
    one = one (G \<times>\<^sub>m H),
ballarin@13813
   267
    m_inv = (%(g, h). (m_inv G g, m_inv H h)) |)"
ballarin@13813
   268
ballarin@13817
   269
lemma DirProdSemigroup_magma:
ballarin@13813
   270
  includes magma G + magma H
ballarin@13817
   271
  shows "magma (G \<times>\<^sub>s H)"
ballarin@13817
   272
  by rule (auto simp add: DirProdSemigroup_def)
ballarin@13813
   273
ballarin@13817
   274
lemma DirProdSemigroup_semigroup_axioms:
ballarin@13813
   275
  includes semigroup G + semigroup H
ballarin@13817
   276
  shows "semigroup_axioms (G \<times>\<^sub>s H)"
ballarin@13817
   277
  by rule (auto simp add: DirProdSemigroup_def G.m_assoc H.m_assoc)
ballarin@13813
   278
ballarin@13817
   279
lemma DirProdSemigroup_semigroup:
ballarin@13813
   280
  includes semigroup G + semigroup H
ballarin@13817
   281
  shows "semigroup (G \<times>\<^sub>s H)"
ballarin@13813
   282
  using prems
ballarin@13813
   283
  by (fast intro: semigroup.intro
ballarin@13817
   284
    DirProdSemigroup_magma DirProdSemigroup_semigroup_axioms)
ballarin@13813
   285
ballarin@13813
   286
lemma DirProdGroup_magma:
ballarin@13813
   287
  includes magma G + magma H
ballarin@13813
   288
  shows "magma (G \<times>\<^sub>g H)"
ballarin@13817
   289
  by rule
ballarin@13817
   290
    (auto simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def)
ballarin@13813
   291
ballarin@13813
   292
lemma DirProdGroup_semigroup_axioms:
ballarin@13813
   293
  includes semigroup G + semigroup H
ballarin@13813
   294
  shows "semigroup_axioms (G \<times>\<^sub>g H)"
ballarin@13813
   295
  by rule
ballarin@13817
   296
    (auto simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def
ballarin@13817
   297
      G.m_assoc H.m_assoc)
ballarin@13813
   298
ballarin@13813
   299
lemma DirProdGroup_semigroup:
ballarin@13813
   300
  includes semigroup G + semigroup H
ballarin@13813
   301
  shows "semigroup (G \<times>\<^sub>g H)"
ballarin@13813
   302
  using prems
ballarin@13813
   303
  by (fast intro: semigroup.intro
ballarin@13813
   304
    DirProdGroup_magma DirProdGroup_semigroup_axioms)
ballarin@13813
   305
ballarin@13813
   306
(* ... and further lemmas for group ... *)
ballarin@13813
   307
ballarin@13817
   308
lemma DirProdGroup_group:
ballarin@13813
   309
  includes group G + group H
ballarin@13813
   310
  shows "group (G \<times>\<^sub>g H)"
ballarin@13813
   311
by rule
ballarin@13817
   312
  (auto intro: magma.intro l_one.intro
ballarin@13817
   313
      semigroup_axioms.intro group_axioms.intro
ballarin@13817
   314
    simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def
ballarin@13813
   315
      G.m_assoc H.m_assoc G.l_inv H.l_inv)
ballarin@13813
   316
ballarin@13813
   317
subsection {* Homomorphisms *}
ballarin@13813
   318
ballarin@13813
   319
constdefs
ballarin@13817
   320
  hom :: "[('a, 'c) semigroup_scheme, ('b, 'd) semigroup_scheme]
ballarin@13817
   321
    => ('a => 'b)set"
ballarin@13813
   322
  "hom G H ==
ballarin@13813
   323
    {h. h \<in> carrier G -> carrier H &
ballarin@13813
   324
      (\<forall>x \<in> carrier G. \<forall>y \<in> carrier G. h (mult G x y) = mult H (h x) (h y))}"
ballarin@13813
   325
ballarin@13813
   326
lemma (in semigroup) hom:
ballarin@13813
   327
  includes semigroup G
ballarin@13813
   328
  shows "semigroup (| carrier = hom G G, mult = op o |)"
ballarin@13813
   329
proof
ballarin@13813
   330
  show "magma (| carrier = hom G G, mult = op o |)"
ballarin@13813
   331
    by rule (simp add: Pi_def hom_def)
ballarin@13813
   332
next
ballarin@13813
   333
  show "semigroup_axioms (| carrier = hom G G, mult = op o |)"
ballarin@13813
   334
    by rule (simp add: o_assoc)
ballarin@13813
   335
qed
ballarin@13813
   336
ballarin@13813
   337
lemma hom_mult:
ballarin@13813
   338
  "[| h \<in> hom G H; x \<in> carrier G; y \<in> carrier G |] 
ballarin@13813
   339
   ==> h (mult G x y) = mult H (h x) (h y)"
ballarin@13813
   340
  by (simp add: hom_def) 
ballarin@13813
   341
ballarin@13813
   342
lemma hom_closed:
ballarin@13813
   343
  "[| h \<in> hom G H; x \<in> carrier G |] ==> h x \<in> carrier H"
ballarin@13813
   344
  by (auto simp add: hom_def funcset_mem)
ballarin@13813
   345
ballarin@13813
   346
locale group_hom = group G + group H + var h +
ballarin@13813
   347
  assumes homh: "h \<in> hom G H"
ballarin@13813
   348
  notes hom_mult [simp] = hom_mult [OF homh]
ballarin@13813
   349
    and hom_closed [simp] = hom_closed [OF homh]
ballarin@13813
   350
ballarin@13813
   351
lemma (in group_hom) one_closed [simp]:
ballarin@13813
   352
  "h \<one> \<in> carrier H"
ballarin@13813
   353
  by simp
ballarin@13813
   354
ballarin@13813
   355
lemma (in group_hom) hom_one [simp]:
ballarin@13813
   356
  "h \<one> = \<one>\<^sub>2"
ballarin@13813
   357
proof -
ballarin@13813
   358
  have "h \<one> \<otimes>\<^sub>2 \<one>\<^sub>2 = h \<one> \<otimes>\<^sub>2 h \<one>"
ballarin@13813
   359
    by (simp add: hom_mult [symmetric] del: hom_mult)
ballarin@13813
   360
  then show ?thesis by (simp del: r_one)
ballarin@13813
   361
qed
ballarin@13813
   362
ballarin@13813
   363
lemma (in group_hom) inv_closed [simp]:
ballarin@13813
   364
  "x \<in> carrier G ==> h (inv x) \<in> carrier H"
ballarin@13813
   365
  by simp
ballarin@13813
   366
ballarin@13813
   367
lemma (in group_hom) hom_inv [simp]:
ballarin@13813
   368
  "x \<in> carrier G ==> h (inv x) = inv\<^sub>2 (h x)"
ballarin@13813
   369
proof -
ballarin@13813
   370
  assume x: "x \<in> carrier G"
ballarin@13813
   371
  then have "h x \<otimes>\<^sub>2 h (inv x) = \<one>\<^sub>2"
ballarin@13813
   372
    by (simp add: hom_mult [symmetric] G.r_inv del: hom_mult)
ballarin@13813
   373
  also from x have "... = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)"
ballarin@13813
   374
    by (simp add: hom_mult [symmetric] H.r_inv del: hom_mult)
ballarin@13813
   375
  finally have "h x \<otimes>\<^sub>2 h (inv x) = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)" .
ballarin@13813
   376
  with x show ?thesis by simp
ballarin@13813
   377
qed
ballarin@13813
   378
ballarin@13813
   379
section {* Abelian Structures *}
ballarin@13813
   380
ballarin@13813
   381
subsection {* Definition *}
ballarin@13813
   382
ballarin@13813
   383
locale abelian_semigroup = semigroup +
ballarin@13813
   384
  assumes m_comm: "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"
ballarin@13813
   385
ballarin@13813
   386
lemma (in abelian_semigroup) m_lcomm:
ballarin@13813
   387
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13813
   388
   x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)"
ballarin@13813
   389
proof -
ballarin@13813
   390
  assume xyz: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
ballarin@13813
   391
  from xyz have "x \<otimes> (y \<otimes> z) = (x \<otimes> y) \<otimes> z" by (simp add: m_assoc)
ballarin@13813
   392
  also from xyz have "... = (y \<otimes> x) \<otimes> z" by (simp add: m_comm)
ballarin@13813
   393
  also from xyz have "... = y \<otimes> (x \<otimes> z)" by (simp add: m_assoc)
ballarin@13813
   394
  finally show ?thesis .
ballarin@13813
   395
qed
ballarin@13813
   396
ballarin@13813
   397
lemmas (in abelian_semigroup) ac = m_assoc m_comm m_lcomm
ballarin@13813
   398
ballarin@13817
   399
locale abelian_monoid = abelian_semigroup + l_one
ballarin@13817
   400
ballarin@13817
   401
lemma (in abelian_monoid) l_one [simp]:
ballarin@13817
   402
  "x \<in> carrier G ==> x \<otimes> \<one> = x"
ballarin@13817
   403
proof -
ballarin@13817
   404
  assume G: "x \<in> carrier G"
ballarin@13817
   405
  then have "x \<otimes> \<one> = \<one> \<otimes> x" by (simp add: m_comm)
ballarin@13817
   406
  also from G have "... = x" by simp
ballarin@13817
   407
  finally show ?thesis .
ballarin@13817
   408
qed
ballarin@13817
   409
ballarin@13817
   410
locale abelian_group = abelian_monoid + group
ballarin@13817
   411
ballarin@13813
   412
end