src/HOL/Algebra/Coset.thy
author wenzelm
Sun Mar 21 15:57:40 2010 +0100 (2010-03-21)
changeset 35847 19f1f7066917
parent 35416 d8d7d1b785af
child 35848 5443079512ea
permissions -rw-r--r--
eliminated old constdefs;
wenzelm@14706
     1
(*  Title:      HOL/Algebra/Coset.thy
ballarin@20318
     2
    Author:     Florian Kammueller, with new proofs by L C Paulson, and
ballarin@20318
     3
                Stephan Hohe
paulson@13870
     4
*)
paulson@13870
     5
ballarin@27717
     6
theory Coset imports Group begin
paulson@13870
     7
ballarin@20318
     8
ballarin@20318
     9
section {*Cosets and Quotient Groups*}
paulson@13870
    10
wenzelm@35847
    11
definition
paulson@14963
    12
  r_coset    :: "[_, 'a set, 'a] \<Rightarrow> 'a set"    (infixl "#>\<index>" 60)
wenzelm@35847
    13
  where "H #>\<^bsub>G\<^esub> a \<equiv> \<Union>h\<in>H. {h \<otimes>\<^bsub>G\<^esub> a}"
paulson@13870
    14
wenzelm@35847
    15
definition
paulson@14963
    16
  l_coset    :: "[_, 'a, 'a set] \<Rightarrow> 'a set"    (infixl "<#\<index>" 60)
wenzelm@35847
    17
  where "a <#\<^bsub>G\<^esub> H \<equiv> \<Union>h\<in>H. {a \<otimes>\<^bsub>G\<^esub> h}"
paulson@13870
    18
wenzelm@35847
    19
definition
paulson@14963
    20
  RCOSETS  :: "[_, 'a set] \<Rightarrow> ('a set)set"   ("rcosets\<index> _" [81] 80)
wenzelm@35847
    21
  where "rcosets\<^bsub>G\<^esub> H \<equiv> \<Union>a\<in>carrier G. {H #>\<^bsub>G\<^esub> a}"
paulson@14963
    22
wenzelm@35847
    23
definition
paulson@14963
    24
  set_mult  :: "[_, 'a set ,'a set] \<Rightarrow> 'a set" (infixl "<#>\<index>" 60)
wenzelm@35847
    25
  where "H <#>\<^bsub>G\<^esub> K \<equiv> \<Union>h\<in>H. \<Union>k\<in>K. {h \<otimes>\<^bsub>G\<^esub> k}"
paulson@13870
    26
wenzelm@35847
    27
definition
paulson@14963
    28
  SET_INV :: "[_,'a set] \<Rightarrow> 'a set"  ("set'_inv\<index> _" [81] 80)
wenzelm@35847
    29
  where "set_inv\<^bsub>G\<^esub> H \<equiv> \<Union>h\<in>H. {inv\<^bsub>G\<^esub> h}"
paulson@13870
    30
paulson@14963
    31
paulson@14963
    32
locale normal = subgroup + group +
paulson@14963
    33
  assumes coset_eq: "(\<forall>x \<in> carrier G. H #> x = x <# H)"
paulson@13870
    34
wenzelm@19380
    35
abbreviation
wenzelm@21404
    36
  normal_rel :: "['a set, ('a, 'b) monoid_scheme] \<Rightarrow> bool"  (infixl "\<lhd>" 60) where
wenzelm@19380
    37
  "H \<lhd> G \<equiv> normal H G"
paulson@13870
    38
paulson@13870
    39
paulson@14803
    40
subsection {*Basic Properties of Cosets*}
paulson@13870
    41
paulson@14747
    42
lemma (in group) coset_mult_assoc:
paulson@14747
    43
     "[| M \<subseteq> carrier G; g \<in> carrier G; h \<in> carrier G |]
paulson@13870
    44
      ==> (M #> g) #> h = M #> (g \<otimes> h)"
paulson@14747
    45
by (force simp add: r_coset_def m_assoc)
paulson@13870
    46
paulson@14747
    47
lemma (in group) coset_mult_one [simp]: "M \<subseteq> carrier G ==> M #> \<one> = M"
paulson@14747
    48
by (force simp add: r_coset_def)
paulson@13870
    49
paulson@14747
    50
lemma (in group) coset_mult_inv1:
wenzelm@14666
    51
     "[| M #> (x \<otimes> (inv y)) = M;  x \<in> carrier G ; y \<in> carrier G;
paulson@14747
    52
         M \<subseteq> carrier G |] ==> M #> x = M #> y"
paulson@13870
    53
apply (erule subst [of concl: "%z. M #> x = z #> y"])
paulson@13870
    54
apply (simp add: coset_mult_assoc m_assoc)
paulson@13870
    55
done
paulson@13870
    56
paulson@14747
    57
lemma (in group) coset_mult_inv2:
paulson@14747
    58
     "[| M #> x = M #> y;  x \<in> carrier G;  y \<in> carrier G;  M \<subseteq> carrier G |]
paulson@13870
    59
      ==> M #> (x \<otimes> (inv y)) = M "
paulson@13870
    60
apply (simp add: coset_mult_assoc [symmetric])
paulson@13870
    61
apply (simp add: coset_mult_assoc)
paulson@13870
    62
done
paulson@13870
    63
paulson@14747
    64
lemma (in group) coset_join1:
paulson@14747
    65
     "[| H #> x = H;  x \<in> carrier G;  subgroup H G |] ==> x \<in> H"
paulson@13870
    66
apply (erule subst)
paulson@14963
    67
apply (simp add: r_coset_def)
paulson@14963
    68
apply (blast intro: l_one subgroup.one_closed sym)
paulson@13870
    69
done
paulson@13870
    70
paulson@14747
    71
lemma (in group) solve_equation:
paulson@14963
    72
    "\<lbrakk>subgroup H G; x \<in> H; y \<in> H\<rbrakk> \<Longrightarrow> \<exists>h\<in>H. y = h \<otimes> x"
paulson@13870
    73
apply (rule bexI [of _ "y \<otimes> (inv x)"])
wenzelm@14666
    74
apply (auto simp add: subgroup.m_closed subgroup.m_inv_closed m_assoc
paulson@13870
    75
                      subgroup.subset [THEN subsetD])
paulson@13870
    76
done
paulson@13870
    77
paulson@14963
    78
lemma (in group) repr_independence:
paulson@14963
    79
     "\<lbrakk>y \<in> H #> x;  x \<in> carrier G; subgroup H G\<rbrakk> \<Longrightarrow> H #> x = H #> y"
paulson@14963
    80
by (auto simp add: r_coset_def m_assoc [symmetric]
paulson@14963
    81
                   subgroup.subset [THEN subsetD]
paulson@14963
    82
                   subgroup.m_closed solve_equation)
paulson@14963
    83
paulson@14747
    84
lemma (in group) coset_join2:
paulson@14963
    85
     "\<lbrakk>x \<in> carrier G;  subgroup H G;  x\<in>H\<rbrakk> \<Longrightarrow> H #> x = H"
paulson@14963
    86
  --{*Alternative proof is to put @{term "x=\<one>"} in @{text repr_independence}.*}
paulson@14963
    87
by (force simp add: subgroup.m_closed r_coset_def solve_equation)
paulson@13870
    88
ballarin@20318
    89
lemma (in monoid) r_coset_subset_G:
paulson@14747
    90
     "[| H \<subseteq> carrier G; x \<in> carrier G |] ==> H #> x \<subseteq> carrier G"
paulson@14747
    91
by (auto simp add: r_coset_def)
paulson@13870
    92
paulson@14747
    93
lemma (in group) rcosI:
paulson@14747
    94
     "[| h \<in> H; H \<subseteq> carrier G; x \<in> carrier G|] ==> h \<otimes> x \<in> H #> x"
paulson@14747
    95
by (auto simp add: r_coset_def)
paulson@13870
    96
paulson@14963
    97
lemma (in group) rcosetsI:
paulson@14963
    98
     "\<lbrakk>H \<subseteq> carrier G; x \<in> carrier G\<rbrakk> \<Longrightarrow> H #> x \<in> rcosets H"
paulson@14963
    99
by (auto simp add: RCOSETS_def)
paulson@13870
   100
paulson@13870
   101
text{*Really needed?*}
paulson@14747
   102
lemma (in group) transpose_inv:
wenzelm@14666
   103
     "[| x \<otimes> y = z;  x \<in> carrier G;  y \<in> carrier G;  z \<in> carrier G |]
paulson@13870
   104
      ==> (inv x) \<otimes> z = y"
paulson@13870
   105
by (force simp add: m_assoc [symmetric])
paulson@13870
   106
paulson@14747
   107
lemma (in group) rcos_self: "[| x \<in> carrier G; subgroup H G |] ==> x \<in> H #> x"
paulson@14963
   108
apply (simp add: r_coset_def)
paulson@14963
   109
apply (blast intro: sym l_one subgroup.subset [THEN subsetD]
paulson@13870
   110
                    subgroup.one_closed)
paulson@13870
   111
done
paulson@13870
   112
wenzelm@23350
   113
text (in group) {* Opposite of @{thm [source] "repr_independence"} *}
ballarin@20318
   114
lemma (in group) repr_independenceD:
ballarin@27611
   115
  assumes "subgroup H G"
ballarin@20318
   116
  assumes ycarr: "y \<in> carrier G"
ballarin@20318
   117
      and repr:  "H #> x = H #> y"
ballarin@20318
   118
  shows "y \<in> H #> x"
ballarin@27611
   119
proof -
ballarin@29237
   120
  interpret subgroup H G by fact
ballarin@27611
   121
  show ?thesis  apply (subst repr)
wenzelm@23350
   122
  apply (intro rcos_self)
wenzelm@23350
   123
   apply (rule ycarr)
wenzelm@23350
   124
   apply (rule is_subgroup)
wenzelm@23350
   125
  done
ballarin@27611
   126
qed
ballarin@20318
   127
ballarin@20318
   128
text {* Elements of a right coset are in the carrier *}
ballarin@20318
   129
lemma (in subgroup) elemrcos_carrier:
ballarin@27611
   130
  assumes "group G"
ballarin@20318
   131
  assumes acarr: "a \<in> carrier G"
ballarin@20318
   132
    and a': "a' \<in> H #> a"
ballarin@20318
   133
  shows "a' \<in> carrier G"
ballarin@20318
   134
proof -
ballarin@29237
   135
  interpret group G by fact
ballarin@20318
   136
  from subset and acarr
ballarin@20318
   137
  have "H #> a \<subseteq> carrier G" by (rule r_coset_subset_G)
ballarin@20318
   138
  from this and a'
ballarin@20318
   139
  show "a' \<in> carrier G"
ballarin@20318
   140
    by fast
ballarin@20318
   141
qed
ballarin@20318
   142
ballarin@20318
   143
lemma (in subgroup) rcos_const:
ballarin@27611
   144
  assumes "group G"
ballarin@20318
   145
  assumes hH: "h \<in> H"
ballarin@20318
   146
  shows "H #> h = H"
ballarin@27611
   147
proof -
ballarin@29237
   148
  interpret group G by fact
ballarin@27611
   149
  show ?thesis apply (unfold r_coset_def)
ballarin@27611
   150
    apply rule
ballarin@27611
   151
    apply rule
ballarin@27611
   152
    apply clarsimp
ballarin@27611
   153
    apply (intro subgroup.m_closed)
ballarin@27611
   154
    apply (rule is_subgroup)
wenzelm@23463
   155
    apply assumption
ballarin@27611
   156
    apply (rule hH)
ballarin@27611
   157
    apply rule
ballarin@27611
   158
    apply simp
ballarin@27611
   159
  proof -
ballarin@27611
   160
    fix h'
ballarin@27611
   161
    assume h'H: "h' \<in> H"
ballarin@27611
   162
    note carr = hH[THEN mem_carrier] h'H[THEN mem_carrier]
ballarin@27611
   163
    from carr
ballarin@27611
   164
    have a: "h' = (h' \<otimes> inv h) \<otimes> h" by (simp add: m_assoc)
ballarin@27611
   165
    from h'H hH
ballarin@27611
   166
    have "h' \<otimes> inv h \<in> H" by simp
ballarin@27611
   167
    from this and a
ballarin@27611
   168
    show "\<exists>x\<in>H. h' = x \<otimes> h" by fast
ballarin@27611
   169
  qed
ballarin@20318
   170
qed
ballarin@20318
   171
ballarin@20318
   172
text {* Step one for lemma @{text "rcos_module"} *}
ballarin@20318
   173
lemma (in subgroup) rcos_module_imp:
ballarin@27611
   174
  assumes "group G"
ballarin@20318
   175
  assumes xcarr: "x \<in> carrier G"
ballarin@20318
   176
      and x'cos: "x' \<in> H #> x"
ballarin@20318
   177
  shows "(x' \<otimes> inv x) \<in> H"
ballarin@20318
   178
proof -
ballarin@29237
   179
  interpret group G by fact
ballarin@20318
   180
  from xcarr x'cos
ballarin@20318
   181
      have x'carr: "x' \<in> carrier G"
ballarin@20318
   182
      by (rule elemrcos_carrier[OF is_group])
ballarin@20318
   183
  from xcarr
ballarin@20318
   184
      have ixcarr: "inv x \<in> carrier G"
ballarin@20318
   185
      by simp
ballarin@20318
   186
  from x'cos
ballarin@20318
   187
      have "\<exists>h\<in>H. x' = h \<otimes> x"
ballarin@20318
   188
      unfolding r_coset_def
ballarin@20318
   189
      by fast
ballarin@20318
   190
  from this
ballarin@20318
   191
      obtain h
ballarin@20318
   192
        where hH: "h \<in> H"
ballarin@20318
   193
        and x': "x' = h \<otimes> x"
ballarin@20318
   194
      by auto
ballarin@20318
   195
  from hH and subset
ballarin@20318
   196
      have hcarr: "h \<in> carrier G" by fast
ballarin@20318
   197
  note carr = xcarr x'carr hcarr
ballarin@20318
   198
  from x' and carr
ballarin@20318
   199
      have "x' \<otimes> (inv x) = (h \<otimes> x) \<otimes> (inv x)" by fast
ballarin@20318
   200
  also from carr
ballarin@20318
   201
      have "\<dots> = h \<otimes> (x \<otimes> inv x)" by (simp add: m_assoc)
ballarin@20318
   202
  also from carr
ballarin@20318
   203
      have "\<dots> = h \<otimes> \<one>" by simp
ballarin@20318
   204
  also from carr
ballarin@20318
   205
      have "\<dots> = h" by simp
ballarin@20318
   206
  finally
ballarin@20318
   207
      have "x' \<otimes> (inv x) = h" by simp
ballarin@20318
   208
  from hH this
ballarin@20318
   209
      show "x' \<otimes> (inv x) \<in> H" by simp
ballarin@20318
   210
qed
ballarin@20318
   211
ballarin@20318
   212
text {* Step two for lemma @{text "rcos_module"} *}
ballarin@20318
   213
lemma (in subgroup) rcos_module_rev:
ballarin@27611
   214
  assumes "group G"
ballarin@20318
   215
  assumes carr: "x \<in> carrier G" "x' \<in> carrier G"
ballarin@20318
   216
      and xixH: "(x' \<otimes> inv x) \<in> H"
ballarin@20318
   217
  shows "x' \<in> H #> x"
ballarin@20318
   218
proof -
ballarin@29237
   219
  interpret group G by fact
ballarin@20318
   220
  from xixH
ballarin@20318
   221
      have "\<exists>h\<in>H. x' \<otimes> (inv x) = h" by fast
ballarin@20318
   222
  from this
ballarin@20318
   223
      obtain h
ballarin@20318
   224
        where hH: "h \<in> H"
ballarin@20318
   225
        and hsym: "x' \<otimes> (inv x) = h"
ballarin@20318
   226
      by fast
ballarin@20318
   227
  from hH subset have hcarr: "h \<in> carrier G" by simp
ballarin@20318
   228
  note carr = carr hcarr
ballarin@20318
   229
  from hsym[symmetric] have "h \<otimes> x = x' \<otimes> (inv x) \<otimes> x" by fast
ballarin@20318
   230
  also from carr
ballarin@20318
   231
      have "\<dots> = x' \<otimes> ((inv x) \<otimes> x)" by (simp add: m_assoc)
ballarin@20318
   232
  also from carr
ballarin@20318
   233
      have "\<dots> = x' \<otimes> \<one>" by (simp add: l_inv)
ballarin@20318
   234
  also from carr
ballarin@20318
   235
      have "\<dots> = x'" by simp
ballarin@20318
   236
  finally
ballarin@20318
   237
      have "h \<otimes> x = x'" by simp
ballarin@20318
   238
  from this[symmetric] and hH
ballarin@20318
   239
      show "x' \<in> H #> x"
ballarin@20318
   240
      unfolding r_coset_def
ballarin@20318
   241
      by fast
ballarin@20318
   242
qed
ballarin@20318
   243
ballarin@20318
   244
text {* Module property of right cosets *}
ballarin@20318
   245
lemma (in subgroup) rcos_module:
ballarin@27611
   246
  assumes "group G"
ballarin@20318
   247
  assumes carr: "x \<in> carrier G" "x' \<in> carrier G"
ballarin@20318
   248
  shows "(x' \<in> H #> x) = (x' \<otimes> inv x \<in> H)"
ballarin@27611
   249
proof -
ballarin@29237
   250
  interpret group G by fact
ballarin@27611
   251
  show ?thesis proof  assume "x' \<in> H #> x"
ballarin@27611
   252
    from this and carr
ballarin@27611
   253
    show "x' \<otimes> inv x \<in> H"
ballarin@20318
   254
      by (intro rcos_module_imp[OF is_group])
ballarin@27611
   255
  next
ballarin@27611
   256
    assume "x' \<otimes> inv x \<in> H"
ballarin@27611
   257
    from this and carr
ballarin@27611
   258
    show "x' \<in> H #> x"
ballarin@20318
   259
      by (intro rcos_module_rev[OF is_group])
ballarin@27611
   260
  qed
ballarin@20318
   261
qed
ballarin@20318
   262
ballarin@20318
   263
text {* Right cosets are subsets of the carrier. *} 
ballarin@20318
   264
lemma (in subgroup) rcosets_carrier:
ballarin@27611
   265
  assumes "group G"
ballarin@20318
   266
  assumes XH: "X \<in> rcosets H"
ballarin@20318
   267
  shows "X \<subseteq> carrier G"
ballarin@20318
   268
proof -
ballarin@29237
   269
  interpret group G by fact
ballarin@20318
   270
  from XH have "\<exists>x\<in> carrier G. X = H #> x"
ballarin@20318
   271
      unfolding RCOSETS_def
ballarin@20318
   272
      by fast
ballarin@20318
   273
  from this
ballarin@20318
   274
      obtain x
ballarin@20318
   275
        where xcarr: "x\<in> carrier G"
ballarin@20318
   276
        and X: "X = H #> x"
ballarin@20318
   277
      by fast
ballarin@20318
   278
  from subset and xcarr
ballarin@20318
   279
      show "X \<subseteq> carrier G"
ballarin@20318
   280
      unfolding X
ballarin@20318
   281
      by (rule r_coset_subset_G)
ballarin@20318
   282
qed
ballarin@20318
   283
ballarin@20318
   284
text {* Multiplication of general subsets *}
ballarin@20318
   285
lemma (in monoid) set_mult_closed:
ballarin@20318
   286
  assumes Acarr: "A \<subseteq> carrier G"
ballarin@20318
   287
      and Bcarr: "B \<subseteq> carrier G"
ballarin@20318
   288
  shows "A <#> B \<subseteq> carrier G"
ballarin@20318
   289
apply rule apply (simp add: set_mult_def, clarsimp)
ballarin@20318
   290
proof -
ballarin@20318
   291
  fix a b
ballarin@20318
   292
  assume "a \<in> A"
ballarin@20318
   293
  from this and Acarr
ballarin@20318
   294
      have acarr: "a \<in> carrier G" by fast
ballarin@20318
   295
ballarin@20318
   296
  assume "b \<in> B"
ballarin@20318
   297
  from this and Bcarr
ballarin@20318
   298
      have bcarr: "b \<in> carrier G" by fast
ballarin@20318
   299
ballarin@20318
   300
  from acarr bcarr
ballarin@20318
   301
      show "a \<otimes> b \<in> carrier G" by (rule m_closed)
ballarin@20318
   302
qed
ballarin@20318
   303
ballarin@20318
   304
lemma (in comm_group) mult_subgroups:
ballarin@20318
   305
  assumes subH: "subgroup H G"
ballarin@20318
   306
      and subK: "subgroup K G"
ballarin@20318
   307
  shows "subgroup (H <#> K) G"
ballarin@20318
   308
apply (rule subgroup.intro)
ballarin@20318
   309
   apply (intro set_mult_closed subgroup.subset[OF subH] subgroup.subset[OF subK])
ballarin@20318
   310
  apply (simp add: set_mult_def) apply clarsimp defer 1
ballarin@20318
   311
  apply (simp add: set_mult_def) defer 1
ballarin@20318
   312
  apply (simp add: set_mult_def, clarsimp) defer 1
ballarin@20318
   313
proof -
ballarin@20318
   314
  fix ha hb ka kb
ballarin@20318
   315
  assume haH: "ha \<in> H" and hbH: "hb \<in> H" and kaK: "ka \<in> K" and kbK: "kb \<in> K"
ballarin@20318
   316
  note carr = haH[THEN subgroup.mem_carrier[OF subH]] hbH[THEN subgroup.mem_carrier[OF subH]]
ballarin@20318
   317
              kaK[THEN subgroup.mem_carrier[OF subK]] kbK[THEN subgroup.mem_carrier[OF subK]]
ballarin@20318
   318
  from carr
ballarin@20318
   319
      have "(ha \<otimes> ka) \<otimes> (hb \<otimes> kb) = ha \<otimes> (ka \<otimes> hb) \<otimes> kb" by (simp add: m_assoc)
ballarin@20318
   320
  also from carr
ballarin@20318
   321
      have "\<dots> = ha \<otimes> (hb \<otimes> ka) \<otimes> kb" by (simp add: m_comm)
ballarin@20318
   322
  also from carr
ballarin@20318
   323
      have "\<dots> = (ha \<otimes> hb) \<otimes> (ka \<otimes> kb)" by (simp add: m_assoc)
ballarin@20318
   324
  finally
ballarin@20318
   325
      have eq: "(ha \<otimes> ka) \<otimes> (hb \<otimes> kb) = (ha \<otimes> hb) \<otimes> (ka \<otimes> kb)" .
ballarin@20318
   326
ballarin@20318
   327
  from haH hbH have hH: "ha \<otimes> hb \<in> H" by (simp add: subgroup.m_closed[OF subH])
ballarin@20318
   328
  from kaK kbK have kK: "ka \<otimes> kb \<in> K" by (simp add: subgroup.m_closed[OF subK])
ballarin@20318
   329
  
ballarin@20318
   330
  from hH and kK and eq
ballarin@20318
   331
      show "\<exists>h'\<in>H. \<exists>k'\<in>K. (ha \<otimes> ka) \<otimes> (hb \<otimes> kb) = h' \<otimes> k'" by fast
ballarin@20318
   332
next
ballarin@20318
   333
  have "\<one> = \<one> \<otimes> \<one>" by simp
ballarin@20318
   334
  from subgroup.one_closed[OF subH] subgroup.one_closed[OF subK] this
ballarin@20318
   335
      show "\<exists>h\<in>H. \<exists>k\<in>K. \<one> = h \<otimes> k" by fast
ballarin@20318
   336
next
ballarin@20318
   337
  fix h k
ballarin@20318
   338
  assume hH: "h \<in> H"
ballarin@20318
   339
     and kK: "k \<in> K"
ballarin@20318
   340
ballarin@20318
   341
  from hH[THEN subgroup.mem_carrier[OF subH]] kK[THEN subgroup.mem_carrier[OF subK]]
ballarin@20318
   342
      have "inv (h \<otimes> k) = inv h \<otimes> inv k" by (simp add: inv_mult_group m_comm)
ballarin@20318
   343
ballarin@20318
   344
  from subgroup.m_inv_closed[OF subH hH] and subgroup.m_inv_closed[OF subK kK] and this
ballarin@20318
   345
      show "\<exists>ha\<in>H. \<exists>ka\<in>K. inv (h \<otimes> k) = ha \<otimes> ka" by fast
ballarin@20318
   346
qed
ballarin@20318
   347
ballarin@20318
   348
lemma (in subgroup) lcos_module_rev:
ballarin@27611
   349
  assumes "group G"
ballarin@20318
   350
  assumes carr: "x \<in> carrier G" "x' \<in> carrier G"
ballarin@20318
   351
      and xixH: "(inv x \<otimes> x') \<in> H"
ballarin@20318
   352
  shows "x' \<in> x <# H"
ballarin@20318
   353
proof -
ballarin@29237
   354
  interpret group G by fact
ballarin@20318
   355
  from xixH
ballarin@20318
   356
      have "\<exists>h\<in>H. (inv x) \<otimes> x' = h" by fast
ballarin@20318
   357
  from this
ballarin@20318
   358
      obtain h
ballarin@20318
   359
        where hH: "h \<in> H"
ballarin@20318
   360
        and hsym: "(inv x) \<otimes> x' = h"
ballarin@20318
   361
      by fast
ballarin@20318
   362
ballarin@20318
   363
  from hH subset have hcarr: "h \<in> carrier G" by simp
ballarin@20318
   364
  note carr = carr hcarr
ballarin@20318
   365
  from hsym[symmetric] have "x \<otimes> h = x \<otimes> ((inv x) \<otimes> x')" by fast
ballarin@20318
   366
  also from carr
ballarin@20318
   367
      have "\<dots> = (x \<otimes> (inv x)) \<otimes> x'" by (simp add: m_assoc[symmetric])
ballarin@20318
   368
  also from carr
ballarin@20318
   369
      have "\<dots> = \<one> \<otimes> x'" by simp
ballarin@20318
   370
  also from carr
ballarin@20318
   371
      have "\<dots> = x'" by simp
ballarin@20318
   372
  finally
ballarin@20318
   373
      have "x \<otimes> h = x'" by simp
ballarin@20318
   374
ballarin@20318
   375
  from this[symmetric] and hH
ballarin@20318
   376
      show "x' \<in> x <# H"
ballarin@20318
   377
      unfolding l_coset_def
ballarin@20318
   378
      by fast
ballarin@20318
   379
qed
ballarin@20318
   380
paulson@13870
   381
wenzelm@14666
   382
subsection {* Normal subgroups *}
paulson@13870
   383
paulson@14963
   384
lemma normal_imp_subgroup: "H \<lhd> G \<Longrightarrow> subgroup H G"
paulson@14963
   385
  by (simp add: normal_def subgroup_def)
paulson@13870
   386
paulson@14963
   387
lemma (in group) normalI: 
wenzelm@26310
   388
  "subgroup H G \<Longrightarrow> (\<forall>x \<in> carrier G. H #> x = x <# H) \<Longrightarrow> H \<lhd> G"
paulson@14963
   389
  by (simp add: normal_def normal_axioms_def prems) 
paulson@14963
   390
paulson@14963
   391
lemma (in normal) inv_op_closed1:
paulson@14963
   392
     "\<lbrakk>x \<in> carrier G; h \<in> H\<rbrakk> \<Longrightarrow> (inv x) \<otimes> h \<otimes> x \<in> H"
paulson@14963
   393
apply (insert coset_eq) 
paulson@14963
   394
apply (auto simp add: l_coset_def r_coset_def)
wenzelm@14666
   395
apply (drule bspec, assumption)
paulson@13870
   396
apply (drule equalityD1 [THEN subsetD], blast, clarify)
paulson@14963
   397
apply (simp add: m_assoc)
paulson@14963
   398
apply (simp add: m_assoc [symmetric])
paulson@13870
   399
done
paulson@13870
   400
paulson@14963
   401
lemma (in normal) inv_op_closed2:
paulson@14963
   402
     "\<lbrakk>x \<in> carrier G; h \<in> H\<rbrakk> \<Longrightarrow> x \<otimes> h \<otimes> (inv x) \<in> H"
paulson@14963
   403
apply (subgoal_tac "inv (inv x) \<otimes> h \<otimes> (inv x) \<in> H") 
wenzelm@26310
   404
apply (simp add: ) 
paulson@14963
   405
apply (blast intro: inv_op_closed1) 
paulson@13870
   406
done
paulson@13870
   407
paulson@14747
   408
text{*Alternative characterization of normal subgroups*}
paulson@14747
   409
lemma (in group) normal_inv_iff:
paulson@14747
   410
     "(N \<lhd> G) = 
paulson@14747
   411
      (subgroup N G & (\<forall>x \<in> carrier G. \<forall>h \<in> N. x \<otimes> h \<otimes> (inv x) \<in> N))"
paulson@14747
   412
      (is "_ = ?rhs")
paulson@14747
   413
proof
paulson@14747
   414
  assume N: "N \<lhd> G"
paulson@14747
   415
  show ?rhs
paulson@14963
   416
    by (blast intro: N normal.inv_op_closed2 normal_imp_subgroup) 
paulson@14747
   417
next
paulson@14747
   418
  assume ?rhs
paulson@14747
   419
  hence sg: "subgroup N G" 
paulson@14963
   420
    and closed: "\<And>x. x\<in>carrier G \<Longrightarrow> \<forall>h\<in>N. x \<otimes> h \<otimes> inv x \<in> N" by auto
paulson@14747
   421
  hence sb: "N \<subseteq> carrier G" by (simp add: subgroup.subset) 
paulson@14747
   422
  show "N \<lhd> G"
paulson@14963
   423
  proof (intro normalI [OF sg], simp add: l_coset_def r_coset_def, clarify)
paulson@14747
   424
    fix x
paulson@14747
   425
    assume x: "x \<in> carrier G"
nipkow@15120
   426
    show "(\<Union>h\<in>N. {h \<otimes> x}) = (\<Union>h\<in>N. {x \<otimes> h})"
paulson@14747
   427
    proof
nipkow@15120
   428
      show "(\<Union>h\<in>N. {h \<otimes> x}) \<subseteq> (\<Union>h\<in>N. {x \<otimes> h})"
paulson@14747
   429
      proof clarify
paulson@14747
   430
        fix n
paulson@14747
   431
        assume n: "n \<in> N" 
nipkow@15120
   432
        show "n \<otimes> x \<in> (\<Union>h\<in>N. {x \<otimes> h})"
paulson@14747
   433
        proof 
paulson@14963
   434
          from closed [of "inv x"]
paulson@14963
   435
          show "inv x \<otimes> n \<otimes> x \<in> N" by (simp add: x n)
paulson@14963
   436
          show "n \<otimes> x \<in> {x \<otimes> (inv x \<otimes> n \<otimes> x)}"
paulson@14747
   437
            by (simp add: x n m_assoc [symmetric] sb [THEN subsetD])
paulson@14747
   438
        qed
paulson@14747
   439
      qed
paulson@14747
   440
    next
nipkow@15120
   441
      show "(\<Union>h\<in>N. {x \<otimes> h}) \<subseteq> (\<Union>h\<in>N. {h \<otimes> x})"
paulson@14747
   442
      proof clarify
paulson@14747
   443
        fix n
paulson@14747
   444
        assume n: "n \<in> N" 
nipkow@15120
   445
        show "x \<otimes> n \<in> (\<Union>h\<in>N. {h \<otimes> x})"
paulson@14747
   446
        proof 
paulson@14963
   447
          show "x \<otimes> n \<otimes> inv x \<in> N" by (simp add: x n closed)
paulson@14963
   448
          show "x \<otimes> n \<in> {x \<otimes> n \<otimes> inv x \<otimes> x}"
paulson@14747
   449
            by (simp add: x n m_assoc sb [THEN subsetD])
paulson@14747
   450
        qed
paulson@14747
   451
      qed
paulson@14747
   452
    qed
paulson@14747
   453
  qed
paulson@14747
   454
qed
paulson@13870
   455
paulson@14963
   456
paulson@14803
   457
subsection{*More Properties of Cosets*}
paulson@14803
   458
paulson@14747
   459
lemma (in group) lcos_m_assoc:
paulson@14747
   460
     "[| M \<subseteq> carrier G; g \<in> carrier G; h \<in> carrier G |]
paulson@14747
   461
      ==> g <# (h <# M) = (g \<otimes> h) <# M"
paulson@14747
   462
by (force simp add: l_coset_def m_assoc)
paulson@13870
   463
paulson@14747
   464
lemma (in group) lcos_mult_one: "M \<subseteq> carrier G ==> \<one> <# M = M"
paulson@14747
   465
by (force simp add: l_coset_def)
paulson@13870
   466
paulson@14747
   467
lemma (in group) l_coset_subset_G:
paulson@14747
   468
     "[| H \<subseteq> carrier G; x \<in> carrier G |] ==> x <# H \<subseteq> carrier G"
paulson@14747
   469
by (auto simp add: l_coset_def subsetD)
paulson@14747
   470
paulson@14747
   471
lemma (in group) l_coset_swap:
paulson@14963
   472
     "\<lbrakk>y \<in> x <# H;  x \<in> carrier G;  subgroup H G\<rbrakk> \<Longrightarrow> x \<in> y <# H"
paulson@14963
   473
proof (simp add: l_coset_def)
paulson@14963
   474
  assume "\<exists>h\<in>H. y = x \<otimes> h"
wenzelm@14666
   475
    and x: "x \<in> carrier G"
paulson@14530
   476
    and sb: "subgroup H G"
paulson@14530
   477
  then obtain h' where h': "h' \<in> H & x \<otimes> h' = y" by blast
paulson@14963
   478
  show "\<exists>h\<in>H. x = y \<otimes> h"
paulson@14530
   479
  proof
paulson@14963
   480
    show "x = y \<otimes> inv h'" using h' x sb
paulson@14530
   481
      by (auto simp add: m_assoc subgroup.subset [THEN subsetD])
paulson@14530
   482
    show "inv h' \<in> H" using h' sb
paulson@14530
   483
      by (auto simp add: subgroup.subset [THEN subsetD] subgroup.m_inv_closed)
paulson@14530
   484
  qed
paulson@14530
   485
qed
paulson@14530
   486
paulson@14747
   487
lemma (in group) l_coset_carrier:
paulson@14530
   488
     "[| y \<in> x <# H;  x \<in> carrier G;  subgroup H G |] ==> y \<in> carrier G"
paulson@14747
   489
by (auto simp add: l_coset_def m_assoc
paulson@14530
   490
                   subgroup.subset [THEN subsetD] subgroup.m_closed)
paulson@14530
   491
paulson@14747
   492
lemma (in group) l_repr_imp_subset:
wenzelm@14666
   493
  assumes y: "y \<in> x <# H" and x: "x \<in> carrier G" and sb: "subgroup H G"
paulson@14530
   494
  shows "y <# H \<subseteq> x <# H"
paulson@14530
   495
proof -
paulson@14530
   496
  from y
paulson@14747
   497
  obtain h' where "h' \<in> H" "x \<otimes> h' = y" by (auto simp add: l_coset_def)
paulson@14530
   498
  thus ?thesis using x sb
paulson@14747
   499
    by (auto simp add: l_coset_def m_assoc
paulson@14530
   500
                       subgroup.subset [THEN subsetD] subgroup.m_closed)
paulson@14530
   501
qed
paulson@14530
   502
paulson@14747
   503
lemma (in group) l_repr_independence:
wenzelm@14666
   504
  assumes y: "y \<in> x <# H" and x: "x \<in> carrier G" and sb: "subgroup H G"
paulson@14530
   505
  shows "x <# H = y <# H"
wenzelm@14666
   506
proof
paulson@14530
   507
  show "x <# H \<subseteq> y <# H"
wenzelm@14666
   508
    by (rule l_repr_imp_subset,
paulson@14530
   509
        (blast intro: l_coset_swap l_coset_carrier y x sb)+)
wenzelm@14666
   510
  show "y <# H \<subseteq> x <# H" by (rule l_repr_imp_subset [OF y x sb])
paulson@14530
   511
qed
paulson@13870
   512
paulson@14747
   513
lemma (in group) setmult_subset_G:
paulson@14963
   514
     "\<lbrakk>H \<subseteq> carrier G; K \<subseteq> carrier G\<rbrakk> \<Longrightarrow> H <#> K \<subseteq> carrier G"
paulson@14963
   515
by (auto simp add: set_mult_def subsetD)
paulson@13870
   516
paulson@14963
   517
lemma (in group) subgroup_mult_id: "subgroup H G \<Longrightarrow> H <#> H = H"
paulson@14963
   518
apply (auto simp add: subgroup.m_closed set_mult_def Sigma_def image_def)
paulson@13870
   519
apply (rule_tac x = x in bexI)
paulson@13870
   520
apply (rule bexI [of _ "\<one>"])
wenzelm@14666
   521
apply (auto simp add: subgroup.m_closed subgroup.one_closed
paulson@13870
   522
                      r_one subgroup.subset [THEN subsetD])
paulson@13870
   523
done
paulson@13870
   524
paulson@13870
   525
ballarin@20318
   526
subsubsection {* Set of Inverses of an @{text r_coset}. *}
wenzelm@14666
   527
paulson@14963
   528
lemma (in normal) rcos_inv:
paulson@14963
   529
  assumes x:     "x \<in> carrier G"
paulson@14963
   530
  shows "set_inv (H #> x) = H #> (inv x)" 
paulson@14963
   531
proof (simp add: r_coset_def SET_INV_def x inv_mult_group, safe)
paulson@14963
   532
  fix h
paulson@14963
   533
  assume "h \<in> H"
nipkow@15120
   534
  show "inv x \<otimes> inv h \<in> (\<Union>j\<in>H. {j \<otimes> inv x})"
paulson@14963
   535
  proof
paulson@14963
   536
    show "inv x \<otimes> inv h \<otimes> x \<in> H"
paulson@14963
   537
      by (simp add: inv_op_closed1 prems)
paulson@14963
   538
    show "inv x \<otimes> inv h \<in> {inv x \<otimes> inv h \<otimes> x \<otimes> inv x}"
paulson@14963
   539
      by (simp add: prems m_assoc)
paulson@14963
   540
  qed
paulson@14963
   541
next
paulson@14963
   542
  fix h
paulson@14963
   543
  assume "h \<in> H"
nipkow@15120
   544
  show "h \<otimes> inv x \<in> (\<Union>j\<in>H. {inv x \<otimes> inv j})"
paulson@14963
   545
  proof
paulson@14963
   546
    show "x \<otimes> inv h \<otimes> inv x \<in> H"
paulson@14963
   547
      by (simp add: inv_op_closed2 prems)
paulson@14963
   548
    show "h \<otimes> inv x \<in> {inv x \<otimes> inv (x \<otimes> inv h \<otimes> inv x)}"
paulson@14963
   549
      by (simp add: prems m_assoc [symmetric] inv_mult_group)
paulson@13870
   550
  qed
paulson@13870
   551
qed
paulson@13870
   552
paulson@13870
   553
paulson@14803
   554
subsubsection {*Theorems for @{text "<#>"} with @{text "#>"} or @{text "<#"}.*}
wenzelm@14666
   555
paulson@14747
   556
lemma (in group) setmult_rcos_assoc:
paulson@14963
   557
     "\<lbrakk>H \<subseteq> carrier G; K \<subseteq> carrier G; x \<in> carrier G\<rbrakk>
paulson@14963
   558
      \<Longrightarrow> H <#> (K #> x) = (H <#> K) #> x"
paulson@14963
   559
by (force simp add: r_coset_def set_mult_def m_assoc)
paulson@13870
   560
paulson@14747
   561
lemma (in group) rcos_assoc_lcos:
paulson@14963
   562
     "\<lbrakk>H \<subseteq> carrier G; K \<subseteq> carrier G; x \<in> carrier G\<rbrakk>
paulson@14963
   563
      \<Longrightarrow> (H #> x) <#> K = H <#> (x <# K)"
paulson@14963
   564
by (force simp add: r_coset_def l_coset_def set_mult_def m_assoc)
paulson@13870
   565
paulson@14963
   566
lemma (in normal) rcos_mult_step1:
paulson@14963
   567
     "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk>
paulson@14963
   568
      \<Longrightarrow> (H #> x) <#> (H #> y) = (H <#> (x <# H)) #> y"
paulson@14963
   569
by (simp add: setmult_rcos_assoc subset
paulson@13870
   570
              r_coset_subset_G l_coset_subset_G rcos_assoc_lcos)
paulson@13870
   571
paulson@14963
   572
lemma (in normal) rcos_mult_step2:
paulson@14963
   573
     "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk>
paulson@14963
   574
      \<Longrightarrow> (H <#> (x <# H)) #> y = (H <#> (H #> x)) #> y"
paulson@14963
   575
by (insert coset_eq, simp add: normal_def)
paulson@13870
   576
paulson@14963
   577
lemma (in normal) rcos_mult_step3:
paulson@14963
   578
     "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk>
paulson@14963
   579
      \<Longrightarrow> (H <#> (H #> x)) #> y = H #> (x \<otimes> y)"
paulson@14963
   580
by (simp add: setmult_rcos_assoc coset_mult_assoc
ballarin@19931
   581
              subgroup_mult_id normal.axioms subset prems)
paulson@13870
   582
paulson@14963
   583
lemma (in normal) rcos_sum:
paulson@14963
   584
     "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk>
paulson@14963
   585
      \<Longrightarrow> (H #> x) <#> (H #> y) = H #> (x \<otimes> y)"
paulson@13870
   586
by (simp add: rcos_mult_step1 rcos_mult_step2 rcos_mult_step3)
paulson@13870
   587
paulson@14963
   588
lemma (in normal) rcosets_mult_eq: "M \<in> rcosets H \<Longrightarrow> H <#> M = M"
wenzelm@14666
   589
  -- {* generalizes @{text subgroup_mult_id} *}
paulson@14963
   590
  by (auto simp add: RCOSETS_def subset
ballarin@19931
   591
        setmult_rcos_assoc subgroup_mult_id normal.axioms prems)
paulson@14963
   592
paulson@14963
   593
paulson@14963
   594
subsubsection{*An Equivalence Relation*}
paulson@14963
   595
wenzelm@35847
   596
definition
wenzelm@35847
   597
  r_congruent :: "[('a,'b)monoid_scheme, 'a set] \<Rightarrow> ('a*'a)set"  ("rcong\<index> _")
wenzelm@35847
   598
  where "rcong\<^bsub>G\<^esub> H \<equiv> {(x,y). x \<in> carrier G & y \<in> carrier G & inv\<^bsub>G\<^esub> x \<otimes>\<^bsub>G\<^esub> y \<in> H}"
paulson@14963
   599
paulson@14963
   600
paulson@14963
   601
lemma (in subgroup) equiv_rcong:
ballarin@27611
   602
   assumes "group G"
paulson@14963
   603
   shows "equiv (carrier G) (rcong H)"
ballarin@27611
   604
proof -
ballarin@29237
   605
  interpret group G by fact
ballarin@27611
   606
  show ?thesis
ballarin@27611
   607
  proof (intro equiv.intro)
nipkow@30198
   608
    show "refl_on (carrier G) (rcong H)"
nipkow@30198
   609
      by (auto simp add: r_congruent_def refl_on_def) 
ballarin@27611
   610
  next
ballarin@27611
   611
    show "sym (rcong H)"
ballarin@27611
   612
    proof (simp add: r_congruent_def sym_def, clarify)
ballarin@27611
   613
      fix x y
ballarin@27611
   614
      assume [simp]: "x \<in> carrier G" "y \<in> carrier G" 
wenzelm@32960
   615
         and "inv x \<otimes> y \<in> H"
ballarin@27611
   616
      hence "inv (inv x \<otimes> y) \<in> H" by (simp add: m_inv_closed) 
ballarin@27611
   617
      thus "inv y \<otimes> x \<in> H" by (simp add: inv_mult_group)
ballarin@27611
   618
    qed
ballarin@27611
   619
  next
ballarin@27611
   620
    show "trans (rcong H)"
ballarin@27611
   621
    proof (simp add: r_congruent_def trans_def, clarify)
ballarin@27611
   622
      fix x y z
ballarin@27611
   623
      assume [simp]: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
wenzelm@32960
   624
         and "inv x \<otimes> y \<in> H" and "inv y \<otimes> z \<in> H"
ballarin@27611
   625
      hence "(inv x \<otimes> y) \<otimes> (inv y \<otimes> z) \<in> H" by simp
ballarin@27698
   626
      hence "inv x \<otimes> (y \<otimes> inv y) \<otimes> z \<in> H"
wenzelm@32960
   627
        by (simp add: m_assoc del: r_inv Units_r_inv) 
ballarin@27611
   628
      thus "inv x \<otimes> z \<in> H" by simp
ballarin@27611
   629
    qed
paulson@14963
   630
  qed
paulson@14963
   631
qed
paulson@14963
   632
paulson@14963
   633
text{*Equivalence classes of @{text rcong} correspond to left cosets.
paulson@14963
   634
  Was there a mistake in the definitions? I'd have expected them to
paulson@14963
   635
  correspond to right cosets.*}
paulson@14963
   636
paulson@14963
   637
(* CB: This is correct, but subtle.
paulson@14963
   638
   We call H #> a the right coset of a relative to H.  According to
paulson@14963
   639
   Jacobson, this is what the majority of group theory literature does.
paulson@14963
   640
   He then defines the notion of congruence relation ~ over monoids as
paulson@14963
   641
   equivalence relation with a ~ a' & b ~ b' \<Longrightarrow> a*b ~ a'*b'.
paulson@14963
   642
   Our notion of right congruence induced by K: rcong K appears only in
paulson@14963
   643
   the context where K is a normal subgroup.  Jacobson doesn't name it.
paulson@14963
   644
   But in this context left and right cosets are identical.
paulson@14963
   645
*)
paulson@14963
   646
paulson@14963
   647
lemma (in subgroup) l_coset_eq_rcong:
ballarin@27611
   648
  assumes "group G"
paulson@14963
   649
  assumes a: "a \<in> carrier G"
paulson@14963
   650
  shows "a <# H = rcong H `` {a}"
ballarin@27611
   651
proof -
ballarin@29237
   652
  interpret group G by fact
ballarin@27611
   653
  show ?thesis by (force simp add: r_congruent_def l_coset_def m_assoc [symmetric] a ) 
ballarin@27611
   654
qed
paulson@13870
   655
ballarin@20318
   656
subsubsection{*Two Distinct Right Cosets are Disjoint*}
paulson@14803
   657
paulson@14803
   658
lemma (in group) rcos_equation:
ballarin@27611
   659
  assumes "subgroup H G"
ballarin@27611
   660
  assumes p: "ha \<otimes> a = h \<otimes> b" "a \<in> carrier G" "b \<in> carrier G" "h \<in> H" "ha \<in> H" "hb \<in> H"
ballarin@27611
   661
  shows "hb \<otimes> a \<in> (\<Union>h\<in>H. {h \<otimes> b})"
ballarin@27611
   662
proof -
ballarin@29237
   663
  interpret subgroup H G by fact
ballarin@27611
   664
  from p show ?thesis apply (rule_tac UN_I [of "hb \<otimes> ((inv ha) \<otimes> h)"])
ballarin@27611
   665
    apply (simp add: )
ballarin@27611
   666
    apply (simp add: m_assoc transpose_inv)
ballarin@27611
   667
    done
ballarin@27611
   668
qed
paulson@14803
   669
paulson@14803
   670
lemma (in group) rcos_disjoint:
ballarin@27611
   671
  assumes "subgroup H G"
ballarin@27611
   672
  assumes p: "a \<in> rcosets H" "b \<in> rcosets H" "a\<noteq>b"
ballarin@27611
   673
  shows "a \<inter> b = {}"
ballarin@27611
   674
proof -
ballarin@29237
   675
  interpret subgroup H G by fact
ballarin@27611
   676
  from p show ?thesis apply (simp add: RCOSETS_def r_coset_def)
ballarin@27611
   677
    apply (blast intro: rcos_equation prems sym)
ballarin@27611
   678
    done
ballarin@27611
   679
qed
paulson@14803
   680
ballarin@20318
   681
subsection {* Further lemmas for @{text "r_congruent"} *}
ballarin@20318
   682
ballarin@20318
   683
text {* The relation is a congruence *}
ballarin@20318
   684
ballarin@20318
   685
lemma (in normal) congruent_rcong:
ballarin@20318
   686
  shows "congruent2 (rcong H) (rcong H) (\<lambda>a b. a \<otimes> b <# H)"
ballarin@20318
   687
proof (intro congruent2I[of "carrier G" _ "carrier G" _] equiv_rcong is_group)
ballarin@20318
   688
  fix a b c
ballarin@20318
   689
  assume abrcong: "(a, b) \<in> rcong H"
ballarin@20318
   690
    and ccarr: "c \<in> carrier G"
ballarin@20318
   691
ballarin@20318
   692
  from abrcong
ballarin@20318
   693
      have acarr: "a \<in> carrier G"
ballarin@20318
   694
        and bcarr: "b \<in> carrier G"
ballarin@20318
   695
        and abH: "inv a \<otimes> b \<in> H"
ballarin@20318
   696
      unfolding r_congruent_def
ballarin@20318
   697
      by fast+
ballarin@20318
   698
ballarin@20318
   699
  note carr = acarr bcarr ccarr
ballarin@20318
   700
ballarin@20318
   701
  from ccarr and abH
ballarin@20318
   702
      have "inv c \<otimes> (inv a \<otimes> b) \<otimes> c \<in> H" by (rule inv_op_closed1)
ballarin@20318
   703
  moreover
ballarin@20318
   704
      from carr and inv_closed
ballarin@20318
   705
      have "inv c \<otimes> (inv a \<otimes> b) \<otimes> c = (inv c \<otimes> inv a) \<otimes> (b \<otimes> c)" 
ballarin@20318
   706
      by (force cong: m_assoc)
ballarin@20318
   707
  moreover 
ballarin@20318
   708
      from carr and inv_closed
ballarin@20318
   709
      have "\<dots> = (inv (a \<otimes> c)) \<otimes> (b \<otimes> c)"
ballarin@20318
   710
      by (simp add: inv_mult_group)
ballarin@20318
   711
  ultimately
ballarin@20318
   712
      have "(inv (a \<otimes> c)) \<otimes> (b \<otimes> c) \<in> H" by simp
ballarin@20318
   713
  from carr and this
ballarin@20318
   714
     have "(b \<otimes> c) \<in> (a \<otimes> c) <# H"
ballarin@20318
   715
     by (simp add: lcos_module_rev[OF is_group])
ballarin@20318
   716
  from carr and this and is_subgroup
ballarin@20318
   717
     show "(a \<otimes> c) <# H = (b \<otimes> c) <# H" by (intro l_repr_independence, simp+)
ballarin@20318
   718
next
ballarin@20318
   719
  fix a b c
ballarin@20318
   720
  assume abrcong: "(a, b) \<in> rcong H"
ballarin@20318
   721
    and ccarr: "c \<in> carrier G"
ballarin@20318
   722
ballarin@20318
   723
  from ccarr have "c \<in> Units G" by (simp add: Units_eq)
ballarin@20318
   724
  hence cinvc_one: "inv c \<otimes> c = \<one>" by (rule Units_l_inv)
ballarin@20318
   725
ballarin@20318
   726
  from abrcong
ballarin@20318
   727
      have acarr: "a \<in> carrier G"
ballarin@20318
   728
       and bcarr: "b \<in> carrier G"
ballarin@20318
   729
       and abH: "inv a \<otimes> b \<in> H"
ballarin@20318
   730
      by (unfold r_congruent_def, fast+)
ballarin@20318
   731
ballarin@20318
   732
  note carr = acarr bcarr ccarr
ballarin@20318
   733
ballarin@20318
   734
  from carr and inv_closed
ballarin@20318
   735
     have "inv a \<otimes> b = inv a \<otimes> (\<one> \<otimes> b)" by simp
ballarin@20318
   736
  also from carr and inv_closed
ballarin@20318
   737
      have "\<dots> = inv a \<otimes> (inv c \<otimes> c) \<otimes> b" by simp
ballarin@20318
   738
  also from carr and inv_closed
ballarin@20318
   739
      have "\<dots> = (inv a \<otimes> inv c) \<otimes> (c \<otimes> b)" by (force cong: m_assoc)
ballarin@20318
   740
  also from carr and inv_closed
ballarin@20318
   741
      have "\<dots> = inv (c \<otimes> a) \<otimes> (c \<otimes> b)" by (simp add: inv_mult_group)
ballarin@20318
   742
  finally
ballarin@20318
   743
      have "inv a \<otimes> b = inv (c \<otimes> a) \<otimes> (c \<otimes> b)" .
ballarin@20318
   744
  from abH and this
ballarin@20318
   745
      have "inv (c \<otimes> a) \<otimes> (c \<otimes> b) \<in> H" by simp
ballarin@20318
   746
ballarin@20318
   747
  from carr and this
ballarin@20318
   748
     have "(c \<otimes> b) \<in> (c \<otimes> a) <# H"
ballarin@20318
   749
     by (simp add: lcos_module_rev[OF is_group])
ballarin@20318
   750
  from carr and this and is_subgroup
ballarin@20318
   751
     show "(c \<otimes> a) <# H = (c \<otimes> b) <# H" by (intro l_repr_independence, simp+)
ballarin@20318
   752
qed
ballarin@20318
   753
paulson@14803
   754
paulson@14803
   755
subsection {*Order of a Group and Lagrange's Theorem*}
paulson@14803
   756
haftmann@35416
   757
definition order :: "('a, 'b) monoid_scheme \<Rightarrow> nat" where
paulson@14963
   758
  "order S \<equiv> card (carrier S)"
paulson@13870
   759
paulson@14963
   760
lemma (in group) rcosets_part_G:
ballarin@27611
   761
  assumes "subgroup H G"
paulson@14963
   762
  shows "\<Union>(rcosets H) = carrier G"
ballarin@27611
   763
proof -
ballarin@29237
   764
  interpret subgroup H G by fact
ballarin@27611
   765
  show ?thesis
ballarin@27611
   766
    apply (rule equalityI)
ballarin@27611
   767
    apply (force simp add: RCOSETS_def r_coset_def)
ballarin@27611
   768
    apply (auto simp add: RCOSETS_def intro: rcos_self prems)
ballarin@27611
   769
    done
ballarin@27611
   770
qed
paulson@13870
   771
paulson@14747
   772
lemma (in group) cosets_finite:
paulson@14963
   773
     "\<lbrakk>c \<in> rcosets H;  H \<subseteq> carrier G;  finite (carrier G)\<rbrakk> \<Longrightarrow> finite c"
paulson@14963
   774
apply (auto simp add: RCOSETS_def)
paulson@14963
   775
apply (simp add: r_coset_subset_G [THEN finite_subset])
paulson@13870
   776
done
paulson@13870
   777
paulson@14747
   778
text{*The next two lemmas support the proof of @{text card_cosets_equal}.*}
paulson@14747
   779
lemma (in group) inj_on_f:
paulson@14963
   780
    "\<lbrakk>H \<subseteq> carrier G;  a \<in> carrier G\<rbrakk> \<Longrightarrow> inj_on (\<lambda>y. y \<otimes> inv a) (H #> a)"
paulson@13870
   781
apply (rule inj_onI)
paulson@13870
   782
apply (subgoal_tac "x \<in> carrier G & y \<in> carrier G")
paulson@13870
   783
 prefer 2 apply (blast intro: r_coset_subset_G [THEN subsetD])
paulson@13870
   784
apply (simp add: subsetD)
paulson@13870
   785
done
paulson@13870
   786
paulson@14747
   787
lemma (in group) inj_on_g:
paulson@14963
   788
    "\<lbrakk>H \<subseteq> carrier G;  a \<in> carrier G\<rbrakk> \<Longrightarrow> inj_on (\<lambda>y. y \<otimes> a) H"
paulson@13870
   789
by (force simp add: inj_on_def subsetD)
paulson@13870
   790
paulson@14747
   791
lemma (in group) card_cosets_equal:
paulson@14963
   792
     "\<lbrakk>c \<in> rcosets H;  H \<subseteq> carrier G; finite(carrier G)\<rbrakk>
paulson@14963
   793
      \<Longrightarrow> card c = card H"
paulson@14963
   794
apply (auto simp add: RCOSETS_def)
paulson@13870
   795
apply (rule card_bij_eq)
wenzelm@14666
   796
     apply (rule inj_on_f, assumption+)
paulson@14747
   797
    apply (force simp add: m_assoc subsetD r_coset_def)
wenzelm@14666
   798
   apply (rule inj_on_g, assumption+)
paulson@14747
   799
  apply (force simp add: m_assoc subsetD r_coset_def)
paulson@13870
   800
 txt{*The sets @{term "H #> a"} and @{term "H"} are finite.*}
paulson@13870
   801
 apply (simp add: r_coset_subset_G [THEN finite_subset])
paulson@13870
   802
apply (blast intro: finite_subset)
paulson@13870
   803
done
paulson@13870
   804
paulson@14963
   805
lemma (in group) rcosets_subset_PowG:
paulson@14963
   806
     "subgroup H G  \<Longrightarrow> rcosets H \<subseteq> Pow(carrier G)"
paulson@14963
   807
apply (simp add: RCOSETS_def)
paulson@13870
   808
apply (blast dest: r_coset_subset_G subgroup.subset)
paulson@13870
   809
done
paulson@13870
   810
paulson@14803
   811
paulson@14803
   812
theorem (in group) lagrange:
paulson@14963
   813
     "\<lbrakk>finite(carrier G); subgroup H G\<rbrakk>
paulson@14963
   814
      \<Longrightarrow> card(rcosets H) * card(H) = order(G)"
paulson@14963
   815
apply (simp (no_asm_simp) add: order_def rcosets_part_G [symmetric])
paulson@14803
   816
apply (subst mult_commute)
paulson@14803
   817
apply (rule card_partition)
paulson@14963
   818
   apply (simp add: rcosets_subset_PowG [THEN finite_subset])
paulson@14963
   819
  apply (simp add: rcosets_part_G)
paulson@14803
   820
 apply (simp add: card_cosets_equal subgroup.subset)
paulson@14803
   821
apply (simp add: rcos_disjoint)
paulson@14803
   822
done
paulson@14803
   823
paulson@14803
   824
paulson@14747
   825
subsection {*Quotient Groups: Factorization of a Group*}
paulson@13870
   826
haftmann@35416
   827
definition FactGroup :: "[('a,'b) monoid_scheme, 'a set] \<Rightarrow> ('a set) monoid" (infixl "Mod" 65) where
paulson@14747
   828
    --{*Actually defined for groups rather than monoids*}
paulson@14963
   829
  "FactGroup G H \<equiv>
paulson@14963
   830
    \<lparr>carrier = rcosets\<^bsub>G\<^esub> H, mult = set_mult G, one = H\<rparr>"
paulson@14747
   831
paulson@14963
   832
lemma (in normal) setmult_closed:
paulson@14963
   833
     "\<lbrakk>K1 \<in> rcosets H; K2 \<in> rcosets H\<rbrakk> \<Longrightarrow> K1 <#> K2 \<in> rcosets H"
paulson@14963
   834
by (auto simp add: rcos_sum RCOSETS_def)
paulson@13870
   835
paulson@14963
   836
lemma (in normal) setinv_closed:
paulson@14963
   837
     "K \<in> rcosets H \<Longrightarrow> set_inv K \<in> rcosets H"
paulson@14963
   838
by (auto simp add: rcos_inv RCOSETS_def)
ballarin@13889
   839
paulson@14963
   840
lemma (in normal) rcosets_assoc:
paulson@14963
   841
     "\<lbrakk>M1 \<in> rcosets H; M2 \<in> rcosets H; M3 \<in> rcosets H\<rbrakk>
paulson@14963
   842
      \<Longrightarrow> M1 <#> M2 <#> M3 = M1 <#> (M2 <#> M3)"
paulson@14963
   843
by (auto simp add: RCOSETS_def rcos_sum m_assoc)
paulson@13870
   844
paulson@14963
   845
lemma (in subgroup) subgroup_in_rcosets:
ballarin@27611
   846
  assumes "group G"
paulson@14963
   847
  shows "H \<in> rcosets H"
ballarin@13889
   848
proof -
ballarin@29237
   849
  interpret group G by fact
wenzelm@26203
   850
  from _ subgroup_axioms have "H #> \<one> = H"
wenzelm@23350
   851
    by (rule coset_join2) auto
ballarin@13889
   852
  then show ?thesis
paulson@14963
   853
    by (auto simp add: RCOSETS_def)
ballarin@13889
   854
qed
ballarin@13889
   855
paulson@14963
   856
lemma (in normal) rcosets_inv_mult_group_eq:
paulson@14963
   857
     "M \<in> rcosets H \<Longrightarrow> set_inv M <#> M = H"
ballarin@19931
   858
by (auto simp add: RCOSETS_def rcos_inv rcos_sum subgroup.subset normal.axioms prems)
ballarin@13889
   859
paulson@14963
   860
theorem (in normal) factorgroup_is_group:
paulson@14963
   861
  "group (G Mod H)"
wenzelm@14666
   862
apply (simp add: FactGroup_def)
ballarin@13936
   863
apply (rule groupI)
paulson@14747
   864
    apply (simp add: setmult_closed)
paulson@14963
   865
   apply (simp add: normal_imp_subgroup subgroup_in_rcosets [OF is_group])
paulson@14963
   866
  apply (simp add: restrictI setmult_closed rcosets_assoc)
ballarin@13889
   867
 apply (simp add: normal_imp_subgroup
paulson@14963
   868
                  subgroup_in_rcosets rcosets_mult_eq)
paulson@14963
   869
apply (auto dest: rcosets_inv_mult_group_eq simp add: setinv_closed)
ballarin@13889
   870
done
ballarin@13889
   871
paulson@14803
   872
lemma mult_FactGroup [simp]: "X \<otimes>\<^bsub>(G Mod H)\<^esub> X' = X <#>\<^bsub>G\<^esub> X'"
paulson@14803
   873
  by (simp add: FactGroup_def) 
paulson@14803
   874
paulson@14963
   875
lemma (in normal) inv_FactGroup:
paulson@14963
   876
     "X \<in> carrier (G Mod H) \<Longrightarrow> inv\<^bsub>G Mod H\<^esub> X = set_inv X"
paulson@14747
   877
apply (rule group.inv_equality [OF factorgroup_is_group]) 
paulson@14963
   878
apply (simp_all add: FactGroup_def setinv_closed rcosets_inv_mult_group_eq)
paulson@14747
   879
done
paulson@14747
   880
paulson@14747
   881
text{*The coset map is a homomorphism from @{term G} to the quotient group
paulson@14963
   882
  @{term "G Mod H"}*}
paulson@14963
   883
lemma (in normal) r_coset_hom_Mod:
paulson@14963
   884
  "(\<lambda>a. H #> a) \<in> hom G (G Mod H)"
paulson@14963
   885
  by (auto simp add: FactGroup_def RCOSETS_def Pi_def hom_def rcos_sum)
paulson@14747
   886
paulson@14963
   887
 
paulson@14963
   888
subsection{*The First Isomorphism Theorem*}
paulson@14803
   889
paulson@14963
   890
text{*The quotient by the kernel of a homomorphism is isomorphic to the 
paulson@14963
   891
  range of that homomorphism.*}
paulson@14803
   892
haftmann@35416
   893
definition kernel :: "('a, 'm) monoid_scheme \<Rightarrow> ('b, 'n) monoid_scheme \<Rightarrow> 
haftmann@35416
   894
             ('a \<Rightarrow> 'b) \<Rightarrow> 'a set" where 
paulson@14803
   895
    --{*the kernel of a homomorphism*}
wenzelm@26310
   896
  "kernel G H h \<equiv> {x. x \<in> carrier G & h x = \<one>\<^bsub>H\<^esub>}"
paulson@14803
   897
paulson@14803
   898
lemma (in group_hom) subgroup_kernel: "subgroup (kernel G H h) G"
paulson@14963
   899
apply (rule subgroup.intro) 
paulson@14803
   900
apply (auto simp add: kernel_def group.intro prems) 
paulson@14803
   901
done
paulson@14803
   902
paulson@14803
   903
text{*The kernel of a homomorphism is a normal subgroup*}
paulson@14963
   904
lemma (in group_hom) normal_kernel: "(kernel G H h) \<lhd> G"
ballarin@19931
   905
apply (simp add: G.normal_inv_iff subgroup_kernel)
ballarin@19931
   906
apply (simp add: kernel_def)
paulson@14803
   907
done
paulson@14803
   908
paulson@14803
   909
lemma (in group_hom) FactGroup_nonempty:
paulson@14803
   910
  assumes X: "X \<in> carrier (G Mod kernel G H h)"
paulson@14803
   911
  shows "X \<noteq> {}"
paulson@14803
   912
proof -
paulson@14803
   913
  from X
paulson@14803
   914
  obtain g where "g \<in> carrier G" 
paulson@14803
   915
             and "X = kernel G H h #> g"
paulson@14963
   916
    by (auto simp add: FactGroup_def RCOSETS_def)
paulson@14803
   917
  thus ?thesis 
paulson@14963
   918
   by (auto simp add: kernel_def r_coset_def image_def intro: hom_one)
paulson@14803
   919
qed
paulson@14803
   920
paulson@14803
   921
paulson@14803
   922
lemma (in group_hom) FactGroup_contents_mem:
paulson@14803
   923
  assumes X: "X \<in> carrier (G Mod (kernel G H h))"
paulson@14803
   924
  shows "contents (h`X) \<in> carrier H"
paulson@14803
   925
proof -
paulson@14803
   926
  from X
paulson@14803
   927
  obtain g where g: "g \<in> carrier G" 
paulson@14803
   928
             and "X = kernel G H h #> g"
paulson@14963
   929
    by (auto simp add: FactGroup_def RCOSETS_def)
paulson@14963
   930
  hence "h ` X = {h g}" by (auto simp add: kernel_def r_coset_def image_def g)
paulson@14803
   931
  thus ?thesis by (auto simp add: g)
paulson@14803
   932
qed
paulson@14803
   933
paulson@14803
   934
lemma (in group_hom) FactGroup_hom:
paulson@14963
   935
     "(\<lambda>X. contents (h`X)) \<in> hom (G Mod (kernel G H h)) H"
nipkow@31727
   936
apply (simp add: hom_def FactGroup_contents_mem  normal.factorgroup_is_group [OF normal_kernel] group.axioms monoid.m_closed)
nipkow@31727
   937
proof (intro ballI)
paulson@14803
   938
  fix X and X'
paulson@14803
   939
  assume X:  "X  \<in> carrier (G Mod kernel G H h)"
paulson@14803
   940
     and X': "X' \<in> carrier (G Mod kernel G H h)"
paulson@14803
   941
  then
paulson@14803
   942
  obtain g and g'
paulson@14803
   943
           where "g \<in> carrier G" and "g' \<in> carrier G" 
paulson@14803
   944
             and "X = kernel G H h #> g" and "X' = kernel G H h #> g'"
paulson@14963
   945
    by (auto simp add: FactGroup_def RCOSETS_def)
paulson@14803
   946
  hence all: "\<forall>x\<in>X. h x = h g" "\<forall>x\<in>X'. h x = h g'" 
paulson@14803
   947
    and Xsub: "X \<subseteq> carrier G" and X'sub: "X' \<subseteq> carrier G"
paulson@14803
   948
    by (force simp add: kernel_def r_coset_def image_def)+
paulson@14803
   949
  hence "h ` (X <#> X') = {h g \<otimes>\<^bsub>H\<^esub> h g'}" using X X'
paulson@14803
   950
    by (auto dest!: FactGroup_nonempty
paulson@14803
   951
             simp add: set_mult_def image_eq_UN 
paulson@14803
   952
                       subsetD [OF Xsub] subsetD [OF X'sub]) 
paulson@14803
   953
  thus "contents (h ` (X <#> X')) = contents (h ` X) \<otimes>\<^bsub>H\<^esub> contents (h ` X')"
nipkow@31727
   954
    by (simp add: all image_eq_UN FactGroup_nonempty X X')
paulson@14803
   955
qed
paulson@14803
   956
paulson@14963
   957
paulson@14803
   958
text{*Lemma for the following injectivity result*}
paulson@14803
   959
lemma (in group_hom) FactGroup_subset:
paulson@14963
   960
     "\<lbrakk>g \<in> carrier G; g' \<in> carrier G; h g = h g'\<rbrakk>
paulson@14963
   961
      \<Longrightarrow>  kernel G H h #> g \<subseteq> kernel G H h #> g'"
wenzelm@26310
   962
apply (clarsimp simp add: kernel_def r_coset_def image_def)
paulson@14803
   963
apply (rename_tac y)  
paulson@14803
   964
apply (rule_tac x="y \<otimes> g \<otimes> inv g'" in exI) 
wenzelm@26310
   965
apply (simp add: G.m_assoc) 
paulson@14803
   966
done
paulson@14803
   967
paulson@14803
   968
lemma (in group_hom) FactGroup_inj_on:
paulson@14803
   969
     "inj_on (\<lambda>X. contents (h ` X)) (carrier (G Mod kernel G H h))"
paulson@14803
   970
proof (simp add: inj_on_def, clarify) 
paulson@14803
   971
  fix X and X'
paulson@14803
   972
  assume X:  "X  \<in> carrier (G Mod kernel G H h)"
paulson@14803
   973
     and X': "X' \<in> carrier (G Mod kernel G H h)"
paulson@14803
   974
  then
paulson@14803
   975
  obtain g and g'
paulson@14803
   976
           where gX: "g \<in> carrier G"  "g' \<in> carrier G" 
paulson@14803
   977
              "X = kernel G H h #> g" "X' = kernel G H h #> g'"
paulson@14963
   978
    by (auto simp add: FactGroup_def RCOSETS_def)
paulson@14803
   979
  hence all: "\<forall>x\<in>X. h x = h g" "\<forall>x\<in>X'. h x = h g'" 
paulson@14803
   980
    by (force simp add: kernel_def r_coset_def image_def)+
paulson@14803
   981
  assume "contents (h ` X) = contents (h ` X')"
paulson@14803
   982
  hence h: "h g = h g'"
paulson@14803
   983
    by (simp add: image_eq_UN all FactGroup_nonempty X X') 
paulson@14803
   984
  show "X=X'" by (rule equalityI) (simp_all add: FactGroup_subset h gX) 
paulson@14803
   985
qed
paulson@14803
   986
paulson@14803
   987
text{*If the homomorphism @{term h} is onto @{term H}, then so is the
paulson@14803
   988
homomorphism from the quotient group*}
paulson@14803
   989
lemma (in group_hom) FactGroup_onto:
paulson@14803
   990
  assumes h: "h ` carrier G = carrier H"
paulson@14803
   991
  shows "(\<lambda>X. contents (h ` X)) ` carrier (G Mod kernel G H h) = carrier H"
paulson@14803
   992
proof
paulson@14803
   993
  show "(\<lambda>X. contents (h ` X)) ` carrier (G Mod kernel G H h) \<subseteq> carrier H"
paulson@14803
   994
    by (auto simp add: FactGroup_contents_mem)
paulson@14803
   995
  show "carrier H \<subseteq> (\<lambda>X. contents (h ` X)) ` carrier (G Mod kernel G H h)"
paulson@14803
   996
  proof
paulson@14803
   997
    fix y
paulson@14803
   998
    assume y: "y \<in> carrier H"
paulson@14803
   999
    with h obtain g where g: "g \<in> carrier G" "h g = y"
wenzelm@26310
  1000
      by (blast elim: equalityE) 
nipkow@15120
  1001
    hence "(\<Union>x\<in>kernel G H h #> g. {h x}) = {y}" 
paulson@14803
  1002
      by (auto simp add: y kernel_def r_coset_def) 
paulson@14803
  1003
    with g show "y \<in> (\<lambda>X. contents (h ` X)) ` carrier (G Mod kernel G H h)" 
paulson@14963
  1004
      by (auto intro!: bexI simp add: FactGroup_def RCOSETS_def image_eq_UN)
paulson@14803
  1005
  qed
paulson@14803
  1006
qed
paulson@14803
  1007
paulson@14803
  1008
paulson@14803
  1009
text{*If @{term h} is a homomorphism from @{term G} onto @{term H}, then the
paulson@14803
  1010
 quotient group @{term "G Mod (kernel G H h)"} is isomorphic to @{term H}.*}
paulson@14803
  1011
theorem (in group_hom) FactGroup_iso:
paulson@14803
  1012
  "h ` carrier G = carrier H
paulson@14963
  1013
   \<Longrightarrow> (\<lambda>X. contents (h`X)) \<in> (G Mod (kernel G H h)) \<cong> H"
paulson@14803
  1014
by (simp add: iso_def FactGroup_hom FactGroup_inj_on bij_betw_def 
paulson@14803
  1015
              FactGroup_onto) 
paulson@14803
  1016
paulson@14963
  1017
paulson@13870
  1018
end