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