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