src/HOL/Algebra/Ideal.thy
author wenzelm
Sun Mar 21 15:57:40 2010 +0100 (2010-03-21)
changeset 35847 19f1f7066917
parent 30729 461ee3e49ad3
child 35848 5443079512ea
permissions -rw-r--r--
eliminated old constdefs;
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
wenzelm@30363
    48
subsubsection (in ring) {* Ideals Generated by a Subset of @{term "carrier R"} *}
ballarin@20318
    49
wenzelm@35847
    50
definition
ballarin@20318
    51
  genideal :: "('a, 'b) ring_scheme \<Rightarrow> 'a set \<Rightarrow> 'a set"  ("Idl\<index> _" [80] 79)
wenzelm@35847
    52
  where "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
wenzelm@30363
   349
subsection (in ring) {* Ideals generated by a subset of @{term "carrier R"} *}
ballarin@20318
   350
ballarin@20318
   351
text {* @{term genideal} generates an ideal *}
ballarin@20318
   352
lemma (in ring) genideal_ideal:
ballarin@20318
   353
  assumes Scarr: "S \<subseteq> carrier R"
ballarin@20318
   354
  shows "ideal (Idl S) R"
ballarin@20318
   355
unfolding genideal_def
ballarin@20318
   356
proof (rule i_Intersect, fast, simp)
ballarin@20318
   357
  from oneideal and Scarr
ballarin@20318
   358
  show "\<exists>I. ideal I R \<and> S \<le> I" by fast
ballarin@20318
   359
qed
ballarin@20318
   360
ballarin@20318
   361
lemma (in ring) genideal_self:
ballarin@20318
   362
  assumes "S \<subseteq> carrier R"
ballarin@20318
   363
  shows "S \<subseteq> Idl S"
ballarin@20318
   364
unfolding genideal_def
ballarin@20318
   365
by fast
ballarin@20318
   366
ballarin@20318
   367
lemma (in ring) genideal_self':
ballarin@20318
   368
  assumes carr: "i \<in> carrier R"
ballarin@20318
   369
  shows "i \<in> Idl {i}"
ballarin@20318
   370
proof -
ballarin@20318
   371
  from carr
ballarin@20318
   372
      have "{i} \<subseteq> Idl {i}" by (fast intro!: genideal_self)
ballarin@20318
   373
  thus "i \<in> Idl {i}" by fast
ballarin@20318
   374
qed
ballarin@20318
   375
ballarin@20318
   376
text {* @{term genideal} generates the minimal ideal *}
ballarin@20318
   377
lemma (in ring) genideal_minimal:
ballarin@20318
   378
  assumes a: "ideal I R"
ballarin@20318
   379
      and b: "S \<subseteq> I"
ballarin@20318
   380
  shows "Idl S \<subseteq> I"
ballarin@20318
   381
unfolding genideal_def
ballarin@20318
   382
by (rule, elim InterD, simp add: a b)
ballarin@20318
   383
ballarin@20318
   384
text {* Generated ideals and subsets *}
ballarin@20318
   385
lemma (in ring) Idl_subset_ideal:
ballarin@20318
   386
  assumes Iideal: "ideal I R"
ballarin@20318
   387
      and Hcarr: "H \<subseteq> carrier R"
ballarin@20318
   388
  shows "(Idl H \<subseteq> I) = (H \<subseteq> I)"
ballarin@20318
   389
proof
ballarin@20318
   390
  assume a: "Idl H \<subseteq> I"
wenzelm@23350
   391
  from Hcarr have "H \<subseteq> Idl H" by (rule genideal_self)
ballarin@20318
   392
  from this and a
ballarin@20318
   393
      show "H \<subseteq> I" by simp
ballarin@20318
   394
next
ballarin@20318
   395
  fix x
ballarin@20318
   396
  assume HI: "H \<subseteq> I"
ballarin@20318
   397
ballarin@20318
   398
  from Iideal and HI
ballarin@20318
   399
      have "I \<in> {I. ideal I R \<and> H \<subseteq> I}" by fast
ballarin@20318
   400
  from this
ballarin@20318
   401
      show "Idl H \<subseteq> I"
ballarin@20318
   402
      unfolding genideal_def
ballarin@20318
   403
      by fast
ballarin@20318
   404
qed
ballarin@20318
   405
ballarin@20318
   406
lemma (in ring) subset_Idl_subset:
ballarin@20318
   407
  assumes Icarr: "I \<subseteq> carrier R"
ballarin@20318
   408
      and HI: "H \<subseteq> I"
ballarin@20318
   409
  shows "Idl H \<subseteq> Idl I"
ballarin@20318
   410
proof -
ballarin@20318
   411
  from HI and genideal_self[OF Icarr] 
ballarin@20318
   412
      have HIdlI: "H \<subseteq> Idl I" by fast
ballarin@20318
   413
ballarin@20318
   414
  from Icarr
ballarin@20318
   415
      have Iideal: "ideal (Idl I) R" by (rule genideal_ideal)
ballarin@20318
   416
  from HI and Icarr
ballarin@20318
   417
      have "H \<subseteq> carrier R" by fast
ballarin@20318
   418
  from Iideal and this
ballarin@20318
   419
      have "(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)"
ballarin@20318
   420
      by (rule Idl_subset_ideal[symmetric])
ballarin@20318
   421
ballarin@20318
   422
  from HIdlI and this
ballarin@20318
   423
      show "Idl H \<subseteq> Idl I" by simp
ballarin@20318
   424
qed
ballarin@20318
   425
ballarin@20318
   426
lemma (in ring) Idl_subset_ideal':
ballarin@20318
   427
  assumes acarr: "a \<in> carrier R" and bcarr: "b \<in> carrier R"
ballarin@20318
   428
  shows "(Idl {a} \<subseteq> Idl {b}) = (a \<in> Idl {b})"
ballarin@20318
   429
apply (subst Idl_subset_ideal[OF genideal_ideal[of "{b}"], of "{a}"])
ballarin@20318
   430
  apply (fast intro: bcarr, fast intro: acarr)
ballarin@20318
   431
apply fast
ballarin@20318
   432
done
ballarin@20318
   433
ballarin@20318
   434
lemma (in ring) genideal_zero:
ballarin@20318
   435
  "Idl {\<zero>} = {\<zero>}"
ballarin@20318
   436
apply rule
ballarin@20318
   437
 apply (rule genideal_minimal[OF zeroideal], simp)
ballarin@20318
   438
apply (simp add: genideal_self')
ballarin@20318
   439
done
ballarin@20318
   440
ballarin@20318
   441
lemma (in ring) genideal_one:
ballarin@20318
   442
  "Idl {\<one>} = carrier R"
ballarin@20318
   443
proof -
ballarin@29237
   444
  interpret ideal "Idl {\<one>}" "R" by (rule genideal_ideal, fast intro: one_closed)
ballarin@20318
   445
  show "Idl {\<one>} = carrier R"
ballarin@20318
   446
  apply (rule, rule a_subset)
ballarin@20318
   447
  apply (simp add: one_imp_carrier genideal_self')
ballarin@20318
   448
  done
ballarin@20318
   449
qed
ballarin@20318
   450
ballarin@20318
   451
ballarin@27717
   452
text {* Generation of Principal Ideals in Commutative Rings *}
ballarin@20318
   453
wenzelm@35847
   454
definition
ballarin@20318
   455
  cgenideal :: "('a, 'b) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a set"  ("PIdl\<index> _" [80] 79)
wenzelm@35847
   456
  where "cgenideal R a \<equiv> {x \<otimes>\<^bsub>R\<^esub> a | x. x \<in> carrier R}"
ballarin@20318
   457
ballarin@20318
   458
text {* genhideal (?) really generates an ideal *}
ballarin@20318
   459
lemma (in cring) cgenideal_ideal:
ballarin@20318
   460
  assumes acarr: "a \<in> carrier R"
ballarin@20318
   461
  shows "ideal (PIdl a) R"
ballarin@20318
   462
apply (unfold cgenideal_def)
ballarin@20318
   463
apply (rule idealI[OF is_ring])
ballarin@20318
   464
   apply (rule subgroup.intro)
ballarin@20318
   465
      apply (simp_all add: monoid_record_simps)
ballarin@20318
   466
      apply (blast intro: acarr m_closed)
ballarin@20318
   467
      apply clarsimp defer 1
ballarin@20318
   468
      defer 1
ballarin@20318
   469
      apply (fold a_inv_def, clarsimp) defer 1
ballarin@20318
   470
      apply clarsimp defer 1
ballarin@20318
   471
      apply clarsimp defer 1
ballarin@20318
   472
proof -
ballarin@20318
   473
  fix x y
ballarin@20318
   474
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   475
     and ycarr: "y \<in> carrier R"
ballarin@20318
   476
  note carr = acarr xcarr ycarr
ballarin@20318
   477
ballarin@20318
   478
  from carr
ballarin@20318
   479
      have "x \<otimes> a \<oplus> y \<otimes> a = (x \<oplus> y) \<otimes> a" by (simp add: l_distr)
ballarin@20318
   480
  from this and carr
ballarin@20318
   481
      show "\<exists>z. x \<otimes> a \<oplus> y \<otimes> a = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   482
next
ballarin@20318
   483
  from l_null[OF acarr, symmetric] and zero_closed
ballarin@20318
   484
      show "\<exists>x. \<zero> = x \<otimes> a \<and> x \<in> carrier R" by fast
ballarin@20318
   485
next
ballarin@20318
   486
  fix x
ballarin@20318
   487
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   488
  note carr = acarr xcarr
ballarin@20318
   489
ballarin@20318
   490
  from carr
ballarin@20318
   491
      have "\<ominus> (x \<otimes> a) = (\<ominus> x) \<otimes> a" by (simp add: l_minus)
ballarin@20318
   492
  from this and carr
ballarin@20318
   493
      show "\<exists>z. \<ominus> (x \<otimes> a) = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   494
next
ballarin@20318
   495
  fix x y
ballarin@20318
   496
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   497
     and ycarr: "y \<in> carrier R"
ballarin@20318
   498
  note carr = acarr xcarr ycarr
ballarin@20318
   499
  
ballarin@20318
   500
  from carr
ballarin@20318
   501
      have "y \<otimes> a \<otimes> x = (y \<otimes> x) \<otimes> a" by (simp add: m_assoc, simp add: m_comm)
ballarin@20318
   502
  from this and carr
ballarin@20318
   503
      show "\<exists>z. y \<otimes> a \<otimes> x = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   504
next
ballarin@20318
   505
  fix x y
ballarin@20318
   506
  assume xcarr: "x \<in> carrier R"
ballarin@20318
   507
     and ycarr: "y \<in> carrier R"
ballarin@20318
   508
  note carr = acarr xcarr ycarr
ballarin@20318
   509
ballarin@20318
   510
  from carr
ballarin@20318
   511
      have "x \<otimes> (y \<otimes> a) = (x \<otimes> y) \<otimes> a" by (simp add: m_assoc)
ballarin@20318
   512
  from this and carr
ballarin@20318
   513
      show "\<exists>z. x \<otimes> (y \<otimes> a) = z \<otimes> a \<and> z \<in> carrier R" by fast
ballarin@20318
   514
qed
ballarin@20318
   515
ballarin@20318
   516
lemma (in ring) cgenideal_self:
ballarin@20318
   517
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   518
  shows "i \<in> PIdl i"
ballarin@20318
   519
unfolding cgenideal_def
ballarin@20318
   520
proof simp
ballarin@20318
   521
  from icarr
ballarin@20318
   522
      have "i = \<one> \<otimes> i" by simp
ballarin@20318
   523
  from this and icarr
ballarin@20318
   524
      show "\<exists>x. i = x \<otimes> i \<and> x \<in> carrier R" by fast
ballarin@20318
   525
qed
ballarin@20318
   526
ballarin@20318
   527
text {* @{const "cgenideal"} is minimal *}
ballarin@20318
   528
ballarin@20318
   529
lemma (in ring) cgenideal_minimal:
ballarin@27611
   530
  assumes "ideal J R"
ballarin@20318
   531
  assumes aJ: "a \<in> J"
ballarin@20318
   532
  shows "PIdl a \<subseteq> J"
ballarin@27611
   533
proof -
ballarin@29240
   534
  interpret ideal J R by fact
ballarin@27611
   535
  show ?thesis unfolding cgenideal_def
ballarin@27611
   536
    apply rule
ballarin@27611
   537
    apply clarify
ballarin@27611
   538
    using aJ
ballarin@27611
   539
    apply (erule I_l_closed)
ballarin@27611
   540
    done
ballarin@27611
   541
qed
ballarin@20318
   542
ballarin@20318
   543
lemma (in cring) cgenideal_eq_genideal:
ballarin@20318
   544
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   545
  shows "PIdl i = Idl {i}"
ballarin@20318
   546
apply rule
ballarin@20318
   547
 apply (intro cgenideal_minimal)
ballarin@20318
   548
  apply (rule genideal_ideal, fast intro: icarr)
ballarin@20318
   549
 apply (rule genideal_self', fast intro: icarr)
ballarin@20318
   550
apply (intro genideal_minimal)
wenzelm@23463
   551
 apply (rule cgenideal_ideal [OF icarr])
wenzelm@23463
   552
apply (simp, rule cgenideal_self [OF icarr])
ballarin@20318
   553
done
ballarin@20318
   554
ballarin@20318
   555
lemma (in cring) cgenideal_eq_rcos:
ballarin@20318
   556
 "PIdl i = carrier R #> i"
ballarin@20318
   557
unfolding cgenideal_def r_coset_def
ballarin@20318
   558
by fast
ballarin@20318
   559
ballarin@20318
   560
lemma (in cring) cgenideal_is_principalideal:
ballarin@20318
   561
  assumes icarr: "i \<in> carrier R"
ballarin@20318
   562
  shows "principalideal (PIdl i) R"
ballarin@20318
   563
apply (rule principalidealI)
wenzelm@23464
   564
apply (rule cgenideal_ideal [OF icarr])
ballarin@20318
   565
proof -
ballarin@20318
   566
  from icarr
ballarin@20318
   567
      have "PIdl i = Idl {i}" by (rule cgenideal_eq_genideal)
ballarin@20318
   568
  from icarr and this
ballarin@20318
   569
      show "\<exists>i'\<in>carrier R. PIdl i = Idl {i'}" by fast
ballarin@20318
   570
qed
ballarin@20318
   571
ballarin@20318
   572
ballarin@20318
   573
subsection {* Union of Ideals *}
ballarin@20318
   574
ballarin@20318
   575
lemma (in ring) union_genideal:
ballarin@20318
   576
  assumes idealI: "ideal I R"
ballarin@20318
   577
      and idealJ: "ideal J R"
ballarin@20318
   578
  shows "Idl (I \<union> J) = I <+> J"
ballarin@20318
   579
apply rule
ballarin@20318
   580
 apply (rule ring.genideal_minimal)
ballarin@29240
   581
   apply (rule is_ring)
ballarin@20318
   582
  apply (rule add_ideals[OF idealI idealJ])
ballarin@20318
   583
 apply (rule)
ballarin@20318
   584
 apply (simp add: set_add_defs) apply (elim disjE) defer 1 defer 1
ballarin@20318
   585
 apply (rule) apply (simp add: set_add_defs genideal_def) apply clarsimp defer 1
ballarin@20318
   586
proof -
ballarin@20318
   587
  fix x
ballarin@20318
   588
  assume xI: "x \<in> I"
ballarin@20318
   589
  have ZJ: "\<zero> \<in> J"
ballarin@20318
   590
      by (intro additive_subgroup.zero_closed, rule ideal.axioms[OF idealJ])
ballarin@20318
   591
  from ideal.Icarr[OF idealI xI]
ballarin@20318
   592
      have "x = x \<oplus> \<zero>" by algebra
ballarin@20318
   593
  from xI and ZJ and this
ballarin@20318
   594
      show "\<exists>h\<in>I. \<exists>k\<in>J. x = h \<oplus> k" by fast
ballarin@20318
   595
next
ballarin@20318
   596
  fix x
ballarin@20318
   597
  assume xJ: "x \<in> J"
ballarin@20318
   598
  have ZI: "\<zero> \<in> I"
ballarin@20318
   599
      by (intro additive_subgroup.zero_closed, rule ideal.axioms[OF idealI])
ballarin@20318
   600
  from ideal.Icarr[OF idealJ xJ]
ballarin@20318
   601
      have "x = \<zero> \<oplus> x" by algebra
ballarin@20318
   602
  from ZI and xJ and this
ballarin@20318
   603
      show "\<exists>h\<in>I. \<exists>k\<in>J. x = h \<oplus> k" by fast
ballarin@20318
   604
next
ballarin@20318
   605
  fix i j K
ballarin@20318
   606
  assume iI: "i \<in> I"
ballarin@20318
   607
     and jJ: "j \<in> J"
ballarin@20318
   608
     and idealK: "ideal K R"
ballarin@20318
   609
     and IK: "I \<subseteq> K"
ballarin@20318
   610
     and JK: "J \<subseteq> K"
ballarin@20318
   611
  from iI and IK
ballarin@20318
   612
     have iK: "i \<in> K" by fast
ballarin@20318
   613
  from jJ and JK
ballarin@20318
   614
     have jK: "j \<in> K" by fast
ballarin@20318
   615
  from iK and jK
ballarin@20318
   616
     show "i \<oplus> j \<in> K" by (intro additive_subgroup.a_closed) (rule ideal.axioms[OF idealK])
ballarin@20318
   617
qed
ballarin@20318
   618
ballarin@20318
   619
ballarin@20318
   620
subsection {* Properties of Principal Ideals *}
ballarin@20318
   621
ballarin@20318
   622
text {* @{text "\<zero>"} generates the zero ideal *}
ballarin@20318
   623
lemma (in ring) zero_genideal:
ballarin@20318
   624
  shows "Idl {\<zero>} = {\<zero>}"
ballarin@20318
   625
apply rule
ballarin@20318
   626
apply (simp add: genideal_minimal zeroideal)
ballarin@20318
   627
apply (fast intro!: genideal_self)
ballarin@20318
   628
done
ballarin@20318
   629
ballarin@20318
   630
text {* @{text "\<one>"} generates the unit ideal *}
ballarin@20318
   631
lemma (in ring) one_genideal:
ballarin@20318
   632
  shows "Idl {\<one>} = carrier R"
ballarin@20318
   633
proof -
ballarin@20318
   634
  have "\<one> \<in> Idl {\<one>}" by (simp add: genideal_self')
ballarin@20318
   635
  thus "Idl {\<one>} = carrier R" by (intro ideal.one_imp_carrier, fast intro: genideal_ideal)
ballarin@20318
   636
qed
ballarin@20318
   637
ballarin@20318
   638
ballarin@20318
   639
text {* The zero ideal is a principal ideal *}
ballarin@20318
   640
corollary (in ring) zeropideal:
ballarin@20318
   641
  shows "principalideal {\<zero>} R"
ballarin@20318
   642
apply (rule principalidealI)
ballarin@20318
   643
 apply (rule zeroideal)
ballarin@20318
   644
apply (blast intro!: zero_closed zero_genideal[symmetric])
ballarin@20318
   645
done
ballarin@20318
   646
ballarin@20318
   647
text {* The unit ideal is a principal ideal *}
ballarin@20318
   648
corollary (in ring) onepideal:
ballarin@20318
   649
  shows "principalideal (carrier R) R"
ballarin@20318
   650
apply (rule principalidealI)
ballarin@20318
   651
 apply (rule oneideal)
ballarin@20318
   652
apply (blast intro!: one_closed one_genideal[symmetric])
ballarin@20318
   653
done
ballarin@20318
   654
ballarin@20318
   655
ballarin@20318
   656
text {* Every principal ideal is a right coset of the carrier *}
ballarin@20318
   657
lemma (in principalideal) rcos_generate:
ballarin@27611
   658
  assumes "cring R"
ballarin@20318
   659
  shows "\<exists>x\<in>I. I = carrier R #> x"
ballarin@20318
   660
proof -
ballarin@29237
   661
  interpret cring R by fact
ballarin@20318
   662
  from generate
ballarin@20318
   663
      obtain i
ballarin@20318
   664
        where icarr: "i \<in> carrier R"
ballarin@20318
   665
        and I1: "I = Idl {i}"
ballarin@20318
   666
      by fast+
ballarin@20318
   667
ballarin@20318
   668
  from icarr and genideal_self[of "{i}"]
ballarin@20318
   669
      have "i \<in> Idl {i}" by fast
ballarin@20318
   670
  hence iI: "i \<in> I" by (simp add: I1)
ballarin@20318
   671
ballarin@20318
   672
  from I1 icarr
ballarin@20318
   673
      have I2: "I = PIdl i" by (simp add: cgenideal_eq_genideal)
ballarin@20318
   674
ballarin@20318
   675
  have "PIdl i = carrier R #> i"
ballarin@20318
   676
      unfolding cgenideal_def r_coset_def
ballarin@20318
   677
      by fast
ballarin@20318
   678
ballarin@20318
   679
  from I2 and this
ballarin@20318
   680
      have "I = carrier R #> i" by simp
ballarin@20318
   681
ballarin@20318
   682
  from iI and this
ballarin@20318
   683
      show "\<exists>x\<in>I. I = carrier R #> x" by fast
ballarin@20318
   684
qed
ballarin@20318
   685
ballarin@20318
   686
ballarin@20318
   687
subsection {* Prime Ideals *}
ballarin@20318
   688
ballarin@20318
   689
lemma (in ideal) primeidealCD:
ballarin@27611
   690
  assumes "cring R"
ballarin@20318
   691
  assumes notprime: "\<not> primeideal I R"
ballarin@20318
   692
  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
   693
proof (rule ccontr, clarsimp)
ballarin@29237
   694
  interpret cring R by fact
ballarin@20318
   695
  assume InR: "carrier R \<noteq> I"
ballarin@20318
   696
     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
   697
  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
   698
  have "primeideal I R"
wenzelm@23464
   699
      apply (rule primeideal.intro [OF is_ideal is_cring])
wenzelm@23464
   700
      apply (rule primeideal_axioms.intro)
wenzelm@23464
   701
       apply (rule InR)
wenzelm@23464
   702
      apply (erule (2) I_prime)
wenzelm@23464
   703
      done
ballarin@20318
   704
  from this and notprime
ballarin@20318
   705
      show "False" by simp
ballarin@20318
   706
qed
ballarin@20318
   707
ballarin@20318
   708
lemma (in ideal) primeidealCE:
ballarin@27611
   709
  assumes "cring R"
ballarin@20318
   710
  assumes notprime: "\<not> primeideal I R"
wenzelm@23383
   711
  obtains "carrier R = I"
wenzelm@23383
   712
    | "\<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
   713
proof -
wenzelm@30729
   714
  interpret R: cring R by fact
ballarin@27611
   715
  assume "carrier R = I ==> thesis"
ballarin@27611
   716
    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
   717
  then show thesis using primeidealCD [OF R.is_cring notprime] by blast
ballarin@27611
   718
qed
ballarin@20318
   719
ballarin@20318
   720
text {* If @{text "{\<zero>}"} is a prime ideal of a commutative ring, the ring is a domain *}
ballarin@20318
   721
lemma (in cring) zeroprimeideal_domainI:
ballarin@20318
   722
  assumes pi: "primeideal {\<zero>} R"
ballarin@20318
   723
  shows "domain R"
wenzelm@23464
   724
apply (rule domain.intro, rule is_cring)
ballarin@20318
   725
apply (rule domain_axioms.intro)
ballarin@20318
   726
proof (rule ccontr, simp)
ballarin@29237
   727
  interpret primeideal "{\<zero>}" "R" by (rule pi)
ballarin@20318
   728
  assume "\<one> = \<zero>"
ballarin@20318
   729
  hence "carrier R = {\<zero>}" by (rule one_zeroD)
ballarin@20318
   730
  from this[symmetric] and I_notcarr
ballarin@20318
   731
      show "False" by simp
ballarin@20318
   732
next
ballarin@29237
   733
  interpret primeideal "{\<zero>}" "R" by (rule pi)
ballarin@20318
   734
  fix a b
ballarin@20318
   735
  assume ab: "a \<otimes> b = \<zero>"
ballarin@20318
   736
     and carr: "a \<in> carrier R" "b \<in> carrier R"
ballarin@20318
   737
  from ab
ballarin@20318
   738
      have abI: "a \<otimes> b \<in> {\<zero>}" by fast
ballarin@20318
   739
  from carr and this
ballarin@20318
   740
      have "a \<in> {\<zero>} \<or> b \<in> {\<zero>}" by (rule I_prime)
ballarin@20318
   741
  thus "a = \<zero> \<or> b = \<zero>" by simp
ballarin@20318
   742
qed
ballarin@20318
   743
ballarin@20318
   744
corollary (in cring) domain_eq_zeroprimeideal:
ballarin@20318
   745
  shows "domain R = primeideal {\<zero>} R"
ballarin@20318
   746
apply rule
ballarin@20318
   747
 apply (erule domain.zeroprimeideal)
ballarin@20318
   748
apply (erule zeroprimeideal_domainI)
ballarin@20318
   749
done
ballarin@20318
   750
ballarin@20318
   751
ballarin@20318
   752
subsection {* Maximal Ideals *}
ballarin@20318
   753
ballarin@20318
   754
lemma (in ideal) helper_I_closed:
ballarin@20318
   755
  assumes carr: "a \<in> carrier R" "x \<in> carrier R" "y \<in> carrier R"
ballarin@20318
   756
      and axI: "a \<otimes> x \<in> I"
ballarin@20318
   757
  shows "a \<otimes> (x \<otimes> y) \<in> I"
ballarin@20318
   758
proof -
ballarin@20318
   759
  from axI and carr
ballarin@20318
   760
     have "(a \<otimes> x) \<otimes> y \<in> I" by (simp add: I_r_closed)
ballarin@20318
   761
  also from carr
ballarin@20318
   762
     have "(a \<otimes> x) \<otimes> y = a \<otimes> (x \<otimes> y)" by (simp add: m_assoc)
ballarin@20318
   763
  finally
ballarin@20318
   764
     show "a \<otimes> (x \<otimes> y) \<in> I" .
ballarin@20318
   765
qed
ballarin@20318
   766
ballarin@20318
   767
lemma (in ideal) helper_max_prime:
ballarin@27611
   768
  assumes "cring R"
ballarin@20318
   769
  assumes acarr: "a \<in> carrier R"
ballarin@20318
   770
  shows "ideal {x\<in>carrier R. a \<otimes> x \<in> I} R"
ballarin@27611
   771
proof -
ballarin@29237
   772
  interpret cring R by fact
ballarin@27611
   773
  show ?thesis apply (rule idealI)
ballarin@27611
   774
    apply (rule cring.axioms[OF is_cring])
ballarin@27611
   775
    apply (rule subgroup.intro)
ballarin@27611
   776
    apply (simp, fast)
ballarin@20318
   777
    apply clarsimp apply (simp add: r_distr acarr)
ballarin@27611
   778
    apply (simp add: acarr)
ballarin@27611
   779
    apply (simp add: a_inv_def[symmetric], clarify) defer 1
ballarin@27611
   780
    apply clarsimp defer 1
ballarin@27611
   781
    apply (fast intro!: helper_I_closed acarr)
ballarin@27611
   782
  proof -
ballarin@27611
   783
    fix x
ballarin@27611
   784
    assume xcarr: "x \<in> carrier R"
ballarin@27611
   785
      and ax: "a \<otimes> x \<in> I"
ballarin@27611
   786
    from ax and acarr xcarr
ballarin@27611
   787
    have "\<ominus>(a \<otimes> x) \<in> I" by simp
ballarin@27611
   788
    also from acarr xcarr
ballarin@27611
   789
    have "\<ominus>(a \<otimes> x) = a \<otimes> (\<ominus>x)" by algebra
ballarin@27611
   790
    finally
ballarin@27611
   791
    show "a \<otimes> (\<ominus>x) \<in> I" .
ballarin@27611
   792
    from acarr
ballarin@27611
   793
    have "a \<otimes> \<zero> = \<zero>" by simp
ballarin@27611
   794
  next
ballarin@27611
   795
    fix x y
ballarin@27611
   796
    assume xcarr: "x \<in> carrier R"
ballarin@27611
   797
      and ycarr: "y \<in> carrier R"
ballarin@27611
   798
      and ayI: "a \<otimes> y \<in> I"
ballarin@27611
   799
    from ayI and acarr xcarr ycarr
ballarin@27611
   800
    have "a \<otimes> (y \<otimes> x) \<in> I" by (simp add: helper_I_closed)
ballarin@27611
   801
    moreover from xcarr ycarr
ballarin@27611
   802
    have "y \<otimes> x = x \<otimes> y" by (simp add: m_comm)
ballarin@27611
   803
    ultimately
ballarin@27611
   804
    show "a \<otimes> (x \<otimes> y) \<in> I" by simp
ballarin@27611
   805
  qed
ballarin@20318
   806
qed
ballarin@20318
   807
ballarin@20318
   808
text {* In a cring every maximal ideal is prime *}
ballarin@20318
   809
lemma (in cring) maximalideal_is_prime:
ballarin@27611
   810
  assumes "maximalideal I R"
ballarin@20318
   811
  shows "primeideal I R"
ballarin@20318
   812
proof -
ballarin@29237
   813
  interpret maximalideal I R by fact
ballarin@27611
   814
  show ?thesis apply (rule ccontr)
ballarin@27611
   815
    apply (rule primeidealCE)
ballarin@27611
   816
    apply (rule is_cring)
ballarin@27611
   817
    apply assumption
ballarin@27611
   818
    apply (simp add: I_notcarr)
ballarin@27611
   819
  proof -
ballarin@27611
   820
    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
   821
    from this
ballarin@27611
   822
    obtain a b
ballarin@27611
   823
      where acarr: "a \<in> carrier R"
ballarin@27611
   824
      and bcarr: "b \<in> carrier R"
ballarin@27611
   825
      and abI: "a \<otimes> b \<in> I"
ballarin@27611
   826
      and anI: "a \<notin> I"
ballarin@27611
   827
      and bnI: "b \<notin> I"
ballarin@20318
   828
      by fast
ballarin@27611
   829
    def J \<equiv> "{x\<in>carrier R. a \<otimes> x \<in> I}"
ballarin@27611
   830
    
ballarin@29240
   831
    from is_cring and acarr
ballarin@27611
   832
    have idealJ: "ideal J R" unfolding J_def by (rule helper_max_prime)
ballarin@27611
   833
    
ballarin@27611
   834
    have IsubJ: "I \<subseteq> J"
ballarin@27611
   835
    proof
ballarin@27611
   836
      fix x
ballarin@27611
   837
      assume xI: "x \<in> I"
ballarin@27611
   838
      from this and acarr
ballarin@27611
   839
      have "a \<otimes> x \<in> I" by (intro I_l_closed)
ballarin@27611
   840
      from xI[THEN a_Hcarr] this
ballarin@27611
   841
      show "x \<in> J" unfolding J_def by fast
ballarin@27611
   842
    qed
ballarin@27611
   843
    
ballarin@27611
   844
    from abI and acarr bcarr
ballarin@27611
   845
    have "b \<in> J" unfolding J_def by fast
ballarin@27611
   846
    from bnI and this
ballarin@27611
   847
    have JnI: "J \<noteq> I" by fast
ballarin@27611
   848
    from acarr
ballarin@27611
   849
    have "a = a \<otimes> \<one>" by algebra
ballarin@27611
   850
    from this and anI
ballarin@27611
   851
    have "a \<otimes> \<one> \<notin> I" by simp
ballarin@27611
   852
    from one_closed and this
ballarin@27611
   853
    have "\<one> \<notin> J" unfolding J_def by fast
ballarin@27611
   854
    hence Jncarr: "J \<noteq> carrier R" by fast
ballarin@27611
   855
    
ballarin@29237
   856
    interpret ideal J R by (rule idealJ)
ballarin@27611
   857
    
ballarin@27611
   858
    have "J = I \<or> J = carrier R"
ballarin@27611
   859
      apply (intro I_maximal)
ballarin@27611
   860
      apply (rule idealJ)
ballarin@27611
   861
      apply (rule IsubJ)
ballarin@27611
   862
      apply (rule a_subset)
ballarin@27611
   863
      done
ballarin@27611
   864
    
ballarin@27611
   865
    from this and JnI and Jncarr
ballarin@27611
   866
    show "False" by simp
ballarin@20318
   867
  qed
ballarin@20318
   868
qed
ballarin@20318
   869
ballarin@27717
   870
subsection {* Derived Theorems *}
ballarin@20318
   871
ballarin@20318
   872
--"A non-zero cring that has only the two trivial ideals is a field"
ballarin@20318
   873
lemma (in cring) trivialideals_fieldI:
ballarin@20318
   874
  assumes carrnzero: "carrier R \<noteq> {\<zero>}"
ballarin@20318
   875
      and haveideals: "{I. ideal I R} = {{\<zero>}, carrier R}"
ballarin@20318
   876
  shows "field R"
ballarin@20318
   877
apply (rule cring_fieldI)
ballarin@20318
   878
apply (rule, rule, rule)
ballarin@20318
   879
 apply (erule Units_closed)
ballarin@20318
   880
defer 1
ballarin@20318
   881
  apply rule
ballarin@20318
   882
defer 1
ballarin@20318
   883
proof (rule ccontr, simp)
ballarin@20318
   884
  assume zUnit: "\<zero> \<in> Units R"
ballarin@20318
   885
  hence a: "\<zero> \<otimes> inv \<zero> = \<one>" by (rule Units_r_inv)
ballarin@20318
   886
  from zUnit
ballarin@20318
   887
      have "\<zero> \<otimes> inv \<zero> = \<zero>" by (intro l_null, rule Units_inv_closed)
ballarin@20318
   888
  from a[symmetric] and this
ballarin@20318
   889
      have "\<one> = \<zero>" by simp
ballarin@20318
   890
  hence "carrier R = {\<zero>}" by (rule one_zeroD)
ballarin@20318
   891
  from this and carrnzero
ballarin@20318
   892
      show "False" by simp
ballarin@20318
   893
next
ballarin@20318
   894
  fix x
ballarin@20318
   895
  assume xcarr': "x \<in> carrier R - {\<zero>}"
ballarin@20318
   896
  hence xcarr: "x \<in> carrier R" by fast
ballarin@20318
   897
  from xcarr'
ballarin@20318
   898
      have xnZ: "x \<noteq> \<zero>" by fast
ballarin@20318
   899
  from xcarr
ballarin@20318
   900
      have xIdl: "ideal (PIdl x) R" by (intro cgenideal_ideal, fast)
ballarin@20318
   901
ballarin@20318
   902
  from xcarr
ballarin@20318
   903
      have "x \<in> PIdl x" by (intro cgenideal_self, fast)
ballarin@20318
   904
  from this and xnZ
ballarin@20318
   905
      have "PIdl x \<noteq> {\<zero>}" by fast
ballarin@20318
   906
  from haveideals and this
ballarin@20318
   907
      have "PIdl x = carrier R"
ballarin@20318
   908
      by (blast intro!: xIdl)
ballarin@20318
   909
  hence "\<one> \<in> PIdl x" by simp
ballarin@20318
   910
  hence "\<exists>y. \<one> = y \<otimes> x \<and> y \<in> carrier R" unfolding cgenideal_def by blast
ballarin@20318
   911
  from this
ballarin@20318
   912
      obtain y
ballarin@20318
   913
        where ycarr: " y \<in> carrier R"
ballarin@20318
   914
        and ylinv: "\<one> = y \<otimes> x"
ballarin@20318
   915
      by fast+
ballarin@20318
   916
  from ylinv and xcarr ycarr
ballarin@20318
   917
      have yrinv: "\<one> = x \<otimes> y" by (simp add: m_comm)
ballarin@20318
   918
  from ycarr and ylinv[symmetric] and yrinv[symmetric]
ballarin@20318
   919
      have "\<exists>y \<in> carrier R. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast
ballarin@20318
   920
  from this and xcarr
ballarin@20318
   921
      show "x \<in> Units R"
ballarin@20318
   922
      unfolding Units_def
ballarin@20318
   923
      by fast
ballarin@20318
   924
qed
ballarin@20318
   925
ballarin@20318
   926
lemma (in field) all_ideals:
ballarin@20318
   927
  shows "{I. ideal I R} = {{\<zero>}, carrier R}"
ballarin@20318
   928
apply (rule, rule)
ballarin@20318
   929
proof -
ballarin@20318
   930
  fix I
ballarin@20318
   931
  assume a: "I \<in> {I. ideal I R}"
ballarin@20318
   932
  with this
ballarin@29237
   933
      interpret ideal I R by simp
ballarin@20318
   934
ballarin@20318
   935
  show "I \<in> {{\<zero>}, carrier R}"
ballarin@20318
   936
  proof (cases "\<exists>a. a \<in> I - {\<zero>}")
ballarin@20318
   937
    assume "\<exists>a. a \<in> I - {\<zero>}"
ballarin@20318
   938
    from this
ballarin@20318
   939
        obtain a
ballarin@20318
   940
          where aI: "a \<in> I"
ballarin@20318
   941
          and anZ: "a \<noteq> \<zero>"
ballarin@20318
   942
        by fast+
ballarin@20318
   943
    from aI[THEN a_Hcarr] anZ
ballarin@20318
   944
        have aUnit: "a \<in> Units R" by (simp add: field_Units)
ballarin@20318
   945
    hence a: "a \<otimes> inv a = \<one>" by (rule Units_r_inv)
ballarin@20318
   946
    from aI and aUnit
ballarin@27698
   947
        have "a \<otimes> inv a \<in> I" by (simp add: I_r_closed del: Units_r_inv)
ballarin@20318
   948
    hence oneI: "\<one> \<in> I" by (simp add: a[symmetric])
ballarin@20318
   949
ballarin@20318
   950
    have "carrier R \<subseteq> I"
ballarin@20318
   951
    proof
ballarin@20318
   952
      fix x
ballarin@20318
   953
      assume xcarr: "x \<in> carrier R"
ballarin@20318
   954
      from oneI and this
ballarin@20318
   955
          have "\<one> \<otimes> x \<in> I" by (rule I_r_closed)
ballarin@20318
   956
      from this and xcarr
ballarin@20318
   957
          show "x \<in> I" by simp
ballarin@20318
   958
    qed
ballarin@20318
   959
    from this and a_subset
ballarin@20318
   960
        have "I = carrier R" by fast
ballarin@20318
   961
    thus "I \<in> {{\<zero>}, carrier R}" by fast
ballarin@20318
   962
  next
ballarin@20318
   963
    assume "\<not> (\<exists>a. a \<in> I - {\<zero>})"
ballarin@20318
   964
    hence IZ: "\<And>a. a \<in> I \<Longrightarrow> a = \<zero>" by simp
ballarin@20318
   965
ballarin@20318
   966
    have a: "I \<subseteq> {\<zero>}"
ballarin@20318
   967
    proof
ballarin@20318
   968
      fix x
ballarin@20318
   969
      assume "x \<in> I"
ballarin@20318
   970
      hence "x = \<zero>" by (rule IZ)
ballarin@20318
   971
      thus "x \<in> {\<zero>}" by fast
ballarin@20318
   972
    qed
ballarin@20318
   973
ballarin@20318
   974
    have "\<zero> \<in> I" by simp
ballarin@20318
   975
    hence "{\<zero>} \<subseteq> I" by fast
ballarin@20318
   976
ballarin@20318
   977
    from this and a
ballarin@20318
   978
        have "I = {\<zero>}" by fast
ballarin@20318
   979
    thus "I \<in> {{\<zero>}, carrier R}" by fast
ballarin@20318
   980
  qed
ballarin@20318
   981
qed (simp add: zeroideal oneideal)
ballarin@20318
   982
ballarin@20318
   983
--"Jacobson Theorem 2.2"
ballarin@20318
   984
lemma (in cring) trivialideals_eq_field:
ballarin@20318
   985
  assumes carrnzero: "carrier R \<noteq> {\<zero>}"
ballarin@20318
   986
  shows "({I. ideal I R} = {{\<zero>}, carrier R}) = field R"
ballarin@20318
   987
by (fast intro!: trivialideals_fieldI[OF carrnzero] field.all_ideals)
ballarin@20318
   988
ballarin@20318
   989
ballarin@20318
   990
text {* Like zeroprimeideal for domains *}
ballarin@20318
   991
lemma (in field) zeromaximalideal:
ballarin@20318
   992
  "maximalideal {\<zero>} R"
ballarin@20318
   993
apply (rule maximalidealI)
ballarin@20318
   994
  apply (rule zeroideal)
ballarin@20318
   995
proof-
ballarin@20318
   996
  from one_not_zero
ballarin@20318
   997
      have "\<one> \<notin> {\<zero>}" by simp
ballarin@20318
   998
  from this and one_closed
ballarin@20318
   999
      show "carrier R \<noteq> {\<zero>}" by fast
ballarin@20318
  1000
next
ballarin@20318
  1001
  fix J
ballarin@20318
  1002
  assume Jideal: "ideal J R"
ballarin@20318
  1003
  hence "J \<in> {I. ideal I R}"
ballarin@20318
  1004
      by fast
ballarin@20318
  1005
ballarin@20318
  1006
  from this and all_ideals
ballarin@20318
  1007
      show "J = {\<zero>} \<or> J = carrier R" by simp
ballarin@20318
  1008
qed
ballarin@20318
  1009
ballarin@20318
  1010
lemma (in cring) zeromaximalideal_fieldI:
ballarin@20318
  1011
  assumes zeromax: "maximalideal {\<zero>} R"
ballarin@20318
  1012
  shows "field R"
ballarin@20318
  1013
apply (rule trivialideals_fieldI, rule maximalideal.I_notcarr[OF zeromax])
ballarin@20318
  1014
apply rule apply clarsimp defer 1
ballarin@20318
  1015
 apply (simp add: zeroideal oneideal)
ballarin@20318
  1016
proof -
ballarin@20318
  1017
  fix J
ballarin@20318
  1018
  assume Jn0: "J \<noteq> {\<zero>}"
ballarin@20318
  1019
     and idealJ: "ideal J R"
ballarin@29237
  1020
  interpret ideal J R by (rule idealJ)
ballarin@20318
  1021
  have "{\<zero>} \<subseteq> J" by (rule ccontr, simp)
ballarin@20318
  1022
  from zeromax and idealJ and this and a_subset
ballarin@20318
  1023
      have "J = {\<zero>} \<or> J = carrier R" by (rule maximalideal.I_maximal)
ballarin@20318
  1024
  from this and Jn0
ballarin@20318
  1025
      show "J = carrier R" by simp
ballarin@20318
  1026
qed
ballarin@20318
  1027
ballarin@20318
  1028
lemma (in cring) zeromaximalideal_eq_field:
ballarin@20318
  1029
  "maximalideal {\<zero>} R = field R"
ballarin@20318
  1030
apply rule
ballarin@20318
  1031
 apply (erule zeromaximalideal_fieldI)
ballarin@20318
  1032
apply (erule field.zeromaximalideal)
ballarin@20318
  1033
done
ballarin@20318
  1034
ballarin@20318
  1035
end