src/HOL/Algebra/Ideal.thy
author ballarin
Wed Dec 17 17:53:56 2008 +0100 (2008-12-17)
changeset 29240 bb81c3709fb6
parent 29237 e90d9d51106b
child 30363 9b8d9b6ef803
permissions -rw-r--r--
More porting to new locales.
ballarin@20318
     1
(*
ballarin@20318
     2
  Title:     HOL/Algebra/CIdeal.thy
ballarin@20318
     3
  Author:    Stephan Hohe, TU Muenchen
ballarin@20318
     4
*)
ballarin@20318
     5
ballarin@20318
     6
theory Ideal
ballarin@20318
     7
imports Ring AbelCoset
ballarin@20318
     8
begin
ballarin@20318
     9
ballarin@20318
    10
section {* Ideals *}
ballarin@20318
    11
ballarin@27717
    12
subsection {* Definitions *}
ballarin@27717
    13
ballarin@27717
    14
subsubsection {* General definition *}
ballarin@20318
    15
ballarin@29240
    16
locale ideal = additive_subgroup I R + ring R for I and R (structure) +
ballarin@20318
    17
  assumes I_l_closed: "\<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> x \<otimes> a \<in> I"
ballarin@20318
    18
      and I_r_closed: "\<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> a \<otimes> x \<in> I"
ballarin@20318
    19
ballarin@29237
    20
sublocale ideal \<subseteq> abelian_subgroup I R
ballarin@20318
    21
apply (intro abelian_subgroupI3 abelian_group.intro)
wenzelm@23463
    22
  apply (rule ideal.axioms, rule ideal_axioms)
wenzelm@23463
    23
 apply (rule abelian_group.axioms, rule ring.axioms, rule ideal.axioms, rule ideal_axioms)
wenzelm@23463
    24
apply (rule abelian_group.axioms, rule ring.axioms, rule ideal.axioms, rule ideal_axioms)
ballarin@20318
    25
done
ballarin@20318
    26
ballarin@20318
    27
lemma (in ideal) is_ideal:
ballarin@20318
    28
  "ideal I R"
wenzelm@26203
    29
by (rule ideal_axioms)
ballarin@20318
    30
ballarin@20318
    31
lemma idealI:
ballarin@27611
    32
  fixes R (structure)
ballarin@27611
    33
  assumes "ring R"
ballarin@20318
    34
  assumes a_subgroup: "subgroup I \<lparr>carrier = carrier R, mult = add R, one = zero R\<rparr>"
ballarin@20318
    35
      and I_l_closed: "\<And>a x. \<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> x \<otimes> a \<in> I"
ballarin@20318
    36
      and I_r_closed: "\<And>a x. \<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> a \<otimes> x \<in> I"
ballarin@20318
    37
  shows "ideal I R"
ballarin@27611
    38
proof -
ballarin@29237
    39
  interpret ring R by fact
ballarin@27611
    40
  show ?thesis  apply (intro ideal.intro ideal_axioms.intro additive_subgroupI)
wenzelm@23463
    41
     apply (rule a_subgroup)
wenzelm@23463
    42
    apply (rule is_ring)
wenzelm@23463
    43
   apply (erule (1) I_l_closed)
wenzelm@23463
    44
  apply (erule (1) I_r_closed)
wenzelm@23463
    45
  done
ballarin@27611
    46
qed
ballarin@20318
    47
ballarin@27717
    48
subsubsection {* Ideals Generated by a Subset of @{term [locale=ring] "carrier R"} *}
ballarin@20318
    49
ballarin@20318
    50
constdefs (structure R)
ballarin@20318
    51
  genideal :: "('a, 'b) ring_scheme \<Rightarrow> 'a set \<Rightarrow> 'a set"  ("Idl\<index> _" [80] 79)
ballarin@20318
    52
  "genideal R S \<equiv> Inter {I. ideal I R \<and> S \<subseteq> I}"
ballarin@20318
    53
ballarin@20318
    54
ballarin@27717
    55
subsubsection {* Principal Ideals *}
ballarin@20318
    56
ballarin@20318
    57
locale principalideal = ideal +
ballarin@20318
    58
  assumes generate: "\<exists>i \<in> carrier R. I = Idl {i}"
ballarin@20318
    59
ballarin@20318
    60
lemma (in principalideal) is_principalideal:
ballarin@20318
    61
  shows "principalideal I R"
wenzelm@26203
    62
by (rule principalideal_axioms)
ballarin@20318
    63
ballarin@20318
    64
lemma principalidealI:
ballarin@27611
    65
  fixes R (structure)
ballarin@27611
    66
  assumes "ideal I R"
ballarin@20318
    67
  assumes generate: "\<exists>i \<in> carrier R. I = Idl {i}"
ballarin@20318
    68
  shows "principalideal I R"
ballarin@27611
    69
proof -
ballarin@29237
    70
  interpret ideal I R by fact
ballarin@27611
    71
  show ?thesis  by (intro principalideal.intro principalideal_axioms.intro) (rule is_ideal, rule generate)
ballarin@27611
    72
qed
ballarin@20318
    73
ballarin@27717
    74
subsubsection {* Maximal Ideals *}
ballarin@20318
    75
ballarin@20318
    76
locale maximalideal = ideal +
ballarin@20318
    77
  assumes I_notcarr: "carrier R \<noteq> I"
ballarin@20318
    78
      and I_maximal: "\<lbrakk>ideal J R; I \<subseteq> J; J \<subseteq> carrier R\<rbrakk> \<Longrightarrow> J = I \<or> J = carrier R"
ballarin@20318
    79
ballarin@20318
    80
lemma (in maximalideal) is_maximalideal:
ballarin@20318
    81
 shows "maximalideal I R"
wenzelm@26203
    82
by (rule maximalideal_axioms)
ballarin@20318
    83
ballarin@20318
    84
lemma maximalidealI:
ballarin@27611
    85
  fixes R
ballarin@27611
    86
  assumes "ideal I R"
ballarin@20318
    87
  assumes I_notcarr: "carrier R \<noteq> I"
ballarin@20318
    88
     and I_maximal: "\<And>J. \<lbrakk>ideal J R; I \<subseteq> J; J \<subseteq> carrier R\<rbrakk> \<Longrightarrow> J = I \<or> J = carrier R"
ballarin@20318
    89
  shows "maximalideal I R"
ballarin@27611
    90
proof -
ballarin@29237
    91
  interpret ideal I R by fact
ballarin@27611
    92
  show ?thesis by (intro maximalideal.intro maximalideal_axioms.intro)
wenzelm@23463
    93
    (rule is_ideal, rule I_notcarr, rule I_maximal)
ballarin@27611
    94
qed
ballarin@20318
    95
ballarin@27717
    96
subsubsection {* Prime Ideals *}
ballarin@20318
    97
ballarin@20318
    98
locale primeideal = ideal + cring +
ballarin@20318
    99
  assumes I_notcarr: "carrier R \<noteq> I"
ballarin@20318
   100
      and I_prime: "\<lbrakk>a \<in> carrier R; b \<in> carrier R; a \<otimes> b \<in> I\<rbrakk> \<Longrightarrow> a \<in> I \<or> b \<in> I"
ballarin@20318
   101
ballarin@20318
   102
lemma (in primeideal) is_primeideal:
ballarin@20318
   103
 shows "primeideal I R"
wenzelm@26203
   104
by (rule primeideal_axioms)
ballarin@20318
   105
ballarin@20318
   106
lemma primeidealI:
ballarin@27611
   107
  fixes R (structure)
ballarin@27611
   108
  assumes "ideal I R"
ballarin@27611
   109
  assumes "cring R"
ballarin@20318
   110
  assumes I_notcarr: "carrier R \<noteq> I"
ballarin@20318
   111
      and I_prime: "\<And>a b. \<lbrakk>a \<in> carrier R; b \<in> carrier R; a \<otimes> b \<in> I\<rbrakk> \<Longrightarrow> a \<in> I \<or> b \<in> I"
ballarin@20318
   112
  shows "primeideal I R"
ballarin@27611
   113
proof -
ballarin@29237
   114
  interpret ideal I R by fact
ballarin@29237
   115
  interpret cring R by fact
ballarin@27611
   116
  show ?thesis by (intro primeideal.intro primeideal_axioms.intro)
wenzelm@23463
   117
    (rule is_ideal, rule is_cring, rule I_notcarr, rule I_prime)
ballarin@27611
   118
qed
ballarin@20318
   119
ballarin@20318
   120
lemma primeidealI2:
ballarin@27611
   121
  fixes R (structure)
ballarin@27611
   122
  assumes "additive_subgroup I R"
ballarin@27611
   123
  assumes "cring R"
ballarin@20318
   124
  assumes I_l_closed: "\<And>a x. \<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> x \<otimes> a \<in> I"
ballarin@20318
   125
      and I_r_closed: "\<And>a x. \<lbrakk>a \<in> I; x \<in> carrier R\<rbrakk> \<Longrightarrow> a \<otimes> x \<in> I"
ballarin@20318
   126
      and I_notcarr: "carrier R \<noteq> I"
ballarin@20318
   127
      and I_prime: "\<And>a b. \<lbrakk>a \<in> carrier R; b \<in> carrier R; a \<otimes> b \<in> I\<rbrakk> \<Longrightarrow> a \<in> I \<or> b \<in> I"
ballarin@20318
   128
  shows "primeideal I R"
ballarin@27611
   129
proof -
ballarin@29240
   130
  interpret additive_subgroup I R by fact
ballarin@29237
   131
  interpret cring R by fact
ballarin@27611
   132
  show ?thesis apply (intro_locales)
ballarin@27611
   133
    apply (intro ideal_axioms.intro)
ballarin@27611
   134
    apply (erule (1) I_l_closed)
ballarin@27611
   135
    apply (erule (1) I_r_closed)
ballarin@27611
   136
    apply (intro primeideal_axioms.intro)
ballarin@27611
   137
    apply (rule I_notcarr)
ballarin@27611
   138
    apply (erule (2) I_prime)
ballarin@27611
   139
    done
ballarin@27611
   140
qed
ballarin@20318
   141
ballarin@20318
   142
subsection {* Special Ideals *}
ballarin@20318
   143
ballarin@20318
   144
lemma (in ring) zeroideal:
ballarin@20318
   145
  shows "ideal {\<zero>} R"
ballarin@20318
   146
apply (intro idealI subgroup.intro)
ballarin@20318
   147
      apply (rule is_ring)
ballarin@20318
   148
     apply simp+
ballarin@20318
   149
  apply (fold a_inv_def, simp)
ballarin@20318
   150
 apply simp+
ballarin@20318
   151
done
ballarin@20318
   152
ballarin@20318
   153
lemma (in ring) oneideal:
ballarin@20318
   154
  shows "ideal (carrier R) R"
ballarin@20318
   155
apply (intro idealI  subgroup.intro)
ballarin@20318
   156
      apply (rule is_ring)
ballarin@20318
   157
     apply simp+
ballarin@20318
   158
  apply (fold a_inv_def, simp)
ballarin@20318
   159
 apply simp+
ballarin@20318
   160
done
ballarin@20318
   161
ballarin@20318
   162
lemma (in "domain") zeroprimeideal:
ballarin@20318
   163
 shows "primeideal {\<zero>} R"
ballarin@20318
   164
apply (intro primeidealI)
ballarin@20318
   165
   apply (rule zeroideal)
wenzelm@23463
   166
  apply (rule domain.axioms, rule domain_axioms)
ballarin@20318
   167
 defer 1
ballarin@20318
   168
 apply (simp add: integral)
ballarin@20318
   169
proof (rule ccontr, simp)
ballarin@20318
   170
  assume "carrier R = {\<zero>}"
ballarin@20318
   171
  from this have "\<one> = \<zero>" by (rule one_zeroI)
ballarin@20318
   172
  from this and one_not_zero
ballarin@20318
   173
      show "False" by simp
ballarin@20318
   174
qed
ballarin@20318
   175
ballarin@20318
   176
ballarin@20318
   177
subsection {* General Ideal Properies *}
ballarin@20318
   178
ballarin@20318
   179
lemma (in ideal) one_imp_carrier:
ballarin@20318
   180
  assumes I_one_closed: "\<one> \<in> I"
ballarin@20318
   181
  shows "I = carrier R"
ballarin@20318
   182
apply (rule)
ballarin@20318
   183
apply (rule)
ballarin@20318
   184
apply (rule a_Hcarr, simp)
ballarin@20318
   185
proof
ballarin@20318
   186
  fix x
ballarin@20318
   187
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   188
  from I_one_closed and this
ballarin@20318
   189
      have "x \<otimes> \<one> \<in> I" by (intro I_l_closed)
ballarin@20318
   190
  from this and xcarr
ballarin@20318
   191
      show "x \<in> I" by simp
ballarin@20318
   192
qed
ballarin@20318
   193
ballarin@20318
   194
lemma (in ideal) Icarr:
ballarin@20318
   195
  assumes iI: "i \<in> I"
ballarin@20318
   196
  shows "i \<in> carrier R"
wenzelm@23350
   197
using iI by (rule a_Hcarr)
ballarin@20318
   198
ballarin@20318
   199
ballarin@20318
   200
subsection {* Intersection of Ideals *}
ballarin@20318
   201
ballarin@20318
   202
text {* \paragraph{Intersection of two ideals} The intersection of any
ballarin@20318
   203
  two ideals is again an ideal in @{term R} *}
ballarin@20318
   204
lemma (in ring) i_intersect:
ballarin@27611
   205
  assumes "ideal I R"
ballarin@27611
   206
  assumes "ideal J R"
ballarin@20318
   207
  shows "ideal (I \<inter> J) R"
ballarin@27611
   208
proof -
ballarin@29237
   209
  interpret ideal I R by fact
ballarin@29240
   210
  interpret ideal J R by fact
ballarin@27611
   211
  show ?thesis
ballarin@20318
   212
apply (intro idealI subgroup.intro)
ballarin@20318
   213
      apply (rule is_ring)
ballarin@20318
   214
     apply (force simp add: a_subset)
ballarin@20318
   215
    apply (simp add: a_inv_def[symmetric])
ballarin@20318
   216
   apply simp
ballarin@20318
   217
  apply (simp add: a_inv_def[symmetric])
ballarin@20318
   218
 apply (clarsimp, rule)
ballarin@27714
   219
  apply (fast intro: ideal.I_l_closed ideal.intro assms)+
ballarin@20318
   220
apply (clarsimp, rule)
ballarin@27714
   221
 apply (fast intro: ideal.I_r_closed ideal.intro assms)+
ballarin@20318
   222
done
ballarin@27611
   223
qed
ballarin@20318
   224
ballarin@20318
   225
text {* The intersection of any Number of Ideals is again
ballarin@20318
   226
        an Ideal in @{term R} *}
ballarin@20318
   227
lemma (in ring) i_Intersect:
ballarin@20318
   228
  assumes Sideals: "\<And>I. I \<in> S \<Longrightarrow> ideal I R"
ballarin@20318
   229
    and notempty: "S \<noteq> {}"
ballarin@20318
   230
  shows "ideal (Inter S) R"
ballarin@20318
   231
apply (unfold_locales)
ballarin@20318
   232
apply (simp_all add: Inter_def INTER_def)
ballarin@20318
   233
      apply (rule, simp) defer 1
ballarin@20318
   234
      apply rule defer 1
ballarin@20318
   235
      apply rule defer 1
ballarin@20318
   236
      apply (fold a_inv_def, rule) defer 1
ballarin@20318
   237
      apply rule defer 1
ballarin@20318
   238
      apply rule defer 1
ballarin@20318
   239
proof -
ballarin@20318
   240
  fix x
ballarin@20318
   241
  assume "\<forall>I\<in>S. x \<in> I"
ballarin@20318
   242
  hence xI: "\<And>I. I \<in> S \<Longrightarrow> x \<in> I" by simp
ballarin@20318
   243
ballarin@20318
   244
  from notempty have "\<exists>I0. I0 \<in> S" by blast
ballarin@20318
   245
  from this obtain I0 where I0S: "I0 \<in> S" by auto
ballarin@20318
   246
ballarin@29237
   247
  interpret ideal I0 R by (rule Sideals[OF I0S])
ballarin@20318
   248
ballarin@20318
   249
  from xI[OF I0S] have "x \<in> I0" .
ballarin@20318
   250
  from this and a_subset show "x \<in> carrier R" by fast
ballarin@20318
   251
next
ballarin@20318
   252
  fix x y
ballarin@20318
   253
  assume "\<forall>I\<in>S. x \<in> I"
ballarin@20318
   254
  hence xI: "\<And>I. I \<in> S \<Longrightarrow> x \<in> I" by simp
ballarin@20318
   255
  assume "\<forall>I\<in>S. y \<in> I"
ballarin@20318
   256
  hence yI: "\<And>I. I \<in> S \<Longrightarrow> y \<in> I" by simp
ballarin@20318
   257
ballarin@20318
   258
  fix J
ballarin@20318
   259
  assume JS: "J \<in> S"
ballarin@29237
   260
  interpret ideal J R by (rule Sideals[OF JS])
ballarin@20318
   261
  from xI[OF JS] and yI[OF JS]
ballarin@20318
   262
      show "x \<oplus> y \<in> J" by (rule a_closed)
ballarin@20318
   263
next
ballarin@20318
   264
  fix J
ballarin@20318
   265
  assume JS: "J \<in> S"
ballarin@29237
   266
  interpret ideal J R by (rule Sideals[OF JS])
ballarin@20318
   267
  show "\<zero> \<in> J" by simp
ballarin@20318
   268
next
ballarin@20318
   269
  fix x
ballarin@20318
   270
  assume "\<forall>I\<in>S. x \<in> I"
ballarin@20318
   271
  hence xI: "\<And>I. I \<in> S \<Longrightarrow> x \<in> I" by simp
ballarin@20318
   272
ballarin@20318
   273
  fix J
ballarin@20318
   274
  assume JS: "J \<in> S"
ballarin@29237
   275
  interpret ideal J R by (rule Sideals[OF JS])
ballarin@20318
   276
ballarin@20318
   277
  from xI[OF JS]
ballarin@20318
   278
      show "\<ominus> x \<in> J" by (rule a_inv_closed)
ballarin@20318
   279
next
ballarin@20318
   280
  fix x y
ballarin@20318
   281
  assume "\<forall>I\<in>S. x \<in> I"
ballarin@20318
   282
  hence xI: "\<And>I. I \<in> S \<Longrightarrow> x \<in> I" by simp
ballarin@20318
   283
  assume ycarr: "y \<in> carrier R"
ballarin@20318
   284
ballarin@20318
   285
  fix J
ballarin@20318
   286
  assume JS: "J \<in> S"
ballarin@29237
   287
  interpret ideal J R by (rule Sideals[OF JS])
ballarin@20318
   288
ballarin@20318
   289
  from xI[OF JS] and ycarr
ballarin@20318
   290
      show "y \<otimes> x \<in> J" by (rule I_l_closed)
ballarin@20318
   291
next
ballarin@20318
   292
  fix x y
ballarin@20318
   293
  assume "\<forall>I\<in>S. x \<in> I"
ballarin@20318
   294
  hence xI: "\<And>I. I \<in> S \<Longrightarrow> x \<in> I" by simp
ballarin@20318
   295
  assume ycarr: "y \<in> carrier R"
ballarin@20318
   296
ballarin@20318
   297
  fix J
ballarin@20318
   298
  assume JS: "J \<in> S"
ballarin@29237
   299
  interpret ideal J R by (rule Sideals[OF JS])
ballarin@20318
   300
ballarin@20318
   301
  from xI[OF JS] and ycarr
ballarin@20318
   302
      show "x \<otimes> y \<in> J" by (rule I_r_closed)
ballarin@20318
   303
qed
ballarin@20318
   304
ballarin@20318
   305
ballarin@20318
   306
subsection {* Addition of Ideals *}
ballarin@20318
   307
ballarin@20318
   308
lemma (in ring) add_ideals:
ballarin@20318
   309
  assumes idealI: "ideal I R"
ballarin@20318
   310
      and idealJ: "ideal J R"
ballarin@20318
   311
  shows "ideal (I <+> J) R"
ballarin@20318
   312
apply (rule ideal.intro)
ballarin@20318
   313
  apply (rule add_additive_subgroups)
ballarin@20318
   314
   apply (intro ideal.axioms[OF idealI])
ballarin@20318
   315
  apply (intro ideal.axioms[OF idealJ])
wenzelm@23463
   316
 apply (rule is_ring)
ballarin@20318
   317
apply (rule ideal_axioms.intro)
ballarin@20318
   318
 apply (simp add: set_add_defs, clarsimp) defer 1
ballarin@20318
   319
 apply (simp add: set_add_defs, clarsimp) defer 1
ballarin@20318
   320
proof -
ballarin@20318
   321
  fix x i j
ballarin@20318
   322
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   323
     and iI: "i \<in> I"
ballarin@20318
   324
     and jJ: "j \<in> J"
ballarin@20318
   325
  from xcarr ideal.Icarr[OF idealI iI] ideal.Icarr[OF idealJ jJ]
ballarin@20318
   326
      have c: "(i \<oplus> j) \<otimes> x = (i \<otimes> x) \<oplus> (j \<otimes> x)" by algebra
ballarin@20318
   327
  from xcarr and iI
ballarin@20318
   328
      have a: "i \<otimes> x \<in> I" by (simp add: ideal.I_r_closed[OF idealI])
ballarin@20318
   329
  from xcarr and jJ
ballarin@20318
   330
      have b: "j \<otimes> x \<in> J" by (simp add: ideal.I_r_closed[OF idealJ])
ballarin@20318
   331
  from a b c
ballarin@20318
   332
      show "\<exists>ha\<in>I. \<exists>ka\<in>J. (i \<oplus> j) \<otimes> x = ha \<oplus> ka" by fast
ballarin@20318
   333
next
ballarin@20318
   334
  fix x i j
ballarin@20318
   335
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   336
     and iI: "i \<in> I"
ballarin@20318
   337
     and jJ: "j \<in> J"
ballarin@20318
   338
  from xcarr ideal.Icarr[OF idealI iI] ideal.Icarr[OF idealJ jJ]
ballarin@20318
   339
      have c: "x \<otimes> (i \<oplus> j) = (x \<otimes> i) \<oplus> (x \<otimes> j)" by algebra
ballarin@20318
   340
  from xcarr and iI
ballarin@20318
   341
      have a: "x \<otimes> i \<in> I" by (simp add: ideal.I_l_closed[OF idealI])
ballarin@20318
   342
  from xcarr and jJ
ballarin@20318
   343
      have b: "x \<otimes> j \<in> J" by (simp add: ideal.I_l_closed[OF idealJ])
ballarin@20318
   344
  from a b c
ballarin@20318
   345
      show "\<exists>ha\<in>I. \<exists>ka\<in>J. x \<otimes> (i \<oplus> j) = ha \<oplus> ka" by fast
ballarin@20318
   346
qed
ballarin@20318
   347
ballarin@20318
   348
ballarin@20318
   349
subsection {* Ideals generated by a subset of @{term [locale=ring]
ballarin@20318
   350
  "carrier R"} *}
ballarin@20318
   351
ballarin@20318
   352
text {* @{term genideal} generates an ideal *}
ballarin@20318
   353
lemma (in ring) genideal_ideal:
ballarin@20318
   354
  assumes Scarr: "S \<subseteq> carrier R"
ballarin@20318
   355
  shows "ideal (Idl S) R"
ballarin@20318
   356
unfolding genideal_def
ballarin@20318
   357
proof (rule i_Intersect, fast, simp)
ballarin@20318
   358
  from oneideal and Scarr
ballarin@20318
   359
  show "\<exists>I. ideal I R \<and> S \<le> I" by fast
ballarin@20318
   360
qed
ballarin@20318
   361
ballarin@20318
   362
lemma (in ring) genideal_self:
ballarin@20318
   363
  assumes "S \<subseteq> carrier R"
ballarin@20318
   364
  shows "S \<subseteq> Idl S"
ballarin@20318
   365
unfolding genideal_def
ballarin@20318
   366
by fast
ballarin@20318
   367
ballarin@20318
   368
lemma (in ring) genideal_self':
ballarin@20318
   369
  assumes carr: "i \<in> carrier R"
ballarin@20318
   370
  shows "i \<in> Idl {i}"
ballarin@20318
   371
proof -
ballarin@20318
   372
  from carr
ballarin@20318
   373
      have "{i} \<subseteq> Idl {i}" by (fast intro!: genideal_self)
ballarin@20318
   374
  thus "i \<in> Idl {i}" by fast
ballarin@20318
   375
qed
ballarin@20318
   376
ballarin@20318
   377
text {* @{term genideal} generates the minimal ideal *}
ballarin@20318
   378
lemma (in ring) genideal_minimal:
ballarin@20318
   379
  assumes a: "ideal I R"
ballarin@20318
   380
      and b: "S \<subseteq> I"
ballarin@20318
   381
  shows "Idl S \<subseteq> I"
ballarin@20318
   382
unfolding genideal_def
ballarin@20318
   383
by (rule, elim InterD, simp add: a b)
ballarin@20318
   384
ballarin@20318
   385
text {* Generated ideals and subsets *}
ballarin@20318
   386
lemma (in ring) Idl_subset_ideal:
ballarin@20318
   387
  assumes Iideal: "ideal I R"
ballarin@20318
   388
      and Hcarr: "H \<subseteq> carrier R"
ballarin@20318
   389
  shows "(Idl H \<subseteq> I) = (H \<subseteq> I)"
ballarin@20318
   390
proof
ballarin@20318
   391
  assume a: "Idl H \<subseteq> I"
wenzelm@23350
   392
  from Hcarr have "H \<subseteq> Idl H" by (rule genideal_self)
ballarin@20318
   393
  from this and a
ballarin@20318
   394
      show "H \<subseteq> I" by simp
ballarin@20318
   395
next
ballarin@20318
   396
  fix x
ballarin@20318
   397
  assume HI: "H \<subseteq> I"
ballarin@20318
   398
ballarin@20318
   399
  from Iideal and HI
ballarin@20318
   400
      have "I \<in> {I. ideal I R \<and> H \<subseteq> I}" by fast
ballarin@20318
   401
  from this
ballarin@20318
   402
      show "Idl H \<subseteq> I"
ballarin@20318
   403
      unfolding genideal_def
ballarin@20318
   404
      by fast
ballarin@20318
   405
qed
ballarin@20318
   406
ballarin@20318
   407
lemma (in ring) subset_Idl_subset:
ballarin@20318
   408
  assumes Icarr: "I \<subseteq> carrier R"
ballarin@20318
   409
      and HI: "H \<subseteq> I"
ballarin@20318
   410
  shows "Idl H \<subseteq> Idl I"
ballarin@20318
   411
proof -
ballarin@20318
   412
  from HI and genideal_self[OF Icarr] 
ballarin@20318
   413
      have HIdlI: "H \<subseteq> Idl I" by fast
ballarin@20318
   414
ballarin@20318
   415
  from Icarr
ballarin@20318
   416
      have Iideal: "ideal (Idl I) R" by (rule genideal_ideal)
ballarin@20318
   417
  from HI and Icarr
ballarin@20318
   418
      have "H \<subseteq> carrier R" by fast
ballarin@20318
   419
  from Iideal and this
ballarin@20318
   420
      have "(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)"
ballarin@20318
   421
      by (rule Idl_subset_ideal[symmetric])
ballarin@20318
   422
ballarin@20318
   423
  from HIdlI and this
ballarin@20318
   424
      show "Idl H \<subseteq> Idl I" by simp
ballarin@20318
   425
qed
ballarin@20318
   426
ballarin@20318
   427
lemma (in ring) Idl_subset_ideal':
ballarin@20318
   428
  assumes acarr: "a \<in> carrier R" and bcarr: "b \<in> carrier R"
ballarin@20318
   429
  shows "(Idl {a} \<subseteq> Idl {b}) = (a \<in> Idl {b})"
ballarin@20318
   430
apply (subst Idl_subset_ideal[OF genideal_ideal[of "{b}"], of "{a}"])
ballarin@20318
   431
  apply (fast intro: bcarr, fast intro: acarr)
ballarin@20318
   432
apply fast
ballarin@20318
   433
done
ballarin@20318
   434
ballarin@20318
   435
lemma (in ring) genideal_zero:
ballarin@20318
   436
  "Idl {\<zero>} = {\<zero>}"
ballarin@20318
   437
apply rule
ballarin@20318
   438
 apply (rule genideal_minimal[OF zeroideal], simp)
ballarin@20318
   439
apply (simp add: genideal_self')
ballarin@20318
   440
done
ballarin@20318
   441
ballarin@20318
   442
lemma (in ring) genideal_one:
ballarin@20318
   443
  "Idl {\<one>} = carrier R"
ballarin@20318
   444
proof -
ballarin@29237
   445
  interpret ideal "Idl {\<one>}" "R" by (rule genideal_ideal, fast intro: one_closed)
ballarin@20318
   446
  show "Idl {\<one>} = carrier R"
ballarin@20318
   447
  apply (rule, rule a_subset)
ballarin@20318
   448
  apply (simp add: one_imp_carrier genideal_self')
ballarin@20318
   449
  done
ballarin@20318
   450
qed
ballarin@20318
   451
ballarin@20318
   452
ballarin@27717
   453
text {* Generation of Principal Ideals in Commutative Rings *}
ballarin@20318
   454
ballarin@20318
   455
constdefs (structure R)
ballarin@20318
   456
  cgenideal :: "('a, 'b) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a set"  ("PIdl\<index> _" [80] 79)
ballarin@20318
   457
  "cgenideal R a \<equiv> { x \<otimes> a | x. x \<in> carrier R }"
ballarin@20318
   458
ballarin@20318
   459
text {* genhideal (?) really generates an ideal *}
ballarin@20318
   460
lemma (in cring) cgenideal_ideal:
ballarin@20318
   461
  assumes acarr: "a \<in> carrier R"
ballarin@20318
   462
  shows "ideal (PIdl a) R"
ballarin@20318
   463
apply (unfold cgenideal_def)
ballarin@20318
   464
apply (rule idealI[OF is_ring])
ballarin@20318
   465
   apply (rule subgroup.intro)
ballarin@20318
   466
      apply (simp_all add: monoid_record_simps)
ballarin@20318
   467
      apply (blast intro: acarr m_closed)
ballarin@20318
   468
      apply clarsimp defer 1
ballarin@20318
   469
      defer 1
ballarin@20318
   470
      apply (fold a_inv_def, clarsimp) defer 1
ballarin@20318
   471
      apply clarsimp defer 1
ballarin@20318
   472
      apply clarsimp defer 1
ballarin@20318
   473
proof -
ballarin@20318
   474
  fix x y
ballarin@20318
   475
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   476
     and ycarr: "y \<in> carrier R"
ballarin@20318
   477
  note carr = acarr xcarr ycarr
ballarin@20318
   478
ballarin@20318
   479
  from carr
ballarin@20318
   480
      have "x \<otimes> a \<oplus> y \<otimes> a = (x \<oplus> y) \<otimes> a" by (simp add: l_distr)
ballarin@20318
   481
  from this and carr
ballarin@20318
   482
      show "\<exists>z. x \<otimes> a \<oplus> y \<otimes> a = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   483
next
ballarin@20318
   484
  from l_null[OF acarr, symmetric] and zero_closed
ballarin@20318
   485
      show "\<exists>x. \<zero> = x \<otimes> a \<and> x \<in> carrier R" by fast
ballarin@20318
   486
next
ballarin@20318
   487
  fix x
ballarin@20318
   488
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   489
  note carr = acarr xcarr
ballarin@20318
   490
ballarin@20318
   491
  from carr
ballarin@20318
   492
      have "\<ominus> (x \<otimes> a) = (\<ominus> x) \<otimes> a" by (simp add: l_minus)
ballarin@20318
   493
  from this and carr
ballarin@20318
   494
      show "\<exists>z. \<ominus> (x \<otimes> a) = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   495
next
ballarin@20318
   496
  fix x y
ballarin@20318
   497
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   498
     and ycarr: "y \<in> carrier R"
ballarin@20318
   499
  note carr = acarr xcarr ycarr
ballarin@20318
   500
  
ballarin@20318
   501
  from carr
ballarin@20318
   502
      have "y \<otimes> a \<otimes> x = (y \<otimes> x) \<otimes> a" by (simp add: m_assoc, simp add: m_comm)
ballarin@20318
   503
  from this and carr
ballarin@20318
   504
      show "\<exists>z. y \<otimes> a \<otimes> x = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   505
next
ballarin@20318
   506
  fix x y
ballarin@20318
   507
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   508
     and ycarr: "y \<in> carrier R"
ballarin@20318
   509
  note carr = acarr xcarr ycarr
ballarin@20318
   510
ballarin@20318
   511
  from carr
ballarin@20318
   512
      have "x \<otimes> (y \<otimes> a) = (x \<otimes> y) \<otimes> a" by (simp add: m_assoc)
ballarin@20318
   513
  from this and carr
ballarin@20318
   514
      show "\<exists>z. x \<otimes> (y \<otimes> a) = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   515
qed
ballarin@20318
   516
ballarin@20318
   517
lemma (in ring) cgenideal_self:
ballarin@20318
   518
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   519
  shows "i \<in> PIdl i"
ballarin@20318
   520
unfolding cgenideal_def
ballarin@20318
   521
proof simp
ballarin@20318
   522
  from icarr
ballarin@20318
   523
      have "i = \<one> \<otimes> i" by simp
ballarin@20318
   524
  from this and icarr
ballarin@20318
   525
      show "\<exists>x. i = x \<otimes> i \<and> x \<in> carrier R" by fast
ballarin@20318
   526
qed
ballarin@20318
   527
ballarin@20318
   528
text {* @{const "cgenideal"} is minimal *}
ballarin@20318
   529
ballarin@20318
   530
lemma (in ring) cgenideal_minimal:
ballarin@27611
   531
  assumes "ideal J R"
ballarin@20318
   532
  assumes aJ: "a \<in> J"
ballarin@20318
   533
  shows "PIdl a \<subseteq> J"
ballarin@27611
   534
proof -
ballarin@29240
   535
  interpret ideal J R by fact
ballarin@27611
   536
  show ?thesis unfolding cgenideal_def
ballarin@27611
   537
    apply rule
ballarin@27611
   538
    apply clarify
ballarin@27611
   539
    using aJ
ballarin@27611
   540
    apply (erule I_l_closed)
ballarin@27611
   541
    done
ballarin@27611
   542
qed
ballarin@20318
   543
ballarin@20318
   544
lemma (in cring) cgenideal_eq_genideal:
ballarin@20318
   545
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   546
  shows "PIdl i = Idl {i}"
ballarin@20318
   547
apply rule
ballarin@20318
   548
 apply (intro cgenideal_minimal)
ballarin@20318
   549
  apply (rule genideal_ideal, fast intro: icarr)
ballarin@20318
   550
 apply (rule genideal_self', fast intro: icarr)
ballarin@20318
   551
apply (intro genideal_minimal)
wenzelm@23463
   552
 apply (rule cgenideal_ideal [OF icarr])
wenzelm@23463
   553
apply (simp, rule cgenideal_self [OF icarr])
ballarin@20318
   554
done
ballarin@20318
   555
ballarin@20318
   556
lemma (in cring) cgenideal_eq_rcos:
ballarin@20318
   557
 "PIdl i = carrier R #> i"
ballarin@20318
   558
unfolding cgenideal_def r_coset_def
ballarin@20318
   559
by fast
ballarin@20318
   560
ballarin@20318
   561
lemma (in cring) cgenideal_is_principalideal:
ballarin@20318
   562
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   563
  shows "principalideal (PIdl i) R"
ballarin@20318
   564
apply (rule principalidealI)
wenzelm@23464
   565
apply (rule cgenideal_ideal [OF icarr])
ballarin@20318
   566
proof -
ballarin@20318
   567
  from icarr
ballarin@20318
   568
      have "PIdl i = Idl {i}" by (rule cgenideal_eq_genideal)
ballarin@20318
   569
  from icarr and this
ballarin@20318
   570
      show "\<exists>i'\<in>carrier R. PIdl i = Idl {i'}" by fast
ballarin@20318
   571
qed
ballarin@20318
   572
ballarin@20318
   573
ballarin@20318
   574
subsection {* Union of Ideals *}
ballarin@20318
   575
ballarin@20318
   576
lemma (in ring) union_genideal:
ballarin@20318
   577
  assumes idealI: "ideal I R"
ballarin@20318
   578
      and idealJ: "ideal J R"
ballarin@20318
   579
  shows "Idl (I \<union> J) = I <+> J"
ballarin@20318
   580
apply rule
ballarin@20318
   581
 apply (rule ring.genideal_minimal)
ballarin@29240
   582
   apply (rule is_ring)
ballarin@20318
   583
  apply (rule add_ideals[OF idealI idealJ])
ballarin@20318
   584
 apply (rule)
ballarin@20318
   585
 apply (simp add: set_add_defs) apply (elim disjE) defer 1 defer 1
ballarin@20318
   586
 apply (rule) apply (simp add: set_add_defs genideal_def) apply clarsimp defer 1
ballarin@20318
   587
proof -
ballarin@20318
   588
  fix x
ballarin@20318
   589
  assume xI: "x \<in> I"
ballarin@20318
   590
  have ZJ: "\<zero> \<in> J"
ballarin@20318
   591
      by (intro additive_subgroup.zero_closed, rule ideal.axioms[OF idealJ])
ballarin@20318
   592
  from ideal.Icarr[OF idealI xI]
ballarin@20318
   593
      have "x = x \<oplus> \<zero>" by algebra
ballarin@20318
   594
  from xI and ZJ and this
ballarin@20318
   595
      show "\<exists>h\<in>I. \<exists>k\<in>J. x = h \<oplus> k" by fast
ballarin@20318
   596
next
ballarin@20318
   597
  fix x
ballarin@20318
   598
  assume xJ: "x \<in> J"
ballarin@20318
   599
  have ZI: "\<zero> \<in> I"
ballarin@20318
   600
      by (intro additive_subgroup.zero_closed, rule ideal.axioms[OF idealI])
ballarin@20318
   601
  from ideal.Icarr[OF idealJ xJ]
ballarin@20318
   602
      have "x = \<zero> \<oplus> x" by algebra
ballarin@20318
   603
  from ZI and xJ and this
ballarin@20318
   604
      show "\<exists>h\<in>I. \<exists>k\<in>J. x = h \<oplus> k" by fast
ballarin@20318
   605
next
ballarin@20318
   606
  fix i j K
ballarin@20318
   607
  assume iI: "i \<in> I"
ballarin@20318
   608
     and jJ: "j \<in> J"
ballarin@20318
   609
     and idealK: "ideal K R"
ballarin@20318
   610
     and IK: "I \<subseteq> K"
ballarin@20318
   611
     and JK: "J \<subseteq> K"
ballarin@20318
   612
  from iI and IK
ballarin@20318
   613
     have iK: "i \<in> K" by fast
ballarin@20318
   614
  from jJ and JK
ballarin@20318
   615
     have jK: "j \<in> K" by fast
ballarin@20318
   616
  from iK and jK
ballarin@20318
   617
     show "i \<oplus> j \<in> K" by (intro additive_subgroup.a_closed) (rule ideal.axioms[OF idealK])
ballarin@20318
   618
qed
ballarin@20318
   619
ballarin@20318
   620
ballarin@20318
   621
subsection {* Properties of Principal Ideals *}
ballarin@20318
   622
ballarin@20318
   623
text {* @{text "\<zero>"} generates the zero ideal *}
ballarin@20318
   624
lemma (in ring) zero_genideal:
ballarin@20318
   625
  shows "Idl {\<zero>} = {\<zero>}"
ballarin@20318
   626
apply rule
ballarin@20318
   627
apply (simp add: genideal_minimal zeroideal)
ballarin@20318
   628
apply (fast intro!: genideal_self)
ballarin@20318
   629
done
ballarin@20318
   630
ballarin@20318
   631
text {* @{text "\<one>"} generates the unit ideal *}
ballarin@20318
   632
lemma (in ring) one_genideal:
ballarin@20318
   633
  shows "Idl {\<one>} = carrier R"
ballarin@20318
   634
proof -
ballarin@20318
   635
  have "\<one> \<in> Idl {\<one>}" by (simp add: genideal_self')
ballarin@20318
   636
  thus "Idl {\<one>} = carrier R" by (intro ideal.one_imp_carrier, fast intro: genideal_ideal)
ballarin@20318
   637
qed
ballarin@20318
   638
ballarin@20318
   639
ballarin@20318
   640
text {* The zero ideal is a principal ideal *}
ballarin@20318
   641
corollary (in ring) zeropideal:
ballarin@20318
   642
  shows "principalideal {\<zero>} R"
ballarin@20318
   643
apply (rule principalidealI)
ballarin@20318
   644
 apply (rule zeroideal)
ballarin@20318
   645
apply (blast intro!: zero_closed zero_genideal[symmetric])
ballarin@20318
   646
done
ballarin@20318
   647
ballarin@20318
   648
text {* The unit ideal is a principal ideal *}
ballarin@20318
   649
corollary (in ring) onepideal:
ballarin@20318
   650
  shows "principalideal (carrier R) R"
ballarin@20318
   651
apply (rule principalidealI)
ballarin@20318
   652
 apply (rule oneideal)
ballarin@20318
   653
apply (blast intro!: one_closed one_genideal[symmetric])
ballarin@20318
   654
done
ballarin@20318
   655
ballarin@20318
   656
ballarin@20318
   657
text {* Every principal ideal is a right coset of the carrier *}
ballarin@20318
   658
lemma (in principalideal) rcos_generate:
ballarin@27611
   659
  assumes "cring R"
ballarin@20318
   660
  shows "\<exists>x\<in>I. I = carrier R #> x"
ballarin@20318
   661
proof -
ballarin@29237
   662
  interpret cring R by fact
ballarin@20318
   663
  from generate
ballarin@20318
   664
      obtain i
ballarin@20318
   665
        where icarr: "i \<in> carrier R"
ballarin@20318
   666
        and I1: "I = Idl {i}"
ballarin@20318
   667
      by fast+
ballarin@20318
   668
ballarin@20318
   669
  from icarr and genideal_self[of "{i}"]
ballarin@20318
   670
      have "i \<in> Idl {i}" by fast
ballarin@20318
   671
  hence iI: "i \<in> I" by (simp add: I1)
ballarin@20318
   672
ballarin@20318
   673
  from I1 icarr
ballarin@20318
   674
      have I2: "I = PIdl i" by (simp add: cgenideal_eq_genideal)
ballarin@20318
   675
ballarin@20318
   676
  have "PIdl i = carrier R #> i"
ballarin@20318
   677
      unfolding cgenideal_def r_coset_def
ballarin@20318
   678
      by fast
ballarin@20318
   679
ballarin@20318
   680
  from I2 and this
ballarin@20318
   681
      have "I = carrier R #> i" by simp
ballarin@20318
   682
ballarin@20318
   683
  from iI and this
ballarin@20318
   684
      show "\<exists>x\<in>I. I = carrier R #> x" by fast
ballarin@20318
   685
qed
ballarin@20318
   686
ballarin@20318
   687
ballarin@20318
   688
subsection {* Prime Ideals *}
ballarin@20318
   689
ballarin@20318
   690
lemma (in ideal) primeidealCD:
ballarin@27611
   691
  assumes "cring R"
ballarin@20318
   692
  assumes notprime: "\<not> primeideal I R"
ballarin@20318
   693
  shows "carrier R = I \<or> (\<exists>a b. a \<in> carrier R \<and> b \<in> carrier R \<and> a \<otimes> b \<in> I \<and> a \<notin> I \<and> b \<notin> I)"
ballarin@20318
   694
proof (rule ccontr, clarsimp)
ballarin@29237
   695
  interpret cring R by fact
ballarin@20318
   696
  assume InR: "carrier R \<noteq> I"
ballarin@20318
   697
     and "\<forall>a. a \<in> carrier R \<longrightarrow> (\<forall>b. a \<otimes> b \<in> I \<longrightarrow> b \<in> carrier R \<longrightarrow> a \<in> I \<or> b \<in> I)"
ballarin@20318
   698
  hence I_prime: "\<And> a b. \<lbrakk>a \<in> carrier R; b \<in> carrier R; a \<otimes> b \<in> I\<rbrakk> \<Longrightarrow> a \<in> I \<or> b \<in> I" by simp
ballarin@20318
   699
  have "primeideal I R"
wenzelm@23464
   700
      apply (rule primeideal.intro [OF is_ideal is_cring])
wenzelm@23464
   701
      apply (rule primeideal_axioms.intro)
wenzelm@23464
   702
       apply (rule InR)
wenzelm@23464
   703
      apply (erule (2) I_prime)
wenzelm@23464
   704
      done
ballarin@20318
   705
  from this and notprime
ballarin@20318
   706
      show "False" by simp
ballarin@20318
   707
qed
ballarin@20318
   708
ballarin@20318
   709
lemma (in ideal) primeidealCE:
ballarin@27611
   710
  assumes "cring R"
ballarin@20318
   711
  assumes notprime: "\<not> primeideal I R"
wenzelm@23383
   712
  obtains "carrier R = I"
wenzelm@23383
   713
    | "\<exists>a b. a \<in> carrier R \<and> b \<in> carrier R \<and> a \<otimes> b \<in> I \<and> a \<notin> I \<and> b \<notin> I"
ballarin@27611
   714
proof -
ballarin@29237
   715
  interpret R!: cring R by fact
ballarin@27611
   716
  assume "carrier R = I ==> thesis"
ballarin@27611
   717
    and "\<exists>a b. a \<in> carrier R \<and> b \<in> carrier R \<and> a \<otimes> b \<in> I \<and> a \<notin> I \<and> b \<notin> I \<Longrightarrow> thesis"
ballarin@27611
   718
  then show thesis using primeidealCD [OF R.is_cring notprime] by blast
ballarin@27611
   719
qed
ballarin@20318
   720
ballarin@20318
   721
text {* If @{text "{\<zero>}"} is a prime ideal of a commutative ring, the ring is a domain *}
ballarin@20318
   722
lemma (in cring) zeroprimeideal_domainI:
ballarin@20318
   723
  assumes pi: "primeideal {\<zero>} R"
ballarin@20318
   724
  shows "domain R"
wenzelm@23464
   725
apply (rule domain.intro, rule is_cring)
ballarin@20318
   726
apply (rule domain_axioms.intro)
ballarin@20318
   727
proof (rule ccontr, simp)
ballarin@29237
   728
  interpret primeideal "{\<zero>}" "R" by (rule pi)
ballarin@20318
   729
  assume "\<one> = \<zero>"
ballarin@20318
   730
  hence "carrier R = {\<zero>}" by (rule one_zeroD)
ballarin@20318
   731
  from this[symmetric] and I_notcarr
ballarin@20318
   732
      show "False" by simp
ballarin@20318
   733
next
ballarin@29237
   734
  interpret primeideal "{\<zero>}" "R" by (rule pi)
ballarin@20318
   735
  fix a b
ballarin@20318
   736
  assume ab: "a \<otimes> b = \<zero>"
ballarin@20318
   737
     and carr: "a \<in> carrier R" "b \<in> carrier R"
ballarin@20318
   738
  from ab
ballarin@20318
   739
      have abI: "a \<otimes> b \<in> {\<zero>}" by fast
ballarin@20318
   740
  from carr and this
ballarin@20318
   741
      have "a \<in> {\<zero>} \<or> b \<in> {\<zero>}" by (rule I_prime)
ballarin@20318
   742
  thus "a = \<zero> \<or> b = \<zero>" by simp
ballarin@20318
   743
qed
ballarin@20318
   744
ballarin@20318
   745
corollary (in cring) domain_eq_zeroprimeideal:
ballarin@20318
   746
  shows "domain R = primeideal {\<zero>} R"
ballarin@20318
   747
apply rule
ballarin@20318
   748
 apply (erule domain.zeroprimeideal)
ballarin@20318
   749
apply (erule zeroprimeideal_domainI)
ballarin@20318
   750
done
ballarin@20318
   751
ballarin@20318
   752
ballarin@20318
   753
subsection {* Maximal Ideals *}
ballarin@20318
   754
ballarin@20318
   755
lemma (in ideal) helper_I_closed:
ballarin@20318
   756
  assumes carr: "a \<in> carrier R" "x \<in> carrier R" "y \<in> carrier R"
ballarin@20318
   757
      and axI: "a \<otimes> x \<in> I"
ballarin@20318
   758
  shows "a \<otimes> (x \<otimes> y) \<in> I"
ballarin@20318
   759
proof -
ballarin@20318
   760
  from axI and carr
ballarin@20318
   761
     have "(a \<otimes> x) \<otimes> y \<in> I" by (simp add: I_r_closed)
ballarin@20318
   762
  also from carr
ballarin@20318
   763
     have "(a \<otimes> x) \<otimes> y = a \<otimes> (x \<otimes> y)" by (simp add: m_assoc)
ballarin@20318
   764
  finally
ballarin@20318
   765
     show "a \<otimes> (x \<otimes> y) \<in> I" .
ballarin@20318
   766
qed
ballarin@20318
   767
ballarin@20318
   768
lemma (in ideal) helper_max_prime:
ballarin@27611
   769
  assumes "cring R"
ballarin@20318
   770
  assumes acarr: "a \<in> carrier R"
ballarin@20318
   771
  shows "ideal {x\<in>carrier R. a \<otimes> x \<in> I} R"
ballarin@27611
   772
proof -
ballarin@29237
   773
  interpret cring R by fact
ballarin@27611
   774
  show ?thesis apply (rule idealI)
ballarin@27611
   775
    apply (rule cring.axioms[OF is_cring])
ballarin@27611
   776
    apply (rule subgroup.intro)
ballarin@27611
   777
    apply (simp, fast)
ballarin@20318
   778
    apply clarsimp apply (simp add: r_distr acarr)
ballarin@27611
   779
    apply (simp add: acarr)
ballarin@27611
   780
    apply (simp add: a_inv_def[symmetric], clarify) defer 1
ballarin@27611
   781
    apply clarsimp defer 1
ballarin@27611
   782
    apply (fast intro!: helper_I_closed acarr)
ballarin@27611
   783
  proof -
ballarin@27611
   784
    fix x
ballarin@27611
   785
    assume xcarr: "x \<in> carrier R"
ballarin@27611
   786
      and ax: "a \<otimes> x \<in> I"
ballarin@27611
   787
    from ax and acarr xcarr
ballarin@27611
   788
    have "\<ominus>(a \<otimes> x) \<in> I" by simp
ballarin@27611
   789
    also from acarr xcarr
ballarin@27611
   790
    have "\<ominus>(a \<otimes> x) = a \<otimes> (\<ominus>x)" by algebra
ballarin@27611
   791
    finally
ballarin@27611
   792
    show "a \<otimes> (\<ominus>x) \<in> I" .
ballarin@27611
   793
    from acarr
ballarin@27611
   794
    have "a \<otimes> \<zero> = \<zero>" by simp
ballarin@27611
   795
  next
ballarin@27611
   796
    fix x y
ballarin@27611
   797
    assume xcarr: "x \<in> carrier R"
ballarin@27611
   798
      and ycarr: "y \<in> carrier R"
ballarin@27611
   799
      and ayI: "a \<otimes> y \<in> I"
ballarin@27611
   800
    from ayI and acarr xcarr ycarr
ballarin@27611
   801
    have "a \<otimes> (y \<otimes> x) \<in> I" by (simp add: helper_I_closed)
ballarin@27611
   802
    moreover from xcarr ycarr
ballarin@27611
   803
    have "y \<otimes> x = x \<otimes> y" by (simp add: m_comm)
ballarin@27611
   804
    ultimately
ballarin@27611
   805
    show "a \<otimes> (x \<otimes> y) \<in> I" by simp
ballarin@27611
   806
  qed
ballarin@20318
   807
qed
ballarin@20318
   808
ballarin@20318
   809
text {* In a cring every maximal ideal is prime *}
ballarin@20318
   810
lemma (in cring) maximalideal_is_prime:
ballarin@27611
   811
  assumes "maximalideal I R"
ballarin@20318
   812
  shows "primeideal I R"
ballarin@20318
   813
proof -
ballarin@29237
   814
  interpret maximalideal I R by fact
ballarin@27611
   815
  show ?thesis apply (rule ccontr)
ballarin@27611
   816
    apply (rule primeidealCE)
ballarin@27611
   817
    apply (rule is_cring)
ballarin@27611
   818
    apply assumption
ballarin@27611
   819
    apply (simp add: I_notcarr)
ballarin@27611
   820
  proof -
ballarin@27611
   821
    assume "\<exists>a b. a \<in> carrier R \<and> b \<in> carrier R \<and> a \<otimes> b \<in> I \<and> a \<notin> I \<and> b \<notin> I"
ballarin@27611
   822
    from this
ballarin@27611
   823
    obtain a b
ballarin@27611
   824
      where acarr: "a \<in> carrier R"
ballarin@27611
   825
      and bcarr: "b \<in> carrier R"
ballarin@27611
   826
      and abI: "a \<otimes> b \<in> I"
ballarin@27611
   827
      and anI: "a \<notin> I"
ballarin@27611
   828
      and bnI: "b \<notin> I"
ballarin@20318
   829
      by fast
ballarin@27611
   830
    def J \<equiv> "{x\<in>carrier R. a \<otimes> x \<in> I}"
ballarin@27611
   831
    
ballarin@29240
   832
    from is_cring and acarr
ballarin@27611
   833
    have idealJ: "ideal J R" unfolding J_def by (rule helper_max_prime)
ballarin@27611
   834
    
ballarin@27611
   835
    have IsubJ: "I \<subseteq> J"
ballarin@27611
   836
    proof
ballarin@27611
   837
      fix x
ballarin@27611
   838
      assume xI: "x \<in> I"
ballarin@27611
   839
      from this and acarr
ballarin@27611
   840
      have "a \<otimes> x \<in> I" by (intro I_l_closed)
ballarin@27611
   841
      from xI[THEN a_Hcarr] this
ballarin@27611
   842
      show "x \<in> J" unfolding J_def by fast
ballarin@27611
   843
    qed
ballarin@27611
   844
    
ballarin@27611
   845
    from abI and acarr bcarr
ballarin@27611
   846
    have "b \<in> J" unfolding J_def by fast
ballarin@27611
   847
    from bnI and this
ballarin@27611
   848
    have JnI: "J \<noteq> I" by fast
ballarin@27611
   849
    from acarr
ballarin@27611
   850
    have "a = a \<otimes> \<one>" by algebra
ballarin@27611
   851
    from this and anI
ballarin@27611
   852
    have "a \<otimes> \<one> \<notin> I" by simp
ballarin@27611
   853
    from one_closed and this
ballarin@27611
   854
    have "\<one> \<notin> J" unfolding J_def by fast
ballarin@27611
   855
    hence Jncarr: "J \<noteq> carrier R" by fast
ballarin@27611
   856
    
ballarin@29237
   857
    interpret ideal J R by (rule idealJ)
ballarin@27611
   858
    
ballarin@27611
   859
    have "J = I \<or> J = carrier R"
ballarin@27611
   860
      apply (intro I_maximal)
ballarin@27611
   861
      apply (rule idealJ)
ballarin@27611
   862
      apply (rule IsubJ)
ballarin@27611
   863
      apply (rule a_subset)
ballarin@27611
   864
      done
ballarin@27611
   865
    
ballarin@27611
   866
    from this and JnI and Jncarr
ballarin@27611
   867
    show "False" by simp
ballarin@20318
   868
  qed
ballarin@20318
   869
qed
ballarin@20318
   870
ballarin@27717
   871
subsection {* Derived Theorems *}
ballarin@20318
   872
ballarin@20318
   873
--"A non-zero cring that has only the two trivial ideals is a field"
ballarin@20318
   874
lemma (in cring) trivialideals_fieldI:
ballarin@20318
   875
  assumes carrnzero: "carrier R \<noteq> {\<zero>}"
ballarin@20318
   876
      and haveideals: "{I. ideal I R} = {{\<zero>}, carrier R}"
ballarin@20318
   877
  shows "field R"
ballarin@20318
   878
apply (rule cring_fieldI)
ballarin@20318
   879
apply (rule, rule, rule)
ballarin@20318
   880
 apply (erule Units_closed)
ballarin@20318
   881
defer 1
ballarin@20318
   882
  apply rule
ballarin@20318
   883
defer 1
ballarin@20318
   884
proof (rule ccontr, simp)
ballarin@20318
   885
  assume zUnit: "\<zero> \<in> Units R"
ballarin@20318
   886
  hence a: "\<zero> \<otimes> inv \<zero> = \<one>" by (rule Units_r_inv)
ballarin@20318
   887
  from zUnit
ballarin@20318
   888
      have "\<zero> \<otimes> inv \<zero> = \<zero>" by (intro l_null, rule Units_inv_closed)
ballarin@20318
   889
  from a[symmetric] and this
ballarin@20318
   890
      have "\<one> = \<zero>" by simp
ballarin@20318
   891
  hence "carrier R = {\<zero>}" by (rule one_zeroD)
ballarin@20318
   892
  from this and carrnzero
ballarin@20318
   893
      show "False" by simp
ballarin@20318
   894
next
ballarin@20318
   895
  fix x
ballarin@20318
   896
  assume xcarr': "x \<in> carrier R - {\<zero>}"
ballarin@20318
   897
  hence xcarr: "x \<in> carrier R" by fast
ballarin@20318
   898
  from xcarr'
ballarin@20318
   899
      have xnZ: "x \<noteq> \<zero>" by fast
ballarin@20318
   900
  from xcarr
ballarin@20318
   901
      have xIdl: "ideal (PIdl x) R" by (intro cgenideal_ideal, fast)
ballarin@20318
   902
ballarin@20318
   903
  from xcarr
ballarin@20318
   904
      have "x \<in> PIdl x" by (intro cgenideal_self, fast)
ballarin@20318
   905
  from this and xnZ
ballarin@20318
   906
      have "PIdl x \<noteq> {\<zero>}" by fast
ballarin@20318
   907
  from haveideals and this
ballarin@20318
   908
      have "PIdl x = carrier R"
ballarin@20318
   909
      by (blast intro!: xIdl)
ballarin@20318
   910
  hence "\<one> \<in> PIdl x" by simp
ballarin@20318
   911
  hence "\<exists>y. \<one> = y \<otimes> x \<and> y \<in> carrier R" unfolding cgenideal_def by blast
ballarin@20318
   912
  from this
ballarin@20318
   913
      obtain y
ballarin@20318
   914
        where ycarr: " y \<in> carrier R"
ballarin@20318
   915
        and ylinv: "\<one> = y \<otimes> x"
ballarin@20318
   916
      by fast+
ballarin@20318
   917
  from ylinv and xcarr ycarr
ballarin@20318
   918
      have yrinv: "\<one> = x \<otimes> y" by (simp add: m_comm)
ballarin@20318
   919
  from ycarr and ylinv[symmetric] and yrinv[symmetric]
ballarin@20318
   920
      have "\<exists>y \<in> carrier R. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast
ballarin@20318
   921
  from this and xcarr
ballarin@20318
   922
      show "x \<in> Units R"
ballarin@20318
   923
      unfolding Units_def
ballarin@20318
   924
      by fast
ballarin@20318
   925
qed
ballarin@20318
   926
ballarin@20318
   927
lemma (in field) all_ideals:
ballarin@20318
   928
  shows "{I. ideal I R} = {{\<zero>}, carrier R}"
ballarin@20318
   929
apply (rule, rule)
ballarin@20318
   930
proof -
ballarin@20318
   931
  fix I
ballarin@20318
   932
  assume a: "I \<in> {I. ideal I R}"
ballarin@20318
   933
  with this
ballarin@29237
   934
      interpret ideal I R by simp
ballarin@20318
   935
ballarin@20318
   936
  show "I \<in> {{\<zero>}, carrier R}"
ballarin@20318
   937
  proof (cases "\<exists>a. a \<in> I - {\<zero>}")
ballarin@20318
   938
    assume "\<exists>a. a \<in> I - {\<zero>}"
ballarin@20318
   939
    from this
ballarin@20318
   940
        obtain a
ballarin@20318
   941
          where aI: "a \<in> I"
ballarin@20318
   942
          and anZ: "a \<noteq> \<zero>"
ballarin@20318
   943
        by fast+
ballarin@20318
   944
    from aI[THEN a_Hcarr] anZ
ballarin@20318
   945
        have aUnit: "a \<in> Units R" by (simp add: field_Units)
ballarin@20318
   946
    hence a: "a \<otimes> inv a = \<one>" by (rule Units_r_inv)
ballarin@20318
   947
    from aI and aUnit
ballarin@27698
   948
        have "a \<otimes> inv a \<in> I" by (simp add: I_r_closed del: Units_r_inv)
ballarin@20318
   949
    hence oneI: "\<one> \<in> I" by (simp add: a[symmetric])
ballarin@20318
   950
ballarin@20318
   951
    have "carrier R \<subseteq> I"
ballarin@20318
   952
    proof
ballarin@20318
   953
      fix x
ballarin@20318
   954
      assume xcarr: "x \<in> carrier R"
ballarin@20318
   955
      from oneI and this
ballarin@20318
   956
          have "\<one> \<otimes> x \<in> I" by (rule I_r_closed)
ballarin@20318
   957
      from this and xcarr
ballarin@20318
   958
          show "x \<in> I" by simp
ballarin@20318
   959
    qed
ballarin@20318
   960
    from this and a_subset
ballarin@20318
   961
        have "I = carrier R" by fast
ballarin@20318
   962
    thus "I \<in> {{\<zero>}, carrier R}" by fast
ballarin@20318
   963
  next
ballarin@20318
   964
    assume "\<not> (\<exists>a. a \<in> I - {\<zero>})"
ballarin@20318
   965
    hence IZ: "\<And>a. a \<in> I \<Longrightarrow> a = \<zero>" by simp
ballarin@20318
   966
ballarin@20318
   967
    have a: "I \<subseteq> {\<zero>}"
ballarin@20318
   968
    proof
ballarin@20318
   969
      fix x
ballarin@20318
   970
      assume "x \<in> I"
ballarin@20318
   971
      hence "x = \<zero>" by (rule IZ)
ballarin@20318
   972
      thus "x \<in> {\<zero>}" by fast
ballarin@20318
   973
    qed
ballarin@20318
   974
ballarin@20318
   975
    have "\<zero> \<in> I" by simp
ballarin@20318
   976
    hence "{\<zero>} \<subseteq> I" by fast
ballarin@20318
   977
ballarin@20318
   978
    from this and a
ballarin@20318
   979
        have "I = {\<zero>}" by fast
ballarin@20318
   980
    thus "I \<in> {{\<zero>}, carrier R}" by fast
ballarin@20318
   981
  qed
ballarin@20318
   982
qed (simp add: zeroideal oneideal)
ballarin@20318
   983
ballarin@20318
   984
--"Jacobson Theorem 2.2"
ballarin@20318
   985
lemma (in cring) trivialideals_eq_field:
ballarin@20318
   986
  assumes carrnzero: "carrier R \<noteq> {\<zero>}"
ballarin@20318
   987
  shows "({I. ideal I R} = {{\<zero>}, carrier R}) = field R"
ballarin@20318
   988
by (fast intro!: trivialideals_fieldI[OF carrnzero] field.all_ideals)
ballarin@20318
   989
ballarin@20318
   990
ballarin@20318
   991
text {* Like zeroprimeideal for domains *}
ballarin@20318
   992
lemma (in field) zeromaximalideal:
ballarin@20318
   993
  "maximalideal {\<zero>} R"
ballarin@20318
   994
apply (rule maximalidealI)
ballarin@20318
   995
  apply (rule zeroideal)
ballarin@20318
   996
proof-
ballarin@20318
   997
  from one_not_zero
ballarin@20318
   998
      have "\<one> \<notin> {\<zero>}" by simp
ballarin@20318
   999
  from this and one_closed
ballarin@20318
  1000
      show "carrier R \<noteq> {\<zero>}" by fast
ballarin@20318
  1001
next
ballarin@20318
  1002
  fix J
ballarin@20318
  1003
  assume Jideal: "ideal J R"
ballarin@20318
  1004
  hence "J \<in> {I. ideal I R}"
ballarin@20318
  1005
      by fast
ballarin@20318
  1006
ballarin@20318
  1007
  from this and all_ideals
ballarin@20318
  1008
      show "J = {\<zero>} \<or> J = carrier R" by simp
ballarin@20318
  1009
qed
ballarin@20318
  1010
ballarin@20318
  1011
lemma (in cring) zeromaximalideal_fieldI:
ballarin@20318
  1012
  assumes zeromax: "maximalideal {\<zero>} R"
ballarin@20318
  1013
  shows "field R"
ballarin@20318
  1014
apply (rule trivialideals_fieldI, rule maximalideal.I_notcarr[OF zeromax])
ballarin@20318
  1015
apply rule apply clarsimp defer 1
ballarin@20318
  1016
 apply (simp add: zeroideal oneideal)
ballarin@20318
  1017
proof -
ballarin@20318
  1018
  fix J
ballarin@20318
  1019
  assume Jn0: "J \<noteq> {\<zero>}"
ballarin@20318
  1020
     and idealJ: "ideal J R"
ballarin@29237
  1021
  interpret ideal J R by (rule idealJ)
ballarin@20318
  1022
  have "{\<zero>} \<subseteq> J" by (rule ccontr, simp)
ballarin@20318
  1023
  from zeromax and idealJ and this and a_subset
ballarin@20318
  1024
      have "J = {\<zero>} \<or> J = carrier R" by (rule maximalideal.I_maximal)
ballarin@20318
  1025
  from this and Jn0
ballarin@20318
  1026
      show "J = carrier R" by simp
ballarin@20318
  1027
qed
ballarin@20318
  1028
ballarin@20318
  1029
lemma (in cring) zeromaximalideal_eq_field:
ballarin@20318
  1030
  "maximalideal {\<zero>} R = field R"
ballarin@20318
  1031
apply rule
ballarin@20318
  1032
 apply (erule zeromaximalideal_fieldI)
ballarin@20318
  1033
apply (erule field.zeromaximalideal)
ballarin@20318
  1034
done
ballarin@20318
  1035
ballarin@20318
  1036
end