src/HOL/Algebra/QuotRing.thy
author ballarin
Fri Aug 01 18:10:52 2008 +0200 (2008-08-01)
changeset 27717 21bbd410ba04
parent 27611 2c01c0bdb385
child 29237 e90d9d51106b
permissions -rw-r--r--
Generalised polynomial lemmas from cring to ring.
ballarin@20318
     1
(*
ballarin@20318
     2
  Title:     HOL/Algebra/QuotRing.thy
ballarin@20318
     3
  Id:        $Id$
ballarin@20318
     4
  Author:    Stephan Hohe
ballarin@20318
     5
*)
ballarin@20318
     6
ballarin@20318
     7
theory QuotRing
ballarin@20318
     8
imports RingHom
ballarin@20318
     9
begin
ballarin@20318
    10
ballarin@27717
    11
section {* Quotient Rings *}
ballarin@27717
    12
ballarin@20318
    13
subsection {* Multiplication on Cosets *}
ballarin@20318
    14
ballarin@20318
    15
constdefs (structure R)
wenzelm@23463
    16
  rcoset_mult :: "[('a, _) ring_scheme, 'a set, 'a set, 'a set] \<Rightarrow> 'a set"
wenzelm@23463
    17
    ("[mod _:] _ \<Otimes>\<index> _" [81,81,81] 80)
ballarin@20318
    18
  "rcoset_mult R I A B \<equiv> \<Union>a\<in>A. \<Union>b\<in>B. I +> (a \<otimes> b)"
ballarin@20318
    19
ballarin@20318
    20
ballarin@20318
    21
text {* @{const "rcoset_mult"} fulfils the properties required by
ballarin@20318
    22
  congruences *}
ballarin@20318
    23
lemma (in ideal) rcoset_mult_add:
ballarin@20318
    24
  "\<lbrakk>x \<in> carrier R; y \<in> carrier R\<rbrakk> \<Longrightarrow> [mod I:] (I +> x) \<Otimes> (I +> y) = I +> (x \<otimes> y)"
ballarin@20318
    25
apply rule
ballarin@20318
    26
apply (rule, simp add: rcoset_mult_def, clarsimp)
ballarin@20318
    27
defer 1
ballarin@20318
    28
apply (rule, simp add: rcoset_mult_def)
ballarin@20318
    29
defer 1
ballarin@20318
    30
proof -
ballarin@20318
    31
  fix z x' y'
ballarin@20318
    32
  assume carr: "x \<in> carrier R" "y \<in> carrier R"
ballarin@20318
    33
     and x'rcos: "x' \<in> I +> x"
ballarin@20318
    34
     and y'rcos: "y' \<in> I +> y"
ballarin@20318
    35
     and zrcos: "z \<in> I +> x' \<otimes> y'"
ballarin@20318
    36
ballarin@20318
    37
  from x'rcos 
ballarin@20318
    38
      have "\<exists>h\<in>I. x' = h \<oplus> x" by (simp add: a_r_coset_def r_coset_def)
ballarin@20318
    39
  from this obtain hx
ballarin@20318
    40
      where hxI: "hx \<in> I"
ballarin@20318
    41
      and x': "x' = hx \<oplus> x"
ballarin@20318
    42
      by fast+
ballarin@20318
    43
  
ballarin@20318
    44
  from y'rcos
ballarin@20318
    45
      have "\<exists>h\<in>I. y' = h \<oplus> y" by (simp add: a_r_coset_def r_coset_def)
ballarin@20318
    46
  from this
ballarin@20318
    47
      obtain hy
ballarin@20318
    48
      where hyI: "hy \<in> I"
ballarin@20318
    49
      and y': "y' = hy \<oplus> y"
ballarin@20318
    50
      by fast+
ballarin@20318
    51
ballarin@20318
    52
  from zrcos
ballarin@20318
    53
      have "\<exists>h\<in>I. z = h \<oplus> (x' \<otimes> y')" by (simp add: a_r_coset_def r_coset_def)
ballarin@20318
    54
  from this
ballarin@20318
    55
      obtain hz
ballarin@20318
    56
      where hzI: "hz \<in> I"
ballarin@20318
    57
      and z: "z = hz \<oplus> (x' \<otimes> y')"
ballarin@20318
    58
      by fast+
ballarin@20318
    59
ballarin@20318
    60
  note carr = carr hxI[THEN a_Hcarr] hyI[THEN a_Hcarr] hzI[THEN a_Hcarr]
ballarin@20318
    61
ballarin@20318
    62
  from z have "z = hz \<oplus> (x' \<otimes> y')" .
ballarin@20318
    63
  also from x' y'
ballarin@20318
    64
      have "\<dots> = hz \<oplus> ((hx \<oplus> x) \<otimes> (hy \<oplus> y))" by simp
ballarin@20318
    65
  also from carr
ballarin@20318
    66
      have "\<dots> = (hz \<oplus> (hx \<otimes> (hy \<oplus> y)) \<oplus> x \<otimes> hy) \<oplus> x \<otimes> y" by algebra
ballarin@20318
    67
  finally
ballarin@20318
    68
      have z2: "z = (hz \<oplus> (hx \<otimes> (hy \<oplus> y)) \<oplus> x \<otimes> hy) \<oplus> x \<otimes> y" .
ballarin@20318
    69
ballarin@20318
    70
  from hxI hyI hzI carr
ballarin@20318
    71
      have "hz \<oplus> (hx \<otimes> (hy \<oplus> y)) \<oplus> x \<otimes> hy \<in> I"  by (simp add: I_l_closed I_r_closed)
ballarin@20318
    72
ballarin@20318
    73
  from this and z2
ballarin@20318
    74
      have "\<exists>h\<in>I. z = h \<oplus> x \<otimes> y" by fast
ballarin@20318
    75
  thus "z \<in> I +> x \<otimes> y" by (simp add: a_r_coset_def r_coset_def)
ballarin@20318
    76
next
ballarin@20318
    77
  fix z
ballarin@20318
    78
  assume xcarr: "x \<in> carrier R"
ballarin@20318
    79
     and ycarr: "y \<in> carrier R"
ballarin@20318
    80
     and zrcos: "z \<in> I +> x \<otimes> y"
ballarin@20318
    81
  from xcarr
ballarin@20318
    82
      have xself: "x \<in> I +> x" by (intro a_rcos_self)
ballarin@20318
    83
  from ycarr
ballarin@20318
    84
      have yself: "y \<in> I +> y" by (intro a_rcos_self)
ballarin@20318
    85
ballarin@20318
    86
  from xself and yself and zrcos
ballarin@20318
    87
      show "\<exists>a\<in>I +> x. \<exists>b\<in>I +> y. z \<in> I +> a \<otimes> b" by fast
ballarin@20318
    88
qed
ballarin@20318
    89
ballarin@20318
    90
ballarin@20318
    91
subsection {* Quotient Ring Definition *}
ballarin@20318
    92
ballarin@20318
    93
constdefs (structure R)
ballarin@20318
    94
  FactRing :: "[('a,'b) ring_scheme, 'a set] \<Rightarrow> ('a set) ring"
ballarin@20318
    95
     (infixl "Quot" 65)
ballarin@20318
    96
  "FactRing R I \<equiv>
ballarin@20318
    97
    \<lparr>carrier = a_rcosets I, mult = rcoset_mult R I, one = (I +> \<one>), zero = I, add = set_add R\<rparr>"
ballarin@20318
    98
ballarin@20318
    99
ballarin@20318
   100
subsection {* Factorization over General Ideals *}
ballarin@20318
   101
ballarin@20318
   102
text {* The quotient is a ring *}
ballarin@20318
   103
lemma (in ideal) quotient_is_ring:
ballarin@20318
   104
  shows "ring (R Quot I)"
ballarin@20318
   105
apply (rule ringI)
ballarin@20318
   106
   --{* abelian group *}
ballarin@20318
   107
   apply (rule comm_group_abelian_groupI)
ballarin@20318
   108
   apply (simp add: FactRing_def)
ballarin@20318
   109
   apply (rule a_factorgroup_is_comm_group[unfolded A_FactGroup_def'])
ballarin@20318
   110
  --{* mult monoid *}
ballarin@20318
   111
  apply (rule monoidI)
ballarin@20318
   112
      apply (simp_all add: FactRing_def A_RCOSETS_def RCOSETS_def
ballarin@20318
   113
             a_r_coset_def[symmetric])
ballarin@20318
   114
      --{* mult closed *}
ballarin@20318
   115
      apply (clarify)
ballarin@20318
   116
      apply (simp add: rcoset_mult_add, fast)
wenzelm@21502
   117
     --{* mult @{text one_closed} *}
ballarin@20318
   118
     apply (force intro: one_closed)
ballarin@20318
   119
    --{* mult assoc *}
ballarin@20318
   120
    apply clarify
ballarin@20318
   121
    apply (simp add: rcoset_mult_add m_assoc)
ballarin@20318
   122
   --{* mult one *}
ballarin@20318
   123
   apply clarify
ballarin@20318
   124
   apply (simp add: rcoset_mult_add l_one)
ballarin@20318
   125
  apply clarify
ballarin@20318
   126
  apply (simp add: rcoset_mult_add r_one)
ballarin@20318
   127
 --{* distr *}
ballarin@20318
   128
 apply clarify
ballarin@20318
   129
 apply (simp add: rcoset_mult_add a_rcos_sum l_distr)
ballarin@20318
   130
apply clarify
ballarin@20318
   131
apply (simp add: rcoset_mult_add a_rcos_sum r_distr)
ballarin@20318
   132
done
ballarin@20318
   133
ballarin@20318
   134
ballarin@20318
   135
text {* This is a ring homomorphism *}
ballarin@20318
   136
ballarin@20318
   137
lemma (in ideal) rcos_ring_hom:
ballarin@20318
   138
  "(op +> I) \<in> ring_hom R (R Quot I)"
ballarin@20318
   139
apply (rule ring_hom_memI)
ballarin@20318
   140
   apply (simp add: FactRing_def a_rcosetsI[OF a_subset])
ballarin@20318
   141
  apply (simp add: FactRing_def rcoset_mult_add)
ballarin@20318
   142
 apply (simp add: FactRing_def a_rcos_sum)
ballarin@20318
   143
apply (simp add: FactRing_def)
ballarin@20318
   144
done
ballarin@20318
   145
ballarin@20318
   146
lemma (in ideal) rcos_ring_hom_ring:
ballarin@20318
   147
  "ring_hom_ring R (R Quot I) (op +> I)"
ballarin@20318
   148
apply (rule ring_hom_ringI)
ballarin@20318
   149
     apply (rule is_ring, rule quotient_is_ring)
ballarin@20318
   150
   apply (simp add: FactRing_def a_rcosetsI[OF a_subset])
ballarin@20318
   151
  apply (simp add: FactRing_def rcoset_mult_add)
ballarin@20318
   152
 apply (simp add: FactRing_def a_rcos_sum)
ballarin@20318
   153
apply (simp add: FactRing_def)
ballarin@20318
   154
done
ballarin@20318
   155
ballarin@20318
   156
text {* The quotient of a cring is also commutative *}
ballarin@20318
   157
lemma (in ideal) quotient_is_cring:
ballarin@27611
   158
  assumes "cring R"
ballarin@20318
   159
  shows "cring (R Quot I)"
ballarin@27611
   160
proof -
ballarin@27611
   161
  interpret cring [R] by fact
ballarin@27611
   162
  show ?thesis apply (intro cring.intro comm_monoid.intro comm_monoid_axioms.intro)
ballarin@20318
   163
  apply (rule quotient_is_ring)
ballarin@20318
   164
 apply (rule ring.axioms[OF quotient_is_ring])
ballarin@20318
   165
apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric])
ballarin@20318
   166
apply clarify
ballarin@20318
   167
apply (simp add: rcoset_mult_add m_comm)
ballarin@20318
   168
done
ballarin@27611
   169
qed
ballarin@20318
   170
ballarin@20318
   171
text {* Cosets as a ring homomorphism on crings *}
ballarin@20318
   172
lemma (in ideal) rcos_ring_hom_cring:
ballarin@27611
   173
  assumes "cring R"
ballarin@20318
   174
  shows "ring_hom_cring R (R Quot I) (op +> I)"
ballarin@27611
   175
proof -
ballarin@27611
   176
  interpret cring [R] by fact
ballarin@27611
   177
  show ?thesis apply (rule ring_hom_cringI)
ballarin@20318
   178
  apply (rule rcos_ring_hom_ring)
wenzelm@23463
   179
 apply (rule R.is_cring)
wenzelm@23463
   180
apply (rule quotient_is_cring)
wenzelm@23463
   181
apply (rule R.is_cring)
ballarin@20318
   182
done
ballarin@27611
   183
qed
ballarin@20318
   184
ballarin@20318
   185
subsection {* Factorization over Prime Ideals *}
ballarin@20318
   186
ballarin@20318
   187
text {* The quotient ring generated by a prime ideal is a domain *}
ballarin@20318
   188
lemma (in primeideal) quotient_is_domain:
ballarin@20318
   189
  shows "domain (R Quot I)"
ballarin@20318
   190
apply (rule domain.intro)
ballarin@20318
   191
 apply (rule quotient_is_cring, rule is_cring)
ballarin@20318
   192
apply (rule domain_axioms.intro)
ballarin@20318
   193
 apply (simp add: FactRing_def) defer 1
ballarin@20318
   194
 apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric], clarify)
ballarin@20318
   195
 apply (simp add: rcoset_mult_add) defer 1
ballarin@20318
   196
proof (rule ccontr, clarsimp)
ballarin@20318
   197
  assume "I +> \<one> = I"
ballarin@20318
   198
  hence "\<one> \<in> I" by (simp only: a_coset_join1 one_closed a_subgroup)
ballarin@20318
   199
  hence "carrier R \<subseteq> I" by (subst one_imp_carrier, simp, fast)
ballarin@20318
   200
  from this and a_subset
ballarin@20318
   201
      have "I = carrier R" by fast
ballarin@20318
   202
  from this and I_notcarr
ballarin@20318
   203
      show "False" by fast
ballarin@20318
   204
next
ballarin@20318
   205
  fix x y
ballarin@20318
   206
  assume carr: "x \<in> carrier R" "y \<in> carrier R"
ballarin@20318
   207
     and a: "I +> x \<otimes> y = I"
ballarin@20318
   208
     and b: "I +> y \<noteq> I"
ballarin@20318
   209
ballarin@20318
   210
  have ynI: "y \<notin> I"
ballarin@20318
   211
  proof (rule ccontr, simp)
ballarin@20318
   212
    assume "y \<in> I"
ballarin@20318
   213
    hence "I +> y = I" by (rule a_rcos_const)
ballarin@20318
   214
    from this and b
ballarin@20318
   215
        show "False" by simp
ballarin@20318
   216
  qed
ballarin@20318
   217
ballarin@20318
   218
  from carr
ballarin@20318
   219
      have "x \<otimes> y \<in> I +> x \<otimes> y" by (simp add: a_rcos_self)
ballarin@20318
   220
  from this
ballarin@20318
   221
      have xyI: "x \<otimes> y \<in> I" by (simp add: a)
ballarin@20318
   222
ballarin@20318
   223
  from xyI and carr
ballarin@20318
   224
      have xI: "x \<in> I \<or> y \<in> I" by (simp add: I_prime)
ballarin@20318
   225
  from this and ynI
ballarin@20318
   226
      have "x \<in> I" by fast
ballarin@20318
   227
  thus "I +> x = I" by (rule a_rcos_const)
ballarin@20318
   228
qed
ballarin@20318
   229
ballarin@20318
   230
text {* Generating right cosets of a prime ideal is a homomorphism
ballarin@20318
   231
        on commutative rings *}
ballarin@20318
   232
lemma (in primeideal) rcos_ring_hom_cring:
ballarin@20318
   233
  shows "ring_hom_cring R (R Quot I) (op +> I)"
ballarin@20318
   234
by (rule rcos_ring_hom_cring, rule is_cring)
ballarin@20318
   235
ballarin@20318
   236
ballarin@20318
   237
subsection {* Factorization over Maximal Ideals *}
ballarin@20318
   238
ballarin@20318
   239
text {* In a commutative ring, the quotient ring over a maximal ideal
ballarin@20318
   240
        is a field.
ballarin@20318
   241
        The proof follows ``W. Adkins, S. Weintraub: Algebra --
ballarin@20318
   242
        An Approach via Module Theory'' *}
ballarin@20318
   243
lemma (in maximalideal) quotient_is_field:
ballarin@27611
   244
  assumes "cring R"
ballarin@20318
   245
  shows "field (R Quot I)"
ballarin@27611
   246
proof -
ballarin@27611
   247
  interpret cring [R] by fact
ballarin@27611
   248
  show ?thesis apply (intro cring.cring_fieldI2)
ballarin@20318
   249
  apply (rule quotient_is_cring, rule is_cring)
ballarin@20318
   250
 defer 1
ballarin@20318
   251
 apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric], clarsimp)
ballarin@20318
   252
 apply (simp add: rcoset_mult_add) defer 1
ballarin@20318
   253
proof (rule ccontr, simp)
ballarin@20318
   254
  --{* Quotient is not empty *}
ballarin@20318
   255
  assume "\<zero>\<^bsub>R Quot I\<^esub> = \<one>\<^bsub>R Quot I\<^esub>"
ballarin@20318
   256
  hence II1: "I = I +> \<one>" by (simp add: FactRing_def)
ballarin@20318
   257
  from a_rcos_self[OF one_closed]
wenzelm@23350
   258
  have "\<one> \<in> I" by (simp add: II1[symmetric])
ballarin@20318
   259
  hence "I = carrier R" by (rule one_imp_carrier)
ballarin@20318
   260
  from this and I_notcarr
wenzelm@23350
   261
  show "False" by simp
ballarin@20318
   262
next
ballarin@20318
   263
  --{* Existence of Inverse *}
ballarin@20318
   264
  fix a
ballarin@20318
   265
  assume IanI: "I +> a \<noteq> I"
wenzelm@23350
   266
    and acarr: "a \<in> carrier R"
ballarin@20318
   267
ballarin@20318
   268
  --{* Helper ideal @{text "J"} *}
ballarin@20318
   269
  def J \<equiv> "(carrier R #> a) <+> I :: 'a set"
ballarin@20318
   270
  have idealJ: "ideal J R"
wenzelm@23350
   271
    apply (unfold J_def, rule add_ideals)
wenzelm@23350
   272
     apply (simp only: cgenideal_eq_rcos[symmetric], rule cgenideal_ideal, rule acarr)
wenzelm@23350
   273
    apply (rule is_ideal)
wenzelm@23350
   274
    done
ballarin@20318
   275
ballarin@20318
   276
  --{* Showing @{term "J"} not smaller than @{term "I"} *}
ballarin@20318
   277
  have IinJ: "I \<subseteq> J"
ballarin@20318
   278
  proof (rule, simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   279
    fix x
ballarin@20318
   280
    assume xI: "x \<in> I"
ballarin@20318
   281
    have Zcarr: "\<zero> \<in> carrier R" by fast
ballarin@20318
   282
    from xI[THEN a_Hcarr] acarr
ballarin@20318
   283
    have "x = \<zero> \<otimes> a \<oplus> x" by algebra
ballarin@20318
   284
ballarin@20318
   285
    from Zcarr and xI and this
wenzelm@23350
   286
    show "\<exists>xa\<in>carrier R. \<exists>k\<in>I. x = xa \<otimes> a \<oplus> k" by fast
ballarin@20318
   287
  qed
ballarin@20318
   288
ballarin@20318
   289
  --{* Showing @{term "J \<noteq> I"} *}
ballarin@20318
   290
  have anI: "a \<notin> I"
ballarin@20318
   291
  proof (rule ccontr, simp)
ballarin@20318
   292
    assume "a \<in> I"
ballarin@20318
   293
    hence "I +> a = I" by (rule a_rcos_const)
ballarin@20318
   294
    from this and IanI
wenzelm@23350
   295
    show "False" by simp
ballarin@20318
   296
  qed
ballarin@20318
   297
ballarin@20318
   298
  have aJ: "a \<in> J"
ballarin@20318
   299
  proof (simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   300
    from acarr
wenzelm@23350
   301
    have "a = \<one> \<otimes> a \<oplus> \<zero>" by algebra
ballarin@20318
   302
    from one_closed and additive_subgroup.zero_closed[OF is_additive_subgroup] and this
wenzelm@23350
   303
    show "\<exists>x\<in>carrier R. \<exists>k\<in>I. a = x \<otimes> a \<oplus> k" by fast
ballarin@20318
   304
  qed
ballarin@20318
   305
ballarin@20318
   306
  from aJ and anI
wenzelm@23350
   307
  have JnI: "J \<noteq> I" by fast
ballarin@20318
   308
ballarin@20318
   309
  --{* Deducing @{term "J = carrier R"} because @{term "I"} is maximal *}
ballarin@20318
   310
  from idealJ and IinJ
wenzelm@23350
   311
  have "J = I \<or> J = carrier R"
ballarin@20318
   312
  proof (rule I_maximal, unfold J_def)
ballarin@20318
   313
    have "carrier R #> a \<subseteq> carrier R"
wenzelm@23350
   314
      using subset_refl acarr
wenzelm@23350
   315
      by (rule r_coset_subset_G)
ballarin@20318
   316
    from this and a_subset
wenzelm@23350
   317
    show "carrier R #> a <+> I \<subseteq> carrier R" by (rule set_add_closed)
ballarin@20318
   318
  qed
ballarin@20318
   319
ballarin@20318
   320
  from this and JnI
wenzelm@23350
   321
  have Jcarr: "J = carrier R" by simp
ballarin@20318
   322
ballarin@20318
   323
  --{* Calculating an inverse for @{term "a"} *}
ballarin@20318
   324
  from one_closed[folded Jcarr]
wenzelm@23350
   325
  have "\<exists>r\<in>carrier R. \<exists>i\<in>I. \<one> = r \<otimes> a \<oplus> i"
wenzelm@23350
   326
    by (simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   327
  from this
wenzelm@23350
   328
  obtain r i
wenzelm@23350
   329
    where rcarr: "r \<in> carrier R"
wenzelm@23350
   330
      and iI: "i \<in> I"
wenzelm@23350
   331
      and one: "\<one> = r \<otimes> a \<oplus> i"
wenzelm@23350
   332
    by fast
ballarin@20318
   333
  from one and rcarr and acarr and iI[THEN a_Hcarr]
wenzelm@23350
   334
  have rai1: "a \<otimes> r = \<ominus>i \<oplus> \<one>" by algebra
ballarin@20318
   335
ballarin@20318
   336
  --{* Lifting to cosets *}
ballarin@20318
   337
  from iI
wenzelm@23350
   338
  have "\<ominus>i \<oplus> \<one> \<in> I +> \<one>"
wenzelm@23350
   339
    by (intro a_rcosI, simp, intro a_subset, simp)
ballarin@20318
   340
  from this and rai1
wenzelm@23350
   341
  have "a \<otimes> r \<in> I +> \<one>" by simp
ballarin@20318
   342
  from this have "I +> \<one> = I +> a \<otimes> r"
wenzelm@23350
   343
    by (rule a_repr_independence, simp) (rule a_subgroup)
ballarin@20318
   344
ballarin@20318
   345
  from rcarr and this[symmetric]
wenzelm@23350
   346
  show "\<exists>r\<in>carrier R. I +> a \<otimes> r = I +> \<one>" by fast
ballarin@20318
   347
qed
ballarin@27611
   348
qed
ballarin@20318
   349
ballarin@20318
   350
end