src/HOL/Algebra/QuotRing.thy
author krauss
Fri Nov 24 13:44:51 2006 +0100 (2006-11-24)
changeset 21512 3786eb1b69d6
parent 21502 7f3ea2b3bab6
child 23350 50c5b0912a0c
permissions -rw-r--r--
Lemma "fundef_default_value" uses predicate instead of set.
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@20318
    11
ballarin@20318
    12
section {* Quotient Rings *}
ballarin@20318
    13
ballarin@20318
    14
subsection {* Multiplication on Cosets *}
ballarin@20318
    15
ballarin@20318
    16
constdefs (structure R)
ballarin@20318
    17
  rcoset_mult :: "[('a, _) ring_scheme, 'a set, 'a set, 'a set] \<Rightarrow> 'a set"   ("[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@20318
   158
  includes cring
ballarin@20318
   159
  shows "cring (R Quot I)"
ballarin@20318
   160
apply (intro cring.intro comm_monoid.intro comm_monoid_axioms.intro)
ballarin@20318
   161
  apply (rule quotient_is_ring)
ballarin@20318
   162
 apply (rule ring.axioms[OF quotient_is_ring])
ballarin@20318
   163
apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric])
ballarin@20318
   164
apply clarify
ballarin@20318
   165
apply (simp add: rcoset_mult_add m_comm)
ballarin@20318
   166
done
ballarin@20318
   167
ballarin@20318
   168
text {* Cosets as a ring homomorphism on crings *}
ballarin@20318
   169
lemma (in ideal) rcos_ring_hom_cring:
ballarin@20318
   170
  includes cring
ballarin@20318
   171
  shows "ring_hom_cring R (R Quot I) (op +> I)"
ballarin@20318
   172
apply (rule ring_hom_cringI)
ballarin@20318
   173
  apply (rule rcos_ring_hom_ring)
ballarin@20318
   174
 apply assumption
ballarin@20318
   175
apply (rule quotient_is_cring, assumption)
ballarin@20318
   176
done
ballarin@20318
   177
ballarin@20318
   178
ballarin@20318
   179
subsection {* Factorization over Prime Ideals *}
ballarin@20318
   180
ballarin@20318
   181
text {* The quotient ring generated by a prime ideal is a domain *}
ballarin@20318
   182
lemma (in primeideal) quotient_is_domain:
ballarin@20318
   183
  shows "domain (R Quot I)"
ballarin@20318
   184
apply (rule domain.intro)
ballarin@20318
   185
 apply (rule quotient_is_cring, rule is_cring)
ballarin@20318
   186
apply (rule domain_axioms.intro)
ballarin@20318
   187
 apply (simp add: FactRing_def) defer 1
ballarin@20318
   188
 apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric], clarify)
ballarin@20318
   189
 apply (simp add: rcoset_mult_add) defer 1
ballarin@20318
   190
proof (rule ccontr, clarsimp)
ballarin@20318
   191
  assume "I +> \<one> = I"
ballarin@20318
   192
  hence "\<one> \<in> I" by (simp only: a_coset_join1 one_closed a_subgroup)
ballarin@20318
   193
  hence "carrier R \<subseteq> I" by (subst one_imp_carrier, simp, fast)
ballarin@20318
   194
  from this and a_subset
ballarin@20318
   195
      have "I = carrier R" by fast
ballarin@20318
   196
  from this and I_notcarr
ballarin@20318
   197
      show "False" by fast
ballarin@20318
   198
next
ballarin@20318
   199
  fix x y
ballarin@20318
   200
  assume carr: "x \<in> carrier R" "y \<in> carrier R"
ballarin@20318
   201
     and a: "I +> x \<otimes> y = I"
ballarin@20318
   202
     and b: "I +> y \<noteq> I"
ballarin@20318
   203
ballarin@20318
   204
  have ynI: "y \<notin> I"
ballarin@20318
   205
  proof (rule ccontr, simp)
ballarin@20318
   206
    assume "y \<in> I"
ballarin@20318
   207
    hence "I +> y = I" by (rule a_rcos_const)
ballarin@20318
   208
    from this and b
ballarin@20318
   209
        show "False" by simp
ballarin@20318
   210
  qed
ballarin@20318
   211
ballarin@20318
   212
  from carr
ballarin@20318
   213
      have "x \<otimes> y \<in> I +> x \<otimes> y" by (simp add: a_rcos_self)
ballarin@20318
   214
  from this
ballarin@20318
   215
      have xyI: "x \<otimes> y \<in> I" by (simp add: a)
ballarin@20318
   216
ballarin@20318
   217
  from xyI and carr
ballarin@20318
   218
      have xI: "x \<in> I \<or> y \<in> I" by (simp add: I_prime)
ballarin@20318
   219
  from this and ynI
ballarin@20318
   220
      have "x \<in> I" by fast
ballarin@20318
   221
  thus "I +> x = I" by (rule a_rcos_const)
ballarin@20318
   222
qed
ballarin@20318
   223
ballarin@20318
   224
text {* Generating right cosets of a prime ideal is a homomorphism
ballarin@20318
   225
        on commutative rings *}
ballarin@20318
   226
lemma (in primeideal) rcos_ring_hom_cring:
ballarin@20318
   227
  shows "ring_hom_cring R (R Quot I) (op +> I)"
ballarin@20318
   228
by (rule rcos_ring_hom_cring, rule is_cring)
ballarin@20318
   229
ballarin@20318
   230
ballarin@20318
   231
subsection {* Factorization over Maximal Ideals *}
ballarin@20318
   232
ballarin@20318
   233
text {* In a commutative ring, the quotient ring over a maximal ideal
ballarin@20318
   234
        is a field.
ballarin@20318
   235
        The proof follows ``W. Adkins, S. Weintraub: Algebra --
ballarin@20318
   236
        An Approach via Module Theory'' *}
ballarin@20318
   237
lemma (in maximalideal) quotient_is_field:
ballarin@20318
   238
  includes cring
ballarin@20318
   239
  shows "field (R Quot I)"
ballarin@20318
   240
apply (intro cring.cring_fieldI2)
ballarin@20318
   241
  apply (rule quotient_is_cring, rule is_cring)
ballarin@20318
   242
 defer 1
ballarin@20318
   243
 apply (simp add: FactRing_def A_RCOSETS_defs a_r_coset_def[symmetric], clarsimp)
ballarin@20318
   244
 apply (simp add: rcoset_mult_add) defer 1
ballarin@20318
   245
proof (rule ccontr, simp)
ballarin@20318
   246
  --{* Quotient is not empty *}
ballarin@20318
   247
  assume "\<zero>\<^bsub>R Quot I\<^esub> = \<one>\<^bsub>R Quot I\<^esub>"
ballarin@20318
   248
  hence II1: "I = I +> \<one>" by (simp add: FactRing_def)
ballarin@20318
   249
  from a_rcos_self[OF one_closed]
ballarin@20318
   250
      have "\<one> \<in> I" by (simp add: II1[symmetric])
ballarin@20318
   251
  hence "I = carrier R" by (rule one_imp_carrier)
ballarin@20318
   252
  from this and I_notcarr
ballarin@20318
   253
      show "False" by simp
ballarin@20318
   254
next
ballarin@20318
   255
  --{* Existence of Inverse *}
ballarin@20318
   256
  fix a
ballarin@20318
   257
  assume IanI: "I +> a \<noteq> I"
ballarin@20318
   258
     and acarr: "a \<in> carrier R"
ballarin@20318
   259
ballarin@20318
   260
  --{* Helper ideal @{text "J"} *}
ballarin@20318
   261
  def J \<equiv> "(carrier R #> a) <+> I :: 'a set"
ballarin@20318
   262
  have idealJ: "ideal J R"
ballarin@20318
   263
      apply (unfold J_def, rule add_ideals)
ballarin@20318
   264
      apply (simp only: cgenideal_eq_rcos[symmetric], rule cgenideal_ideal, rule acarr)
ballarin@20318
   265
      apply (rule is_ideal)
ballarin@20318
   266
      done
ballarin@20318
   267
ballarin@20318
   268
  --{* Showing @{term "J"} not smaller than @{term "I"} *}
ballarin@20318
   269
  have IinJ: "I \<subseteq> J"
ballarin@20318
   270
  proof (rule, simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   271
    fix x
ballarin@20318
   272
    assume xI: "x \<in> I"
ballarin@20318
   273
    have Zcarr: "\<zero> \<in> carrier R" by fast
ballarin@20318
   274
    from xI[THEN a_Hcarr] acarr
ballarin@20318
   275
    have "x = \<zero> \<otimes> a \<oplus> x" by algebra
ballarin@20318
   276
ballarin@20318
   277
    from Zcarr and xI and this
ballarin@20318
   278
        show "\<exists>xa\<in>carrier R. \<exists>k\<in>I. x = xa \<otimes> a \<oplus> k" by fast
ballarin@20318
   279
  qed
ballarin@20318
   280
ballarin@20318
   281
  --{* Showing @{term "J \<noteq> I"} *}
ballarin@20318
   282
  have anI: "a \<notin> I"
ballarin@20318
   283
  proof (rule ccontr, simp)
ballarin@20318
   284
    assume "a \<in> I"
ballarin@20318
   285
    hence "I +> a = I" by (rule a_rcos_const)
ballarin@20318
   286
    from this and IanI
ballarin@20318
   287
        show "False" by simp
ballarin@20318
   288
  qed
ballarin@20318
   289
ballarin@20318
   290
  have aJ: "a \<in> J"
ballarin@20318
   291
  proof (simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   292
    from acarr
ballarin@20318
   293
        have "a = \<one> \<otimes> a \<oplus> \<zero>" by algebra
ballarin@20318
   294
    from one_closed and additive_subgroup.zero_closed[OF is_additive_subgroup] and this
ballarin@20318
   295
        show "\<exists>x\<in>carrier R. \<exists>k\<in>I. a = x \<otimes> a \<oplus> k" by fast
ballarin@20318
   296
  qed
ballarin@20318
   297
ballarin@20318
   298
  from aJ and anI
ballarin@20318
   299
      have JnI: "J \<noteq> I" by fast
ballarin@20318
   300
ballarin@20318
   301
  --{* Deducing @{term "J = carrier R"} because @{term "I"} is maximal *}
ballarin@20318
   302
  from idealJ and IinJ
ballarin@20318
   303
      have "J = I \<or> J = carrier R"
ballarin@20318
   304
  proof (rule I_maximal, unfold J_def)
ballarin@20318
   305
    have "carrier R #> a \<subseteq> carrier R"
ballarin@20318
   306
	  by (rule r_coset_subset_G) fast
ballarin@20318
   307
    from this and a_subset
ballarin@20318
   308
        show "carrier R #> a <+> I \<subseteq> carrier R" by (rule set_add_closed)
ballarin@20318
   309
  qed
ballarin@20318
   310
ballarin@20318
   311
  from this and JnI
ballarin@20318
   312
      have Jcarr: "J = carrier R" by simp
ballarin@20318
   313
ballarin@20318
   314
  --{* Calculating an inverse for @{term "a"} *}
ballarin@20318
   315
  from one_closed[folded Jcarr]
ballarin@20318
   316
      have "\<exists>r\<in>carrier R. \<exists>i\<in>I. \<one> = r \<otimes> a \<oplus> i"
ballarin@20318
   317
      by (simp add: J_def r_coset_def set_add_defs)
ballarin@20318
   318
  from this
ballarin@20318
   319
     obtain r i
ballarin@20318
   320
       where rcarr: "r \<in> carrier R"
ballarin@20318
   321
       and iI: "i \<in> I"
ballarin@20318
   322
       and one: "\<one> = r \<otimes> a \<oplus> i"
ballarin@20318
   323
     by fast
ballarin@20318
   324
  from one and rcarr and acarr and iI[THEN a_Hcarr]
ballarin@20318
   325
      have rai1: "a \<otimes> r = \<ominus>i \<oplus> \<one>" by algebra
ballarin@20318
   326
ballarin@20318
   327
  --{* Lifting to cosets *}
ballarin@20318
   328
  from iI
ballarin@20318
   329
      have "\<ominus>i \<oplus> \<one> \<in> I +> \<one>"
ballarin@20318
   330
      by (intro a_rcosI, simp, intro a_subset, simp)
ballarin@20318
   331
  from this and rai1
ballarin@20318
   332
      have "a \<otimes> r \<in> I +> \<one>" by simp
ballarin@20318
   333
  from this have "I +> \<one> = I +> a \<otimes> r"
ballarin@20318
   334
      by (rule a_repr_independence, simp) (rule a_subgroup)
ballarin@20318
   335
ballarin@20318
   336
  from rcarr and this[symmetric]
ballarin@20318
   337
      show "\<exists>r\<in>carrier R. I +> a \<otimes> r = I +> \<one>" by fast
ballarin@20318
   338
qed
ballarin@20318
   339
ballarin@20318
   340
end