68582
|
1 |
(* Title: HOL/Algebra/Ring_Divisibility.thy
|
|
2 |
Author: Paulo EmÃlio de Vilhena
|
|
3 |
*)
|
68578
|
4 |
|
|
5 |
theory Ring_Divisibility
|
|
6 |
imports Ideal Divisibility QuotRing
|
|
7 |
begin
|
|
8 |
|
68580
|
9 |
section \<open>Definitions ported from @{text "Multiplicative_Group.thy"}\<close>
|
68578
|
10 |
|
|
11 |
definition mult_of :: "('a, 'b) ring_scheme \<Rightarrow> 'a monoid" where
|
|
12 |
"mult_of R \<equiv> \<lparr> carrier = carrier R - { \<zero>\<^bsub>R\<^esub> }, mult = mult R, one = \<one>\<^bsub>R\<^esub> \<rparr>"
|
|
13 |
|
|
14 |
lemma carrier_mult_of [simp]: "carrier (mult_of R) = carrier R - { \<zero>\<^bsub>R\<^esub> }"
|
|
15 |
by (simp add: mult_of_def)
|
|
16 |
|
|
17 |
lemma mult_mult_of [simp]: "mult (mult_of R) = mult R"
|
|
18 |
by (simp add: mult_of_def)
|
|
19 |
|
|
20 |
lemma nat_pow_mult_of: "([^]\<^bsub>mult_of R\<^esub>) = (([^]\<^bsub>R\<^esub>) :: _ \<Rightarrow> nat \<Rightarrow> _)"
|
|
21 |
by (simp add: mult_of_def fun_eq_iff nat_pow_def)
|
|
22 |
|
|
23 |
lemma one_mult_of [simp]: "\<one>\<^bsub>mult_of R\<^esub> = \<one>\<^bsub>R\<^esub>"
|
|
24 |
by (simp add: mult_of_def)
|
|
25 |
|
|
26 |
lemmas mult_of_simps = carrier_mult_of mult_mult_of nat_pow_mult_of one_mult_of
|
|
27 |
|
|
28 |
|
|
29 |
section \<open>The Arithmetic of Rings\<close>
|
|
30 |
|
|
31 |
text \<open>In this section we study the links between the divisibility theory and that of rings\<close>
|
|
32 |
|
|
33 |
|
|
34 |
subsection \<open>Definitions\<close>
|
|
35 |
|
|
36 |
locale factorial_domain = domain + factorial_monoid "mult_of R"
|
|
37 |
|
|
38 |
locale noetherian_ring = ring +
|
|
39 |
assumes finetely_gen: "ideal I R \<Longrightarrow> \<exists>A. A \<subseteq> carrier R \<and> finite A \<and> I = Idl A"
|
|
40 |
|
|
41 |
locale noetherian_domain = noetherian_ring + domain
|
|
42 |
|
|
43 |
locale principal_domain = domain +
|
|
44 |
assumes principal_I: "ideal I R \<Longrightarrow> principalideal I R"
|
|
45 |
|
|
46 |
locale euclidean_domain = R?: domain R for R (structure) + fixes \<phi> :: "'a \<Rightarrow> nat"
|
|
47 |
assumes euclidean_function:
|
|
48 |
" \<lbrakk> a \<in> carrier R - { \<zero> }; b \<in> carrier R - { \<zero> } \<rbrakk> \<Longrightarrow>
|
|
49 |
\<exists>q r. q \<in> carrier R \<and> r \<in> carrier R \<and> a = (b \<otimes> q) \<oplus> r \<and> ((r = \<zero>) \<or> (\<phi> r < \<phi> b))"
|
|
50 |
|
|
51 |
lemma (in domain) mult_of_is_comm_monoid: "comm_monoid (mult_of R)"
|
|
52 |
apply (rule comm_monoidI)
|
|
53 |
apply (auto simp add: integral_iff m_assoc)
|
|
54 |
apply (simp add: m_comm)
|
|
55 |
done
|
|
56 |
|
|
57 |
lemma (in domain) cancel_property: "comm_monoid_cancel (mult_of R)"
|
|
58 |
by (rule comm_monoid_cancelI) (auto simp add: mult_of_is_comm_monoid m_rcancel)
|
|
59 |
|
|
60 |
sublocale domain < mult_of: comm_monoid_cancel "(mult_of R)"
|
|
61 |
rewrites "mult (mult_of R) = mult R"
|
|
62 |
and "one (mult_of R) = one R"
|
|
63 |
using cancel_property by auto
|
|
64 |
|
|
65 |
sublocale noetherian_domain \<subseteq> domain ..
|
|
66 |
|
|
67 |
sublocale principal_domain \<subseteq> domain ..
|
|
68 |
|
|
69 |
sublocale euclidean_domain \<subseteq> domain ..
|
|
70 |
|
|
71 |
lemma (in factorial_monoid) is_factorial_monoid: "factorial_monoid G" ..
|
|
72 |
|
|
73 |
sublocale factorial_domain < mult_of: factorial_monoid "mult_of R"
|
|
74 |
rewrites "mult (mult_of R) = mult R"
|
|
75 |
and "one (mult_of R) = one R"
|
|
76 |
using factorial_monoid_axioms by auto
|
|
77 |
|
|
78 |
lemma (in domain) factorial_domainI:
|
|
79 |
assumes "\<And>a. a \<in> carrier (mult_of R) \<Longrightarrow>
|
|
80 |
\<exists>fs. set fs \<subseteq> carrier (mult_of R) \<and> wfactors (mult_of R) fs a"
|
|
81 |
and "\<And>a fs fs'. \<lbrakk> a \<in> carrier (mult_of R);
|
|
82 |
set fs \<subseteq> carrier (mult_of R);
|
|
83 |
set fs' \<subseteq> carrier (mult_of R);
|
|
84 |
wfactors (mult_of R) fs a;
|
|
85 |
wfactors (mult_of R) fs' a \<rbrakk> \<Longrightarrow>
|
|
86 |
essentially_equal (mult_of R) fs fs'"
|
|
87 |
shows "factorial_domain R"
|
|
88 |
unfolding factorial_domain_def using mult_of.factorial_monoidI assms domain_axioms by auto
|
|
89 |
|
|
90 |
lemma (in domain) is_domain: "domain R" ..
|
|
91 |
|
|
92 |
lemma (in ring) noetherian_ringI:
|
|
93 |
assumes "\<And>I. ideal I R \<Longrightarrow> \<exists>A. A \<subseteq> carrier R \<and> finite A \<and> I = Idl A"
|
|
94 |
shows "noetherian_ring R"
|
|
95 |
unfolding noetherian_ring_def noetherian_ring_axioms_def using assms is_ring by simp
|
|
96 |
|
|
97 |
lemma (in domain) noetherian_domainI:
|
|
98 |
assumes "\<And>I. ideal I R \<Longrightarrow> \<exists>A. A \<subseteq> carrier R \<and> finite A \<and> I = Idl A"
|
|
99 |
shows "noetherian_domain R"
|
|
100 |
unfolding noetherian_domain_def noetherian_ring_def noetherian_ring_axioms_def
|
|
101 |
using assms is_ring is_domain by simp
|
|
102 |
|
|
103 |
lemma (in domain) principal_domainI:
|
|
104 |
assumes "\<And>I. ideal I R \<Longrightarrow> principalideal I R"
|
|
105 |
shows "principal_domain R"
|
|
106 |
unfolding principal_domain_def principal_domain_axioms_def using is_domain assms by auto
|
|
107 |
|
|
108 |
lemma (in domain) principal_domainI2:
|
|
109 |
assumes "\<And>I. ideal I R \<Longrightarrow> \<exists>a \<in> carrier R. I = PIdl a"
|
|
110 |
shows "principal_domain R"
|
|
111 |
unfolding principal_domain_def principal_domain_axioms_def
|
|
112 |
using is_domain assms principalidealI cgenideal_eq_genideal by auto
|
|
113 |
|
|
114 |
lemma (in domain) euclidean_domainI:
|
|
115 |
assumes "\<And>a b. \<lbrakk> a \<in> carrier R - { \<zero> }; b \<in> carrier R - { \<zero> } \<rbrakk> \<Longrightarrow>
|
|
116 |
\<exists>q r. q \<in> carrier R \<and> r \<in> carrier R \<and> a = (b \<otimes> q) \<oplus> r \<and> ((r = \<zero>) \<or> (\<phi> r < \<phi> b))"
|
|
117 |
shows "euclidean_domain R \<phi>"
|
|
118 |
using assms by unfold_locales auto
|
|
119 |
|
|
120 |
|
|
121 |
subsection \<open>Basic Properties\<close>
|
|
122 |
|
|
123 |
text \<open>Links between domains and commutative cancellative monoids\<close>
|
|
124 |
|
|
125 |
lemma (in cring) to_contain_is_to_divide:
|
|
126 |
assumes "a \<in> carrier R" "b \<in> carrier R"
|
|
127 |
shows "(PIdl b \<subseteq> PIdl a) = (a divides b)"
|
|
128 |
proof
|
|
129 |
show "PIdl b \<subseteq> PIdl a \<Longrightarrow> a divides b"
|
|
130 |
proof -
|
|
131 |
assume "PIdl b \<subseteq> PIdl a"
|
|
132 |
hence "b \<in> PIdl a"
|
|
133 |
by (meson assms(2) local.ring_axioms ring.cgenideal_self subsetCE)
|
|
134 |
thus ?thesis
|
|
135 |
unfolding factor_def cgenideal_def using m_comm assms(1) by blast
|
|
136 |
qed
|
|
137 |
show "a divides b \<Longrightarrow> PIdl b \<subseteq> PIdl a"
|
|
138 |
proof -
|
|
139 |
assume "a divides b" then obtain c where c: "c \<in> carrier R" "b = c \<otimes> a"
|
|
140 |
unfolding factor_def using m_comm[OF assms(1)] by blast
|
|
141 |
show "PIdl b \<subseteq> PIdl a"
|
|
142 |
proof
|
|
143 |
fix x assume "x \<in> PIdl b"
|
|
144 |
then obtain d where d: "d \<in> carrier R" "x = d \<otimes> b"
|
|
145 |
unfolding cgenideal_def by blast
|
|
146 |
hence "x = (d \<otimes> c) \<otimes> a"
|
|
147 |
using c d m_assoc assms by simp
|
|
148 |
thus "x \<in> PIdl a"
|
|
149 |
unfolding cgenideal_def using m_assoc assms c d by blast
|
|
150 |
qed
|
|
151 |
qed
|
|
152 |
qed
|
|
153 |
|
|
154 |
lemma (in cring) associated_iff_same_ideal:
|
|
155 |
assumes "a \<in> carrier R" "b \<in> carrier R"
|
|
156 |
shows "(a \<sim> b) = (PIdl a = PIdl b)"
|
|
157 |
unfolding associated_def
|
|
158 |
using to_contain_is_to_divide[OF assms]
|
|
159 |
to_contain_is_to_divide[OF assms(2) assms(1)] by auto
|
|
160 |
|
|
161 |
lemma divides_mult_imp_divides [simp]: "a divides\<^bsub>(mult_of R)\<^esub> b \<Longrightarrow> a divides\<^bsub>R\<^esub> b"
|
|
162 |
unfolding factor_def by auto
|
|
163 |
|
|
164 |
lemma (in domain) divides_imp_divides_mult [simp]:
|
|
165 |
"\<lbrakk> a \<in> carrier R; b \<in> carrier R - { \<zero> } \<rbrakk> \<Longrightarrow>
|
|
166 |
a divides\<^bsub>R\<^esub> b \<Longrightarrow> a divides\<^bsub>(mult_of R)\<^esub> b"
|
|
167 |
unfolding factor_def using integral_iff by auto
|
|
168 |
|
|
169 |
lemma assoc_mult_imp_assoc [simp]: "a \<sim>\<^bsub>(mult_of R)\<^esub> b \<Longrightarrow> a \<sim>\<^bsub>R\<^esub> b"
|
|
170 |
unfolding associated_def by simp
|
|
171 |
|
|
172 |
lemma (in domain) assoc_imp_assoc_mult [simp]:
|
|
173 |
"\<lbrakk> a \<in> carrier R - { \<zero> } ; b \<in> carrier R - { \<zero> } \<rbrakk> \<Longrightarrow>
|
|
174 |
a \<sim>\<^bsub>R\<^esub> b \<Longrightarrow> a \<sim>\<^bsub>(mult_of R)\<^esub> b"
|
|
175 |
unfolding associated_def by simp
|
|
176 |
|
|
177 |
lemma (in domain) Units_mult_eq_Units [simp]: "Units (mult_of R) = Units R"
|
|
178 |
unfolding Units_def using insert_Diff integral_iff by auto
|
|
179 |
|
|
180 |
lemma (in domain) properfactor_mult_imp_properfactor:
|
|
181 |
"\<lbrakk> a \<in> carrier R; b \<in> carrier R \<rbrakk> \<Longrightarrow> properfactor (mult_of R) b a \<Longrightarrow> properfactor R b a"
|
|
182 |
proof -
|
|
183 |
assume A: "a \<in> carrier R" "b \<in> carrier R" "properfactor (mult_of R) b a"
|
|
184 |
then obtain c where c: "c \<in> carrier (mult_of R)" "a = b \<otimes> c"
|
|
185 |
unfolding properfactor_def factor_def by auto
|
|
186 |
have "a \<noteq> \<zero>"
|
|
187 |
proof (rule ccontr)
|
|
188 |
assume a: "\<not> a \<noteq> \<zero>"
|
|
189 |
hence "b = \<zero>" using c A integral[of b c] by auto
|
|
190 |
hence "b = a \<otimes> \<one>" using a A by simp
|
|
191 |
hence "a divides\<^bsub>(mult_of R)\<^esub> b"
|
|
192 |
unfolding factor_def by auto
|
|
193 |
thus False using A unfolding properfactor_def by simp
|
|
194 |
qed
|
|
195 |
hence "b \<noteq> \<zero>"
|
|
196 |
using c A integral_iff by auto
|
|
197 |
thus "properfactor R b a"
|
|
198 |
using A divides_imp_divides_mult[of a b] unfolding properfactor_def
|
|
199 |
by (meson DiffI divides_mult_imp_divides empty_iff insert_iff)
|
|
200 |
qed
|
|
201 |
|
|
202 |
lemma (in domain) properfactor_imp_properfactor_mult:
|
|
203 |
"\<lbrakk> a \<in> carrier R - { \<zero> }; b \<in> carrier R \<rbrakk> \<Longrightarrow> properfactor R b a \<Longrightarrow> properfactor (mult_of R) b a"
|
|
204 |
unfolding properfactor_def factor_def by auto
|
|
205 |
|
|
206 |
lemma (in domain) primeideal_iff_prime:
|
|
207 |
assumes "p \<in> carrier (mult_of R)"
|
|
208 |
shows "(primeideal (PIdl p) R) = (prime (mult_of R) p)"
|
|
209 |
proof
|
|
210 |
show "prime (mult_of R) p \<Longrightarrow> primeideal (PIdl p) R"
|
|
211 |
proof (rule primeidealI)
|
|
212 |
assume A: "prime (mult_of R) p"
|
|
213 |
show "ideal (PIdl p) R" and "cring R"
|
|
214 |
using assms is_cring by (auto simp add: cgenideal_ideal)
|
|
215 |
show "carrier R \<noteq> PIdl p"
|
|
216 |
proof (rule ccontr)
|
|
217 |
assume "\<not> carrier R \<noteq> PIdl p" hence "carrier R = PIdl p" by simp
|
|
218 |
then obtain c where "c \<in> carrier R" "c \<otimes> p = \<one>"
|
|
219 |
unfolding cgenideal_def using one_closed by (smt mem_Collect_eq)
|
|
220 |
hence "p \<in> Units R" unfolding Units_def using m_comm assms by auto
|
|
221 |
thus False using A unfolding prime_def by simp
|
|
222 |
qed
|
|
223 |
fix a b assume a: "a \<in> carrier R" and b: "b \<in> carrier R" and ab: "a \<otimes> b \<in> PIdl p"
|
|
224 |
thus "a \<in> PIdl p \<or> b \<in> PIdl p"
|
|
225 |
proof (cases "a = \<zero> \<or> b = \<zero>")
|
|
226 |
case True thus "a \<in> PIdl p \<or> b \<in> PIdl p" using ab a b by auto
|
|
227 |
next
|
|
228 |
{ fix a assume "a \<in> carrier R" "p divides\<^bsub>mult_of R\<^esub> a"
|
|
229 |
then obtain c where "c \<in> carrier R" "a = p \<otimes> c"
|
|
230 |
unfolding factor_def by auto
|
|
231 |
hence "a \<in> PIdl p" unfolding cgenideal_def using assms m_comm by auto }
|
|
232 |
note aux_lemma = this
|
|
233 |
|
|
234 |
case False hence "a \<noteq> \<zero> \<and> b \<noteq> \<zero>" by simp
|
|
235 |
hence diff_zero: "a \<otimes> b \<noteq> \<zero>" using a b integral by blast
|
|
236 |
then obtain c where c: "c \<in> carrier R" "a \<otimes> b = p \<otimes> c"
|
|
237 |
using assms ab m_comm unfolding cgenideal_def by auto
|
|
238 |
hence "c \<noteq> \<zero>" using c assms diff_zero by auto
|
|
239 |
hence "p divides\<^bsub>(mult_of R)\<^esub> (a \<otimes> b)"
|
|
240 |
unfolding factor_def using ab c by auto
|
|
241 |
hence "p divides\<^bsub>(mult_of R)\<^esub> a \<or> p divides\<^bsub>(mult_of R)\<^esub> b"
|
|
242 |
using A a b False unfolding prime_def by auto
|
|
243 |
thus "a \<in> PIdl p \<or> b \<in> PIdl p" using a b aux_lemma by blast
|
|
244 |
qed
|
|
245 |
qed
|
|
246 |
next
|
|
247 |
show "primeideal (PIdl p) R \<Longrightarrow> prime (mult_of R) p"
|
|
248 |
proof -
|
|
249 |
assume A: "primeideal (PIdl p) R" show "prime (mult_of R) p"
|
|
250 |
proof (rule primeI)
|
|
251 |
show "p \<notin> Units (mult_of R)"
|
|
252 |
proof (rule ccontr)
|
|
253 |
assume "\<not> p \<notin> Units (mult_of R)"
|
|
254 |
hence p: "p \<in> Units (mult_of R)" by simp
|
|
255 |
then obtain q where q: "q \<in> carrier R - { \<zero> }" "p \<otimes> q = \<one>" "q \<otimes> p = \<one>"
|
|
256 |
unfolding Units_def apply simp by blast
|
|
257 |
have "PIdl p = carrier R"
|
|
258 |
proof
|
|
259 |
show "PIdl p \<subseteq> carrier R"
|
|
260 |
by (simp add: assms A additive_subgroup.a_subset ideal.axioms(1) primeideal.axioms(1))
|
|
261 |
next
|
|
262 |
show "carrier R \<subseteq> PIdl p"
|
|
263 |
proof
|
|
264 |
fix r assume r: "r \<in> carrier R" hence "r = (r \<otimes> q) \<otimes> p"
|
|
265 |
using p q m_assoc unfolding Units_def by simp
|
|
266 |
thus "r \<in> PIdl p" unfolding cgenideal_def using q r m_closed by blast
|
|
267 |
qed
|
|
268 |
qed
|
|
269 |
moreover have "PIdl p \<noteq> carrier R" using A primeideal.I_notcarr by auto
|
|
270 |
ultimately show False by simp
|
|
271 |
qed
|
|
272 |
next
|
|
273 |
{ fix a assume "a \<in> PIdl p" and a: "a \<noteq> \<zero>"
|
|
274 |
then obtain c where c: "c \<in> carrier R" "a = p \<otimes> c"
|
|
275 |
unfolding cgenideal_def using m_comm assms by auto
|
|
276 |
hence "c \<noteq> \<zero>" using assms a by auto
|
|
277 |
hence "p divides\<^bsub>mult_of R\<^esub> a" unfolding factor_def using c by auto }
|
|
278 |
note aux_lemma = this
|
|
279 |
|
|
280 |
fix a b
|
|
281 |
assume a: "a \<in> carrier (mult_of R)" and b: "b \<in> carrier (mult_of R)"
|
|
282 |
and p: "p divides\<^bsub>mult_of R\<^esub> a \<otimes>\<^bsub>mult_of R\<^esub> b"
|
|
283 |
then obtain c where "c \<in> carrier R" "a \<otimes> b = c \<otimes> p"
|
|
284 |
unfolding factor_def using m_comm assms by auto
|
|
285 |
hence "a \<otimes> b \<in> PIdl p" unfolding cgenideal_def by blast
|
|
286 |
hence "a \<in> PIdl p \<or> b \<in> PIdl p" using A primeideal.I_prime[OF A] a b by auto
|
|
287 |
thus "p divides\<^bsub>mult_of R\<^esub> a \<or> p divides\<^bsub>mult_of R\<^esub> b"
|
|
288 |
using a b aux_lemma by auto
|
|
289 |
qed
|
|
290 |
qed
|
|
291 |
qed
|
|
292 |
|
|
293 |
|
|
294 |
subsection \<open>Noetherian Rings\<close>
|
|
295 |
|
|
296 |
lemma (in noetherian_ring) trivial_ideal_seq:
|
|
297 |
assumes "\<And>i :: nat. ideal (I i) R"
|
|
298 |
and "\<And>i j. i \<le> j \<Longrightarrow> I i \<subseteq> I j"
|
|
299 |
shows "\<exists>n. \<forall>k. k \<ge> n \<longrightarrow> I k = I n"
|
|
300 |
proof -
|
|
301 |
have "ideal (\<Union>i. I i) R"
|
|
302 |
proof
|
|
303 |
show "(\<Union>i. I i) \<subseteq> carrier (add_monoid R)"
|
|
304 |
using additive_subgroup.a_subset assms(1) ideal.axioms(1) by fastforce
|
|
305 |
have "\<one>\<^bsub>add_monoid R\<^esub> \<in> I 0"
|
|
306 |
by (simp add: additive_subgroup.zero_closed assms(1) ideal.axioms(1))
|
|
307 |
thus "\<one>\<^bsub>add_monoid R\<^esub> \<in> (\<Union>i. I i)" by blast
|
|
308 |
next
|
|
309 |
fix x y assume x: "x \<in> (\<Union>i. I i)" and y: "y \<in> (\<Union>i. I i)"
|
|
310 |
then obtain i j where i: "x \<in> I i" and j: "y \<in> I j" by blast
|
|
311 |
hence "inv\<^bsub>add_monoid R\<^esub> x \<in> I i"
|
|
312 |
by (simp add: additive_subgroup.a_subgroup assms(1) ideal.axioms(1) subgroup.m_inv_closed)
|
|
313 |
thus "inv\<^bsub>add_monoid R\<^esub> x \<in> (\<Union>i. I i)" by blast
|
|
314 |
have "x \<otimes>\<^bsub>add_monoid R\<^esub> y \<in> I (max i j)"
|
|
315 |
by (metis add.subgroupE(4) additive_subgroup.a_subgroup assms(1-2) i j ideal.axioms(1)
|
|
316 |
max.cobounded1 max.cobounded2 monoid.select_convs(1) rev_subsetD)
|
|
317 |
thus "x \<otimes>\<^bsub>add_monoid R\<^esub> y \<in> (\<Union>i. I i)" by blast
|
|
318 |
next
|
|
319 |
fix x a assume x: "x \<in> carrier R" and a: "a \<in> (\<Union>i. I i)"
|
|
320 |
then obtain i where i: "a \<in> I i" by blast
|
|
321 |
hence "x \<otimes> a \<in> I i" and "a \<otimes> x \<in> I i"
|
|
322 |
by (simp_all add: assms(1) ideal.I_l_closed ideal.I_r_closed x)
|
|
323 |
thus "x \<otimes> a \<in> (\<Union>i. I i)"
|
|
324 |
and "a \<otimes> x \<in> (\<Union>i. I i)" by blast+
|
|
325 |
qed
|
|
326 |
|
|
327 |
then obtain S where S: "S \<subseteq> carrier R" "finite S" "(\<Union>i. I i) = Idl S"
|
|
328 |
by (meson finetely_gen)
|
|
329 |
hence "S \<subseteq> (\<Union>i. I i)"
|
|
330 |
by (simp add: genideal_self)
|
|
331 |
|
|
332 |
from \<open>finite S\<close> and \<open>S \<subseteq> (\<Union>i. I i)\<close> have "\<exists>n. S \<subseteq> I n"
|
|
333 |
proof (induct S set: "finite")
|
|
334 |
case empty thus ?case by simp
|
|
335 |
next
|
|
336 |
case (insert x S')
|
|
337 |
then obtain n m where m: "S' \<subseteq> I m" and n: "x \<in> I n" by blast
|
|
338 |
hence "insert x S' \<subseteq> I (max m n)"
|
|
339 |
by (meson assms(2) insert_subsetI max.cobounded1 max.cobounded2 rev_subsetD subset_trans)
|
|
340 |
thus ?case by blast
|
|
341 |
qed
|
|
342 |
then obtain n where "S \<subseteq> I n" by blast
|
|
343 |
hence "I n = (\<Union>i. I i)"
|
|
344 |
by (metis S(3) Sup_upper assms(1) genideal_minimal range_eqI subset_antisym)
|
|
345 |
thus ?thesis
|
|
346 |
by (metis (full_types) Sup_upper assms(2) range_eqI subset_antisym)
|
|
347 |
qed
|
|
348 |
|
|
349 |
lemma increasing_set_seq_iff:
|
|
350 |
"(\<And>i. I i \<subseteq> I (Suc i)) == (\<And>i j. i \<le> j \<Longrightarrow> I i \<subseteq> I j)"
|
|
351 |
proof
|
|
352 |
fix i j :: "nat"
|
|
353 |
assume A: "\<And>i. I i \<subseteq> I (Suc i)" and "i \<le> j"
|
|
354 |
then obtain k where k: "j = i + k"
|
|
355 |
using le_Suc_ex by blast
|
|
356 |
have "I i \<subseteq> I (i + k)"
|
|
357 |
by (induction k) (simp_all add: A lift_Suc_mono_le)
|
|
358 |
thus "I i \<subseteq> I j" using k by simp
|
|
359 |
next
|
|
360 |
fix i assume "\<And>i j. i \<le> j \<Longrightarrow> I i \<subseteq> I j"
|
|
361 |
thus "I i \<subseteq> I (Suc i)" by simp
|
|
362 |
qed
|
|
363 |
|
|
364 |
|
68579
|
365 |
text \<open>Helper definition for the proofs below\<close>
|
68578
|
366 |
fun S_builder :: "_ \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set" where
|
|
367 |
"S_builder R J 0 = {}" |
|
|
368 |
"S_builder R J (Suc n) =
|
|
369 |
(let diff = (J - Idl\<^bsub>R\<^esub> (S_builder R J n)) in
|
|
370 |
(if diff \<noteq> {} then insert (SOME x. x \<in> diff) (S_builder R J n) else (S_builder R J n)))"
|
|
371 |
|
|
372 |
lemma S_builder_incl: "S_builder R J n \<subseteq> J"
|
|
373 |
by (induction n) (simp_all, (metis (no_types, lifting) some_eq_ex subsetI))
|
|
374 |
|
|
375 |
lemma (in ring) S_builder_const1:
|
|
376 |
assumes "ideal J R" "S_builder R J (Suc n) = S_builder R J n"
|
|
377 |
shows "J = Idl (S_builder R J n)"
|
|
378 |
proof -
|
|
379 |
have "J - Idl (S_builder R J n) = {}"
|
|
380 |
proof (rule ccontr)
|
|
381 |
assume "J - Idl (S_builder R J n) \<noteq> {}"
|
|
382 |
hence "S_builder R J (Suc n) = insert (SOME x. x \<in> (J - Idl (S_builder R J n))) (S_builder R J n)"
|
|
383 |
by simp
|
|
384 |
moreover have "(S_builder R J n) \<subseteq> Idl (S_builder R J n)"
|
|
385 |
using S_builder_incl assms(1)
|
|
386 |
by (metis additive_subgroup.a_subset dual_order.trans genideal_self ideal.axioms(1))
|
|
387 |
ultimately have "S_builder R J (Suc n) \<noteq> S_builder R J n"
|
|
388 |
by (metis Diff_iff \<open>J - Idl S_builder R J n \<noteq> {}\<close> insert_subset some_in_eq)
|
|
389 |
thus False using assms(2) by simp
|
|
390 |
qed
|
|
391 |
thus "J = Idl (S_builder R J n)"
|
|
392 |
by (meson S_builder_incl[of R J n] Diff_eq_empty_iff assms(1) genideal_minimal subset_antisym)
|
|
393 |
qed
|
|
394 |
|
|
395 |
lemma (in ring) S_builder_const2:
|
|
396 |
assumes "ideal J R" "Idl (S_builder R J (Suc n)) = Idl (S_builder R J n)"
|
|
397 |
shows "S_builder R J (Suc n) = S_builder R J n"
|
|
398 |
proof (rule ccontr)
|
|
399 |
assume "S_builder R J (Suc n) \<noteq> S_builder R J n"
|
|
400 |
hence A: "J - Idl (S_builder R J n) \<noteq> {}" by auto
|
|
401 |
hence "S_builder R J (Suc n) = insert (SOME x. x \<in> (J - Idl (S_builder R J n))) (S_builder R J n)" by simp
|
|
402 |
then obtain x where x: "x \<in> (J - Idl (S_builder R J n))"
|
|
403 |
and S: "S_builder R J (Suc n) = insert x (S_builder R J n)"
|
|
404 |
using A some_in_eq by blast
|
|
405 |
have "x \<notin> Idl (S_builder R J n)" using x by blast
|
|
406 |
moreover have "x \<in> Idl (S_builder R J (Suc n))"
|
|
407 |
by (metis (full_types) S S_builder_incl additive_subgroup.a_subset
|
|
408 |
assms(1) dual_order.trans genideal_self ideal.axioms(1) insert_subset)
|
|
409 |
ultimately show False using assms(2) by blast
|
|
410 |
qed
|
|
411 |
|
|
412 |
lemma (in ring) trivial_ideal_seq_imp_noetherian:
|
|
413 |
assumes "\<And>I. \<lbrakk> \<And>i :: nat. ideal (I i) R; \<And>i j. i \<le> j \<Longrightarrow> (I i) \<subseteq> (I j) \<rbrakk> \<Longrightarrow>
|
|
414 |
(\<exists>n. \<forall>k. k \<ge> n \<longrightarrow> I k = I n)"
|
|
415 |
shows "noetherian_ring R"
|
|
416 |
proof -
|
|
417 |
have "\<And>J. ideal J R \<Longrightarrow> \<exists>A. A \<subseteq> carrier R \<and> finite A \<and> J = Idl A"
|
|
418 |
proof -
|
|
419 |
fix J assume J: "ideal J R"
|
|
420 |
define S and I where "S = (\<lambda>i. S_builder R J i)" and "I = (\<lambda>i. Idl (S i))"
|
|
421 |
hence "\<And>i. ideal (I i) R"
|
|
422 |
by (meson J S_builder_incl additive_subgroup.a_subset genideal_ideal ideal.axioms(1) subset_trans)
|
|
423 |
moreover have "\<And>n. S n \<subseteq> S (Suc n)" using S_def by auto
|
|
424 |
hence "\<And>n. I n \<subseteq> I (Suc n)"
|
|
425 |
using S_builder_incl[of R J] J S_def I_def
|
|
426 |
by (meson additive_subgroup.a_subset dual_order.trans ideal.axioms(1) subset_Idl_subset)
|
|
427 |
ultimately obtain n where "\<And>k. k \<ge> n \<Longrightarrow> I k = I n"
|
|
428 |
using assms increasing_set_seq_iff[of I] by (metis lift_Suc_mono_le)
|
|
429 |
hence "J = Idl (S_builder R J n)"
|
|
430 |
using S_builder_const1[OF J, of n] S_builder_const2[OF J, of n] I_def S_def
|
|
431 |
by (meson Suc_n_not_le_n le_cases)
|
|
432 |
moreover have "finite (S_builder R J n)" by (induction n) (simp_all)
|
|
433 |
ultimately show "\<exists>A. A \<subseteq> carrier R \<and> finite A \<and> J = Idl A"
|
|
434 |
by (meson J S_builder_incl ideal.Icarr set_rev_mp subsetI)
|
|
435 |
qed
|
|
436 |
thus ?thesis
|
|
437 |
by (simp add: local.ring_axioms noetherian_ring_axioms_def noetherian_ring_def)
|
|
438 |
qed
|
|
439 |
|
|
440 |
lemma (in noetherian_domain) wfactors_exists:
|
|
441 |
assumes "x \<in> carrier (mult_of R)"
|
|
442 |
shows "\<exists>fs. set fs \<subseteq> carrier (mult_of R) \<and> wfactors (mult_of R) fs x" (is "?P x")
|
|
443 |
proof (rule ccontr)
|
|
444 |
{ fix x
|
|
445 |
assume A: "x \<in> carrier (mult_of R)" "\<not> ?P x"
|
|
446 |
have "\<exists>a. a \<in> carrier (mult_of R) \<and> properfactor (mult_of R) a x \<and> \<not> ?P a"
|
|
447 |
proof -
|
|
448 |
have "\<not> irreducible (mult_of R) x"
|
|
449 |
proof (rule ccontr)
|
|
450 |
assume "\<not> (\<not> irreducible (mult_of R) x)" hence "irreducible (mult_of R) x" by simp
|
|
451 |
hence "wfactors (mult_of R) [ x ] x" unfolding wfactors_def using A by auto
|
|
452 |
thus False using A by auto
|
|
453 |
qed
|
|
454 |
moreover have "\<not> x \<in> Units (mult_of R)"
|
|
455 |
using A monoid.unit_wfactors[OF mult_of.monoid_axioms, of x] by auto
|
|
456 |
ultimately
|
|
457 |
obtain a where a: "a \<in> carrier (mult_of R)" "properfactor (mult_of R) a x" "a \<notin> Units (mult_of R)"
|
|
458 |
unfolding irreducible_def by blast
|
|
459 |
then obtain b where b: "b \<in> carrier (mult_of R)" "x = a \<otimes> b"
|
|
460 |
unfolding properfactor_def by auto
|
|
461 |
hence b_properfactor: "properfactor (mult_of R) b x"
|
|
462 |
using A a mult_of.m_comm mult_of.properfactorI3 by blast
|
|
463 |
have "\<not> ?P a \<or> \<not> ?P b"
|
|
464 |
proof (rule ccontr)
|
|
465 |
assume "\<not> (\<not> ?P a \<or> \<not> ?P b)"
|
|
466 |
then obtain fs_a fs_b
|
|
467 |
where fs_a: "wfactors (mult_of R) fs_a a" "set fs_a \<subseteq> carrier (mult_of R)"
|
|
468 |
and fs_b: "wfactors (mult_of R) fs_b b" "set fs_b \<subseteq> carrier (mult_of R)" by blast
|
|
469 |
hence "wfactors (mult_of R) (fs_a @ fs_b) x"
|
|
470 |
using fs_a fs_b a b mult_of.wfactors_mult by simp
|
|
471 |
moreover have "set (fs_a @ fs_b) \<subseteq> carrier (mult_of R)"
|
|
472 |
using fs_a fs_b by auto
|
|
473 |
ultimately show False using A by blast
|
|
474 |
qed
|
|
475 |
thus ?thesis using a b b_properfactor mult_of.m_comm by blast
|
|
476 |
qed } note aux_lemma = this
|
|
477 |
|
|
478 |
assume A: "\<not> ?P x"
|
|
479 |
|
|
480 |
define f :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
|
|
481 |
where "f = (\<lambda>a x. (a \<in> carrier (mult_of R) \<and> properfactor (mult_of R) a x \<and> \<not> ?P a))"
|
|
482 |
define factor_seq :: "nat \<Rightarrow> 'a"
|
|
483 |
where "factor_seq = rec_nat x (\<lambda>n y. (SOME a. f a y))"
|
|
484 |
define I where "I = (\<lambda>i. PIdl (factor_seq i))"
|
|
485 |
have factor_seq_props:
|
|
486 |
"\<And>n. properfactor (mult_of R) (factor_seq (Suc n)) (factor_seq n) \<and>
|
|
487 |
(factor_seq n) \<in> carrier (mult_of R) \<and> \<not> ?P (factor_seq n)" (is "\<And>n. ?Q n")
|
|
488 |
proof -
|
|
489 |
fix n show "?Q n"
|
|
490 |
proof (induct n)
|
|
491 |
case 0
|
|
492 |
have x: "factor_seq 0 = x"
|
|
493 |
using factor_seq_def by simp
|
|
494 |
hence "factor_seq (Suc 0) = (SOME a. f a x)"
|
|
495 |
by (simp add: factor_seq_def)
|
|
496 |
moreover have "\<exists>a. f a x"
|
|
497 |
using aux_lemma[OF assms] A f_def by blast
|
|
498 |
ultimately have "f (factor_seq (Suc 0)) x"
|
|
499 |
using tfl_some by metis
|
|
500 |
thus ?case using f_def A assms x by simp
|
|
501 |
next
|
|
502 |
case (Suc n)
|
|
503 |
have "factor_seq (Suc n) = (SOME a. f a (factor_seq n))"
|
|
504 |
by (simp add: factor_seq_def)
|
|
505 |
moreover have "\<exists>a. f a (factor_seq n)"
|
|
506 |
using aux_lemma f_def Suc.hyps by blast
|
|
507 |
ultimately have Step0: "f (factor_seq (Suc n)) (factor_seq n)"
|
|
508 |
using tfl_some by metis
|
|
509 |
hence "\<exists>a. f a (factor_seq (Suc n))"
|
|
510 |
using aux_lemma f_def by blast
|
|
511 |
moreover have "factor_seq (Suc (Suc n)) = (SOME a. f a (factor_seq (Suc n)))"
|
|
512 |
by (simp add: factor_seq_def)
|
|
513 |
ultimately have Step1: "f (factor_seq (Suc (Suc n))) (factor_seq (Suc n))"
|
|
514 |
using tfl_some by metis
|
|
515 |
show ?case using Step0 Step1 f_def by simp
|
|
516 |
qed
|
|
517 |
qed
|
|
518 |
|
|
519 |
have in_carrier: "\<And>i. factor_seq i \<in> carrier R"
|
|
520 |
using factor_seq_props by simp
|
|
521 |
hence "\<And>i. ideal (I i) R"
|
|
522 |
using I_def by (simp add: cgenideal_ideal)
|
|
523 |
|
|
524 |
moreover
|
|
525 |
have "\<And>i. factor_seq (Suc i) divides factor_seq i"
|
|
526 |
using factor_seq_props unfolding properfactor_def by auto
|
|
527 |
hence "\<And>i. PIdl (factor_seq i) \<subseteq> PIdl (factor_seq (Suc i))"
|
|
528 |
using in_carrier to_contain_is_to_divide by simp
|
|
529 |
hence "\<And>i j. i \<le> j \<Longrightarrow> I i \<subseteq> I j"
|
|
530 |
using increasing_set_seq_iff[of I] unfolding I_def by auto
|
|
531 |
|
|
532 |
ultimately obtain n where "\<And>k. n \<le> k \<Longrightarrow> I n = I k"
|
|
533 |
by (metis trivial_ideal_seq)
|
|
534 |
hence "I (Suc n) \<subseteq> I n" by (simp add: equalityD2)
|
|
535 |
hence "factor_seq n divides factor_seq (Suc n)"
|
|
536 |
using in_carrier I_def to_contain_is_to_divide by simp
|
|
537 |
moreover have "\<not> factor_seq n divides\<^bsub>(mult_of R)\<^esub> factor_seq (Suc n)"
|
|
538 |
using factor_seq_props[of n] unfolding properfactor_def by simp
|
|
539 |
hence "\<not> factor_seq n divides factor_seq (Suc n)"
|
|
540 |
using divides_imp_divides_mult[of "factor_seq n" "factor_seq (Suc n)"]
|
|
541 |
in_carrier[of n] factor_seq_props[of "Suc n"] by auto
|
|
542 |
ultimately show False by simp
|
|
543 |
qed
|
|
544 |
|
|
545 |
|
|
546 |
subsection \<open>Principal Domains\<close>
|
|
547 |
|
|
548 |
sublocale principal_domain \<subseteq> noetherian_domain
|
|
549 |
proof
|
|
550 |
fix I assume "ideal I R"
|
|
551 |
then obtain i where "i \<in> carrier R" "I = Idl { i }"
|
|
552 |
using principal_I principalideal.generate by blast
|
|
553 |
thus "\<exists>A \<subseteq> carrier R. finite A \<and> I = Idl A" by blast
|
|
554 |
qed
|
|
555 |
|
|
556 |
lemma (in principal_domain) irreducible_imp_maximalideal:
|
|
557 |
assumes "p \<in> carrier (mult_of R)"
|
|
558 |
and "irreducible (mult_of R) p"
|
|
559 |
shows "maximalideal (PIdl p) R"
|
|
560 |
proof (rule maximalidealI)
|
|
561 |
show "ideal (PIdl p) R"
|
|
562 |
using assms(1) by (simp add: cgenideal_ideal)
|
|
563 |
next
|
|
564 |
show "carrier R \<noteq> PIdl p"
|
|
565 |
proof (rule ccontr)
|
|
566 |
assume "\<not> carrier R \<noteq> PIdl p"
|
|
567 |
hence "carrier R = PIdl p" by simp
|
|
568 |
then obtain c where "c \<in> carrier R" "\<one> = c \<otimes> p"
|
|
569 |
unfolding cgenideal_def using one_closed by auto
|
|
570 |
hence "p \<in> Units R"
|
|
571 |
unfolding Units_def using assms(1) m_comm by auto
|
|
572 |
thus False
|
|
573 |
using assms unfolding irreducible_def by auto
|
|
574 |
qed
|
|
575 |
next
|
|
576 |
fix J assume J: "ideal J R" "PIdl p \<subseteq> J" "J \<subseteq> carrier R"
|
|
577 |
then obtain q where q: "q \<in> carrier R" "J = PIdl q"
|
|
578 |
using principal_I[OF J(1)] cgenideal_eq_rcos is_cring
|
|
579 |
principalideal.rcos_generate by (metis contra_subsetD)
|
|
580 |
hence "q divides p"
|
|
581 |
using to_contain_is_to_divide[of q p] using assms(1) J(1-2) by simp
|
|
582 |
hence q_div_p: "q divides\<^bsub>(mult_of R)\<^esub> p"
|
|
583 |
using assms(1) divides_imp_divides_mult[OF q(1), of p] by (simp add: \<open>q divides p\<close>)
|
|
584 |
show "J = PIdl p \<or> J = carrier R"
|
|
585 |
proof (cases "q \<in> Units R")
|
|
586 |
case True thus ?thesis
|
|
587 |
by (metis J(1) Units_r_inv_ex cgenideal_self ideal.I_r_closed ideal.one_imp_carrier q(1) q(2))
|
|
588 |
next
|
|
589 |
case False
|
|
590 |
have q_in_carr: "q \<in> carrier (mult_of R)"
|
|
591 |
using q_div_p unfolding factor_def using assms(1) q(1) by auto
|
|
592 |
hence "p divides\<^bsub>(mult_of R)\<^esub> q"
|
|
593 |
using q_div_p False assms(2) unfolding irreducible_def properfactor_def by auto
|
|
594 |
hence "p \<sim> q" using q_div_p
|
|
595 |
unfolding associated_def by simp
|
|
596 |
thus ?thesis using associated_iff_same_ideal[of p q] assms(1) q_in_carr q by simp
|
|
597 |
qed
|
|
598 |
qed
|
|
599 |
|
|
600 |
corollary (in principal_domain) primeness_condition:
|
|
601 |
assumes "p \<in> carrier (mult_of R)"
|
|
602 |
shows "(irreducible (mult_of R) p) \<longleftrightarrow> (prime (mult_of R) p)"
|
|
603 |
proof
|
|
604 |
show "irreducible (mult_of R) p \<Longrightarrow> prime (mult_of R) p"
|
|
605 |
using irreducible_imp_maximalideal maximalideal_prime primeideal_iff_prime assms by auto
|
|
606 |
next
|
|
607 |
show "prime (mult_of R) p \<Longrightarrow> irreducible (mult_of R) p"
|
|
608 |
using mult_of.prime_irreducible by simp
|
|
609 |
qed
|
|
610 |
|
|
611 |
lemma (in principal_domain) domain_iff_prime:
|
|
612 |
assumes "a \<in> carrier R - { \<zero> }"
|
|
613 |
shows "domain (R Quot (PIdl a)) \<longleftrightarrow> prime (mult_of R) a"
|
|
614 |
using quot_domain_iff_primeideal[of "PIdl a"] primeideal_iff_prime[of a]
|
|
615 |
cgenideal_ideal[of a] assms by auto
|
|
616 |
|
|
617 |
lemma (in principal_domain) field_iff_prime:
|
|
618 |
assumes "a \<in> carrier R - { \<zero> }"
|
|
619 |
shows "field (R Quot (PIdl a)) \<longleftrightarrow> prime (mult_of R) a"
|
|
620 |
proof
|
|
621 |
show "prime (mult_of R) a \<Longrightarrow> field (R Quot (PIdl a))"
|
|
622 |
using primeness_condition[of a] irreducible_imp_maximalideal[of a]
|
|
623 |
maximalideal.quotient_is_field[of "PIdl a" R] is_cring assms by auto
|
|
624 |
next
|
|
625 |
show "field (R Quot (PIdl a)) \<Longrightarrow> prime (mult_of R) a"
|
|
626 |
unfolding field_def using domain_iff_prime[of a] assms by auto
|
|
627 |
qed
|
|
628 |
|
|
629 |
sublocale principal_domain < mult_of: primeness_condition_monoid "(mult_of R)"
|
|
630 |
rewrites "mult (mult_of R) = mult R"
|
|
631 |
and "one (mult_of R) = one R"
|
|
632 |
unfolding primeness_condition_monoid_def
|
|
633 |
primeness_condition_monoid_axioms_def
|
|
634 |
using mult_of.is_comm_monoid_cancel primeness_condition by auto
|
|
635 |
|
|
636 |
sublocale principal_domain < mult_of: factorial_monoid "(mult_of R)"
|
|
637 |
rewrites "mult (mult_of R) = mult R"
|
|
638 |
and "one (mult_of R) = one R"
|
|
639 |
apply (rule mult_of.factorial_monoidI)
|
|
640 |
using mult_of.wfactors_unique wfactors_exists mult_of.is_comm_monoid_cancel by auto
|
|
641 |
|
|
642 |
sublocale principal_domain \<subseteq> factorial_domain
|
|
643 |
unfolding factorial_domain_def using is_domain mult_of.is_factorial_monoid by simp
|
|
644 |
|
|
645 |
lemma (in principal_domain) ideal_sum_iff_gcd:
|
|
646 |
assumes "a \<in> carrier (mult_of R)" "b \<in> carrier (mult_of R)" "d \<in> carrier (mult_of R)"
|
|
647 |
shows "((PIdl a) <+>\<^bsub>R\<^esub> (PIdl b) = (PIdl d)) \<longleftrightarrow> (d gcdof\<^bsub>(mult_of R)\<^esub> a b)"
|
|
648 |
proof
|
|
649 |
assume A: "(PIdl a) <+>\<^bsub>R\<^esub> (PIdl b) = (PIdl d)" show "d gcdof\<^bsub>(mult_of R)\<^esub> a b"
|
|
650 |
proof -
|
|
651 |
have "(PIdl a) \<subseteq> (PIdl d) \<and> (PIdl b) \<subseteq> (PIdl d)"
|
|
652 |
using assms
|
|
653 |
by (simp, metis Un_subset_iff cgenideal_ideal cgenideal_minimal local.ring_axioms
|
|
654 |
ring.genideal_self ring.oneideal ring.union_genideal A)
|
|
655 |
hence "d divides a \<and> d divides b"
|
|
656 |
using assms apply simp
|
|
657 |
using to_contain_is_to_divide[of d a] to_contain_is_to_divide[of d b] by auto
|
|
658 |
hence "d divides\<^bsub>(mult_of R)\<^esub> a \<and> d divides\<^bsub>(mult_of R)\<^esub> b"
|
|
659 |
using assms by simp
|
|
660 |
|
|
661 |
moreover
|
|
662 |
have "\<And>c. \<lbrakk> c \<in> carrier (mult_of R); c divides\<^bsub>(mult_of R)\<^esub> a; c divides\<^bsub>(mult_of R)\<^esub> b \<rbrakk> \<Longrightarrow>
|
|
663 |
c divides\<^bsub>(mult_of R)\<^esub> d"
|
|
664 |
proof -
|
|
665 |
fix c assume c: "c \<in> carrier (mult_of R)"
|
|
666 |
and "c divides\<^bsub>(mult_of R)\<^esub> a" "c divides\<^bsub>(mult_of R)\<^esub> b"
|
|
667 |
hence "c divides a" "c divides b" by auto
|
|
668 |
hence "(PIdl a) \<subseteq> (PIdl c) \<and> (PIdl b) \<subseteq> (PIdl c)"
|
|
669 |
using to_contain_is_to_divide[of c a] to_contain_is_to_divide[of c b] c assms by simp
|
|
670 |
hence "((PIdl a) <+>\<^bsub>R\<^esub> (PIdl b)) \<subseteq> (PIdl c)"
|
|
671 |
using assms c
|
|
672 |
by (simp, metis Un_subset_iff cgenideal_ideal cgenideal_minimal
|
|
673 |
Idl_subset_ideal oneideal union_genideal)
|
|
674 |
hence incl: "(PIdl d) \<subseteq> (PIdl c)" using A by simp
|
|
675 |
hence "c divides d"
|
|
676 |
using c assms(3) apply simp
|
|
677 |
using to_contain_is_to_divide[of c d] by blast
|
|
678 |
thus "c divides\<^bsub>(mult_of R)\<^esub> d" using c assms(3) by simp
|
|
679 |
qed
|
|
680 |
|
|
681 |
ultimately show ?thesis unfolding isgcd_def by simp
|
|
682 |
qed
|
|
683 |
next
|
|
684 |
assume A:"d gcdof\<^bsub>mult_of R\<^esub> a b" show "PIdl a <+>\<^bsub>R\<^esub> PIdl b = PIdl d"
|
|
685 |
proof
|
|
686 |
have "d divides a" "d divides b"
|
|
687 |
using A unfolding isgcd_def by auto
|
|
688 |
hence "(PIdl a) \<subseteq> (PIdl d) \<and> (PIdl b) \<subseteq> (PIdl d)"
|
|
689 |
using to_contain_is_to_divide[of d a] to_contain_is_to_divide[of d b] assms by simp
|
|
690 |
thus "PIdl a <+>\<^bsub>R\<^esub> PIdl b \<subseteq> PIdl d" using assms
|
|
691 |
by (simp, metis Un_subset_iff cgenideal_ideal cgenideal_minimal
|
|
692 |
Idl_subset_ideal oneideal union_genideal)
|
|
693 |
next
|
|
694 |
have "ideal ((PIdl a) <+>\<^bsub>R\<^esub> (PIdl b)) R"
|
|
695 |
using assms by (simp add: cgenideal_ideal local.ring_axioms ring.add_ideals)
|
|
696 |
then obtain c where c: "c \<in> carrier R" "(PIdl c) = (PIdl a) <+>\<^bsub>R\<^esub> (PIdl b)"
|
|
697 |
using cgenideal_eq_genideal principal_I principalideal.generate by force
|
|
698 |
hence "(PIdl a) \<subseteq> (PIdl c) \<and> (PIdl b) \<subseteq> (PIdl c)" using assms
|
|
699 |
by (simp, metis Un_subset_iff cgenideal_ideal cgenideal_minimal
|
|
700 |
genideal_self oneideal union_genideal)
|
|
701 |
hence "c divides a \<and> c divides b" using c(1) assms apply simp
|
|
702 |
using to_contain_is_to_divide[of c a] to_contain_is_to_divide[of c b] by blast
|
|
703 |
hence "c divides\<^bsub>(mult_of R)\<^esub> a \<and> c divides\<^bsub>(mult_of R)\<^esub> b"
|
|
704 |
using assms(1-2) c(1) by simp
|
|
705 |
|
|
706 |
moreover have neq_zero: "c \<noteq> \<zero>"
|
|
707 |
proof (rule ccontr)
|
|
708 |
assume "\<not> c \<noteq> \<zero>" hence "PIdl c = { \<zero> }"
|
|
709 |
using cgenideal_eq_genideal genideal_zero by auto
|
|
710 |
moreover have "\<one> \<otimes> a \<in> PIdl a \<and> \<zero> \<otimes> b \<in> PIdl b"
|
|
711 |
unfolding cgenideal_def using assms one_closed zero_closed by blast
|
|
712 |
hence "(\<one> \<otimes> a) \<oplus> (\<zero> \<otimes> b) \<in> (PIdl a) <+>\<^bsub>R\<^esub> (PIdl b)"
|
|
713 |
unfolding set_add_def' by auto
|
|
714 |
hence "a \<in> PIdl c"
|
|
715 |
using c assms by simp
|
|
716 |
ultimately show False
|
|
717 |
using assms(1) by simp
|
|
718 |
qed
|
|
719 |
|
|
720 |
ultimately have "c divides\<^bsub>(mult_of R)\<^esub> d"
|
|
721 |
using A c(1) unfolding isgcd_def by simp
|
|
722 |
hence "(PIdl d) \<subseteq> (PIdl c)"
|
|
723 |
using to_contain_is_to_divide[of c d] c(1) assms(3) by simp
|
|
724 |
thus "PIdl d \<subseteq> PIdl a <+>\<^bsub>R\<^esub> PIdl b" using c by simp
|
|
725 |
qed
|
|
726 |
qed
|
|
727 |
|
|
728 |
lemma (in principal_domain) bezout_identity:
|
|
729 |
assumes "a \<in> carrier (mult_of R)" "b \<in> carrier (mult_of R)"
|
|
730 |
shows "(PIdl a) <+>\<^bsub>R\<^esub> (PIdl b) = (PIdl (somegcd (mult_of R) a b))"
|
|
731 |
proof -
|
|
732 |
have "(somegcd (mult_of R) a b) \<in> carrier (mult_of R)"
|
|
733 |
using mult_of.gcd_exists[OF assms] by simp
|
|
734 |
hence "\<And>x. x = somegcd (mult_of R) a b \<Longrightarrow> (PIdl a) <+>\<^bsub>R\<^esub> (PIdl b) = (PIdl x)"
|
|
735 |
using mult_of.gcd_isgcd[OF assms] ideal_sum_iff_gcd[OF assms] by simp
|
|
736 |
thus ?thesis
|
|
737 |
using mult_of.gcd_exists[OF assms] by blast
|
|
738 |
qed
|
|
739 |
|
|
740 |
|
|
741 |
subsection \<open>Euclidean Domains\<close>
|
|
742 |
|
|
743 |
sublocale euclidean_domain \<subseteq> principal_domain
|
|
744 |
unfolding principal_domain_def principal_domain_axioms_def
|
|
745 |
proof (auto)
|
|
746 |
show "domain R" by (simp add: domain_axioms)
|
|
747 |
next
|
|
748 |
fix I assume I: "ideal I R" show "principalideal I R"
|
|
749 |
proof (cases "I = { \<zero> }")
|
|
750 |
case True thus ?thesis by (simp add: zeropideal)
|
|
751 |
next
|
|
752 |
case False hence A: "I - { \<zero> } \<noteq> {}"
|
|
753 |
using I additive_subgroup.zero_closed ideal.axioms(1) by auto
|
|
754 |
define phi_img :: "nat set" where "phi_img = (\<phi> ` (I - { \<zero> }))"
|
|
755 |
hence "phi_img \<noteq> {}" using A by simp
|
|
756 |
then obtain m where "m \<in> phi_img" "\<And>k. k \<in> phi_img \<Longrightarrow> m \<le> k"
|
|
757 |
using exists_least_iff[of "\<lambda>n. n \<in> phi_img"] not_less by force
|
|
758 |
then obtain a where a: "a \<in> I - { \<zero> }" "\<And>b. b \<in> I - { \<zero> } \<Longrightarrow> \<phi> a \<le> \<phi> b"
|
|
759 |
using phi_img_def by blast
|
|
760 |
have "I = PIdl a"
|
|
761 |
proof (rule ccontr)
|
|
762 |
assume "I \<noteq> PIdl a"
|
|
763 |
then obtain b where b: "b \<in> I" "b \<notin> PIdl a"
|
|
764 |
using I \<open>a \<in> I - {\<zero>}\<close> cgenideal_minimal by auto
|
|
765 |
hence "b \<noteq> \<zero>"
|
|
766 |
by (metis DiffD1 I a(1) additive_subgroup.zero_closed cgenideal_ideal ideal.Icarr ideal.axioms(1))
|
|
767 |
then obtain q r
|
|
768 |
where eucl_div: "q \<in> carrier R" "r \<in> carrier R" "b = (a \<otimes> q) \<oplus> r" "r = \<zero> \<or> \<phi> r < \<phi> a"
|
|
769 |
using euclidean_function[of b a] a(1) b(1) ideal.Icarr[OF I] by auto
|
|
770 |
hence "r = \<zero> \<Longrightarrow> b \<in> PIdl a"
|
|
771 |
unfolding cgenideal_def using m_comm[of a] ideal.Icarr[OF I] a(1) by auto
|
|
772 |
hence 1: "\<phi> r < \<phi> a \<and> r \<noteq> \<zero>"
|
|
773 |
using eucl_div(4) b(2) by auto
|
|
774 |
|
|
775 |
have "r = (\<ominus> (a \<otimes> q)) \<oplus> b"
|
|
776 |
using eucl_div(1-3) a(1) b(1) ideal.Icarr[OF I] r_neg1 by auto
|
|
777 |
moreover have "\<ominus> (a \<otimes> q) \<in> I"
|
|
778 |
using eucl_div(1) a(1) I
|
|
779 |
by (meson DiffD1 additive_subgroup.a_inv_closed ideal.I_r_closed ideal.axioms(1))
|
|
780 |
ultimately have 2: "r \<in> I"
|
|
781 |
using b(1) additive_subgroup.a_closed[OF ideal.axioms(1)[OF I]] by auto
|
|
782 |
|
|
783 |
from 1 and 2 show False
|
|
784 |
using a(2) by fastforce
|
|
785 |
qed
|
|
786 |
thus ?thesis
|
|
787 |
by (meson DiffD1 I cgenideal_is_principalideal ideal.Icarr local.a(1))
|
|
788 |
qed
|
|
789 |
qed
|
|
790 |
|
|
791 |
sublocale field \<subseteq> euclidean_domain R "\<lambda>_. 0"
|
|
792 |
proof (rule euclidean_domainI)
|
|
793 |
fix a b
|
|
794 |
let ?eucl_div = "\<lambda>q r. q \<in> carrier R \<and> r \<in> carrier R \<and> a = b \<otimes> q \<oplus> r \<and> (r = \<zero> \<or> 0 < 0)"
|
|
795 |
assume a: "a \<in> carrier R - { \<zero> }" and b: "b \<in> carrier R - { \<zero> }"
|
|
796 |
hence "a = b \<otimes> ((inv b) \<otimes> a) \<oplus> \<zero>"
|
|
797 |
by (metis DiffD1 Units_inv_closed Units_r_inv field_Units l_one m_assoc r_zero)
|
|
798 |
hence "?eucl_div _ ((inv b) \<otimes> a) \<zero>"
|
|
799 |
using a b field_Units by auto
|
|
800 |
thus "\<exists>q r. ?eucl_div _ q r"
|
|
801 |
by blast
|
|
802 |
qed
|
|
803 |
|
68583
|
804 |
end
|