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