author | wenzelm |
Sat, 13 Mar 2010 14:44:47 +0100 | |
changeset 35743 | c506c029a082 |
parent 35416 | d8d7d1b785af |
child 35847 | 19f1f7066917 |
permissions | -rw-r--r-- |
27701 | 1 |
(* |
2 |
Title: Divisibility in monoids and rings |
|
3 |
Author: Clemens Ballarin, started 18 July 2008 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
4 |
|
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
5 |
Based on work by Stephan Hohe. |
27701 | 6 |
*) |
7 |
||
8 |
theory Divisibility |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
9 |
imports Permutation Coset Group |
27701 | 10 |
begin |
11 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
12 |
section {* Factorial Monoids *} |
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
13 |
|
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
14 |
subsection {* Monoids with Cancellation Law *} |
27701 | 15 |
|
16 |
locale monoid_cancel = monoid + |
|
17 |
assumes l_cancel: |
|
18 |
"\<lbrakk>c \<otimes> a = c \<otimes> b; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
19 |
and r_cancel: |
|
20 |
"\<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
21 |
||
22 |
lemma (in monoid) monoid_cancelI: |
|
23 |
assumes l_cancel: |
|
24 |
"\<And>a b c. \<lbrakk>c \<otimes> a = c \<otimes> b; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
25 |
and r_cancel: |
|
26 |
"\<And>a b c. \<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
27 |
shows "monoid_cancel G" |
|
28823 | 28 |
proof qed fact+ |
27701 | 29 |
|
30 |
lemma (in monoid_cancel) is_monoid_cancel: |
|
31 |
"monoid_cancel G" |
|
28823 | 32 |
.. |
27701 | 33 |
|
29237 | 34 |
sublocale group \<subseteq> monoid_cancel |
28823 | 35 |
proof qed simp+ |
27701 | 36 |
|
37 |
||
38 |
locale comm_monoid_cancel = monoid_cancel + comm_monoid |
|
39 |
||
40 |
lemma comm_monoid_cancelI: |
|
28599 | 41 |
fixes G (structure) |
42 |
assumes "comm_monoid G" |
|
27701 | 43 |
assumes cancel: |
44 |
"\<And>a b c. \<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
45 |
shows "comm_monoid_cancel G" |
|
28599 | 46 |
proof - |
29237 | 47 |
interpret comm_monoid G by fact |
28599 | 48 |
show "comm_monoid_cancel G" |
49 |
apply unfold_locales |
|
50 |
apply (subgoal_tac "a \<otimes> c = b \<otimes> c") |
|
51 |
apply (iprover intro: cancel) |
|
52 |
apply (simp add: m_comm) |
|
53 |
apply (iprover intro: cancel) |
|
54 |
done |
|
55 |
qed |
|
27701 | 56 |
|
57 |
lemma (in comm_monoid_cancel) is_comm_monoid_cancel: |
|
58 |
"comm_monoid_cancel G" |
|
28823 | 59 |
by intro_locales |
27701 | 60 |
|
29237 | 61 |
sublocale comm_group \<subseteq> comm_monoid_cancel |
28823 | 62 |
.. |
27701 | 63 |
|
64 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
65 |
subsection {* Products of Units in Monoids *} |
27701 | 66 |
|
67 |
lemma (in monoid) Units_m_closed[simp, intro]: |
|
68 |
assumes h1unit: "h1 \<in> Units G" and h2unit: "h2 \<in> Units G" |
|
69 |
shows "h1 \<otimes> h2 \<in> Units G" |
|
70 |
unfolding Units_def |
|
71 |
using assms |
|
72 |
apply safe |
|
73 |
apply fast |
|
74 |
apply (intro bexI[of _ "inv h2 \<otimes> inv h1"], safe) |
|
75 |
apply (simp add: m_assoc Units_closed) |
|
76 |
apply (simp add: m_assoc[symmetric] Units_closed Units_l_inv) |
|
77 |
apply (simp add: m_assoc Units_closed) |
|
78 |
apply (simp add: m_assoc[symmetric] Units_closed Units_r_inv) |
|
79 |
apply fast |
|
80 |
done |
|
81 |
||
82 |
lemma (in monoid) prod_unit_l: |
|
83 |
assumes abunit[simp]: "a \<otimes> b \<in> Units G" and aunit[simp]: "a \<in> Units G" |
|
84 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
85 |
shows "b \<in> Units G" |
|
86 |
proof - |
|
87 |
have c: "inv (a \<otimes> b) \<otimes> a \<in> carrier G" by simp |
|
88 |
||
89 |
have "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = inv (a \<otimes> b) \<otimes> (a \<otimes> b)" by (simp add: m_assoc) |
|
90 |
also have "\<dots> = \<one>" by (simp add: Units_l_inv) |
|
91 |
finally have li: "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = \<one>" . |
|
92 |
||
93 |
have "\<one> = inv a \<otimes> a" by (simp add: Units_l_inv[symmetric]) |
|
94 |
also have "\<dots> = inv a \<otimes> \<one> \<otimes> a" by simp |
|
95 |
also have "\<dots> = inv a \<otimes> ((a \<otimes> b) \<otimes> inv (a \<otimes> b)) \<otimes> a" |
|
96 |
by (simp add: Units_r_inv[OF abunit, symmetric] del: Units_r_inv) |
|
97 |
also have "\<dots> = ((inv a \<otimes> a) \<otimes> b) \<otimes> inv (a \<otimes> b) \<otimes> a" |
|
98 |
by (simp add: m_assoc del: Units_l_inv) |
|
99 |
also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by (simp add: Units_l_inv) |
|
100 |
also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> a)" by (simp add: m_assoc) |
|
101 |
finally have ri: "b \<otimes> (inv (a \<otimes> b) \<otimes> a) = \<one> " by simp |
|
102 |
||
103 |
from c li ri |
|
104 |
show "b \<in> Units G" by (simp add: Units_def, fast) |
|
105 |
qed |
|
106 |
||
107 |
lemma (in monoid) prod_unit_r: |
|
108 |
assumes abunit[simp]: "a \<otimes> b \<in> Units G" and bunit[simp]: "b \<in> Units G" |
|
109 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
110 |
shows "a \<in> Units G" |
|
111 |
proof - |
|
112 |
have c: "b \<otimes> inv (a \<otimes> b) \<in> carrier G" by simp |
|
113 |
||
114 |
have "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = (a \<otimes> b) \<otimes> inv (a \<otimes> b)" |
|
115 |
by (simp add: m_assoc del: Units_r_inv) |
|
116 |
also have "\<dots> = \<one>" by simp |
|
117 |
finally have li: "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = \<one>" . |
|
118 |
||
119 |
have "\<one> = b \<otimes> inv b" by (simp add: Units_r_inv[symmetric]) |
|
120 |
also have "\<dots> = b \<otimes> \<one> \<otimes> inv b" by simp |
|
121 |
also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> (a \<otimes> b)) \<otimes> inv b" |
|
122 |
by (simp add: Units_l_inv[OF abunit, symmetric] del: Units_l_inv) |
|
123 |
also have "\<dots> = (b \<otimes> inv (a \<otimes> b) \<otimes> a) \<otimes> (b \<otimes> inv b)" |
|
124 |
by (simp add: m_assoc del: Units_l_inv) |
|
125 |
also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by simp |
|
126 |
finally have ri: "(b \<otimes> inv (a \<otimes> b)) \<otimes> a = \<one> " by simp |
|
127 |
||
128 |
from c li ri |
|
129 |
show "a \<in> Units G" by (simp add: Units_def, fast) |
|
130 |
qed |
|
131 |
||
132 |
lemma (in comm_monoid) unit_factor: |
|
133 |
assumes abunit: "a \<otimes> b \<in> Units G" |
|
134 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
135 |
shows "a \<in> Units G" |
|
136 |
using abunit[simplified Units_def] |
|
137 |
proof clarsimp |
|
138 |
fix i |
|
139 |
assume [simp]: "i \<in> carrier G" |
|
140 |
and li: "i \<otimes> (a \<otimes> b) = \<one>" |
|
141 |
and ri: "a \<otimes> b \<otimes> i = \<one>" |
|
142 |
||
143 |
have carr': "b \<otimes> i \<in> carrier G" by simp |
|
144 |
||
145 |
have "(b \<otimes> i) \<otimes> a = (i \<otimes> b) \<otimes> a" by (simp add: m_comm) |
|
146 |
also have "\<dots> = i \<otimes> (b \<otimes> a)" by (simp add: m_assoc) |
|
147 |
also have "\<dots> = i \<otimes> (a \<otimes> b)" by (simp add: m_comm) |
|
148 |
also note li |
|
149 |
finally have li': "(b \<otimes> i) \<otimes> a = \<one>" . |
|
150 |
||
151 |
have "a \<otimes> (b \<otimes> i) = a \<otimes> b \<otimes> i" by (simp add: m_assoc) |
|
152 |
also note ri |
|
153 |
finally have ri': "a \<otimes> (b \<otimes> i) = \<one>" . |
|
154 |
||
155 |
from carr' li' ri' |
|
156 |
show "a \<in> Units G" by (simp add: Units_def, fast) |
|
157 |
qed |
|
158 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
159 |
subsection {* Divisibility and Association *} |
27701 | 160 |
|
161 |
subsubsection {* Function definitions *} |
|
162 |
||
163 |
constdefs (structure G) |
|
164 |
factor :: "[_, 'a, 'a] \<Rightarrow> bool" (infix "divides\<index>" 65) |
|
165 |
"a divides b == \<exists>c\<in>carrier G. b = a \<otimes> c" |
|
166 |
||
167 |
constdefs (structure G) |
|
168 |
associated :: "[_, 'a, 'a] => bool" (infix "\<sim>\<index>" 55) |
|
169 |
"a \<sim> b == a divides b \<and> b divides a" |
|
170 |
||
171 |
abbreviation |
|
172 |
"division_rel G == \<lparr>carrier = carrier G, eq = op \<sim>\<^bsub>G\<^esub>, le = op divides\<^bsub>G\<^esub>\<rparr>" |
|
173 |
||
174 |
constdefs (structure G) |
|
175 |
properfactor :: "[_, 'a, 'a] \<Rightarrow> bool" |
|
176 |
"properfactor G a b == a divides b \<and> \<not>(b divides a)" |
|
177 |
||
178 |
constdefs (structure G) |
|
179 |
irreducible :: "[_, 'a] \<Rightarrow> bool" |
|
180 |
"irreducible G a == a \<notin> Units G \<and> (\<forall>b\<in>carrier G. properfactor G b a \<longrightarrow> b \<in> Units G)" |
|
181 |
||
182 |
constdefs (structure G) |
|
183 |
prime :: "[_, 'a] \<Rightarrow> bool" |
|
184 |
"prime G p == p \<notin> Units G \<and> |
|
185 |
(\<forall>a\<in>carrier G. \<forall>b\<in>carrier G. p divides (a \<otimes> b) \<longrightarrow> p divides a \<or> p divides b)" |
|
186 |
||
187 |
||
188 |
||
189 |
subsubsection {* Divisibility *} |
|
190 |
||
191 |
lemma dividesI: |
|
192 |
fixes G (structure) |
|
193 |
assumes carr: "c \<in> carrier G" |
|
194 |
and p: "b = a \<otimes> c" |
|
195 |
shows "a divides b" |
|
196 |
unfolding factor_def |
|
197 |
using assms by fast |
|
198 |
||
199 |
lemma dividesI' [intro]: |
|
200 |
fixes G (structure) |
|
201 |
assumes p: "b = a \<otimes> c" |
|
202 |
and carr: "c \<in> carrier G" |
|
203 |
shows "a divides b" |
|
204 |
using assms |
|
205 |
by (fast intro: dividesI) |
|
206 |
||
207 |
lemma dividesD: |
|
208 |
fixes G (structure) |
|
209 |
assumes "a divides b" |
|
210 |
shows "\<exists>c\<in>carrier G. b = a \<otimes> c" |
|
211 |
using assms |
|
212 |
unfolding factor_def |
|
213 |
by fast |
|
214 |
||
215 |
lemma dividesE [elim]: |
|
216 |
fixes G (structure) |
|
217 |
assumes d: "a divides b" |
|
218 |
and elim: "\<And>c. \<lbrakk>b = a \<otimes> c; c \<in> carrier G\<rbrakk> \<Longrightarrow> P" |
|
219 |
shows "P" |
|
220 |
proof - |
|
221 |
from dividesD[OF d] |
|
222 |
obtain c |
|
223 |
where "c\<in>carrier G" |
|
224 |
and "b = a \<otimes> c" |
|
225 |
by auto |
|
226 |
thus "P" by (elim elim) |
|
227 |
qed |
|
228 |
||
229 |
lemma (in monoid) divides_refl[simp, intro!]: |
|
230 |
assumes carr: "a \<in> carrier G" |
|
231 |
shows "a divides a" |
|
232 |
apply (intro dividesI[of "\<one>"]) |
|
233 |
apply (simp, simp add: carr) |
|
234 |
done |
|
235 |
||
236 |
lemma (in monoid) divides_trans [trans]: |
|
237 |
assumes dvds: "a divides b" "b divides c" |
|
238 |
and acarr: "a \<in> carrier G" |
|
239 |
shows "a divides c" |
|
240 |
using dvds[THEN dividesD] |
|
241 |
by (blast intro: dividesI m_assoc acarr) |
|
242 |
||
243 |
lemma (in monoid) divides_mult_lI [intro]: |
|
244 |
assumes ab: "a divides b" |
|
245 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
246 |
shows "(c \<otimes> a) divides (c \<otimes> b)" |
|
247 |
using ab |
|
248 |
apply (elim dividesE, simp add: m_assoc[symmetric] carr) |
|
249 |
apply (fast intro: dividesI) |
|
250 |
done |
|
251 |
||
252 |
lemma (in monoid_cancel) divides_mult_l [simp]: |
|
253 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
254 |
shows "(c \<otimes> a) divides (c \<otimes> b) = a divides b" |
|
255 |
apply safe |
|
256 |
apply (elim dividesE, intro dividesI, assumption) |
|
257 |
apply (rule l_cancel[of c]) |
|
258 |
apply (simp add: m_assoc carr)+ |
|
259 |
apply (fast intro: divides_mult_lI carr) |
|
260 |
done |
|
261 |
||
262 |
lemma (in comm_monoid) divides_mult_rI [intro]: |
|
263 |
assumes ab: "a divides b" |
|
264 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
265 |
shows "(a \<otimes> c) divides (b \<otimes> c)" |
|
266 |
using carr ab |
|
267 |
apply (simp add: m_comm[of a c] m_comm[of b c]) |
|
268 |
apply (rule divides_mult_lI, assumption+) |
|
269 |
done |
|
270 |
||
271 |
lemma (in comm_monoid_cancel) divides_mult_r [simp]: |
|
272 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
273 |
shows "(a \<otimes> c) divides (b \<otimes> c) = a divides b" |
|
274 |
using carr |
|
275 |
by (simp add: m_comm[of a c] m_comm[of b c]) |
|
276 |
||
277 |
lemma (in monoid) divides_prod_r: |
|
278 |
assumes ab: "a divides b" |
|
279 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
280 |
shows "a divides (b \<otimes> c)" |
|
281 |
using ab carr |
|
282 |
by (fast intro: m_assoc) |
|
283 |
||
284 |
lemma (in comm_monoid) divides_prod_l: |
|
285 |
assumes carr[intro]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
286 |
and ab: "a divides b" |
|
287 |
shows "a divides (c \<otimes> b)" |
|
288 |
using ab carr |
|
289 |
apply (simp add: m_comm[of c b]) |
|
290 |
apply (fast intro: divides_prod_r) |
|
291 |
done |
|
292 |
||
293 |
lemma (in monoid) unit_divides: |
|
294 |
assumes uunit: "u \<in> Units G" |
|
295 |
and acarr: "a \<in> carrier G" |
|
296 |
shows "u divides a" |
|
297 |
proof (intro dividesI[of "(inv u) \<otimes> a"], fast intro: uunit acarr) |
|
298 |
from uunit acarr |
|
299 |
have xcarr: "inv u \<otimes> a \<in> carrier G" by fast |
|
300 |
||
301 |
from uunit acarr |
|
302 |
have "u \<otimes> (inv u \<otimes> a) = (u \<otimes> inv u) \<otimes> a" by (fast intro: m_assoc[symmetric]) |
|
303 |
also have "\<dots> = \<one> \<otimes> a" by (simp add: Units_r_inv[OF uunit]) |
|
304 |
also from acarr |
|
305 |
have "\<dots> = a" by simp |
|
306 |
finally |
|
307 |
show "a = u \<otimes> (inv u \<otimes> a)" .. |
|
308 |
qed |
|
309 |
||
310 |
lemma (in comm_monoid) divides_unit: |
|
311 |
assumes udvd: "a divides u" |
|
312 |
and carr: "a \<in> carrier G" "u \<in> Units G" |
|
313 |
shows "a \<in> Units G" |
|
314 |
using udvd carr |
|
315 |
by (blast intro: unit_factor) |
|
316 |
||
317 |
lemma (in comm_monoid) Unit_eq_dividesone: |
|
318 |
assumes ucarr: "u \<in> carrier G" |
|
319 |
shows "u \<in> Units G = u divides \<one>" |
|
320 |
using ucarr |
|
321 |
by (fast dest: divides_unit intro: unit_divides) |
|
322 |
||
323 |
||
324 |
subsubsection {* Association *} |
|
325 |
||
326 |
lemma associatedI: |
|
327 |
fixes G (structure) |
|
328 |
assumes "a divides b" "b divides a" |
|
329 |
shows "a \<sim> b" |
|
330 |
using assms |
|
331 |
by (simp add: associated_def) |
|
332 |
||
333 |
lemma (in monoid) associatedI2: |
|
334 |
assumes uunit[simp]: "u \<in> Units G" |
|
335 |
and a: "a = b \<otimes> u" |
|
336 |
and bcarr[simp]: "b \<in> carrier G" |
|
337 |
shows "a \<sim> b" |
|
338 |
using uunit bcarr |
|
339 |
unfolding a |
|
340 |
apply (intro associatedI) |
|
341 |
apply (rule dividesI[of "inv u"], simp) |
|
342 |
apply (simp add: m_assoc Units_closed Units_r_inv) |
|
343 |
apply fast |
|
344 |
done |
|
345 |
||
346 |
lemma (in monoid) associatedI2': |
|
347 |
assumes a: "a = b \<otimes> u" |
|
348 |
and uunit: "u \<in> Units G" |
|
349 |
and bcarr: "b \<in> carrier G" |
|
350 |
shows "a \<sim> b" |
|
351 |
using assms by (intro associatedI2) |
|
352 |
||
353 |
lemma associatedD: |
|
354 |
fixes G (structure) |
|
355 |
assumes "a \<sim> b" |
|
356 |
shows "a divides b" |
|
357 |
using assms by (simp add: associated_def) |
|
358 |
||
359 |
lemma (in monoid_cancel) associatedD2: |
|
360 |
assumes assoc: "a \<sim> b" |
|
361 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
|
362 |
shows "\<exists>u\<in>Units G. a = b \<otimes> u" |
|
363 |
using assoc |
|
364 |
unfolding associated_def |
|
365 |
proof clarify |
|
366 |
assume "b divides a" |
|
367 |
hence "\<exists>u\<in>carrier G. a = b \<otimes> u" by (rule dividesD) |
|
368 |
from this obtain u |
|
369 |
where ucarr: "u \<in> carrier G" and a: "a = b \<otimes> u" |
|
370 |
by auto |
|
371 |
||
372 |
assume "a divides b" |
|
373 |
hence "\<exists>u'\<in>carrier G. b = a \<otimes> u'" by (rule dividesD) |
|
374 |
from this obtain u' |
|
375 |
where u'carr: "u' \<in> carrier G" and b: "b = a \<otimes> u'" |
|
376 |
by auto |
|
377 |
note carr = carr ucarr u'carr |
|
378 |
||
379 |
from carr |
|
380 |
have "a \<otimes> \<one> = a" by simp |
|
381 |
also have "\<dots> = b \<otimes> u" by (simp add: a) |
|
382 |
also have "\<dots> = a \<otimes> u' \<otimes> u" by (simp add: b) |
|
383 |
also from carr |
|
384 |
have "\<dots> = a \<otimes> (u' \<otimes> u)" by (simp add: m_assoc) |
|
385 |
finally |
|
386 |
have "a \<otimes> \<one> = a \<otimes> (u' \<otimes> u)" . |
|
387 |
with carr |
|
388 |
have u1: "\<one> = u' \<otimes> u" by (fast dest: l_cancel) |
|
389 |
||
390 |
from carr |
|
391 |
have "b \<otimes> \<one> = b" by simp |
|
392 |
also have "\<dots> = a \<otimes> u'" by (simp add: b) |
|
393 |
also have "\<dots> = b \<otimes> u \<otimes> u'" by (simp add: a) |
|
394 |
also from carr |
|
395 |
have "\<dots> = b \<otimes> (u \<otimes> u')" by (simp add: m_assoc) |
|
396 |
finally |
|
397 |
have "b \<otimes> \<one> = b \<otimes> (u \<otimes> u')" . |
|
398 |
with carr |
|
399 |
have u2: "\<one> = u \<otimes> u'" by (fast dest: l_cancel) |
|
400 |
||
401 |
from u'carr u1[symmetric] u2[symmetric] |
|
402 |
have "\<exists>u'\<in>carrier G. u' \<otimes> u = \<one> \<and> u \<otimes> u' = \<one>" by fast |
|
403 |
hence "u \<in> Units G" by (simp add: Units_def ucarr) |
|
404 |
||
405 |
from ucarr this a |
|
406 |
show "\<exists>u\<in>Units G. a = b \<otimes> u" by fast |
|
407 |
qed |
|
408 |
||
409 |
lemma associatedE: |
|
410 |
fixes G (structure) |
|
411 |
assumes assoc: "a \<sim> b" |
|
412 |
and e: "\<lbrakk>a divides b; b divides a\<rbrakk> \<Longrightarrow> P" |
|
413 |
shows "P" |
|
414 |
proof - |
|
415 |
from assoc |
|
416 |
have "a divides b" "b divides a" |
|
417 |
by (simp add: associated_def)+ |
|
418 |
thus "P" by (elim e) |
|
419 |
qed |
|
420 |
||
421 |
lemma (in monoid_cancel) associatedE2: |
|
422 |
assumes assoc: "a \<sim> b" |
|
423 |
and e: "\<And>u. \<lbrakk>a = b \<otimes> u; u \<in> Units G\<rbrakk> \<Longrightarrow> P" |
|
424 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
|
425 |
shows "P" |
|
426 |
proof - |
|
427 |
from assoc and carr |
|
428 |
have "\<exists>u\<in>Units G. a = b \<otimes> u" by (rule associatedD2) |
|
429 |
from this obtain u |
|
430 |
where "u \<in> Units G" "a = b \<otimes> u" |
|
431 |
by auto |
|
432 |
thus "P" by (elim e) |
|
433 |
qed |
|
434 |
||
435 |
lemma (in monoid) associated_refl [simp, intro!]: |
|
436 |
assumes "a \<in> carrier G" |
|
437 |
shows "a \<sim> a" |
|
438 |
using assms |
|
439 |
by (fast intro: associatedI) |
|
440 |
||
441 |
lemma (in monoid) associated_sym [sym]: |
|
442 |
assumes "a \<sim> b" |
|
443 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
444 |
shows "b \<sim> a" |
|
445 |
using assms |
|
446 |
by (iprover intro: associatedI elim: associatedE) |
|
447 |
||
448 |
lemma (in monoid) associated_trans [trans]: |
|
449 |
assumes "a \<sim> b" "b \<sim> c" |
|
450 |
and "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
451 |
shows "a \<sim> c" |
|
452 |
using assms |
|
453 |
by (iprover intro: associatedI divides_trans elim: associatedE) |
|
454 |
||
455 |
lemma (in monoid) division_equiv [intro, simp]: |
|
456 |
"equivalence (division_rel G)" |
|
457 |
apply unfold_locales |
|
458 |
apply simp_all |
|
459 |
apply (rule associated_sym, assumption+) |
|
460 |
apply (iprover intro: associated_trans) |
|
461 |
done |
|
462 |
||
463 |
||
464 |
subsubsection {* Division and associativity *} |
|
465 |
||
466 |
lemma divides_antisym: |
|
467 |
fixes G (structure) |
|
468 |
assumes "a divides b" "b divides a" |
|
469 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
470 |
shows "a \<sim> b" |
|
471 |
using assms |
|
472 |
by (fast intro: associatedI) |
|
473 |
||
474 |
lemma (in monoid) divides_cong_l [trans]: |
|
475 |
assumes xx': "x \<sim> x'" |
|
476 |
and xdvdy: "x' divides y" |
|
477 |
and carr [simp]: "x \<in> carrier G" "x' \<in> carrier G" "y \<in> carrier G" |
|
478 |
shows "x divides y" |
|
479 |
proof - |
|
480 |
from xx' |
|
481 |
have "x divides x'" by (simp add: associatedD) |
|
482 |
also note xdvdy |
|
483 |
finally |
|
484 |
show "x divides y" by simp |
|
485 |
qed |
|
486 |
||
487 |
lemma (in monoid) divides_cong_r [trans]: |
|
488 |
assumes xdvdy: "x divides y" |
|
489 |
and yy': "y \<sim> y'" |
|
490 |
and carr[simp]: "x \<in> carrier G" "y \<in> carrier G" "y' \<in> carrier G" |
|
491 |
shows "x divides y'" |
|
492 |
proof - |
|
493 |
note xdvdy |
|
494 |
also from yy' |
|
495 |
have "y divides y'" by (simp add: associatedD) |
|
496 |
finally |
|
497 |
show "x divides y'" by simp |
|
498 |
qed |
|
499 |
||
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
500 |
lemma (in monoid) division_weak_partial_order [simp, intro!]: |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
501 |
"weak_partial_order (division_rel G)" |
27701 | 502 |
apply unfold_locales |
503 |
apply simp_all |
|
504 |
apply (simp add: associated_sym) |
|
505 |
apply (blast intro: associated_trans) |
|
506 |
apply (simp add: divides_antisym) |
|
507 |
apply (blast intro: divides_trans) |
|
508 |
apply (blast intro: divides_cong_l divides_cong_r associated_sym) |
|
509 |
done |
|
510 |
||
511 |
||
512 |
subsubsection {* Multiplication and associativity *} |
|
513 |
||
514 |
lemma (in monoid_cancel) mult_cong_r: |
|
515 |
assumes "b \<sim> b'" |
|
516 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "b' \<in> carrier G" |
|
517 |
shows "a \<otimes> b \<sim> a \<otimes> b'" |
|
518 |
using assms |
|
519 |
apply (elim associatedE2, intro associatedI2) |
|
520 |
apply (auto intro: m_assoc[symmetric]) |
|
521 |
done |
|
522 |
||
523 |
lemma (in comm_monoid_cancel) mult_cong_l: |
|
524 |
assumes "a \<sim> a'" |
|
525 |
and carr: "a \<in> carrier G" "a' \<in> carrier G" "b \<in> carrier G" |
|
526 |
shows "a \<otimes> b \<sim> a' \<otimes> b" |
|
527 |
using assms |
|
528 |
apply (elim associatedE2, intro associatedI2) |
|
529 |
apply assumption |
|
530 |
apply (simp add: m_assoc Units_closed) |
|
531 |
apply (simp add: m_comm Units_closed) |
|
532 |
apply simp+ |
|
533 |
done |
|
534 |
||
535 |
lemma (in monoid_cancel) assoc_l_cancel: |
|
536 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "b' \<in> carrier G" |
|
537 |
and "a \<otimes> b \<sim> a \<otimes> b'" |
|
538 |
shows "b \<sim> b'" |
|
539 |
using assms |
|
540 |
apply (elim associatedE2, intro associatedI2) |
|
541 |
apply assumption |
|
542 |
apply (rule l_cancel[of a]) |
|
543 |
apply (simp add: m_assoc Units_closed) |
|
544 |
apply fast+ |
|
545 |
done |
|
546 |
||
547 |
lemma (in comm_monoid_cancel) assoc_r_cancel: |
|
548 |
assumes "a \<otimes> b \<sim> a' \<otimes> b" |
|
549 |
and carr: "a \<in> carrier G" "a' \<in> carrier G" "b \<in> carrier G" |
|
550 |
shows "a \<sim> a'" |
|
551 |
using assms |
|
552 |
apply (elim associatedE2, intro associatedI2) |
|
553 |
apply assumption |
|
554 |
apply (rule r_cancel[of a b]) |
|
555 |
apply (simp add: m_assoc Units_closed) |
|
556 |
apply (simp add: m_comm Units_closed) |
|
557 |
apply fast+ |
|
558 |
done |
|
559 |
||
560 |
||
561 |
subsubsection {* Units *} |
|
562 |
||
563 |
lemma (in monoid_cancel) assoc_unit_l [trans]: |
|
564 |
assumes asc: "a \<sim> b" and bunit: "b \<in> Units G" |
|
565 |
and carr: "a \<in> carrier G" |
|
566 |
shows "a \<in> Units G" |
|
567 |
using assms |
|
568 |
by (fast elim: associatedE2) |
|
569 |
||
570 |
lemma (in monoid_cancel) assoc_unit_r [trans]: |
|
571 |
assumes aunit: "a \<in> Units G" and asc: "a \<sim> b" |
|
572 |
and bcarr: "b \<in> carrier G" |
|
573 |
shows "b \<in> Units G" |
|
574 |
using aunit bcarr associated_sym[OF asc] |
|
575 |
by (blast intro: assoc_unit_l) |
|
576 |
||
577 |
lemma (in comm_monoid) Units_cong: |
|
578 |
assumes aunit: "a \<in> Units G" and asc: "a \<sim> b" |
|
579 |
and bcarr: "b \<in> carrier G" |
|
580 |
shows "b \<in> Units G" |
|
581 |
using assms |
|
582 |
by (blast intro: divides_unit elim: associatedE) |
|
583 |
||
584 |
lemma (in monoid) Units_assoc: |
|
585 |
assumes units: "a \<in> Units G" "b \<in> Units G" |
|
586 |
shows "a \<sim> b" |
|
587 |
using units |
|
588 |
by (fast intro: associatedI unit_divides) |
|
589 |
||
590 |
lemma (in monoid) Units_are_ones: |
|
591 |
"Units G {.=}\<^bsub>(division_rel G)\<^esub> {\<one>}" |
|
592 |
apply (simp add: set_eq_def elem_def, rule, simp_all) |
|
593 |
proof clarsimp |
|
594 |
fix a |
|
595 |
assume aunit: "a \<in> Units G" |
|
596 |
show "a \<sim> \<one>" |
|
597 |
apply (rule associatedI) |
|
598 |
apply (fast intro: dividesI[of "inv a"] aunit Units_r_inv[symmetric]) |
|
599 |
apply (fast intro: dividesI[of "a"] l_one[symmetric] Units_closed[OF aunit]) |
|
600 |
done |
|
601 |
next |
|
602 |
have "\<one> \<in> Units G" by simp |
|
603 |
moreover have "\<one> \<sim> \<one>" by simp |
|
604 |
ultimately show "\<exists>a \<in> Units G. \<one> \<sim> a" by fast |
|
605 |
qed |
|
606 |
||
607 |
lemma (in comm_monoid) Units_Lower: |
|
608 |
"Units G = Lower (division_rel G) (carrier G)" |
|
609 |
apply (simp add: Units_def Lower_def) |
|
610 |
apply (rule, rule) |
|
611 |
apply clarsimp |
|
612 |
apply (rule unit_divides) |
|
613 |
apply (unfold Units_def, fast) |
|
614 |
apply assumption |
|
615 |
apply clarsimp |
|
616 |
proof - |
|
617 |
fix x |
|
618 |
assume xcarr: "x \<in> carrier G" |
|
619 |
assume r[rule_format]: "\<forall>y. y \<in> carrier G \<longrightarrow> x divides y" |
|
620 |
have "\<one> \<in> carrier G" by simp |
|
621 |
hence "x divides \<one>" by (rule r) |
|
622 |
hence "\<exists>x'\<in>carrier G. \<one> = x \<otimes> x'" by (rule dividesE, fast) |
|
623 |
from this obtain x' |
|
624 |
where x'carr: "x' \<in> carrier G" |
|
625 |
and xx': "\<one> = x \<otimes> x'" |
|
626 |
by auto |
|
627 |
||
628 |
note xx' |
|
629 |
also with xcarr x'carr |
|
630 |
have "\<dots> = x' \<otimes> x" by (simp add: m_comm) |
|
631 |
finally |
|
632 |
have "\<one> = x' \<otimes> x" . |
|
633 |
||
634 |
from x'carr xx'[symmetric] this[symmetric] |
|
635 |
show "\<exists>y\<in>carrier G. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast |
|
636 |
qed |
|
637 |
||
638 |
||
639 |
subsubsection {* Proper factors *} |
|
640 |
||
641 |
lemma properfactorI: |
|
642 |
fixes G (structure) |
|
643 |
assumes "a divides b" |
|
644 |
and "\<not>(b divides a)" |
|
645 |
shows "properfactor G a b" |
|
646 |
using assms |
|
647 |
unfolding properfactor_def |
|
648 |
by simp |
|
649 |
||
650 |
lemma properfactorI2: |
|
651 |
fixes G (structure) |
|
652 |
assumes advdb: "a divides b" |
|
653 |
and neq: "\<not>(a \<sim> b)" |
|
654 |
shows "properfactor G a b" |
|
655 |
apply (rule properfactorI, rule advdb) |
|
656 |
proof (rule ccontr, simp) |
|
657 |
assume "b divides a" |
|
658 |
with advdb have "a \<sim> b" by (rule associatedI) |
|
659 |
with neq show "False" by fast |
|
660 |
qed |
|
661 |
||
662 |
lemma (in comm_monoid_cancel) properfactorI3: |
|
663 |
assumes p: "p = a \<otimes> b" |
|
664 |
and nunit: "b \<notin> Units G" |
|
665 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "p \<in> carrier G" |
|
666 |
shows "properfactor G a p" |
|
667 |
unfolding p |
|
668 |
using carr |
|
669 |
apply (intro properfactorI, fast) |
|
670 |
proof (clarsimp, elim dividesE) |
|
671 |
fix c |
|
672 |
assume ccarr: "c \<in> carrier G" |
|
673 |
note [simp] = carr ccarr |
|
674 |
||
675 |
have "a \<otimes> \<one> = a" by simp |
|
676 |
also assume "a = a \<otimes> b \<otimes> c" |
|
677 |
also have "\<dots> = a \<otimes> (b \<otimes> c)" by (simp add: m_assoc) |
|
678 |
finally have "a \<otimes> \<one> = a \<otimes> (b \<otimes> c)" . |
|
679 |
||
680 |
hence rinv: "\<one> = b \<otimes> c" by (intro l_cancel[of "a" "\<one>" "b \<otimes> c"], simp+) |
|
681 |
also have "\<dots> = c \<otimes> b" by (simp add: m_comm) |
|
682 |
finally have linv: "\<one> = c \<otimes> b" . |
|
683 |
||
684 |
from ccarr linv[symmetric] rinv[symmetric] |
|
685 |
have "b \<in> Units G" unfolding Units_def by fastsimp |
|
686 |
with nunit |
|
687 |
show "False" .. |
|
688 |
qed |
|
689 |
||
690 |
lemma properfactorE: |
|
691 |
fixes G (structure) |
|
692 |
assumes pf: "properfactor G a b" |
|
693 |
and r: "\<lbrakk>a divides b; \<not>(b divides a)\<rbrakk> \<Longrightarrow> P" |
|
694 |
shows "P" |
|
695 |
using pf |
|
696 |
unfolding properfactor_def |
|
697 |
by (fast intro: r) |
|
698 |
||
699 |
lemma properfactorE2: |
|
700 |
fixes G (structure) |
|
701 |
assumes pf: "properfactor G a b" |
|
702 |
and elim: "\<lbrakk>a divides b; \<not>(a \<sim> b)\<rbrakk> \<Longrightarrow> P" |
|
703 |
shows "P" |
|
704 |
using pf |
|
705 |
unfolding properfactor_def |
|
706 |
by (fast elim: elim associatedE) |
|
707 |
||
708 |
lemma (in monoid) properfactor_unitE: |
|
709 |
assumes uunit: "u \<in> Units G" |
|
710 |
and pf: "properfactor G a u" |
|
711 |
and acarr: "a \<in> carrier G" |
|
712 |
shows "P" |
|
713 |
using pf unit_divides[OF uunit acarr] |
|
714 |
by (fast elim: properfactorE) |
|
715 |
||
716 |
||
717 |
lemma (in monoid) properfactor_divides: |
|
718 |
assumes pf: "properfactor G a b" |
|
719 |
shows "a divides b" |
|
720 |
using pf |
|
721 |
by (elim properfactorE) |
|
722 |
||
723 |
lemma (in monoid) properfactor_trans1 [trans]: |
|
724 |
assumes dvds: "a divides b" "properfactor G b c" |
|
725 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
726 |
shows "properfactor G a c" |
|
727 |
using dvds carr |
|
728 |
apply (elim properfactorE, intro properfactorI) |
|
729 |
apply (iprover intro: divides_trans)+ |
|
730 |
done |
|
731 |
||
732 |
lemma (in monoid) properfactor_trans2 [trans]: |
|
733 |
assumes dvds: "properfactor G a b" "b divides c" |
|
734 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
735 |
shows "properfactor G a c" |
|
736 |
using dvds carr |
|
737 |
apply (elim properfactorE, intro properfactorI) |
|
738 |
apply (iprover intro: divides_trans)+ |
|
739 |
done |
|
740 |
||
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
741 |
lemma properfactor_lless: |
27701 | 742 |
fixes G (structure) |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
743 |
shows "properfactor G = lless (division_rel G)" |
27701 | 744 |
apply (rule ext) apply (rule ext) apply rule |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
745 |
apply (fastsimp elim: properfactorE2 intro: weak_llessI) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
746 |
apply (fastsimp elim: weak_llessE intro: properfactorI2) |
27701 | 747 |
done |
748 |
||
749 |
lemma (in monoid) properfactor_cong_l [trans]: |
|
750 |
assumes x'x: "x' \<sim> x" |
|
751 |
and pf: "properfactor G x y" |
|
752 |
and carr: "x \<in> carrier G" "x' \<in> carrier G" "y \<in> carrier G" |
|
753 |
shows "properfactor G x' y" |
|
754 |
using pf |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
755 |
unfolding properfactor_lless |
27701 | 756 |
proof - |
29237 | 757 |
interpret weak_partial_order "division_rel G" .. |
27701 | 758 |
from x'x |
759 |
have "x' .=\<^bsub>division_rel G\<^esub> x" by simp |
|
760 |
also assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y" |
|
761 |
finally |
|
762 |
show "x' \<sqsubset>\<^bsub>division_rel G\<^esub> y" by (simp add: carr) |
|
763 |
qed |
|
764 |
||
765 |
lemma (in monoid) properfactor_cong_r [trans]: |
|
766 |
assumes pf: "properfactor G x y" |
|
767 |
and yy': "y \<sim> y'" |
|
768 |
and carr: "x \<in> carrier G" "y \<in> carrier G" "y' \<in> carrier G" |
|
769 |
shows "properfactor G x y'" |
|
770 |
using pf |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
771 |
unfolding properfactor_lless |
27701 | 772 |
proof - |
29237 | 773 |
interpret weak_partial_order "division_rel G" .. |
27701 | 774 |
assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y" |
775 |
also from yy' |
|
776 |
have "y .=\<^bsub>division_rel G\<^esub> y'" by simp |
|
777 |
finally |
|
778 |
show "x \<sqsubset>\<^bsub>division_rel G\<^esub> y'" by (simp add: carr) |
|
779 |
qed |
|
780 |
||
781 |
lemma (in monoid_cancel) properfactor_mult_lI [intro]: |
|
782 |
assumes ab: "properfactor G a b" |
|
783 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
784 |
shows "properfactor G (c \<otimes> a) (c \<otimes> b)" |
|
785 |
using ab carr |
|
786 |
by (fastsimp elim: properfactorE intro: properfactorI) |
|
787 |
||
788 |
lemma (in monoid_cancel) properfactor_mult_l [simp]: |
|
789 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
790 |
shows "properfactor G (c \<otimes> a) (c \<otimes> b) = properfactor G a b" |
|
791 |
using carr |
|
792 |
by (fastsimp elim: properfactorE intro: properfactorI) |
|
793 |
||
794 |
lemma (in comm_monoid_cancel) properfactor_mult_rI [intro]: |
|
795 |
assumes ab: "properfactor G a b" |
|
796 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
797 |
shows "properfactor G (a \<otimes> c) (b \<otimes> c)" |
|
798 |
using ab carr |
|
799 |
by (fastsimp elim: properfactorE intro: properfactorI) |
|
800 |
||
801 |
lemma (in comm_monoid_cancel) properfactor_mult_r [simp]: |
|
802 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
803 |
shows "properfactor G (a \<otimes> c) (b \<otimes> c) = properfactor G a b" |
|
804 |
using carr |
|
805 |
by (fastsimp elim: properfactorE intro: properfactorI) |
|
806 |
||
807 |
lemma (in monoid) properfactor_prod_r: |
|
808 |
assumes ab: "properfactor G a b" |
|
809 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
810 |
shows "properfactor G a (b \<otimes> c)" |
|
811 |
by (intro properfactor_trans2[OF ab] divides_prod_r, simp+) |
|
812 |
||
813 |
lemma (in comm_monoid) properfactor_prod_l: |
|
814 |
assumes ab: "properfactor G a b" |
|
815 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
816 |
shows "properfactor G a (c \<otimes> b)" |
|
817 |
by (intro properfactor_trans2[OF ab] divides_prod_l, simp+) |
|
818 |
||
819 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
820 |
subsection {* Irreducible Elements and Primes *} |
27701 | 821 |
|
822 |
subsubsection {* Irreducible elements *} |
|
823 |
||
824 |
lemma irreducibleI: |
|
825 |
fixes G (structure) |
|
826 |
assumes "a \<notin> Units G" |
|
827 |
and "\<And>b. \<lbrakk>b \<in> carrier G; properfactor G b a\<rbrakk> \<Longrightarrow> b \<in> Units G" |
|
828 |
shows "irreducible G a" |
|
829 |
using assms |
|
830 |
unfolding irreducible_def |
|
831 |
by blast |
|
832 |
||
833 |
lemma irreducibleE: |
|
834 |
fixes G (structure) |
|
835 |
assumes irr: "irreducible G a" |
|
836 |
and elim: "\<lbrakk>a \<notin> Units G; \<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G\<rbrakk> \<Longrightarrow> P" |
|
837 |
shows "P" |
|
838 |
using assms |
|
839 |
unfolding irreducible_def |
|
840 |
by blast |
|
841 |
||
842 |
lemma irreducibleD: |
|
843 |
fixes G (structure) |
|
844 |
assumes irr: "irreducible G a" |
|
845 |
and pf: "properfactor G b a" |
|
846 |
and bcarr: "b \<in> carrier G" |
|
847 |
shows "b \<in> Units G" |
|
848 |
using assms |
|
849 |
by (fast elim: irreducibleE) |
|
850 |
||
851 |
lemma (in monoid_cancel) irreducible_cong [trans]: |
|
852 |
assumes irred: "irreducible G a" |
|
853 |
and aa': "a \<sim> a'" |
|
854 |
and carr[simp]: "a \<in> carrier G" "a' \<in> carrier G" |
|
855 |
shows "irreducible G a'" |
|
856 |
using assms |
|
857 |
apply (elim irreducibleE, intro irreducibleI) |
|
858 |
apply simp_all |
|
859 |
proof clarify |
|
860 |
assume "a' \<in> Units G" |
|
861 |
also note aa'[symmetric] |
|
862 |
finally have aunit: "a \<in> Units G" by simp |
|
863 |
||
864 |
assume "a \<notin> Units G" |
|
865 |
with aunit |
|
866 |
show "False" by fast |
|
867 |
next |
|
868 |
fix b |
|
869 |
assume r[rule_format]: "\<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G" |
|
870 |
and bcarr[simp]: "b \<in> carrier G" |
|
871 |
assume "properfactor G b a'" |
|
872 |
also note aa'[symmetric] |
|
873 |
finally |
|
874 |
have "properfactor G b a" by simp |
|
875 |
||
876 |
with bcarr |
|
877 |
show "b \<in> Units G" by (fast intro: r) |
|
878 |
qed |
|
879 |
||
880 |
||
881 |
lemma (in monoid) irreducible_prod_rI: |
|
882 |
assumes airr: "irreducible G a" |
|
883 |
and bunit: "b \<in> Units G" |
|
884 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
885 |
shows "irreducible G (a \<otimes> b)" |
|
886 |
using airr carr bunit |
|
887 |
apply (elim irreducibleE, intro irreducibleI, clarify) |
|
888 |
apply (subgoal_tac "a \<in> Units G", simp) |
|
889 |
apply (intro prod_unit_r[of a b] carr bunit, assumption) |
|
890 |
proof - |
|
891 |
fix c |
|
892 |
assume [simp]: "c \<in> carrier G" |
|
893 |
and r[rule_format]: "\<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G" |
|
894 |
assume "properfactor G c (a \<otimes> b)" |
|
895 |
also have "a \<otimes> b \<sim> a" by (intro associatedI2[OF bunit], simp+) |
|
896 |
finally |
|
897 |
have pfa: "properfactor G c a" by simp |
|
898 |
show "c \<in> Units G" by (rule r, simp add: pfa) |
|
899 |
qed |
|
900 |
||
901 |
lemma (in comm_monoid) irreducible_prod_lI: |
|
902 |
assumes birr: "irreducible G b" |
|
903 |
and aunit: "a \<in> Units G" |
|
904 |
and carr [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
905 |
shows "irreducible G (a \<otimes> b)" |
|
906 |
apply (subst m_comm, simp+) |
|
907 |
apply (intro irreducible_prod_rI assms) |
|
908 |
done |
|
909 |
||
910 |
lemma (in comm_monoid_cancel) irreducible_prodE [elim]: |
|
911 |
assumes irr: "irreducible G (a \<otimes> b)" |
|
912 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
913 |
and e1: "\<lbrakk>irreducible G a; b \<in> Units G\<rbrakk> \<Longrightarrow> P" |
|
914 |
and e2: "\<lbrakk>a \<in> Units G; irreducible G b\<rbrakk> \<Longrightarrow> P" |
|
915 |
shows "P" |
|
916 |
using irr |
|
917 |
proof (elim irreducibleE) |
|
918 |
assume abnunit: "a \<otimes> b \<notin> Units G" |
|
919 |
and isunit[rule_format]: "\<forall>ba. ba \<in> carrier G \<and> properfactor G ba (a \<otimes> b) \<longrightarrow> ba \<in> Units G" |
|
920 |
||
921 |
show "P" |
|
922 |
proof (cases "a \<in> Units G") |
|
923 |
assume aunit: "a \<in> Units G" |
|
924 |
||
925 |
have "irreducible G b" |
|
926 |
apply (rule irreducibleI) |
|
927 |
proof (rule ccontr, simp) |
|
928 |
assume "b \<in> Units G" |
|
929 |
with aunit have "(a \<otimes> b) \<in> Units G" by fast |
|
930 |
with abnunit show "False" .. |
|
931 |
next |
|
932 |
fix c |
|
933 |
assume ccarr: "c \<in> carrier G" |
|
934 |
and "properfactor G c b" |
|
935 |
hence "properfactor G c (a \<otimes> b)" by (simp add: properfactor_prod_l[of c b a]) |
|
936 |
from ccarr this show "c \<in> Units G" by (fast intro: isunit) |
|
937 |
qed |
|
938 |
||
939 |
from aunit this show "P" by (rule e2) |
|
940 |
next |
|
941 |
assume anunit: "a \<notin> Units G" |
|
942 |
with carr have "properfactor G b (b \<otimes> a)" by (fast intro: properfactorI3) |
|
943 |
hence bf: "properfactor G b (a \<otimes> b)" by (subst m_comm[of a b], simp+) |
|
944 |
hence bunit: "b \<in> Units G" by (intro isunit, simp) |
|
945 |
||
946 |
have "irreducible G a" |
|
947 |
apply (rule irreducibleI) |
|
948 |
proof (rule ccontr, simp) |
|
949 |
assume "a \<in> Units G" |
|
950 |
with bunit have "(a \<otimes> b) \<in> Units G" by fast |
|
951 |
with abnunit show "False" .. |
|
952 |
next |
|
953 |
fix c |
|
954 |
assume ccarr: "c \<in> carrier G" |
|
955 |
and "properfactor G c a" |
|
956 |
hence "properfactor G c (a \<otimes> b)" by (simp add: properfactor_prod_r[of c a b]) |
|
957 |
from ccarr this show "c \<in> Units G" by (fast intro: isunit) |
|
958 |
qed |
|
959 |
||
960 |
from this bunit show "P" by (rule e1) |
|
961 |
qed |
|
962 |
qed |
|
963 |
||
964 |
||
965 |
subsubsection {* Prime elements *} |
|
966 |
||
967 |
lemma primeI: |
|
968 |
fixes G (structure) |
|
969 |
assumes "p \<notin> Units G" |
|
970 |
and "\<And>a b. \<lbrakk>a \<in> carrier G; b \<in> carrier G; p divides (a \<otimes> b)\<rbrakk> \<Longrightarrow> p divides a \<or> p divides b" |
|
971 |
shows "prime G p" |
|
972 |
using assms |
|
973 |
unfolding prime_def |
|
974 |
by blast |
|
975 |
||
976 |
lemma primeE: |
|
977 |
fixes G (structure) |
|
978 |
assumes pprime: "prime G p" |
|
979 |
and e: "\<lbrakk>p \<notin> Units G; \<forall>a\<in>carrier G. \<forall>b\<in>carrier G. |
|
980 |
p divides a \<otimes> b \<longrightarrow> p divides a \<or> p divides b\<rbrakk> \<Longrightarrow> P" |
|
981 |
shows "P" |
|
982 |
using pprime |
|
983 |
unfolding prime_def |
|
984 |
by (blast dest: e) |
|
985 |
||
986 |
lemma (in comm_monoid_cancel) prime_divides: |
|
987 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
988 |
and pprime: "prime G p" |
|
989 |
and pdvd: "p divides a \<otimes> b" |
|
990 |
shows "p divides a \<or> p divides b" |
|
991 |
using assms |
|
992 |
by (blast elim: primeE) |
|
993 |
||
994 |
lemma (in monoid_cancel) prime_cong [trans]: |
|
995 |
assumes pprime: "prime G p" |
|
996 |
and pp': "p \<sim> p'" |
|
997 |
and carr[simp]: "p \<in> carrier G" "p' \<in> carrier G" |
|
998 |
shows "prime G p'" |
|
999 |
using pprime |
|
1000 |
apply (elim primeE, intro primeI) |
|
1001 |
proof clarify |
|
1002 |
assume pnunit: "p \<notin> Units G" |
|
1003 |
assume "p' \<in> Units G" |
|
1004 |
also note pp'[symmetric] |
|
1005 |
finally |
|
1006 |
have "p \<in> Units G" by simp |
|
1007 |
with pnunit |
|
1008 |
show False .. |
|
1009 |
next |
|
1010 |
fix a b |
|
1011 |
assume r[rule_format]: |
|
1012 |
"\<forall>a\<in>carrier G. \<forall>b\<in>carrier G. p divides a \<otimes> b \<longrightarrow> p divides a \<or> p divides b" |
|
1013 |
assume p'dvd: "p' divides a \<otimes> b" |
|
1014 |
and carr'[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
1015 |
||
1016 |
note pp' |
|
1017 |
also note p'dvd |
|
1018 |
finally |
|
1019 |
have "p divides a \<otimes> b" by simp |
|
1020 |
hence "p divides a \<or> p divides b" by (intro r, simp+) |
|
1021 |
moreover { |
|
1022 |
note pp'[symmetric] |
|
1023 |
also assume "p divides a" |
|
1024 |
finally |
|
1025 |
have "p' divides a" by simp |
|
1026 |
hence "p' divides a \<or> p' divides b" by simp |
|
1027 |
} |
|
1028 |
moreover { |
|
1029 |
note pp'[symmetric] |
|
1030 |
also assume "p divides b" |
|
1031 |
finally |
|
1032 |
have "p' divides b" by simp |
|
1033 |
hence "p' divides a \<or> p' divides b" by simp |
|
1034 |
} |
|
1035 |
ultimately |
|
1036 |
show "p' divides a \<or> p' divides b" by fast |
|
1037 |
qed |
|
1038 |
||
1039 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
1040 |
subsection {* Factorization and Factorial Monoids *} |
27701 | 1041 |
|
1042 |
subsubsection {* Function definitions *} |
|
1043 |
||
1044 |
constdefs (structure G) |
|
1045 |
factors :: "[_, 'a list, 'a] \<Rightarrow> bool" |
|
1046 |
"factors G fs a == (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (op \<otimes>) fs \<one> = a" |
|
1047 |
||
1048 |
wfactors ::"[_, 'a list, 'a] \<Rightarrow> bool" |
|
1049 |
"wfactors G fs a == (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (op \<otimes>) fs \<one> \<sim> a" |
|
1050 |
||
1051 |
abbreviation |
|
1052 |
list_assoc :: "('a,_) monoid_scheme \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "[\<sim>]\<index>" 44) where |
|
1053 |
"list_assoc G == list_all2 (op \<sim>\<^bsub>G\<^esub>)" |
|
1054 |
||
1055 |
constdefs (structure G) |
|
1056 |
essentially_equal :: "[_, 'a list, 'a list] \<Rightarrow> bool" |
|
1057 |
"essentially_equal G fs1 fs2 == (\<exists>fs1'. fs1 <~~> fs1' \<and> fs1' [\<sim>] fs2)" |
|
1058 |
||
1059 |
||
1060 |
locale factorial_monoid = comm_monoid_cancel + |
|
1061 |
assumes factors_exist: |
|
1062 |
"\<lbrakk>a \<in> carrier G; a \<notin> Units G\<rbrakk> \<Longrightarrow> \<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" |
|
1063 |
and factors_unique: |
|
1064 |
"\<lbrakk>factors G fs a; factors G fs' a; a \<in> carrier G; a \<notin> Units G; |
|
1065 |
set fs \<subseteq> carrier G; set fs' \<subseteq> carrier G\<rbrakk> \<Longrightarrow> essentially_equal G fs fs'" |
|
1066 |
||
1067 |
||
1068 |
subsubsection {* Comparing lists of elements *} |
|
1069 |
||
1070 |
text {* Association on lists *} |
|
1071 |
||
1072 |
lemma (in monoid) listassoc_refl [simp, intro]: |
|
1073 |
assumes "set as \<subseteq> carrier G" |
|
1074 |
shows "as [\<sim>] as" |
|
1075 |
using assms |
|
1076 |
by (induct as) simp+ |
|
1077 |
||
1078 |
lemma (in monoid) listassoc_sym [sym]: |
|
1079 |
assumes "as [\<sim>] bs" |
|
1080 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
1081 |
shows "bs [\<sim>] as" |
|
1082 |
using assms |
|
1083 |
proof (induct as arbitrary: bs, simp) |
|
1084 |
case Cons |
|
1085 |
thus ?case |
|
1086 |
apply (induct bs, simp) |
|
1087 |
apply clarsimp |
|
1088 |
apply (iprover intro: associated_sym) |
|
1089 |
done |
|
1090 |
qed |
|
1091 |
||
1092 |
lemma (in monoid) listassoc_trans [trans]: |
|
1093 |
assumes "as [\<sim>] bs" and "bs [\<sim>] cs" |
|
1094 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" and "set cs \<subseteq> carrier G" |
|
1095 |
shows "as [\<sim>] cs" |
|
1096 |
using assms |
|
1097 |
apply (simp add: list_all2_conv_all_nth set_conv_nth, safe) |
|
1098 |
apply (rule associated_trans) |
|
1099 |
apply (subgoal_tac "as ! i \<sim> bs ! i", assumption) |
|
1100 |
apply (simp, simp) |
|
1101 |
apply blast+ |
|
1102 |
done |
|
1103 |
||
1104 |
lemma (in monoid_cancel) irrlist_listassoc_cong: |
|
1105 |
assumes "\<forall>a\<in>set as. irreducible G a" |
|
1106 |
and "as [\<sim>] bs" |
|
1107 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
1108 |
shows "\<forall>a\<in>set bs. irreducible G a" |
|
1109 |
using assms |
|
1110 |
apply (clarsimp simp add: list_all2_conv_all_nth set_conv_nth) |
|
1111 |
apply (blast intro: irreducible_cong) |
|
1112 |
done |
|
1113 |
||
1114 |
||
1115 |
text {* Permutations *} |
|
1116 |
||
1117 |
lemma perm_map [intro]: |
|
1118 |
assumes p: "a <~~> b" |
|
1119 |
shows "map f a <~~> map f b" |
|
1120 |
using p |
|
1121 |
by induct auto |
|
1122 |
||
1123 |
lemma perm_map_switch: |
|
1124 |
assumes m: "map f a = map f b" and p: "b <~~> c" |
|
1125 |
shows "\<exists>d. a <~~> d \<and> map f d = map f c" |
|
1126 |
using p m |
|
1127 |
by (induct arbitrary: a) (simp, force, force, blast) |
|
1128 |
||
1129 |
lemma (in monoid) perm_assoc_switch: |
|
1130 |
assumes a:"as [\<sim>] bs" and p: "bs <~~> cs" |
|
1131 |
shows "\<exists>bs'. as <~~> bs' \<and> bs' [\<sim>] cs" |
|
1132 |
using p a |
|
1133 |
apply (induct bs cs arbitrary: as, simp) |
|
1134 |
apply (clarsimp simp add: list_all2_Cons2, blast) |
|
1135 |
apply (clarsimp simp add: list_all2_Cons2) |
|
1136 |
apply blast |
|
1137 |
apply blast |
|
1138 |
done |
|
1139 |
||
1140 |
lemma (in monoid) perm_assoc_switch_r: |
|
1141 |
assumes p: "as <~~> bs" and a:"bs [\<sim>] cs" |
|
1142 |
shows "\<exists>bs'. as [\<sim>] bs' \<and> bs' <~~> cs" |
|
1143 |
using p a |
|
1144 |
apply (induct as bs arbitrary: cs, simp) |
|
1145 |
apply (clarsimp simp add: list_all2_Cons1, blast) |
|
1146 |
apply (clarsimp simp add: list_all2_Cons1) |
|
1147 |
apply blast |
|
1148 |
apply blast |
|
1149 |
done |
|
1150 |
||
1151 |
declare perm_sym [sym] |
|
1152 |
||
1153 |
lemma perm_setP: |
|
1154 |
assumes perm: "as <~~> bs" |
|
1155 |
and as: "P (set as)" |
|
1156 |
shows "P (set bs)" |
|
1157 |
proof - |
|
1158 |
from perm |
|
1159 |
have "multiset_of as = multiset_of bs" |
|
1160 |
by (simp add: multiset_of_eq_perm) |
|
1161 |
hence "set as = set bs" by (rule multiset_of_eq_setD) |
|
1162 |
with as |
|
1163 |
show "P (set bs)" by simp |
|
1164 |
qed |
|
1165 |
||
1166 |
lemmas (in monoid) perm_closed = |
|
1167 |
perm_setP[of _ _ "\<lambda>as. as \<subseteq> carrier G"] |
|
1168 |
||
1169 |
lemmas (in monoid) irrlist_perm_cong = |
|
1170 |
perm_setP[of _ _ "\<lambda>as. \<forall>a\<in>as. irreducible G a"] |
|
1171 |
||
1172 |
||
1173 |
text {* Essentially equal factorizations *} |
|
1174 |
||
1175 |
lemma (in monoid) essentially_equalI: |
|
1176 |
assumes ex: "fs1 <~~> fs1'" "fs1' [\<sim>] fs2" |
|
1177 |
shows "essentially_equal G fs1 fs2" |
|
1178 |
using ex |
|
1179 |
unfolding essentially_equal_def |
|
1180 |
by fast |
|
1181 |
||
1182 |
lemma (in monoid) essentially_equalE: |
|
1183 |
assumes ee: "essentially_equal G fs1 fs2" |
|
1184 |
and e: "\<And>fs1'. \<lbrakk>fs1 <~~> fs1'; fs1' [\<sim>] fs2\<rbrakk> \<Longrightarrow> P" |
|
1185 |
shows "P" |
|
1186 |
using ee |
|
1187 |
unfolding essentially_equal_def |
|
1188 |
by (fast intro: e) |
|
1189 |
||
1190 |
lemma (in monoid) ee_refl [simp,intro]: |
|
1191 |
assumes carr: "set as \<subseteq> carrier G" |
|
1192 |
shows "essentially_equal G as as" |
|
1193 |
using carr |
|
1194 |
by (fast intro: essentially_equalI) |
|
1195 |
||
1196 |
lemma (in monoid) ee_sym [sym]: |
|
1197 |
assumes ee: "essentially_equal G as bs" |
|
1198 |
and carr: "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1199 |
shows "essentially_equal G bs as" |
|
1200 |
using ee |
|
1201 |
proof (elim essentially_equalE) |
|
1202 |
fix fs |
|
1203 |
assume "as <~~> fs" "fs [\<sim>] bs" |
|
1204 |
hence "\<exists>fs'. as [\<sim>] fs' \<and> fs' <~~> bs" by (rule perm_assoc_switch_r) |
|
1205 |
from this obtain fs' |
|
1206 |
where a: "as [\<sim>] fs'" and p: "fs' <~~> bs" |
|
1207 |
by auto |
|
1208 |
from p have "bs <~~> fs'" by (rule perm_sym) |
|
1209 |
with a[symmetric] carr |
|
1210 |
show ?thesis |
|
1211 |
by (iprover intro: essentially_equalI perm_closed) |
|
1212 |
qed |
|
1213 |
||
1214 |
lemma (in monoid) ee_trans [trans]: |
|
1215 |
assumes ab: "essentially_equal G as bs" and bc: "essentially_equal G bs cs" |
|
1216 |
and ascarr: "set as \<subseteq> carrier G" |
|
1217 |
and bscarr: "set bs \<subseteq> carrier G" |
|
1218 |
and cscarr: "set cs \<subseteq> carrier G" |
|
1219 |
shows "essentially_equal G as cs" |
|
1220 |
using ab bc |
|
1221 |
proof (elim essentially_equalE) |
|
1222 |
fix abs bcs |
|
1223 |
assume "abs [\<sim>] bs" and pb: "bs <~~> bcs" |
|
1224 |
hence "\<exists>bs'. abs <~~> bs' \<and> bs' [\<sim>] bcs" by (rule perm_assoc_switch) |
|
1225 |
from this obtain bs' |
|
1226 |
where p: "abs <~~> bs'" and a: "bs' [\<sim>] bcs" |
|
1227 |
by auto |
|
1228 |
||
1229 |
assume "as <~~> abs" |
|
1230 |
with p |
|
1231 |
have pp: "as <~~> bs'" by fast |
|
1232 |
||
1233 |
from pp ascarr have c1: "set bs' \<subseteq> carrier G" by (rule perm_closed) |
|
1234 |
from pb bscarr have c2: "set bcs \<subseteq> carrier G" by (rule perm_closed) |
|
1235 |
note a |
|
1236 |
also assume "bcs [\<sim>] cs" |
|
1237 |
finally (listassoc_trans) have"bs' [\<sim>] cs" by (simp add: c1 c2 cscarr) |
|
1238 |
||
1239 |
with pp |
|
1240 |
show ?thesis |
|
1241 |
by (rule essentially_equalI) |
|
1242 |
qed |
|
1243 |
||
1244 |
||
1245 |
subsubsection {* Properties of lists of elements *} |
|
1246 |
||
1247 |
text {* Multiplication of factors in a list *} |
|
1248 |
||
1249 |
lemma (in monoid) multlist_closed [simp, intro]: |
|
1250 |
assumes ascarr: "set fs \<subseteq> carrier G" |
|
1251 |
shows "foldr (op \<otimes>) fs \<one> \<in> carrier G" |
|
1252 |
by (insert ascarr, induct fs, simp+) |
|
1253 |
||
1254 |
lemma (in comm_monoid) multlist_dividesI (*[intro]*): |
|
1255 |
assumes "f \<in> set fs" and "f \<in> carrier G" and "set fs \<subseteq> carrier G" |
|
1256 |
shows "f divides (foldr (op \<otimes>) fs \<one>)" |
|
1257 |
using assms |
|
1258 |
apply (induct fs) |
|
1259 |
apply simp |
|
1260 |
apply (case_tac "f = a", simp) |
|
1261 |
apply (fast intro: dividesI) |
|
1262 |
apply clarsimp |
|
1263 |
apply (elim dividesE, intro dividesI) |
|
1264 |
defer 1 |
|
1265 |
apply (simp add: m_comm) |
|
1266 |
apply (simp add: m_assoc[symmetric]) |
|
1267 |
apply (simp add: m_comm) |
|
1268 |
apply simp |
|
1269 |
done |
|
1270 |
||
1271 |
lemma (in comm_monoid_cancel) multlist_listassoc_cong: |
|
1272 |
assumes "fs [\<sim>] fs'" |
|
1273 |
and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G" |
|
1274 |
shows "foldr (op \<otimes>) fs \<one> \<sim> foldr (op \<otimes>) fs' \<one>" |
|
1275 |
using assms |
|
1276 |
proof (induct fs arbitrary: fs', simp) |
|
1277 |
case (Cons a as fs') |
|
1278 |
thus ?case |
|
1279 |
apply (induct fs', simp) |
|
1280 |
proof clarsimp |
|
1281 |
fix b bs |
|
1282 |
assume "a \<sim> b" |
|
1283 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1284 |
and ascarr: "set as \<subseteq> carrier G" |
|
1285 |
hence p: "a \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> as \<one>" |
|
1286 |
by (fast intro: mult_cong_l) |
|
1287 |
also |
|
1288 |
assume "as [\<sim>] bs" |
|
1289 |
and bscarr: "set bs \<subseteq> carrier G" |
|
1290 |
and "\<And>fs'. \<lbrakk>as [\<sim>] fs'; set fs' \<subseteq> carrier G\<rbrakk> \<Longrightarrow> foldr op \<otimes> as \<one> \<sim> foldr op \<otimes> fs' \<one>" |
|
1291 |
hence "foldr op \<otimes> as \<one> \<sim> foldr op \<otimes> bs \<one>" by simp |
|
1292 |
with ascarr bscarr bcarr |
|
1293 |
have "b \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> bs \<one>" |
|
1294 |
by (fast intro: mult_cong_r) |
|
1295 |
finally |
|
1296 |
show "a \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> bs \<one>" |
|
1297 |
by (simp add: ascarr bscarr acarr bcarr) |
|
1298 |
qed |
|
1299 |
qed |
|
1300 |
||
1301 |
lemma (in comm_monoid) multlist_perm_cong: |
|
1302 |
assumes prm: "as <~~> bs" |
|
1303 |
and ascarr: "set as \<subseteq> carrier G" |
|
1304 |
shows "foldr (op \<otimes>) as \<one> = foldr (op \<otimes>) bs \<one>" |
|
1305 |
using prm ascarr |
|
1306 |
apply (induct, simp, clarsimp simp add: m_ac, clarsimp) |
|
1307 |
proof clarsimp |
|
1308 |
fix xs ys zs |
|
1309 |
assume "xs <~~> ys" "set xs \<subseteq> carrier G" |
|
1310 |
hence "set ys \<subseteq> carrier G" by (rule perm_closed) |
|
1311 |
moreover assume "set ys \<subseteq> carrier G \<Longrightarrow> foldr op \<otimes> ys \<one> = foldr op \<otimes> zs \<one>" |
|
1312 |
ultimately show "foldr op \<otimes> ys \<one> = foldr op \<otimes> zs \<one>" by simp |
|
1313 |
qed |
|
1314 |
||
1315 |
lemma (in comm_monoid_cancel) multlist_ee_cong: |
|
1316 |
assumes "essentially_equal G fs fs'" |
|
1317 |
and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G" |
|
1318 |
shows "foldr (op \<otimes>) fs \<one> \<sim> foldr (op \<otimes>) fs' \<one>" |
|
1319 |
using assms |
|
1320 |
apply (elim essentially_equalE) |
|
1321 |
apply (simp add: multlist_perm_cong multlist_listassoc_cong perm_closed) |
|
1322 |
done |
|
1323 |
||
1324 |
||
1325 |
subsubsection {* Factorization in irreducible elements *} |
|
1326 |
||
1327 |
lemma wfactorsI: |
|
28599 | 1328 |
fixes G (structure) |
27701 | 1329 |
assumes "\<forall>f\<in>set fs. irreducible G f" |
1330 |
and "foldr (op \<otimes>) fs \<one> \<sim> a" |
|
1331 |
shows "wfactors G fs a" |
|
1332 |
using assms |
|
1333 |
unfolding wfactors_def |
|
1334 |
by simp |
|
1335 |
||
1336 |
lemma wfactorsE: |
|
28599 | 1337 |
fixes G (structure) |
27701 | 1338 |
assumes wf: "wfactors G fs a" |
1339 |
and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (op \<otimes>) fs \<one> \<sim> a\<rbrakk> \<Longrightarrow> P" |
|
1340 |
shows "P" |
|
1341 |
using wf |
|
1342 |
unfolding wfactors_def |
|
1343 |
by (fast dest: e) |
|
1344 |
||
1345 |
lemma (in monoid) factorsI: |
|
1346 |
assumes "\<forall>f\<in>set fs. irreducible G f" |
|
1347 |
and "foldr (op \<otimes>) fs \<one> = a" |
|
1348 |
shows "factors G fs a" |
|
1349 |
using assms |
|
1350 |
unfolding factors_def |
|
1351 |
by simp |
|
1352 |
||
1353 |
lemma factorsE: |
|
28599 | 1354 |
fixes G (structure) |
27701 | 1355 |
assumes f: "factors G fs a" |
1356 |
and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (op \<otimes>) fs \<one> = a\<rbrakk> \<Longrightarrow> P" |
|
1357 |
shows "P" |
|
1358 |
using f |
|
1359 |
unfolding factors_def |
|
1360 |
by (simp add: e) |
|
1361 |
||
1362 |
lemma (in monoid) factors_wfactors: |
|
1363 |
assumes "factors G as a" and "set as \<subseteq> carrier G" |
|
1364 |
shows "wfactors G as a" |
|
1365 |
using assms |
|
1366 |
by (blast elim: factorsE intro: wfactorsI) |
|
1367 |
||
1368 |
lemma (in monoid) wfactors_factors: |
|
1369 |
assumes "wfactors G as a" and "set as \<subseteq> carrier G" |
|
1370 |
shows "\<exists>a'. factors G as a' \<and> a' \<sim> a" |
|
1371 |
using assms |
|
1372 |
by (blast elim: wfactorsE intro: factorsI) |
|
1373 |
||
1374 |
lemma (in monoid) factors_closed [dest]: |
|
1375 |
assumes "factors G fs a" and "set fs \<subseteq> carrier G" |
|
1376 |
shows "a \<in> carrier G" |
|
1377 |
using assms |
|
1378 |
by (elim factorsE, clarsimp) |
|
1379 |
||
1380 |
lemma (in monoid) nunit_factors: |
|
1381 |
assumes anunit: "a \<notin> Units G" |
|
1382 |
and fs: "factors G as a" |
|
1383 |
shows "length as > 0" |
|
1384 |
apply (insert fs, elim factorsE) |
|
1385 |
proof (cases "length as = 0") |
|
1386 |
assume "length as = 0" |
|
1387 |
hence fold: "foldr op \<otimes> as \<one> = \<one>" by force |
|
1388 |
||
1389 |
assume "foldr op \<otimes> as \<one> = a" |
|
1390 |
with fold |
|
1391 |
have "a = \<one>" by simp |
|
1392 |
then have "a \<in> Units G" by fast |
|
1393 |
with anunit |
|
1394 |
have "False" by simp |
|
1395 |
thus ?thesis .. |
|
1396 |
qed simp |
|
1397 |
||
1398 |
lemma (in monoid) unit_wfactors [simp]: |
|
1399 |
assumes aunit: "a \<in> Units G" |
|
1400 |
shows "wfactors G [] a" |
|
1401 |
using aunit |
|
1402 |
by (intro wfactorsI) (simp, simp add: Units_assoc) |
|
1403 |
||
1404 |
lemma (in comm_monoid_cancel) unit_wfactors_empty: |
|
1405 |
assumes aunit: "a \<in> Units G" |
|
1406 |
and wf: "wfactors G fs a" |
|
1407 |
and carr[simp]: "set fs \<subseteq> carrier G" |
|
1408 |
shows "fs = []" |
|
1409 |
proof (rule ccontr, cases fs, simp) |
|
1410 |
fix f fs' |
|
1411 |
assume fs: "fs = f # fs'" |
|
1412 |
||
1413 |
from carr |
|
1414 |
have fcarr[simp]: "f \<in> carrier G" |
|
1415 |
and carr'[simp]: "set fs' \<subseteq> carrier G" |
|
1416 |
by (simp add: fs)+ |
|
1417 |
||
1418 |
from fs wf |
|
1419 |
have "irreducible G f" by (simp add: wfactors_def) |
|
1420 |
hence fnunit: "f \<notin> Units G" by (fast elim: irreducibleE) |
|
1421 |
||
1422 |
from fs wf |
|
1423 |
have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def) |
|
1424 |
||
1425 |
note aunit |
|
1426 |
also from fs wf |
|
1427 |
have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def) |
|
1428 |
have "a \<sim> f \<otimes> foldr (op \<otimes>) fs' \<one>" |
|
1429 |
by (simp add: Units_closed[OF aunit] a[symmetric]) |
|
1430 |
finally |
|
1431 |
have "f \<otimes> foldr (op \<otimes>) fs' \<one> \<in> Units G" by simp |
|
1432 |
hence "f \<in> Units G" by (intro unit_factor[of f], simp+) |
|
1433 |
||
1434 |
with fnunit show "False" by simp |
|
1435 |
qed |
|
1436 |
||
1437 |
||
1438 |
text {* Comparing wfactors *} |
|
1439 |
||
1440 |
lemma (in comm_monoid_cancel) wfactors_listassoc_cong_l: |
|
1441 |
assumes fact: "wfactors G fs a" |
|
1442 |
and asc: "fs [\<sim>] fs'" |
|
1443 |
and carr: "a \<in> carrier G" "set fs \<subseteq> carrier G" "set fs' \<subseteq> carrier G" |
|
1444 |
shows "wfactors G fs' a" |
|
1445 |
using fact |
|
1446 |
apply (elim wfactorsE, intro wfactorsI) |
|
1447 |
proof - |
|
1448 |
assume "\<forall>f\<in>set fs. irreducible G f" |
|
1449 |
also note asc |
|
1450 |
finally (irrlist_listassoc_cong) |
|
1451 |
show "\<forall>f\<in>set fs'. irreducible G f" by (simp add: carr) |
|
1452 |
next |
|
1453 |
from asc[symmetric] |
|
1454 |
have "foldr op \<otimes> fs' \<one> \<sim> foldr op \<otimes> fs \<one>" |
|
1455 |
by (simp add: multlist_listassoc_cong carr) |
|
1456 |
also assume "foldr op \<otimes> fs \<one> \<sim> a" |
|
1457 |
finally |
|
1458 |
show "foldr op \<otimes> fs' \<one> \<sim> a" by (simp add: carr) |
|
1459 |
qed |
|
1460 |
||
1461 |
lemma (in comm_monoid) wfactors_perm_cong_l: |
|
1462 |
assumes "wfactors G fs a" |
|
1463 |
and "fs <~~> fs'" |
|
1464 |
and "set fs \<subseteq> carrier G" |
|
1465 |
shows "wfactors G fs' a" |
|
1466 |
using assms |
|
1467 |
apply (elim wfactorsE, intro wfactorsI) |
|
1468 |
apply (rule irrlist_perm_cong, assumption+) |
|
1469 |
apply (simp add: multlist_perm_cong[symmetric]) |
|
1470 |
done |
|
1471 |
||
1472 |
lemma (in comm_monoid_cancel) wfactors_ee_cong_l [trans]: |
|
1473 |
assumes ee: "essentially_equal G as bs" |
|
1474 |
and bfs: "wfactors G bs b" |
|
1475 |
and carr: "b \<in> carrier G" "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1476 |
shows "wfactors G as b" |
|
1477 |
using ee |
|
1478 |
proof (elim essentially_equalE) |
|
1479 |
fix fs |
|
1480 |
assume prm: "as <~~> fs" |
|
1481 |
with carr |
|
1482 |
have fscarr: "set fs \<subseteq> carrier G" by (simp add: perm_closed) |
|
1483 |
||
1484 |
note bfs |
|
1485 |
also assume [symmetric]: "fs [\<sim>] bs" |
|
1486 |
also (wfactors_listassoc_cong_l) |
|
1487 |
note prm[symmetric] |
|
1488 |
finally (wfactors_perm_cong_l) |
|
1489 |
show "wfactors G as b" by (simp add: carr fscarr) |
|
1490 |
qed |
|
1491 |
||
1492 |
lemma (in monoid) wfactors_cong_r [trans]: |
|
1493 |
assumes fac: "wfactors G fs a" and aa': "a \<sim> a'" |
|
1494 |
and carr[simp]: "a \<in> carrier G" "a' \<in> carrier G" "set fs \<subseteq> carrier G" |
|
1495 |
shows "wfactors G fs a'" |
|
1496 |
using fac |
|
1497 |
proof (elim wfactorsE, intro wfactorsI) |
|
1498 |
assume "foldr op \<otimes> fs \<one> \<sim> a" also note aa' |
|
1499 |
finally show "foldr op \<otimes> fs \<one> \<sim> a'" by simp |
|
1500 |
qed |
|
1501 |
||
1502 |
||
1503 |
subsubsection {* Essentially equal factorizations *} |
|
1504 |
||
1505 |
lemma (in comm_monoid_cancel) unitfactor_ee: |
|
1506 |
assumes uunit: "u \<in> Units G" |
|
1507 |
and carr: "set as \<subseteq> carrier G" |
|
1508 |
shows "essentially_equal G (as[0 := (as!0 \<otimes> u)]) as" (is "essentially_equal G ?as' as") |
|
1509 |
using assms |
|
1510 |
apply (intro essentially_equalI[of _ ?as'], simp) |
|
1511 |
apply (cases as, simp) |
|
1512 |
apply (clarsimp, fast intro: associatedI2[of u]) |
|
1513 |
done |
|
1514 |
||
1515 |
lemma (in comm_monoid_cancel) factors_cong_unit: |
|
1516 |
assumes uunit: "u \<in> Units G" and anunit: "a \<notin> Units G" |
|
1517 |
and afs: "factors G as a" |
|
1518 |
and ascarr: "set as \<subseteq> carrier G" |
|
1519 |
shows "factors G (as[0 := (as!0 \<otimes> u)]) (a \<otimes> u)" (is "factors G ?as' ?a'") |
|
1520 |
using assms |
|
1521 |
apply (elim factorsE, clarify) |
|
1522 |
apply (cases as) |
|
1523 |
apply (simp add: nunit_factors) |
|
1524 |
apply clarsimp |
|
1525 |
apply (elim factorsE, intro factorsI) |
|
1526 |
apply (clarsimp, fast intro: irreducible_prod_rI) |
|
1527 |
apply (simp add: m_ac Units_closed) |
|
1528 |
done |
|
1529 |
||
1530 |
lemma (in comm_monoid) perm_wfactorsD: |
|
1531 |
assumes prm: "as <~~> bs" |
|
1532 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
|
1533 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
1534 |
and ascarr[simp]: "set as \<subseteq> carrier G" |
|
1535 |
shows "a \<sim> b" |
|
1536 |
using afs bfs |
|
1537 |
proof (elim wfactorsE) |
|
1538 |
from prm have [simp]: "set bs \<subseteq> carrier G" by (simp add: perm_closed) |
|
1539 |
assume "foldr op \<otimes> as \<one> \<sim> a" |
|
1540 |
hence "a \<sim> foldr op \<otimes> as \<one>" by (rule associated_sym, simp+) |
|
1541 |
also from prm |
|
1542 |
have "foldr op \<otimes> as \<one> = foldr op \<otimes> bs \<one>" by (rule multlist_perm_cong, simp) |
|
1543 |
also assume "foldr op \<otimes> bs \<one> \<sim> b" |
|
1544 |
finally |
|
1545 |
show "a \<sim> b" by simp |
|
1546 |
qed |
|
1547 |
||
1548 |
lemma (in comm_monoid_cancel) listassoc_wfactorsD: |
|
1549 |
assumes assoc: "as [\<sim>] bs" |
|
1550 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
|
1551 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
1552 |
and [simp]: "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1553 |
shows "a \<sim> b" |
|
1554 |
using afs bfs |
|
1555 |
proof (elim wfactorsE) |
|
1556 |
assume "foldr op \<otimes> as \<one> \<sim> a" |
|
1557 |
hence "a \<sim> foldr op \<otimes> as \<one>" by (rule associated_sym, simp+) |
|
1558 |
also from assoc |
|
1559 |
have "foldr op \<otimes> as \<one> \<sim> foldr op \<otimes> bs \<one>" by (rule multlist_listassoc_cong, simp+) |
|
1560 |
also assume "foldr op \<otimes> bs \<one> \<sim> b" |
|
1561 |
finally |
|
1562 |
show "a \<sim> b" by simp |
|
1563 |
qed |
|
1564 |
||
1565 |
lemma (in comm_monoid_cancel) ee_wfactorsD: |
|
1566 |
assumes ee: "essentially_equal G as bs" |
|
1567 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
|
1568 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
1569 |
and ascarr[simp]: "set as \<subseteq> carrier G" and bscarr[simp]: "set bs \<subseteq> carrier G" |
|
1570 |
shows "a \<sim> b" |
|
1571 |
using ee |
|
1572 |
proof (elim essentially_equalE) |
|
1573 |
fix fs |
|
1574 |
assume prm: "as <~~> fs" |
|
1575 |
hence as'carr[simp]: "set fs \<subseteq> carrier G" by (simp add: perm_closed) |
|
1576 |
from afs prm |
|
1577 |
have afs': "wfactors G fs a" by (rule wfactors_perm_cong_l, simp) |
|
1578 |
assume "fs [\<sim>] bs" |
|
1579 |
from this afs' bfs |
|
1580 |
show "a \<sim> b" by (rule listassoc_wfactorsD, simp+) |
|
1581 |
qed |
|
1582 |
||
1583 |
lemma (in comm_monoid_cancel) ee_factorsD: |
|
1584 |
assumes ee: "essentially_equal G as bs" |
|
1585 |
and afs: "factors G as a" and bfs:"factors G bs b" |
|
1586 |
and "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1587 |
shows "a \<sim> b" |
|
1588 |
using assms |
|
1589 |
by (blast intro: factors_wfactors dest: ee_wfactorsD) |
|
1590 |
||
1591 |
lemma (in factorial_monoid) ee_factorsI: |
|
1592 |
assumes ab: "a \<sim> b" |
|
1593 |
and afs: "factors G as a" and anunit: "a \<notin> Units G" |
|
1594 |
and bfs: "factors G bs b" and bnunit: "b \<notin> Units G" |
|
1595 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1596 |
shows "essentially_equal G as bs" |
|
1597 |
proof - |
|
1598 |
note carr[simp] = factors_closed[OF afs ascarr] ascarr[THEN subsetD] |
|
1599 |
factors_closed[OF bfs bscarr] bscarr[THEN subsetD] |
|
1600 |
||
1601 |
from ab carr |
|
1602 |
have "\<exists>u\<in>Units G. a = b \<otimes> u" by (fast elim: associatedE2) |
|
1603 |
from this obtain u |
|
1604 |
where uunit: "u \<in> Units G" |
|
1605 |
and a: "a = b \<otimes> u" by auto |
|
1606 |
||
1607 |
from uunit bscarr |
|
1608 |
have ee: "essentially_equal G (bs[0 := (bs!0 \<otimes> u)]) bs" |
|
1609 |
(is "essentially_equal G ?bs' bs") |
|
1610 |
by (rule unitfactor_ee) |
|
1611 |
||
1612 |
from bscarr uunit |
|
1613 |
have bs'carr: "set ?bs' \<subseteq> carrier G" |
|
1614 |
by (cases bs) (simp add: Units_closed)+ |
|
1615 |
||
1616 |
from uunit bnunit bfs bscarr |
|
1617 |
have fac: "factors G ?bs' (b \<otimes> u)" |
|
1618 |
by (rule factors_cong_unit) |
|
1619 |
||
1620 |
from afs fac[simplified a[symmetric]] ascarr bs'carr anunit |
|
1621 |
have "essentially_equal G as ?bs'" |
|
1622 |
by (blast intro: factors_unique) |
|
1623 |
also note ee |
|
1624 |
finally |
|
1625 |
show "essentially_equal G as bs" by (simp add: ascarr bscarr bs'carr) |
|
1626 |
qed |
|
1627 |
||
1628 |
lemma (in factorial_monoid) ee_wfactorsI: |
|
1629 |
assumes asc: "a \<sim> b" |
|
1630 |
and asf: "wfactors G as a" and bsf: "wfactors G bs b" |
|
1631 |
and acarr[simp]: "a \<in> carrier G" and bcarr[simp]: "b \<in> carrier G" |
|
1632 |
and ascarr[simp]: "set as \<subseteq> carrier G" and bscarr[simp]: "set bs \<subseteq> carrier G" |
|
1633 |
shows "essentially_equal G as bs" |
|
1634 |
using assms |
|
1635 |
proof (cases "a \<in> Units G") |
|
1636 |
assume aunit: "a \<in> Units G" |
|
1637 |
also note asc |
|
1638 |
finally have bunit: "b \<in> Units G" by simp |
|
1639 |
||
1640 |
from aunit asf ascarr |
|
1641 |
have e: "as = []" by (rule unit_wfactors_empty) |
|
1642 |
from bunit bsf bscarr |
|
1643 |
have e': "bs = []" by (rule unit_wfactors_empty) |
|
1644 |
||
1645 |
have "essentially_equal G [] []" |
|
1646 |
by (fast intro: essentially_equalI) |
|
1647 |
thus ?thesis by (simp add: e e') |
|
1648 |
next |
|
1649 |
assume anunit: "a \<notin> Units G" |
|
1650 |
have bnunit: "b \<notin> Units G" |
|
1651 |
proof clarify |
|
1652 |
assume "b \<in> Units G" |
|
1653 |
also note asc[symmetric] |
|
1654 |
finally have "a \<in> Units G" by simp |
|
1655 |
with anunit |
|
1656 |
show "False" .. |
|
1657 |
qed |
|
1658 |
||
1659 |
have "\<exists>a'. factors G as a' \<and> a' \<sim> a" by (rule wfactors_factors[OF asf ascarr]) |
|
1660 |
from this obtain a' |
|
1661 |
where fa': "factors G as a'" |
|
1662 |
and a': "a' \<sim> a" |
|
1663 |
by auto |
|
1664 |
from fa' ascarr |
|
1665 |
have a'carr[simp]: "a' \<in> carrier G" by fast |
|
1666 |
||
1667 |
have a'nunit: "a' \<notin> Units G" |
|
1668 |
proof (clarify) |
|
1669 |
assume "a' \<in> Units G" |
|
1670 |
also note a' |
|
1671 |
finally have "a \<in> Units G" by simp |
|
1672 |
with anunit |
|
1673 |
show "False" .. |
|
1674 |
qed |
|
1675 |
||
1676 |
have "\<exists>b'. factors G bs b' \<and> b' \<sim> b" by (rule wfactors_factors[OF bsf bscarr]) |
|
1677 |
from this obtain b' |
|
1678 |
where fb': "factors G bs b'" |
|
1679 |
and b': "b' \<sim> b" |
|
1680 |
by auto |
|
1681 |
from fb' bscarr |
|
1682 |
have b'carr[simp]: "b' \<in> carrier G" by fast |
|
1683 |
||
1684 |
have b'nunit: "b' \<notin> Units G" |
|
1685 |
proof (clarify) |
|
1686 |
assume "b' \<in> Units G" |
|
1687 |
also note b' |
|
1688 |
finally have "b \<in> Units G" by simp |
|
1689 |
with bnunit |
|
1690 |
show "False" .. |
|
1691 |
qed |
|
1692 |
||
1693 |
note a' |
|
1694 |
also note asc |
|
1695 |
also note b'[symmetric] |
|
1696 |
finally |
|
1697 |
have "a' \<sim> b'" by simp |
|
1698 |
||
1699 |
from this fa' a'nunit fb' b'nunit ascarr bscarr |
|
1700 |
show "essentially_equal G as bs" |
|
1701 |
by (rule ee_factorsI) |
|
1702 |
qed |
|
1703 |
||
1704 |
lemma (in factorial_monoid) ee_wfactors: |
|
1705 |
assumes asf: "wfactors G as a" |
|
1706 |
and bsf: "wfactors G bs b" |
|
1707 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1708 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1709 |
shows asc: "a \<sim> b = essentially_equal G as bs" |
|
1710 |
using assms |
|
1711 |
by (fast intro: ee_wfactorsI ee_wfactorsD) |
|
1712 |
||
1713 |
lemma (in factorial_monoid) wfactors_exist [intro, simp]: |
|
1714 |
assumes acarr[simp]: "a \<in> carrier G" |
|
1715 |
shows "\<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs a" |
|
1716 |
proof (cases "a \<in> Units G") |
|
1717 |
assume "a \<in> Units G" |
|
1718 |
hence "wfactors G [] a" by (rule unit_wfactors) |
|
1719 |
thus ?thesis by (intro exI) force |
|
1720 |
next |
|
1721 |
assume "a \<notin> Units G" |
|
1722 |
hence "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" by (intro factors_exist acarr) |
|
1723 |
from this obtain fs |
|
1724 |
where fscarr: "set fs \<subseteq> carrier G" |
|
1725 |
and f: "factors G fs a" |
|
1726 |
by auto |
|
1727 |
from f have "wfactors G fs a" by (rule factors_wfactors) fact |
|
1728 |
from fscarr this |
|
1729 |
show ?thesis by fast |
|
1730 |
qed |
|
1731 |
||
1732 |
lemma (in monoid) wfactors_prod_exists [intro, simp]: |
|
1733 |
assumes "\<forall>a \<in> set as. irreducible G a" and "set as \<subseteq> carrier G" |
|
1734 |
shows "\<exists>a. a \<in> carrier G \<and> wfactors G as a" |
|
1735 |
unfolding wfactors_def |
|
1736 |
using assms |
|
1737 |
by blast |
|
1738 |
||
1739 |
lemma (in factorial_monoid) wfactors_unique: |
|
1740 |
assumes "wfactors G fs a" and "wfactors G fs' a" |
|
1741 |
and "a \<in> carrier G" |
|
1742 |
and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G" |
|
1743 |
shows "essentially_equal G fs fs'" |
|
1744 |
using assms |
|
1745 |
by (fast intro: ee_wfactorsI[of a a]) |
|
1746 |
||
1747 |
lemma (in monoid) factors_mult_single: |
|
1748 |
assumes "irreducible G a" and "factors G fb b" and "a \<in> carrier G" |
|
1749 |
shows "factors G (a # fb) (a \<otimes> b)" |
|
1750 |
using assms |
|
1751 |
unfolding factors_def |
|
1752 |
by simp |
|
1753 |
||
1754 |
lemma (in monoid_cancel) wfactors_mult_single: |
|
1755 |
assumes f: "irreducible G a" "wfactors G fb b" |
|
1756 |
"a \<in> carrier G" "b \<in> carrier G" "set fb \<subseteq> carrier G" |
|
1757 |
shows "wfactors G (a # fb) (a \<otimes> b)" |
|
1758 |
using assms |
|
1759 |
unfolding wfactors_def |
|
1760 |
by (simp add: mult_cong_r) |
|
1761 |
||
1762 |
lemma (in monoid) factors_mult: |
|
1763 |
assumes factors: "factors G fa a" "factors G fb b" |
|
1764 |
and ascarr: "set fa \<subseteq> carrier G" and bscarr:"set fb \<subseteq> carrier G" |
|
1765 |
shows "factors G (fa @ fb) (a \<otimes> b)" |
|
1766 |
using assms |
|
1767 |
unfolding factors_def |
|
1768 |
apply (safe, force) |
|
1769 |
apply (induct fa) |
|
1770 |
apply simp |
|
1771 |
apply (simp add: m_assoc) |
|
1772 |
done |
|
1773 |
||
1774 |
lemma (in comm_monoid_cancel) wfactors_mult [intro]: |
|
1775 |
assumes asf: "wfactors G as a" and bsf:"wfactors G bs b" |
|
1776 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1777 |
and ascarr: "set as \<subseteq> carrier G" and bscarr:"set bs \<subseteq> carrier G" |
|
1778 |
shows "wfactors G (as @ bs) (a \<otimes> b)" |
|
1779 |
apply (insert wfactors_factors[OF asf ascarr]) |
|
1780 |
apply (insert wfactors_factors[OF bsf bscarr]) |
|
1781 |
proof (clarsimp) |
|
1782 |
fix a' b' |
|
1783 |
assume asf': "factors G as a'" and a'a: "a' \<sim> a" |
|
1784 |
and bsf': "factors G bs b'" and b'b: "b' \<sim> b" |
|
1785 |
from asf' have a'carr: "a' \<in> carrier G" by (rule factors_closed) fact |
|
1786 |
from bsf' have b'carr: "b' \<in> carrier G" by (rule factors_closed) fact |
|
1787 |
||
1788 |
note carr = acarr bcarr a'carr b'carr ascarr bscarr |
|
1789 |
||
1790 |
from asf' bsf' |
|
1791 |
have "factors G (as @ bs) (a' \<otimes> b')" by (rule factors_mult) fact+ |
|
1792 |
||
1793 |
with carr |
|
1794 |
have abf': "wfactors G (as @ bs) (a' \<otimes> b')" by (intro factors_wfactors) simp+ |
|
1795 |
also from b'b carr |
|
1796 |
have trb: "a' \<otimes> b' \<sim> a' \<otimes> b" by (intro mult_cong_r) |
|
1797 |
also from a'a carr |
|
1798 |
have tra: "a' \<otimes> b \<sim> a \<otimes> b" by (intro mult_cong_l) |
|
1799 |
finally |
|
1800 |
show "wfactors G (as @ bs) (a \<otimes> b)" |
|
1801 |
by (simp add: carr) |
|
1802 |
qed |
|
1803 |
||
1804 |
lemma (in comm_monoid) factors_dividesI: |
|
1805 |
assumes "factors G fs a" and "f \<in> set fs" |
|
1806 |
and "set fs \<subseteq> carrier G" |
|
1807 |
shows "f divides a" |
|
1808 |
using assms |
|
1809 |
by (fast elim: factorsE intro: multlist_dividesI) |
|
1810 |
||
1811 |
lemma (in comm_monoid) wfactors_dividesI: |
|
1812 |
assumes p: "wfactors G fs a" |
|
1813 |
and fscarr: "set fs \<subseteq> carrier G" and acarr: "a \<in> carrier G" |
|
1814 |
and f: "f \<in> set fs" |
|
1815 |
shows "f divides a" |
|
1816 |
apply (insert wfactors_factors[OF p fscarr], clarsimp) |
|
1817 |
proof - |
|
1818 |
fix a' |
|
1819 |
assume fsa': "factors G fs a'" |
|
1820 |
and a'a: "a' \<sim> a" |
|
1821 |
with fscarr |
|
1822 |
have a'carr: "a' \<in> carrier G" by (simp add: factors_closed) |
|
1823 |
||
1824 |
from fsa' fscarr f |
|
1825 |
have "f divides a'" by (fast intro: factors_dividesI) |
|
1826 |
also note a'a |
|
1827 |
finally |
|
1828 |
show "f divides a" by (simp add: f fscarr[THEN subsetD] acarr a'carr) |
|
1829 |
qed |
|
1830 |
||
1831 |
||
1832 |
subsubsection {* Factorial monoids and wfactors *} |
|
1833 |
||
1834 |
lemma (in comm_monoid_cancel) factorial_monoidI: |
|
1835 |
assumes wfactors_exists: |
|
1836 |
"\<And>a. a \<in> carrier G \<Longrightarrow> \<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs a" |
|
1837 |
and wfactors_unique: |
|
1838 |
"\<And>a fs fs'. \<lbrakk>a \<in> carrier G; set fs \<subseteq> carrier G; set fs' \<subseteq> carrier G; |
|
1839 |
wfactors G fs a; wfactors G fs' a\<rbrakk> \<Longrightarrow> essentially_equal G fs fs'" |
|
1840 |
shows "factorial_monoid G" |
|
28823 | 1841 |
proof |
27701 | 1842 |
fix a |
1843 |
assume acarr: "a \<in> carrier G" and anunit: "a \<notin> Units G" |
|
1844 |
||
1845 |
from wfactors_exists[OF acarr] |
|
1846 |
obtain as |
|
1847 |
where ascarr: "set as \<subseteq> carrier G" |
|
1848 |
and afs: "wfactors G as a" |
|
1849 |
by auto |
|
1850 |
from afs ascarr |
|
1851 |
have "\<exists>a'. factors G as a' \<and> a' \<sim> a" by (rule wfactors_factors) |
|
1852 |
from this obtain a' |
|
1853 |
where afs': "factors G as a'" |
|
1854 |
and a'a: "a' \<sim> a" |
|
1855 |
by auto |
|
1856 |
from afs' ascarr |
|
1857 |
have a'carr: "a' \<in> carrier G" by fast |
|
1858 |
have a'nunit: "a' \<notin> Units G" |
|
1859 |
proof clarify |
|
1860 |
assume "a' \<in> Units G" |
|
1861 |
also note a'a |
|
1862 |
finally have "a \<in> Units G" by (simp add: acarr) |
|
1863 |
with anunit |
|
1864 |
show "False" .. |
|
1865 |
qed |
|
1866 |
||
1867 |
from a'carr acarr a'a |
|
1868 |
have "\<exists>u. u \<in> Units G \<and> a' = a \<otimes> u" by (blast elim: associatedE2) |
|
1869 |
from this obtain u |
|
1870 |
where uunit: "u \<in> Units G" |
|
1871 |
and a': "a' = a \<otimes> u" |
|
1872 |
by auto |
|
1873 |
||
1874 |
note [simp] = acarr Units_closed[OF uunit] Units_inv_closed[OF uunit] |
|
1875 |
||
1876 |
have "a = a \<otimes> \<one>" by simp |
|
1877 |
also have "\<dots> = a \<otimes> (u \<otimes> inv u)" by (simp add: Units_r_inv uunit) |
|
1878 |
also have "\<dots> = a' \<otimes> inv u" by (simp add: m_assoc[symmetric] a'[symmetric]) |
|
1879 |
finally |
|
1880 |
have a: "a = a' \<otimes> inv u" . |
|
1881 |
||
1882 |
from ascarr uunit |
|
1883 |
have cr: "set (as[0:=(as!0 \<otimes> inv u)]) \<subseteq> carrier G" |
|
1884 |
by (cases as, clarsimp+) |
|
1885 |
||
1886 |
from afs' uunit a'nunit acarr ascarr |
|
1887 |
have "factors G (as[0:=(as!0 \<otimes> inv u)]) a" |
|
1888 |
by (simp add: a factors_cong_unit) |
|
1889 |
||
1890 |
with cr |
|
1891 |
show "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" by fast |
|
1892 |
qed (blast intro: factors_wfactors wfactors_unique) |
|
1893 |
||
1894 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
1895 |
subsection {* Factorizations as Multisets *} |
27701 | 1896 |
|
1897 |
text {* Gives useful operations like intersection *} |
|
1898 |
||
1899 |
(* FIXME: use class_of x instead of closure_of {x} *) |
|
1900 |
||
1901 |
abbreviation |
|
1902 |
"assocs G x == eq_closure_of (division_rel G) {x}" |
|
1903 |
||
1904 |
constdefs (structure G) |
|
1905 |
"fmset G as \<equiv> multiset_of (map (\<lambda>a. assocs G a) as)" |
|
1906 |
||
1907 |
||
1908 |
text {* Helper lemmas *} |
|
1909 |
||
1910 |
lemma (in monoid) assocs_repr_independence: |
|
1911 |
assumes "y \<in> assocs G x" |
|
1912 |
and "x \<in> carrier G" |
|
1913 |
shows "assocs G x = assocs G y" |
|
1914 |
using assms |
|
1915 |
apply safe |
|
1916 |
apply (elim closure_ofE2, intro closure_ofI2[of _ _ y]) |
|
1917 |
apply (clarsimp, iprover intro: associated_trans associated_sym, simp+) |
|
1918 |
apply (elim closure_ofE2, intro closure_ofI2[of _ _ x]) |
|
1919 |
apply (clarsimp, iprover intro: associated_trans, simp+) |
|
1920 |
done |
|
1921 |
||
1922 |
lemma (in monoid) assocs_self: |
|
1923 |
assumes "x \<in> carrier G" |
|
1924 |
shows "x \<in> assocs G x" |
|
1925 |
using assms |
|
1926 |
by (fastsimp intro: closure_ofI2) |
|
1927 |
||
1928 |
lemma (in monoid) assocs_repr_independenceD: |
|
1929 |
assumes repr: "assocs G x = assocs G y" |
|
1930 |
and ycarr: "y \<in> carrier G" |
|
1931 |
shows "y \<in> assocs G x" |
|
1932 |
unfolding repr |
|
1933 |
using ycarr |
|
1934 |
by (intro assocs_self) |
|
1935 |
||
1936 |
lemma (in comm_monoid) assocs_assoc: |
|
1937 |
assumes "a \<in> assocs G b" |
|
1938 |
and "b \<in> carrier G" |
|
1939 |
shows "a \<sim> b" |
|
1940 |
using assms |
|
1941 |
by (elim closure_ofE2, simp) |
|
1942 |
||
1943 |
lemmas (in comm_monoid) assocs_eqD = |
|
1944 |
assocs_repr_independenceD[THEN assocs_assoc] |
|
1945 |
||
1946 |
||
1947 |
subsubsection {* Comparing multisets *} |
|
1948 |
||
1949 |
lemma (in monoid) fmset_perm_cong: |
|
1950 |
assumes prm: "as <~~> bs" |
|
1951 |
shows "fmset G as = fmset G bs" |
|
1952 |
using perm_map[OF prm] |
|
1953 |
by (simp add: multiset_of_eq_perm fmset_def) |
|
1954 |
||
1955 |
lemma (in comm_monoid_cancel) eqc_listassoc_cong: |
|
1956 |
assumes "as [\<sim>] bs" |
|
1957 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
1958 |
shows "map (assocs G) as = map (assocs G) bs" |
|
1959 |
using assms |
|
1960 |
apply (induct as arbitrary: bs, simp) |
|
1961 |
apply (clarsimp simp add: Cons_eq_map_conv list_all2_Cons1, safe) |
|
1962 |
apply (clarsimp elim!: closure_ofE2) defer 1 |
|
1963 |
apply (clarsimp elim!: closure_ofE2) defer 1 |
|
1964 |
proof - |
|
1965 |
fix a x z |
|
1966 |
assume carr[simp]: "a \<in> carrier G" "x \<in> carrier G" "z \<in> carrier G" |
|
1967 |
assume "x \<sim> a" |
|
1968 |
also assume "a \<sim> z" |
|
1969 |
finally have "x \<sim> z" by simp |
|
1970 |
with carr |
|
1971 |
show "x \<in> assocs G z" |
|
1972 |
by (intro closure_ofI2) simp+ |
|
1973 |
next |
|
1974 |
fix a x z |
|
1975 |
assume carr[simp]: "a \<in> carrier G" "x \<in> carrier G" "z \<in> carrier G" |
|
1976 |
assume "x \<sim> z" |
|
1977 |
also assume [symmetric]: "a \<sim> z" |
|
1978 |
finally have "x \<sim> a" by simp |
|
1979 |
with carr |
|
1980 |
show "x \<in> assocs G a" |
|
1981 |
by (intro closure_ofI2) simp+ |
|
1982 |
qed |
|
1983 |
||
1984 |
lemma (in comm_monoid_cancel) fmset_listassoc_cong: |
|
1985 |
assumes "as [\<sim>] bs" |
|
1986 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
1987 |
shows "fmset G as = fmset G bs" |
|
1988 |
using assms |
|
1989 |
unfolding fmset_def |
|
1990 |
by (simp add: eqc_listassoc_cong) |
|
1991 |
||
1992 |
lemma (in comm_monoid_cancel) ee_fmset: |
|
1993 |
assumes ee: "essentially_equal G as bs" |
|
1994 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1995 |
shows "fmset G as = fmset G bs" |
|
1996 |
using ee |
|
1997 |
proof (elim essentially_equalE) |
|
1998 |
fix as' |
|
1999 |
assume prm: "as <~~> as'" |
|
2000 |
from prm ascarr |
|
2001 |
have as'carr: "set as' \<subseteq> carrier G" by (rule perm_closed) |
|
2002 |
||
2003 |
from prm |
|
2004 |
have "fmset G as = fmset G as'" by (rule fmset_perm_cong) |
|
2005 |
also assume "as' [\<sim>] bs" |
|
2006 |
with as'carr bscarr |
|
2007 |
have "fmset G as' = fmset G bs" by (simp add: fmset_listassoc_cong) |
|
2008 |
finally |
|
2009 |
show "fmset G as = fmset G bs" . |
|
2010 |
qed |
|
2011 |
||
2012 |
lemma (in monoid_cancel) fmset_ee__hlp_induct: |
|
2013 |
assumes prm: "cas <~~> cbs" |
|
2014 |
and cdef: "cas = map (assocs G) as" "cbs = map (assocs G) bs" |
|
2015 |
shows "\<forall>as bs. (cas <~~> cbs \<and> cas = map (assocs G) as \<and> |
|
2016 |
cbs = map (assocs G) bs) \<longrightarrow> (\<exists>as'. as <~~> as' \<and> map (assocs G) as' = cbs)" |
|
2017 |
apply (rule perm.induct[of cas cbs], rule prm) |
|
2018 |
apply safe apply simp_all |
|
2019 |
apply (simp add: map_eq_Cons_conv, blast) |
|
2020 |
apply force |
|
2021 |
proof - |
|
2022 |
fix ys as bs |
|
2023 |
assume p1: "map (assocs G) as <~~> ys" |
|
2024 |
and r1[rule_format]: |
|
2025 |
"\<forall>asa bs. map (assocs G) as = map (assocs G) asa \<and> |
|
2026 |
ys = map (assocs G) bs |
|
2027 |
\<longrightarrow> (\<exists>as'. asa <~~> as' \<and> map (assocs G) as' = map (assocs G) bs)" |
|
2028 |
and p2: "ys <~~> map (assocs G) bs" |
|
2029 |
and r2[rule_format]: |
|
2030 |
"\<forall>as bsa. ys = map (assocs G) as \<and> |
|
2031 |
map (assocs G) bs = map (assocs G) bsa |
|
2032 |
\<longrightarrow> (\<exists>as'. as <~~> as' \<and> map (assocs G) as' = map (assocs G) bsa)" |
|
2033 |
and p3: "map (assocs G) as <~~> map (assocs G) bs" |
|
2034 |
||
2035 |
from p1 |
|
2036 |
have "multiset_of (map (assocs G) as) = multiset_of ys" |
|
2037 |
by (simp add: multiset_of_eq_perm) |
|
2038 |
hence setys: "set (map (assocs G) as) = set ys" by (rule multiset_of_eq_setD) |
|
2039 |
||
2040 |
have "set (map (assocs G) as) = { assocs G x | x. x \<in> set as}" by clarsimp fast |
|
2041 |
with setys have "set ys \<subseteq> { assocs G x | x. x \<in> set as}" by simp |
|
2042 |
hence "\<exists>yy. ys = map (assocs G) yy" |
|
2043 |
apply (induct ys, simp, clarsimp) |
|
2044 |
proof - |
|
2045 |
fix yy x |
|
2046 |
show "\<exists>yya. (assocs G x) # map (assocs G) yy = |
|
2047 |
map (assocs G) yya" |
|
2048 |
by (rule exI[of _ "x#yy"], simp) |
|
2049 |
qed |
|
2050 |
from this obtain yy |
|
2051 |
where ys: "ys = map (assocs G) yy" |
|
2052 |
by auto |
|
2053 |
||
2054 |
from p1 ys |
|
2055 |
have "\<exists>as'. as <~~> as' \<and> map (assocs G) as' = map (assocs G) yy" |
|
2056 |
by (intro r1, simp) |
|
2057 |
from this obtain as' |
|
2058 |
where asas': "as <~~> as'" |
|
2059 |
and as'yy: "map (assocs G) as' = map (assocs G) yy" |
|
2060 |
by auto |
|
2061 |
||
2062 |
from p2 ys |
|
2063 |
have "\<exists>as'. yy <~~> as' \<and> map (assocs G) as' = map (assocs G) bs" |
|
2064 |
by (intro r2, simp) |
|
2065 |
from this obtain as'' |
|
2066 |
where yyas'': "yy <~~> as''" |
|
2067 |
and as''bs: "map (assocs G) as'' = map (assocs G) bs" |
|
2068 |
by auto |
|
2069 |
||
2070 |
from as'yy and yyas'' |
|
2071 |
have "\<exists>cs. as' <~~> cs \<and> map (assocs G) cs = map (assocs G) as''" |
|
2072 |
by (rule perm_map_switch) |
|
2073 |
from this obtain cs |
|
2074 |
where as'cs: "as' <~~> cs" |
|
2075 |
and csas'': "map (assocs G) cs = map (assocs G) as''" |
|
2076 |
by auto |
|
2077 |
||
2078 |
from asas' and as'cs |
|
2079 |
have ascs: "as <~~> cs" by fast |
|
2080 |
from csas'' and as''bs |
|
2081 |
have "map (assocs G) cs = map (assocs G) bs" by simp |
|
2082 |
from ascs and this |
|
2083 |
show "\<exists>as'. as <~~> as' \<and> map (assocs G) as' = map (assocs G) bs" by fast |
|
2084 |
qed |
|
2085 |
||
2086 |
lemma (in comm_monoid_cancel) fmset_ee: |
|
2087 |
assumes mset: "fmset G as = fmset G bs" |
|
2088 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
2089 |
shows "essentially_equal G as bs" |
|
2090 |
proof - |
|
2091 |
from mset |
|
2092 |
have mpp: "map (assocs G) as <~~> map (assocs G) bs" |
|
2093 |
by (simp add: fmset_def multiset_of_eq_perm) |
|
2094 |
||
2095 |
have "\<exists>cas. cas = map (assocs G) as" by simp |
|
2096 |
from this obtain cas where cas: "cas = map (assocs G) as" by simp |
|
2097 |
||
2098 |
have "\<exists>cbs. cbs = map (assocs G) bs" by simp |
|
2099 |
from this obtain cbs where cbs: "cbs = map (assocs G) bs" by simp |
|
2100 |
||
2101 |
from cas cbs mpp |
|
2102 |
have [rule_format]: |
|
2103 |
"\<forall>as bs. (cas <~~> cbs \<and> cas = map (assocs G) as \<and> |
|
2104 |
cbs = map (assocs G) bs) |
|
2105 |
\<longrightarrow> (\<exists>as'. as <~~> as' \<and> map (assocs G) as' = cbs)" |
|
2106 |
by (intro fmset_ee__hlp_induct, simp+) |
|
2107 |
with mpp cas cbs |
|
2108 |
have "\<exists>as'. as <~~> as' \<and> map (assocs G) as' = map (assocs G) bs" |
|
2109 |
by simp |
|
2110 |
||
2111 |
from this obtain as' |
|
2112 |
where tp: "as <~~> as'" |
|
2113 |
and tm: "map (assocs G) as' = map (assocs G) bs" |
|
2114 |
by auto |
|
2115 |
from tm have lene: "length as' = length bs" by (rule map_eq_imp_length_eq) |
|
2116 |
from tp have "set as = set as'" by (simp add: multiset_of_eq_perm multiset_of_eq_setD) |
|
2117 |
with ascarr |
|
2118 |
have as'carr: "set as' \<subseteq> carrier G" by simp |
|
2119 |
||
2120 |
from tm as'carr[THEN subsetD] bscarr[THEN subsetD] |
|
2121 |
have "as' [\<sim>] bs" |
|
2122 |
by (induct as' arbitrary: bs) (simp, fastsimp dest: assocs_eqD[THEN associated_sym]) |
|
2123 |
||
2124 |
from tp and this |
|
2125 |
show "essentially_equal G as bs" by (fast intro: essentially_equalI) |
|
2126 |
qed |
|
2127 |
||
2128 |
lemma (in comm_monoid_cancel) ee_is_fmset: |
|
2129 |
assumes "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
2130 |
shows "essentially_equal G as bs = (fmset G as = fmset G bs)" |
|
2131 |
using assms |
|
2132 |
by (fast intro: ee_fmset fmset_ee) |
|
2133 |
||
2134 |
||
2135 |
subsubsection {* Interpreting multisets as factorizations *} |
|
2136 |
||
2137 |
lemma (in monoid) mset_fmsetEx: |
|
2138 |
assumes elems: "\<And>X. X \<in> set_of Cs \<Longrightarrow> \<exists>x. P x \<and> X = assocs G x" |
|
2139 |
shows "\<exists>cs. (\<forall>c \<in> set cs. P c) \<and> fmset G cs = Cs" |
|
2140 |
proof - |
|
2141 |
have "\<exists>Cs'. Cs = multiset_of Cs'" |
|
2142 |
by (rule surjE[OF surj_multiset_of], fast) |
|
2143 |
from this obtain Cs' |
|
2144 |
where Cs: "Cs = multiset_of Cs'" |
|
2145 |
by auto |
|
2146 |
||
2147 |
have "\<exists>cs. (\<forall>c \<in> set cs. P c) \<and> multiset_of (map (assocs G) cs) = Cs" |
|
2148 |
using elems |
|
2149 |
unfolding Cs |
|
2150 |
apply (induct Cs', simp) |
|
2151 |
apply clarsimp |
|
2152 |
apply (subgoal_tac "\<exists>cs. (\<forall>x\<in>set cs. P x) \<and> |
|
2153 |
multiset_of (map (assocs G) cs) = multiset_of Cs'") |
|
2154 |
proof clarsimp |
|
2155 |
fix a Cs' cs |
|
2156 |
assume ih: "\<And>X. X = a \<or> X \<in> set Cs' \<Longrightarrow> \<exists>x. P x \<and> X = assocs G x" |
|
2157 |
and csP: "\<forall>x\<in>set cs. P x" |
|
2158 |
and mset: "multiset_of (map (assocs G) cs) = multiset_of Cs'" |
|
2159 |
from ih |
|
2160 |
have "\<exists>x. P x \<and> a = assocs G x" by fast |
|
2161 |
from this obtain c |
|
2162 |
where cP: "P c" |
|
2163 |
and a: "a = assocs G c" |
|
2164 |
by auto |
|
2165 |
from cP csP |
|
2166 |
have tP: "\<forall>x\<in>set (c#cs). P x" by simp |
|
2167 |
from mset a |
|
2168 |
have "multiset_of (map (assocs G) (c#cs)) = multiset_of Cs' + {#a#}" by simp |
|
2169 |
from tP this |
|
2170 |
show "\<exists>cs. (\<forall>x\<in>set cs. P x) \<and> |
|
2171 |
multiset_of (map (assocs G) cs) = |
|
2172 |
multiset_of Cs' + {#a#}" by fast |
|
2173 |
qed simp |
|
2174 |
thus ?thesis by (simp add: fmset_def) |
|
2175 |
qed |
|
2176 |
||
2177 |
lemma (in monoid) mset_wfactorsEx: |
|
2178 |
assumes elems: "\<And>X. X \<in> set_of Cs |
|
2179 |
\<Longrightarrow> \<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" |
|
2180 |
shows "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> fmset G cs = Cs" |
|
2181 |
proof - |
|
2182 |
have "\<exists>cs. (\<forall>c\<in>set cs. c \<in> carrier G \<and> irreducible G c) \<and> fmset G cs = Cs" |
|
2183 |
by (intro mset_fmsetEx, rule elems) |
|
2184 |
from this obtain cs |
|
2185 |
where p[rule_format]: "\<forall>c\<in>set cs. c \<in> carrier G \<and> irreducible G c" |
|
2186 |
and Cs[symmetric]: "fmset G cs = Cs" |
|
2187 |
by auto |
|
2188 |
||
2189 |
from p |
|
2190 |
have cscarr: "set cs \<subseteq> carrier G" by fast |
|
2191 |
||
2192 |
from p |
|
2193 |
have "\<exists>c. c \<in> carrier G \<and> wfactors G cs c" |
|
2194 |
by (intro wfactors_prod_exists) fast+ |
|
2195 |
from this obtain c |
|
2196 |
where ccarr: "c \<in> carrier G" |
|
2197 |
and cfs: "wfactors G cs c" |
|
2198 |
by auto |
|
2199 |
||
2200 |
with cscarr Cs |
|
2201 |
show ?thesis by fast |
|
2202 |
qed |
|
2203 |
||
2204 |
||
2205 |
subsubsection {* Multiplication on multisets *} |
|
2206 |
||
2207 |
lemma (in factorial_monoid) mult_wfactors_fmset: |
|
2208 |
assumes afs: "wfactors G as a" and bfs: "wfactors G bs b" and cfs: "wfactors G cs (a \<otimes> b)" |
|
2209 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2210 |
"set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
|
2211 |
shows "fmset G cs = fmset G as + fmset G bs" |
|
2212 |
proof - |
|
2213 |
from assms |
|
2214 |
have "wfactors G (as @ bs) (a \<otimes> b)" by (intro wfactors_mult) |
|
2215 |
with carr cfs |
|
2216 |
have "essentially_equal G cs (as@bs)" by (intro ee_wfactorsI[of "a\<otimes>b" "a\<otimes>b"], simp+) |
|
2217 |
with carr |
|
2218 |
have "fmset G cs = fmset G (as@bs)" by (intro ee_fmset, simp+) |
|
2219 |
also have "fmset G (as@bs) = fmset G as + fmset G bs" by (simp add: fmset_def) |
|
2220 |
finally show "fmset G cs = fmset G as + fmset G bs" . |
|
2221 |
qed |
|
2222 |
||
2223 |
lemma (in factorial_monoid) mult_factors_fmset: |
|
2224 |
assumes afs: "factors G as a" and bfs: "factors G bs b" and cfs: "factors G cs (a \<otimes> b)" |
|
2225 |
and "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
|
2226 |
shows "fmset G cs = fmset G as + fmset G bs" |
|
2227 |
using assms |
|
2228 |
by (blast intro: factors_wfactors mult_wfactors_fmset) |
|
2229 |
||
2230 |
lemma (in comm_monoid_cancel) fmset_wfactors_mult: |
|
2231 |
assumes mset: "fmset G cs = fmset G as + fmset G bs" |
|
2232 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
2233 |
"set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
|
2234 |
and fs: "wfactors G as a" "wfactors G bs b" "wfactors G cs c" |
|
2235 |
shows "c \<sim> a \<otimes> b" |
|
2236 |
proof - |
|
2237 |
from carr fs |
|
2238 |
have m: "wfactors G (as @ bs) (a \<otimes> b)" by (intro wfactors_mult) |
|
2239 |
||
2240 |
from mset |
|
2241 |
have "fmset G cs = fmset G (as@bs)" by (simp add: fmset_def) |
|
2242 |
then have "essentially_equal G cs (as@bs)" by (rule fmset_ee) (simp add: carr)+ |
|
2243 |
then show "c \<sim> a \<otimes> b" by (rule ee_wfactorsD[of "cs" "as@bs"]) (simp add: assms m)+ |
|
2244 |
qed |
|
2245 |
||
2246 |
||
2247 |
subsubsection {* Divisibility on multisets *} |
|
2248 |
||
2249 |
lemma (in factorial_monoid) divides_fmsubset: |
|
2250 |
assumes ab: "a divides b" |
|
2251 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
|
2252 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2253 |
shows "fmset G as \<le> fmset G bs" |
27701 | 2254 |
using ab |
2255 |
proof (elim dividesE) |
|
2256 |
fix c |
|
2257 |
assume ccarr: "c \<in> carrier G" |
|
2258 |
hence "\<exists>cs. set cs \<subseteq> carrier G \<and> wfactors G cs c" by (rule wfactors_exist) |
|
2259 |
from this obtain cs |
|
2260 |
where cscarr: "set cs \<subseteq> carrier G" |
|
2261 |
and cfs: "wfactors G cs c" by auto |
|
2262 |
note carr = carr ccarr cscarr |
|
2263 |
||
2264 |
assume "b = a \<otimes> c" |
|
2265 |
with afs bfs cfs carr |
|
2266 |
have "fmset G bs = fmset G as + fmset G cs" |
|
2267 |
by (intro mult_wfactors_fmset[OF afs cfs]) simp+ |
|
2268 |
||
2269 |
thus ?thesis by simp |
|
2270 |
qed |
|
2271 |
||
2272 |
lemma (in comm_monoid_cancel) fmsubset_divides: |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2273 |
assumes msubset: "fmset G as \<le> fmset G bs" |
27701 | 2274 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
2275 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
2276 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
2277 |
shows "a divides b" |
|
2278 |
proof - |
|
2279 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" by (fast elim: wfactorsE) |
|
2280 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" by (fast elim: wfactorsE) |
|
2281 |
||
2282 |
have "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> fmset G cs = fmset G bs - fmset G as" |
|
2283 |
proof (intro mset_wfactorsEx, simp) |
|
2284 |
fix X |
|
2285 |
assume "count (fmset G as) X < count (fmset G bs) X" |
|
2286 |
hence "0 < count (fmset G bs) X" by simp |
|
2287 |
hence "X \<in> set_of (fmset G bs)" by simp |
|
2288 |
hence "X \<in> set (map (assocs G) bs)" by (simp add: fmset_def) |
|
2289 |
hence "\<exists>x. x \<in> set bs \<and> X = assocs G x" by (induct bs) auto |
|
2290 |
from this obtain x |
|
2291 |
where xbs: "x \<in> set bs" |
|
2292 |
and X: "X = assocs G x" |
|
2293 |
by auto |
|
2294 |
||
2295 |
with bscarr have xcarr: "x \<in> carrier G" by fast |
|
2296 |
from xbs birr have xirr: "irreducible G x" by simp |
|
2297 |
||
2298 |
from xcarr and xirr and X |
|
2299 |
show "\<exists>x. x \<in> carrier G \<and> irreducible G x \<and> X = assocs G x" by fast |
|
2300 |
qed |
|
2301 |
from this obtain c cs |
|
2302 |
where ccarr: "c \<in> carrier G" |
|
2303 |
and cscarr: "set cs \<subseteq> carrier G" |
|
2304 |
and csf: "wfactors G cs c" |
|
2305 |
and csmset: "fmset G cs = fmset G bs - fmset G as" by auto |
|
2306 |
||
2307 |
from csmset msubset |
|
2308 |
have "fmset G bs = fmset G as + fmset G cs" |
|
2309 |
by (simp add: multiset_eq_conv_count_eq mset_le_def) |
|
2310 |
hence basc: "b \<sim> a \<otimes> c" |
|
2311 |
by (rule fmset_wfactors_mult) fact+ |
|
2312 |
||
2313 |
thus ?thesis |
|
2314 |
proof (elim associatedE2) |
|
2315 |
fix u |
|
2316 |
assume "u \<in> Units G" "b = a \<otimes> c \<otimes> u" |
|
2317 |
with acarr ccarr |
|
2318 |
show "a divides b" by (fast intro: dividesI[of "c \<otimes> u"] m_assoc) |
|
2319 |
qed (simp add: acarr bcarr ccarr)+ |
|
2320 |
qed |
|
2321 |
||
2322 |
lemma (in factorial_monoid) divides_as_fmsubset: |
|
2323 |
assumes "wfactors G as a" and "wfactors G bs b" |
|
2324 |
and "a \<in> carrier G" and "b \<in> carrier G" |
|
2325 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2326 |
shows "a divides b = (fmset G as \<le> fmset G bs)" |
27701 | 2327 |
using assms |
2328 |
by (blast intro: divides_fmsubset fmsubset_divides) |
|
2329 |
||
2330 |
||
2331 |
text {* Proper factors on multisets *} |
|
2332 |
||
2333 |
lemma (in factorial_monoid) fmset_properfactor: |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2334 |
assumes asubb: "fmset G as \<le> fmset G bs" |
27701 | 2335 |
and anb: "fmset G as \<noteq> fmset G bs" |
2336 |
and "wfactors G as a" and "wfactors G bs b" |
|
2337 |
and "a \<in> carrier G" and "b \<in> carrier G" |
|
2338 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
2339 |
shows "properfactor G a b" |
|
2340 |
apply (rule properfactorI) |
|
2341 |
apply (rule fmsubset_divides[of as bs], fact+) |
|
2342 |
proof |
|
2343 |
assume "b divides a" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2344 |
hence "fmset G bs \<le> fmset G as" |
27701 | 2345 |
by (rule divides_fmsubset) fact+ |
2346 |
with asubb |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2347 |
have "fmset G as = fmset G bs" by (rule order_antisym) |
27701 | 2348 |
with anb |
2349 |
show "False" .. |
|
2350 |
qed |
|
2351 |
||
2352 |
lemma (in factorial_monoid) properfactor_fmset: |
|
2353 |
assumes pf: "properfactor G a b" |
|
2354 |
and "wfactors G as a" and "wfactors G bs b" |
|
2355 |
and "a \<in> carrier G" and "b \<in> carrier G" |
|
2356 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2357 |
shows "fmset G as \<le> fmset G bs \<and> fmset G as \<noteq> fmset G bs" |
27701 | 2358 |
using pf |
2359 |
apply (elim properfactorE) |
|
2360 |
apply rule |
|
2361 |
apply (intro divides_fmsubset, assumption) |
|
2362 |
apply (rule assms)+ |
|
2363 |
proof |
|
2364 |
assume bna: "\<not> b divides a" |
|
2365 |
assume "fmset G as = fmset G bs" |
|
2366 |
then have "essentially_equal G as bs" by (rule fmset_ee) fact+ |
|
2367 |
hence "a \<sim> b" by (rule ee_wfactorsD[of as bs]) fact+ |
|
2368 |
hence "b divides a" by (elim associatedE) |
|
2369 |
with bna |
|
2370 |
show "False" .. |
|
2371 |
qed |
|
2372 |
||
2373 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
2374 |
subsection {* Irreducible Elements are Prime *} |
27701 | 2375 |
|
2376 |
lemma (in factorial_monoid) irreducible_is_prime: |
|
2377 |
assumes pirr: "irreducible G p" |
|
2378 |
and pcarr: "p \<in> carrier G" |
|
2379 |
shows "prime G p" |
|
2380 |
using pirr |
|
2381 |
proof (elim irreducibleE, intro primeI) |
|
2382 |
fix a b |
|
2383 |
assume acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
2384 |
and pdvdab: "p divides (a \<otimes> b)" |
|
2385 |
and pnunit: "p \<notin> Units G" |
|
2386 |
assume irreduc[rule_format]: |
|
2387 |
"\<forall>b. b \<in> carrier G \<and> properfactor G b p \<longrightarrow> b \<in> Units G" |
|
2388 |
from pdvdab |
|
2389 |
have "\<exists>c\<in>carrier G. a \<otimes> b = p \<otimes> c" by (rule dividesD) |
|
2390 |
from this obtain c |
|
2391 |
where ccarr: "c \<in> carrier G" |
|
2392 |
and abpc: "a \<otimes> b = p \<otimes> c" |
|
2393 |
by auto |
|
2394 |
||
2395 |
from acarr have "\<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs a" by (rule wfactors_exist) |
|
2396 |
from this obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" by auto |
|
2397 |
||
2398 |
from bcarr have "\<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs b" by (rule wfactors_exist) |
|
2399 |
from this obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfs: "wfactors G bs b" by auto |
|
2400 |
||
2401 |
from ccarr have "\<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs c" by (rule wfactors_exist) |
|
2402 |
from this obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfs: "wfactors G cs c" by auto |
|
2403 |
||
2404 |
note carr[simp] = pcarr acarr bcarr ccarr ascarr bscarr cscarr |
|
2405 |
||
2406 |
from afs and bfs |
|
2407 |
have abfs: "wfactors G (as @ bs) (a \<otimes> b)" by (rule wfactors_mult) fact+ |
|
2408 |
||
2409 |
from pirr cfs |
|
2410 |
have pcfs: "wfactors G (p # cs) (p \<otimes> c)" by (rule wfactors_mult_single) fact+ |
|
2411 |
with abpc |
|
2412 |
have abfs': "wfactors G (p # cs) (a \<otimes> b)" by simp |
|
2413 |
||
2414 |
from abfs' abfs |
|
2415 |
have "essentially_equal G (p # cs) (as @ bs)" |
|
2416 |
by (rule wfactors_unique) simp+ |
|
2417 |
||
2418 |
hence "\<exists>ds. p # cs <~~> ds \<and> ds [\<sim>] (as @ bs)" |
|
2419 |
by (fast elim: essentially_equalE) |
|
2420 |
from this obtain ds |
|
2421 |
where "p # cs <~~> ds" |
|
2422 |
and dsassoc: "ds [\<sim>] (as @ bs)" |
|
2423 |
by auto |
|
2424 |
||
2425 |
then have "p \<in> set ds" |
|
2426 |
by (simp add: perm_set_eq[symmetric]) |
|
2427 |
with dsassoc |
|
2428 |
have "\<exists>p'. p' \<in> set (as@bs) \<and> p \<sim> p'" |
|
2429 |
unfolding list_all2_conv_all_nth set_conv_nth |
|
2430 |
by force |
|
2431 |
||
2432 |
from this obtain p' |
|
2433 |
where "p' \<in> set (as@bs)" |
|
2434 |
and pp': "p \<sim> p'" |
|
2435 |
by auto |
|
2436 |
||
2437 |
hence "p' \<in> set as \<or> p' \<in> set bs" by simp |
|
2438 |
moreover |
|
2439 |
{ |
|
2440 |
assume p'elem: "p' \<in> set as" |
|
2441 |
with ascarr have [simp]: "p' \<in> carrier G" by fast |
|
2442 |
||
2443 |
note pp' |
|
2444 |
also from afs |
|
2445 |
have "p' divides a" by (rule wfactors_dividesI) fact+ |
|
2446 |
finally |
|
2447 |
have "p divides a" by simp |
|
2448 |
} |
|
2449 |
moreover |
|
2450 |
{ |
|
2451 |
assume p'elem: "p' \<in> set bs" |
|
2452 |
with bscarr have [simp]: "p' \<in> carrier G" by fast |
|
2453 |
||
2454 |
note pp' |
|
2455 |
also from bfs |
|
2456 |
have "p' divides b" by (rule wfactors_dividesI) fact+ |
|
2457 |
finally |
|
2458 |
have "p divides b" by simp |
|
2459 |
} |
|
2460 |
ultimately |
|
2461 |
show "p divides a \<or> p divides b" by fast |
|
2462 |
qed |
|
2463 |
||
2464 |
||
2465 |
--"A version using @{const factors}, more complicated" |
|
2466 |
lemma (in factorial_monoid) factors_irreducible_is_prime: |
|
2467 |
assumes pirr: "irreducible G p" |
|
2468 |
and pcarr: "p \<in> carrier G" |
|
2469 |
shows "prime G p" |
|
2470 |
using pirr |
|
2471 |
apply (elim irreducibleE, intro primeI) |
|
2472 |
apply assumption |
|
2473 |
proof - |
|
2474 |
fix a b |
|
2475 |
assume acarr: "a \<in> carrier G" |
|
2476 |
and bcarr: "b \<in> carrier G" |
|
2477 |
and pdvdab: "p divides (a \<otimes> b)" |
|
2478 |
assume irreduc[rule_format]: |
|
2479 |
"\<forall>b. b \<in> carrier G \<and> properfactor G b p \<longrightarrow> b \<in> Units G" |
|
2480 |
from pdvdab |
|
2481 |
have "\<exists>c\<in>carrier G. a \<otimes> b = p \<otimes> c" by (rule dividesD) |
|
2482 |
from this obtain c |
|
2483 |
where ccarr: "c \<in> carrier G" |
|
2484 |
and abpc: "a \<otimes> b = p \<otimes> c" |
|
2485 |
by auto |
|
2486 |
note [simp] = pcarr acarr bcarr ccarr |
|
2487 |
||
2488 |
show "p divides a \<or> p divides b" |
|
2489 |
proof (cases "a \<in> Units G") |
|
2490 |
assume aunit: "a \<in> Units G" |
|
2491 |
||
2492 |
note pdvdab |
|
2493 |
also have "a \<otimes> b = b \<otimes> a" by (simp add: m_comm) |
|
2494 |
also from aunit |
|
2495 |
have bab: "b \<otimes> a \<sim> b" |
|
2496 |
by (intro associatedI2[of "a"], simp+) |
|
2497 |
finally |
|
2498 |
have "p divides b" by simp |
|
2499 |
thus "p divides a \<or> p divides b" .. |
|
2500 |
next |
|
2501 |
assume anunit: "a \<notin> Units G" |
|
2502 |
||
2503 |
show "p divides a \<or> p divides b" |
|
2504 |
proof (cases "b \<in> Units G") |
|
2505 |
assume bunit: "b \<in> Units G" |
|
2506 |
||
2507 |
note pdvdab |
|
2508 |
also from bunit |
|
2509 |
have baa: "a \<otimes> b \<sim> a" |
|
2510 |
by (intro associatedI2[of "b"], simp+) |
|
2511 |
finally |
|
2512 |
have "p divides a" by simp |
|
2513 |
thus "p divides a \<or> p divides b" .. |
|
2514 |
next |
|
2515 |
assume bnunit: "b \<notin> Units G" |
|
2516 |
||
2517 |
have cnunit: "c \<notin> Units G" |
|
2518 |
proof (rule ccontr, simp) |
|
2519 |
assume cunit: "c \<in> Units G" |
|
2520 |
from bnunit |
|
2521 |
have "properfactor G a (a \<otimes> b)" |
|
2522 |
by (intro properfactorI3[of _ _ b], simp+) |
|
2523 |
also note abpc |
|
2524 |
also from cunit |
|
2525 |
have "p \<otimes> c \<sim> p" |
|
2526 |
by (intro associatedI2[of c], simp+) |
|
2527 |
finally |
|
2528 |
have "properfactor G a p" by simp |
|
2529 |
||
2530 |
with acarr |
|
2531 |
have "a \<in> Units G" by (fast intro: irreduc) |
|
2532 |
with anunit |
|
2533 |
show "False" .. |
|
2534 |
qed |
|
2535 |
||
2536 |
have abnunit: "a \<otimes> b \<notin> Units G" |
|
2537 |
proof clarsimp |
|
2538 |
assume abunit: "a \<otimes> b \<in> Units G" |
|
2539 |
hence "a \<in> Units G" by (rule unit_factor) fact+ |
|
2540 |
with anunit |
|
2541 |
show "False" .. |
|
2542 |
qed |
|
2543 |
||
2544 |
from acarr anunit have "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" by (rule factors_exist) |
|
2545 |
then obtain as where ascarr: "set as \<subseteq> carrier G" and afac: "factors G as a" by auto |
|
2546 |
||
2547 |
from bcarr bnunit have "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs b" by (rule factors_exist) |
|
2548 |
then obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfac: "factors G bs b" by auto |
|
2549 |
||
2550 |
from ccarr cnunit have "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs c" by (rule factors_exist) |
|
2551 |
then obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfac: "factors G cs c" by auto |
|
2552 |
||
2553 |
note [simp] = ascarr bscarr cscarr |
|
2554 |
||
2555 |
from afac and bfac |
|
2556 |
have abfac: "factors G (as @ bs) (a \<otimes> b)" by (rule factors_mult) fact+ |
|
2557 |
||
2558 |
from pirr cfac |
|
2559 |
have pcfac: "factors G (p # cs) (p \<otimes> c)" by (rule factors_mult_single) fact+ |
|
2560 |
with abpc |
|
2561 |
have abfac': "factors G (p # cs) (a \<otimes> b)" by simp |
|
2562 |
||
2563 |
from abfac' abfac |
|
2564 |
have "essentially_equal G (p # cs) (as @ bs)" |
|
2565 |
by (rule factors_unique) (fact | simp)+ |
|
2566 |
||
2567 |
hence "\<exists>ds. p # cs <~~> ds \<and> ds [\<sim>] (as @ bs)" |
|
2568 |
by (fast elim: essentially_equalE) |
|
2569 |
from this obtain ds |
|
2570 |
where "p # cs <~~> ds" |
|
2571 |
and dsassoc: "ds [\<sim>] (as @ bs)" |
|
2572 |
by auto |
|
2573 |
||
2574 |
then have "p \<in> set ds" |
|
2575 |
by (simp add: perm_set_eq[symmetric]) |
|
2576 |
with dsassoc |
|
2577 |
have "\<exists>p'. p' \<in> set (as@bs) \<and> p \<sim> p'" |
|
2578 |
unfolding list_all2_conv_all_nth set_conv_nth |
|
2579 |
by force |
|
2580 |
||
2581 |
from this obtain p' |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2582 |
where "p' \<in> set (as@bs)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2583 |
and pp': "p \<sim> p'" by auto |
27701 | 2584 |
|
2585 |
hence "p' \<in> set as \<or> p' \<in> set bs" by simp |
|
2586 |
moreover |
|
2587 |
{ |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2588 |
assume p'elem: "p' \<in> set as" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2589 |
with ascarr have [simp]: "p' \<in> carrier G" by fast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2590 |
|
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2591 |
note pp' |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2592 |
also from afac p'elem |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2593 |
have "p' divides a" by (rule factors_dividesI) fact+ |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2594 |
finally |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2595 |
have "p divides a" by simp |
27701 | 2596 |
} |
2597 |
moreover |
|
2598 |
{ |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2599 |
assume p'elem: "p' \<in> set bs" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2600 |
with bscarr have [simp]: "p' \<in> carrier G" by fast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2601 |
|
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2602 |
note pp' |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2603 |
also from bfac |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2604 |
have "p' divides b" by (rule factors_dividesI) fact+ |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2605 |
finally have "p divides b" by simp |
27701 | 2606 |
} |
2607 |
ultimately |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2608 |
show "p divides a \<or> p divides b" by fast |
27701 | 2609 |
qed |
2610 |
qed |
|
2611 |
qed |
|
2612 |
||
2613 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
2614 |
subsection {* Greatest Common Divisors and Lowest Common Multiples *} |
27701 | 2615 |
|
2616 |
subsubsection {* Definitions *} |
|
2617 |
||
2618 |
constdefs (structure G) |
|
2619 |
isgcd :: "[('a,_) monoid_scheme, 'a, 'a, 'a] \<Rightarrow> bool" ("(_ gcdof\<index> _ _)" [81,81,81] 80) |
|
2620 |
"x gcdof a b \<equiv> x divides a \<and> x divides b \<and> |
|
2621 |
(\<forall>y\<in>carrier G. (y divides a \<and> y divides b \<longrightarrow> y divides x))" |
|
2622 |
||
2623 |
islcm :: "[_, 'a, 'a, 'a] \<Rightarrow> bool" ("(_ lcmof\<index> _ _)" [81,81,81] 80) |
|
2624 |
"x lcmof a b \<equiv> a divides x \<and> b divides x \<and> |
|
2625 |
(\<forall>y\<in>carrier G. (a divides y \<and> b divides y \<longrightarrow> x divides y))" |
|
2626 |
||
2627 |
constdefs (structure G) |
|
2628 |
somegcd :: "('a,_) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" |
|
2629 |
"somegcd G a b == SOME x. x \<in> carrier G \<and> x gcdof a b" |
|
2630 |
||
2631 |
somelcm :: "('a,_) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" |
|
2632 |
"somelcm G a b == SOME x. x \<in> carrier G \<and> x lcmof a b" |
|
2633 |
||
2634 |
constdefs (structure G) |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2635 |
"SomeGcd G A == inf (division_rel G) A" |
27701 | 2636 |
|
2637 |
||
2638 |
locale gcd_condition_monoid = comm_monoid_cancel + |
|
2639 |
assumes gcdof_exists: |
|
2640 |
"\<lbrakk>a \<in> carrier G; b \<in> carrier G\<rbrakk> \<Longrightarrow> \<exists>c. c \<in> carrier G \<and> c gcdof a b" |
|
2641 |
||
2642 |
locale primeness_condition_monoid = comm_monoid_cancel + |
|
2643 |
assumes irreducible_prime: |
|
2644 |
"\<lbrakk>a \<in> carrier G; irreducible G a\<rbrakk> \<Longrightarrow> prime G a" |
|
2645 |
||
2646 |
locale divisor_chain_condition_monoid = comm_monoid_cancel + |
|
2647 |
assumes division_wellfounded: |
|
2648 |
"wf {(x, y). x \<in> carrier G \<and> y \<in> carrier G \<and> properfactor G x y}" |
|
2649 |
||
2650 |
||
2651 |
subsubsection {* Connections to \texttt{Lattice.thy} *} |
|
2652 |
||
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2653 |
lemma gcdof_greatestLower: |
27701 | 2654 |
fixes G (structure) |
2655 |
assumes carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
2656 |
shows "(x \<in> carrier G \<and> x gcdof a b) = |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2657 |
greatest (division_rel G) x (Lower (division_rel G) {a, b})" |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2658 |
unfolding isgcd_def greatest_def Lower_def elem_def |
32456
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
nipkow
parents:
29237
diff
changeset
|
2659 |
by auto |
27701 | 2660 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2661 |
lemma lcmof_leastUpper: |
27701 | 2662 |
fixes G (structure) |
2663 |
assumes carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
2664 |
shows "(x \<in> carrier G \<and> x lcmof a b) = |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2665 |
least (division_rel G) x (Upper (division_rel G) {a, b})" |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2666 |
unfolding islcm_def least_def Upper_def elem_def |
32456
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
nipkow
parents:
29237
diff
changeset
|
2667 |
by auto |
27701 | 2668 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2669 |
lemma somegcd_meet: |
27701 | 2670 |
fixes G (structure) |
2671 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2672 |
shows "somegcd G a b = meet (division_rel G) a b" |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2673 |
unfolding somegcd_def meet_def inf_def |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2674 |
by (simp add: gcdof_greatestLower[OF carr]) |
27701 | 2675 |
|
2676 |
lemma (in monoid) isgcd_divides_l: |
|
2677 |
assumes "a divides b" |
|
2678 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
2679 |
shows "a gcdof a b" |
|
2680 |
using assms |
|
2681 |
unfolding isgcd_def |
|
2682 |
by fast |
|
2683 |
||
2684 |
lemma (in monoid) isgcd_divides_r: |
|
2685 |
assumes "b divides a" |
|
2686 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
2687 |
shows "b gcdof a b" |
|
2688 |
using assms |
|
2689 |
unfolding isgcd_def |
|
2690 |
by fast |
|
2691 |
||
2692 |
||
2693 |
subsubsection {* Existence of gcd and lcm *} |
|
2694 |
||
2695 |
lemma (in factorial_monoid) gcdof_exists: |
|
2696 |
assumes acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
2697 |
shows "\<exists>c. c \<in> carrier G \<and> c gcdof a b" |
|
2698 |
proof - |
|
2699 |
from acarr have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" by (rule wfactors_exist) |
|
2700 |
from this obtain as |
|
2701 |
where ascarr: "set as \<subseteq> carrier G" |
|
2702 |
and afs: "wfactors G as a" |
|
2703 |
by auto |
|
2704 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" by (fast elim: wfactorsE) |
|
2705 |
||
2706 |
from bcarr have "\<exists>bs. set bs \<subseteq> carrier G \<and> wfactors G bs b" by (rule wfactors_exist) |
|
2707 |
from this obtain bs |
|
2708 |
where bscarr: "set bs \<subseteq> carrier G" |
|
2709 |
and bfs: "wfactors G bs b" |
|
2710 |
by auto |
|
2711 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" by (fast elim: wfactorsE) |
|
2712 |
||
2713 |
have "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> |
|
2714 |
fmset G cs = fmset G as #\<inter> fmset G bs" |
|
2715 |
proof (intro mset_wfactorsEx) |
|
2716 |
fix X |
|
2717 |
assume "X \<in> set_of (fmset G as #\<inter> fmset G bs)" |
|
2718 |
hence "X \<in> set_of (fmset G as)" by (simp add: multiset_inter_def) |
|
2719 |
hence "X \<in> set (map (assocs G) as)" by (simp add: fmset_def) |
|
2720 |
hence "\<exists>x. X = assocs G x \<and> x \<in> set as" by (induct as) auto |
|
2721 |
from this obtain x |
|
2722 |
where X: "X = assocs G x" |
|
2723 |
and xas: "x \<in> set as" |
|
2724 |
by auto |
|
2725 |
with ascarr have xcarr: "x \<in> carrier G" by fast |
|
2726 |
from xas airr have xirr: "irreducible G x" by simp |
|
2727 |
||
2728 |
from xcarr and xirr and X |
|
2729 |
show "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" by fast |
|
2730 |
qed |
|
2731 |
||
2732 |
from this obtain c cs |
|
2733 |
where ccarr: "c \<in> carrier G" |
|
2734 |
and cscarr: "set cs \<subseteq> carrier G" |
|
2735 |
and csirr: "wfactors G cs c" |
|
2736 |
and csmset: "fmset G cs = fmset G as #\<inter> fmset G bs" by auto |
|
2737 |
||
2738 |
have "c gcdof a b" |
|
2739 |
proof (simp add: isgcd_def, safe) |
|
2740 |
from csmset |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2741 |
have "fmset G cs \<le> fmset G as" |
27701 | 2742 |
by (simp add: multiset_inter_def mset_le_def) |
2743 |
thus "c divides a" by (rule fmsubset_divides) fact+ |
|
2744 |
next |
|
2745 |
from csmset |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2746 |
have "fmset G cs \<le> fmset G bs" |
27701 | 2747 |
by (simp add: multiset_inter_def mset_le_def, force) |
2748 |
thus "c divides b" by (rule fmsubset_divides) fact+ |
|
2749 |
next |
|
2750 |
fix y |
|
2751 |
assume ycarr: "y \<in> carrier G" |
|
2752 |
hence "\<exists>ys. set ys \<subseteq> carrier G \<and> wfactors G ys y" by (rule wfactors_exist) |
|
2753 |
from this obtain ys |
|
2754 |
where yscarr: "set ys \<subseteq> carrier G" |
|
2755 |
and yfs: "wfactors G ys y" |
|
2756 |
by auto |
|
2757 |
||
2758 |
assume "y divides a" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2759 |
hence ya: "fmset G ys \<le> fmset G as" by (rule divides_fmsubset) fact+ |
27701 | 2760 |
|
2761 |
assume "y divides b" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2762 |
hence yb: "fmset G ys \<le> fmset G bs" by (rule divides_fmsubset) fact+ |
27701 | 2763 |
|
2764 |
from ya yb csmset |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2765 |
have "fmset G ys \<le> fmset G cs" by (simp add: mset_le_def multiset_inter_count) |
27701 | 2766 |
thus "y divides c" by (rule fmsubset_divides) fact+ |
2767 |
qed |
|
2768 |
||
2769 |
with ccarr |
|
2770 |
show "\<exists>c. c \<in> carrier G \<and> c gcdof a b" by fast |
|
2771 |
qed |
|
2772 |
||
2773 |
lemma (in factorial_monoid) lcmof_exists: |
|
2774 |
assumes acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
2775 |
shows "\<exists>c. c \<in> carrier G \<and> c lcmof a b" |
|
2776 |
proof - |
|
2777 |
from acarr have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" by (rule wfactors_exist) |
|
2778 |
from this obtain as |
|
2779 |
where ascarr: "set as \<subseteq> carrier G" |
|
2780 |
and afs: "wfactors G as a" |
|
2781 |
by auto |
|
2782 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" by (fast elim: wfactorsE) |
|
2783 |
||
2784 |
from bcarr have "\<exists>bs. set bs \<subseteq> carrier G \<and> wfactors G bs b" by (rule wfactors_exist) |
|
2785 |
from this obtain bs |
|
2786 |
where bscarr: "set bs \<subseteq> carrier G" |
|
2787 |
and bfs: "wfactors G bs b" |
|
2788 |
by auto |
|
2789 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" by (fast elim: wfactorsE) |
|
2790 |
||
2791 |
have "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> |
|
2792 |
fmset G cs = (fmset G as - fmset G bs) + fmset G bs" |
|
2793 |
proof (intro mset_wfactorsEx) |
|
2794 |
fix X |
|
2795 |
assume "X \<in> set_of ((fmset G as - fmset G bs) + fmset G bs)" |
|
2796 |
hence "X \<in> set_of (fmset G as) \<or> X \<in> set_of (fmset G bs)" |
|
2797 |
by (cases "X :# fmset G bs", simp, simp) |
|
2798 |
moreover |
|
2799 |
{ |
|
2800 |
assume "X \<in> set_of (fmset G as)" |
|
2801 |
hence "X \<in> set (map (assocs G) as)" by (simp add: fmset_def) |
|
2802 |
hence "\<exists>x. x \<in> set as \<and> X = assocs G x" by (induct as) auto |
|
2803 |
from this obtain x |
|
2804 |
where xas: "x \<in> set as" |
|
2805 |
and X: "X = assocs G x" by auto |
|
2806 |
||
2807 |
with ascarr have xcarr: "x \<in> carrier G" by fast |
|
2808 |
from xas airr have xirr: "irreducible G x" by simp |
|
2809 |
||
2810 |
from xcarr and xirr and X |
|
2811 |
have "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" by fast |
|
2812 |
} |
|
2813 |
moreover |
|
2814 |
{ |
|
2815 |
assume "X \<in> set_of (fmset G bs)" |
|
2816 |
hence "X \<in> set (map (assocs G) bs)" by (simp add: fmset_def) |
|
2817 |
hence "\<exists>x. x \<in> set bs \<and> X = assocs G x" by (induct as) auto |
|
2818 |
from this obtain x |
|
2819 |
where xbs: "x \<in> set bs" |
|
2820 |
and X: "X = assocs G x" by auto |
|
2821 |
||
2822 |
with bscarr have xcarr: "x \<in> carrier G" by fast |
|
2823 |
from xbs birr have xirr: "irreducible G x" by simp |
|
2824 |
||
2825 |
from xcarr and xirr and X |
|
2826 |
have "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" by fast |
|
2827 |
} |
|
2828 |
ultimately |
|
2829 |
show "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" by fast |
|
2830 |
qed |
|
2831 |
||
2832 |
from this obtain c cs |
|
2833 |
where ccarr: "c \<in> carrier G" |
|
2834 |
and cscarr: "set cs \<subseteq> carrier G" |
|
2835 |
and csirr: "wfactors G cs c" |
|
2836 |
and csmset: "fmset G cs = fmset G as - fmset G bs + fmset G bs" by auto |
|
2837 |
||
2838 |
have "c lcmof a b" |
|
2839 |
proof (simp add: islcm_def, safe) |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2840 |
from csmset have "fmset G as \<le> fmset G cs" by (simp add: mset_le_def, force) |
27701 | 2841 |
thus "a divides c" by (rule fmsubset_divides) fact+ |
2842 |
next |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2843 |
from csmset have "fmset G bs \<le> fmset G cs" by (simp add: mset_le_def) |
27701 | 2844 |
thus "b divides c" by (rule fmsubset_divides) fact+ |
2845 |
next |
|
2846 |
fix y |
|
2847 |
assume ycarr: "y \<in> carrier G" |
|
2848 |
hence "\<exists>ys. set ys \<subseteq> carrier G \<and> wfactors G ys y" by (rule wfactors_exist) |
|
2849 |
from this obtain ys |
|
2850 |
where yscarr: "set ys \<subseteq> carrier G" |
|
2851 |
and yfs: "wfactors G ys y" |
|
2852 |
by auto |
|
2853 |
||
2854 |
assume "a divides y" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2855 |
hence ya: "fmset G as \<le> fmset G ys" by (rule divides_fmsubset) fact+ |
27701 | 2856 |
|
2857 |
assume "b divides y" |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2858 |
hence yb: "fmset G bs \<le> fmset G ys" by (rule divides_fmsubset) fact+ |
27701 | 2859 |
|
2860 |
from ya yb csmset |
|
35272
c283ae736bea
switched notations for pointwise and multiset order
haftmann
parents:
32960
diff
changeset
|
2861 |
have "fmset G cs \<le> fmset G ys" |
27701 | 2862 |
apply (simp add: mset_le_def, clarify) |
2863 |
apply (case_tac "count (fmset G as) a < count (fmset G bs) a") |
|
2864 |
apply simp |
|
2865 |
apply simp |
|
2866 |
done |
|
2867 |
thus "c divides y" by (rule fmsubset_divides) fact+ |
|
2868 |
qed |
|
2869 |
||
2870 |
with ccarr |
|
2871 |
show "\<exists>c. c \<in> carrier G \<and> c lcmof a b" by fast |
|
2872 |
qed |
|
2873 |
||
2874 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
2875 |
subsection {* Conditions for Factoriality *} |
27701 | 2876 |
|
2877 |
subsubsection {* Gcd condition *} |
|
2878 |
||
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2879 |
lemma (in gcd_condition_monoid) division_weak_lower_semilattice [simp]: |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2880 |
shows "weak_lower_semilattice (division_rel G)" |
27701 | 2881 |
proof - |
29237 | 2882 |
interpret weak_partial_order "division_rel G" .. |
27701 | 2883 |
show ?thesis |
2884 |
apply (unfold_locales, simp_all) |
|
2885 |
proof - |
|
2886 |
fix x y |
|
2887 |
assume carr: "x \<in> carrier G" "y \<in> carrier G" |
|
2888 |
hence "\<exists>z. z \<in> carrier G \<and> z gcdof x y" by (rule gcdof_exists) |
|
2889 |
from this obtain z |
|
2890 |
where zcarr: "z \<in> carrier G" |
|
2891 |
and isgcd: "z gcdof x y" |
|
2892 |
by auto |
|
2893 |
with carr |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2894 |
have "greatest (division_rel G) z (Lower (division_rel G) {x, y})" |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2895 |
by (subst gcdof_greatestLower[symmetric], simp+) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2896 |
thus "\<exists>z. greatest (division_rel G) z (Lower (division_rel G) {x, y})" by fast |
27701 | 2897 |
qed |
2898 |
qed |
|
2899 |
||
2900 |
lemma (in gcd_condition_monoid) gcdof_cong_l: |
|
2901 |
assumes a'a: "a' \<sim> a" |
|
2902 |
and agcd: "a gcdof b c" |
|
2903 |
and a'carr: "a' \<in> carrier G" and carr': "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
2904 |
shows "a' gcdof b c" |
|
2905 |
proof - |
|
2906 |
note carr = a'carr carr' |
|
29237 | 2907 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2908 |
have "a' \<in> carrier G \<and> a' gcdof b c" |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2909 |
apply (simp add: gcdof_greatestLower carr') |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2910 |
apply (subst greatest_Lower_cong_l[of _ a]) |
27701 | 2911 |
apply (simp add: a'a) |
2912 |
apply (simp add: carr) |
|
2913 |
apply (simp add: carr) |
|
2914 |
apply (simp add: carr) |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2915 |
apply (simp add: gcdof_greatestLower[symmetric] agcd carr) |
27701 | 2916 |
done |
2917 |
thus ?thesis .. |
|
2918 |
qed |
|
2919 |
||
2920 |
lemma (in gcd_condition_monoid) gcd_closed [simp]: |
|
2921 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2922 |
shows "somegcd G a b \<in> carrier G" |
|
2923 |
proof - |
|
29237 | 2924 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2925 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2926 |
apply (simp add: somegcd_meet[OF carr]) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2927 |
apply (rule meet_closed[simplified], fact+) |
27701 | 2928 |
done |
2929 |
qed |
|
2930 |
||
2931 |
lemma (in gcd_condition_monoid) gcd_isgcd: |
|
2932 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2933 |
shows "(somegcd G a b) gcdof a b" |
|
2934 |
proof - |
|
29237 | 2935 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2936 |
from carr |
2937 |
have "somegcd G a b \<in> carrier G \<and> (somegcd G a b) gcdof a b" |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2938 |
apply (subst gcdof_greatestLower, simp, simp) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2939 |
apply (simp add: somegcd_meet[OF carr] meet_def) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2940 |
apply (rule inf_of_two_greatest[simplified], assumption+) |
27701 | 2941 |
done |
2942 |
thus "(somegcd G a b) gcdof a b" by simp |
|
2943 |
qed |
|
2944 |
||
2945 |
lemma (in gcd_condition_monoid) gcd_exists: |
|
2946 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2947 |
shows "\<exists>x\<in>carrier G. x = somegcd G a b" |
|
2948 |
proof - |
|
29237 | 2949 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2950 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2951 |
apply (simp add: somegcd_meet[OF carr]) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2952 |
apply (rule meet_closed[simplified], fact+) |
27701 | 2953 |
done |
2954 |
qed |
|
2955 |
||
2956 |
lemma (in gcd_condition_monoid) gcd_divides_l: |
|
2957 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2958 |
shows "(somegcd G a b) divides a" |
|
2959 |
proof - |
|
29237 | 2960 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2961 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2962 |
apply (simp add: somegcd_meet[OF carr]) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2963 |
apply (rule meet_left[simplified], fact+) |
27701 | 2964 |
done |
2965 |
qed |
|
2966 |
||
2967 |
lemma (in gcd_condition_monoid) gcd_divides_r: |
|
2968 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2969 |
shows "(somegcd G a b) divides b" |
|
2970 |
proof - |
|
29237 | 2971 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2972 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2973 |
apply (simp add: somegcd_meet[OF carr]) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2974 |
apply (rule meet_right[simplified], fact+) |
27701 | 2975 |
done |
2976 |
qed |
|
2977 |
||
2978 |
lemma (in gcd_condition_monoid) gcd_divides: |
|
2979 |
assumes sub: "z divides x" "z divides y" |
|
2980 |
and L: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G" |
|
2981 |
shows "z divides (somegcd G x y)" |
|
2982 |
proof - |
|
29237 | 2983 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2984 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2985 |
apply (simp add: somegcd_meet L) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2986 |
apply (rule meet_le[simplified], fact+) |
27701 | 2987 |
done |
2988 |
qed |
|
2989 |
||
2990 |
lemma (in gcd_condition_monoid) gcd_cong_l: |
|
2991 |
assumes xx': "x \<sim> x'" |
|
2992 |
and carr: "x \<in> carrier G" "x' \<in> carrier G" "y \<in> carrier G" |
|
2993 |
shows "somegcd G x y \<sim> somegcd G x' y" |
|
2994 |
proof - |
|
29237 | 2995 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2996 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2997 |
apply (simp add: somegcd_meet carr) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2998 |
apply (rule meet_cong_l[simplified], fact+) |
27701 | 2999 |
done |
3000 |
qed |
|
3001 |
||
3002 |
lemma (in gcd_condition_monoid) gcd_cong_r: |
|
3003 |
assumes carr: "x \<in> carrier G" "y \<in> carrier G" "y' \<in> carrier G" |
|
3004 |
and yy': "y \<sim> y'" |
|
3005 |
shows "somegcd G x y \<sim> somegcd G x y'" |
|
3006 |
proof - |
|
29237 | 3007 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 3008 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3009 |
apply (simp add: somegcd_meet carr) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3010 |
apply (rule meet_cong_r[simplified], fact+) |
27701 | 3011 |
done |
3012 |
qed |
|
3013 |
||
3014 |
(* |
|
3015 |
lemma (in gcd_condition_monoid) asc_cong_gcd_l [intro]: |
|
3016 |
assumes carr: "b \<in> carrier G" |
|
3017 |
shows "asc_cong (\<lambda>a. somegcd G a b)" |
|
3018 |
using carr |
|
3019 |
unfolding CONG_def |
|
3020 |
by clarsimp (blast intro: gcd_cong_l) |
|
3021 |
||
3022 |
lemma (in gcd_condition_monoid) asc_cong_gcd_r [intro]: |
|
3023 |
assumes carr: "a \<in> carrier G" |
|
3024 |
shows "asc_cong (\<lambda>b. somegcd G a b)" |
|
3025 |
using carr |
|
3026 |
unfolding CONG_def |
|
3027 |
by clarsimp (blast intro: gcd_cong_r) |
|
3028 |
||
3029 |
lemmas (in gcd_condition_monoid) asc_cong_gcd_split [simp] = |
|
3030 |
assoc_split[OF _ asc_cong_gcd_l] assoc_split[OF _ asc_cong_gcd_r] |
|
3031 |
*) |
|
3032 |
||
3033 |
lemma (in gcd_condition_monoid) gcdI: |
|
3034 |
assumes dvd: "a divides b" "a divides c" |
|
3035 |
and others: "\<forall>y\<in>carrier G. y divides b \<and> y divides c \<longrightarrow> y divides a" |
|
3036 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" and ccarr: "c \<in> carrier G" |
|
3037 |
shows "a \<sim> somegcd G b c" |
|
3038 |
apply (simp add: somegcd_def) |
|
3039 |
apply (rule someI2_ex) |
|
3040 |
apply (rule exI[of _ a], simp add: isgcd_def) |
|
3041 |
apply (simp add: assms) |
|
3042 |
apply (simp add: isgcd_def assms, clarify) |
|
3043 |
apply (insert assms, blast intro: associatedI) |
|
3044 |
done |
|
3045 |
||
3046 |
lemma (in gcd_condition_monoid) gcdI2: |
|
3047 |
assumes "a gcdof b c" |
|
3048 |
and "a \<in> carrier G" and bcarr: "b \<in> carrier G" and ccarr: "c \<in> carrier G" |
|
3049 |
shows "a \<sim> somegcd G b c" |
|
3050 |
using assms |
|
3051 |
unfolding isgcd_def |
|
3052 |
by (blast intro: gcdI) |
|
3053 |
||
3054 |
lemma (in gcd_condition_monoid) SomeGcd_ex: |
|
3055 |
assumes "finite A" "A \<subseteq> carrier G" "A \<noteq> {}" |
|
3056 |
shows "\<exists>x\<in> carrier G. x = SomeGcd G A" |
|
3057 |
proof - |
|
29237 | 3058 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 3059 |
show ?thesis |
3060 |
apply (simp add: SomeGcd_def) |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3061 |
apply (rule finite_inf_closed[simplified], fact+) |
27701 | 3062 |
done |
3063 |
qed |
|
3064 |
||
3065 |
lemma (in gcd_condition_monoid) gcd_assoc: |
|
3066 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
3067 |
shows "somegcd G (somegcd G a b) c \<sim> somegcd G a (somegcd G b c)" |
|
3068 |
proof - |
|
29237 | 3069 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 3070 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3071 |
apply (subst (2 3) somegcd_meet, (simp add: carr)+) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3072 |
apply (simp add: somegcd_meet carr) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3073 |
apply (rule weak_meet_assoc[simplified], fact+) |
27701 | 3074 |
done |
3075 |
qed |
|
3076 |
||
3077 |
lemma (in gcd_condition_monoid) gcd_mult: |
|
3078 |
assumes acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" and ccarr: "c \<in> carrier G" |
|
3079 |
shows "c \<otimes> somegcd G a b \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
3080 |
proof - (* following Jacobson, Basic Algebra, p.140 *) |
|
3081 |
let ?d = "somegcd G a b" |
|
3082 |
let ?e = "somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
3083 |
note carr[simp] = acarr bcarr ccarr |
|
3084 |
have dcarr: "?d \<in> carrier G" by simp |
|
3085 |
have ecarr: "?e \<in> carrier G" by simp |
|
3086 |
note carr = carr dcarr ecarr |
|
3087 |
||
3088 |
have "?d divides a" by (simp add: gcd_divides_l) |
|
3089 |
hence cd'ca: "c \<otimes> ?d divides (c \<otimes> a)" by (simp add: divides_mult_lI) |
|
3090 |
||
3091 |
have "?d divides b" by (simp add: gcd_divides_r) |
|
3092 |
hence cd'cb: "c \<otimes> ?d divides (c \<otimes> b)" by (simp add: divides_mult_lI) |
|
3093 |
||
3094 |
from cd'ca cd'cb |
|
3095 |
have cd'e: "c \<otimes> ?d divides ?e" |
|
3096 |
by (rule gcd_divides) simp+ |
|
3097 |
||
3098 |
hence "\<exists>u. u \<in> carrier G \<and> ?e = c \<otimes> ?d \<otimes> u" |
|
3099 |
by (elim dividesE, fast) |
|
3100 |
from this obtain u |
|
3101 |
where ucarr[simp]: "u \<in> carrier G" |
|
3102 |
and e_cdu: "?e = c \<otimes> ?d \<otimes> u" |
|
3103 |
by auto |
|
3104 |
||
3105 |
note carr = carr ucarr |
|
3106 |
||
3107 |
have "?e divides c \<otimes> a" by (rule gcd_divides_l) simp+ |
|
3108 |
hence "\<exists>x. x \<in> carrier G \<and> c \<otimes> a = ?e \<otimes> x" |
|
3109 |
by (elim dividesE, fast) |
|
3110 |
from this obtain x |
|
3111 |
where xcarr: "x \<in> carrier G" |
|
3112 |
and ca_ex: "c \<otimes> a = ?e \<otimes> x" |
|
3113 |
by auto |
|
3114 |
with e_cdu |
|
3115 |
have ca_cdux: "c \<otimes> a = c \<otimes> ?d \<otimes> u \<otimes> x" by simp |
|
3116 |
||
3117 |
from ca_cdux xcarr |
|
3118 |
have "c \<otimes> a = c \<otimes> (?d \<otimes> u \<otimes> x)" by (simp add: m_assoc) |
|
3119 |
then have "a = ?d \<otimes> u \<otimes> x" by (rule l_cancel[of c a]) (simp add: xcarr)+ |
|
3120 |
hence du'a: "?d \<otimes> u divides a" by (rule dividesI[OF xcarr]) |
|
3121 |
||
3122 |
have "?e divides c \<otimes> b" by (intro gcd_divides_r, simp+) |
|
3123 |
hence "\<exists>x. x \<in> carrier G \<and> c \<otimes> b = ?e \<otimes> x" |
|
3124 |
by (elim dividesE, fast) |
|
3125 |
from this obtain x |
|
3126 |
where xcarr: "x \<in> carrier G" |
|
3127 |
and cb_ex: "c \<otimes> b = ?e \<otimes> x" |
|
3128 |
by auto |
|
3129 |
with e_cdu |
|
3130 |
have cb_cdux: "c \<otimes> b = c \<otimes> ?d \<otimes> u \<otimes> x" by simp |
|
3131 |
||
3132 |
from cb_cdux xcarr |
|
3133 |
have "c \<otimes> b = c \<otimes> (?d \<otimes> u \<otimes> x)" by (simp add: m_assoc) |
|
3134 |
with xcarr |
|
3135 |
have "b = ?d \<otimes> u \<otimes> x" by (intro l_cancel[of c b], simp+) |
|
3136 |
hence du'b: "?d \<otimes> u divides b" by (intro dividesI[OF xcarr]) |
|
3137 |
||
3138 |
from du'a du'b carr |
|
3139 |
have du'd: "?d \<otimes> u divides ?d" |
|
3140 |
by (intro gcd_divides, simp+) |
|
3141 |
hence uunit: "u \<in> Units G" |
|
3142 |
proof (elim dividesE) |
|
3143 |
fix v |
|
3144 |
assume vcarr[simp]: "v \<in> carrier G" |
|
3145 |
assume d: "?d = ?d \<otimes> u \<otimes> v" |
|
3146 |
have "?d \<otimes> \<one> = ?d \<otimes> u \<otimes> v" by simp fact |
|
3147 |
also have "?d \<otimes> u \<otimes> v = ?d \<otimes> (u \<otimes> v)" by (simp add: m_assoc) |
|
3148 |
finally have "?d \<otimes> \<one> = ?d \<otimes> (u \<otimes> v)" . |
|
3149 |
hence i2: "\<one> = u \<otimes> v" by (rule l_cancel) simp+ |
|
3150 |
hence i1: "\<one> = v \<otimes> u" by (simp add: m_comm) |
|
3151 |
from vcarr i1[symmetric] i2[symmetric] |
|
3152 |
show "u \<in> Units G" |
|
3153 |
by (unfold Units_def, simp, fast) |
|
3154 |
qed |
|
3155 |
||
3156 |
from e_cdu uunit |
|
3157 |
have "somegcd G (c \<otimes> a) (c \<otimes> b) \<sim> c \<otimes> somegcd G a b" |
|
3158 |
by (intro associatedI2[of u], simp+) |
|
3159 |
from this[symmetric] |
|
3160 |
show "c \<otimes> somegcd G a b \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" by simp |
|
3161 |
qed |
|
3162 |
||
3163 |
lemma (in monoid) assoc_subst: |
|
3164 |
assumes ab: "a \<sim> b" |
|
3165 |
and cP: "ALL a b. a : carrier G & b : carrier G & a \<sim> b |
|
3166 |
--> f a : carrier G & f b : carrier G & f a \<sim> f b" |
|
3167 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
|
3168 |
shows "f a \<sim> f b" |
|
3169 |
using assms by auto |
|
3170 |
||
3171 |
lemma (in gcd_condition_monoid) relprime_mult: |
|
3172 |
assumes abrelprime: "somegcd G a b \<sim> \<one>" and acrelprime: "somegcd G a c \<sim> \<one>" |
|
3173 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
3174 |
shows "somegcd G a (b \<otimes> c) \<sim> \<one>" |
|
3175 |
proof - |
|
3176 |
have "c = c \<otimes> \<one>" by simp |
|
3177 |
also from abrelprime[symmetric] |
|
3178 |
have "\<dots> \<sim> c \<otimes> somegcd G a b" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3179 |
by (rule assoc_subst) (simp add: mult_cong_r)+ |
27701 | 3180 |
also have "\<dots> \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" by (rule gcd_mult) fact+ |
3181 |
finally |
|
3182 |
have c: "c \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" by simp |
|
3183 |
||
3184 |
from carr |
|
3185 |
have a: "a \<sim> somegcd G a (c \<otimes> a)" |
|
3186 |
by (fast intro: gcdI divides_prod_l) |
|
3187 |
||
3188 |
have "somegcd G a (b \<otimes> c) \<sim> somegcd G a (c \<otimes> b)" by (simp add: m_comm) |
|
3189 |
also from a |
|
3190 |
have "\<dots> \<sim> somegcd G (somegcd G a (c \<otimes> a)) (c \<otimes> b)" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3191 |
by (rule assoc_subst) (simp add: gcd_cong_l)+ |
27701 | 3192 |
also from gcd_assoc |
3193 |
have "\<dots> \<sim> somegcd G a (somegcd G (c \<otimes> a) (c \<otimes> b))" |
|
3194 |
by (rule assoc_subst) simp+ |
|
3195 |
also from c[symmetric] |
|
3196 |
have "\<dots> \<sim> somegcd G a c" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3197 |
by (rule assoc_subst) (simp add: gcd_cong_r)+ |
27701 | 3198 |
also note acrelprime |
3199 |
finally |
|
3200 |
show "somegcd G a (b \<otimes> c) \<sim> \<one>" by simp |
|
3201 |
qed |
|
3202 |
||
3203 |
lemma (in gcd_condition_monoid) primeness_condition: |
|
3204 |
"primeness_condition_monoid G" |
|
3205 |
apply unfold_locales |
|
3206 |
apply (rule primeI) |
|
3207 |
apply (elim irreducibleE, assumption) |
|
3208 |
proof - |
|
3209 |
fix p a b |
|
3210 |
assume pcarr: "p \<in> carrier G" and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
3211 |
and pirr: "irreducible G p" |
|
3212 |
and pdvdab: "p divides a \<otimes> b" |
|
3213 |
from pirr |
|
3214 |
have pnunit: "p \<notin> Units G" |
|
3215 |
and r[rule_format]: "\<forall>b. b \<in> carrier G \<and> properfactor G b p \<longrightarrow> b \<in> Units G" |
|
3216 |
by - (fast elim: irreducibleE)+ |
|
3217 |
||
3218 |
show "p divides a \<or> p divides b" |
|
3219 |
proof (rule ccontr, clarsimp) |
|
3220 |
assume npdvda: "\<not> p divides a" |
|
3221 |
with pcarr acarr |
|
3222 |
have "\<one> \<sim> somegcd G p a" |
|
3223 |
apply (intro gcdI, simp, simp, simp) |
|
3224 |
apply (fast intro: unit_divides) |
|
3225 |
apply (fast intro: unit_divides) |
|
3226 |
apply (clarsimp simp add: Unit_eq_dividesone[symmetric]) |
|
3227 |
apply (rule r, rule, assumption) |
|
3228 |
apply (rule properfactorI, assumption) |
|
3229 |
proof (rule ccontr, simp) |
|
3230 |
fix y |
|
3231 |
assume ycarr: "y \<in> carrier G" |
|
3232 |
assume "p divides y" |
|
3233 |
also assume "y divides a" |
|
3234 |
finally |
|
3235 |
have "p divides a" by (simp add: pcarr ycarr acarr) |
|
3236 |
with npdvda |
|
3237 |
show "False" .. |
|
3238 |
qed simp+ |
|
3239 |
with pcarr acarr |
|
3240 |
have pa: "somegcd G p a \<sim> \<one>" by (fast intro: associated_sym[of "\<one>"] gcd_closed) |
|
3241 |
||
3242 |
assume npdvdb: "\<not> p divides b" |
|
3243 |
with pcarr bcarr |
|
3244 |
have "\<one> \<sim> somegcd G p b" |
|
3245 |
apply (intro gcdI, simp, simp, simp) |
|
3246 |
apply (fast intro: unit_divides) |
|
3247 |
apply (fast intro: unit_divides) |
|
3248 |
apply (clarsimp simp add: Unit_eq_dividesone[symmetric]) |
|
3249 |
apply (rule r, rule, assumption) |
|
3250 |
apply (rule properfactorI, assumption) |
|
3251 |
proof (rule ccontr, simp) |
|
3252 |
fix y |
|
3253 |
assume ycarr: "y \<in> carrier G" |
|
3254 |
assume "p divides y" |
|
3255 |
also assume "y divides b" |
|
3256 |
finally have "p divides b" by (simp add: pcarr ycarr bcarr) |
|
3257 |
with npdvdb |
|
3258 |
show "False" .. |
|
3259 |
qed simp+ |
|
3260 |
with pcarr bcarr |
|
3261 |
have pb: "somegcd G p b \<sim> \<one>" by (fast intro: associated_sym[of "\<one>"] gcd_closed) |
|
3262 |
||
3263 |
from pcarr acarr bcarr pdvdab |
|
3264 |
have "p gcdof p (a \<otimes> b)" by (fast intro: isgcd_divides_l) |
|
3265 |
||
3266 |
with pcarr acarr bcarr |
|
3267 |
have "p \<sim> somegcd G p (a \<otimes> b)" by (fast intro: gcdI2) |
|
3268 |
also from pa pb pcarr acarr bcarr |
|
3269 |
have "somegcd G p (a \<otimes> b) \<sim> \<one>" by (rule relprime_mult) |
|
3270 |
finally have "p \<sim> \<one>" by (simp add: pcarr acarr bcarr) |
|
3271 |
||
3272 |
with pcarr |
|
3273 |
have "p \<in> Units G" by (fast intro: assoc_unit_l) |
|
3274 |
with pnunit |
|
3275 |
show "False" .. |
|
3276 |
qed |
|
3277 |
qed |
|
3278 |
||
29237 | 3279 |
sublocale gcd_condition_monoid \<subseteq> primeness_condition_monoid |
27701 | 3280 |
by (rule primeness_condition) |
3281 |
||
3282 |
||
3283 |
subsubsection {* Divisor chain condition *} |
|
3284 |
||
3285 |
lemma (in divisor_chain_condition_monoid) wfactors_exist: |
|
3286 |
assumes acarr: "a \<in> carrier G" |
|
3287 |
shows "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" |
|
3288 |
proof - |
|
3289 |
have r[rule_format]: "a \<in> carrier G \<longrightarrow> (\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a)" |
|
3290 |
apply (rule wf_induct[OF division_wellfounded]) |
|
3291 |
proof - |
|
3292 |
fix x |
|
3293 |
assume ih: "\<forall>y. (y, x) \<in> {(x, y). x \<in> carrier G \<and> y \<in> carrier G \<and> properfactor G x y} |
|
3294 |
\<longrightarrow> y \<in> carrier G \<longrightarrow> (\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as y)" |
|
3295 |
||
3296 |
show "x \<in> carrier G \<longrightarrow> (\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as x)" |
|
3297 |
apply clarify |
|
3298 |
apply (cases "x \<in> Units G") |
|
3299 |
apply (rule exI[of _ "[]"], simp) |
|
3300 |
apply (cases "irreducible G x") |
|
3301 |
apply (rule exI[of _ "[x]"], simp add: wfactors_def) |
|
3302 |
proof - |
|
3303 |
assume xcarr: "x \<in> carrier G" |
|
3304 |
and xnunit: "x \<notin> Units G" |
|
3305 |
and xnirr: "\<not> irreducible G x" |
|
3306 |
hence "\<exists>y. y \<in> carrier G \<and> properfactor G y x \<and> y \<notin> Units G" |
|
3307 |
apply - apply (rule ccontr, simp) |
|
3308 |
apply (subgoal_tac "irreducible G x", simp) |
|
3309 |
apply (rule irreducibleI, simp, simp) |
|
3310 |
done |
|
3311 |
from this obtain y |
|
3312 |
where ycarr: "y \<in> carrier G" |
|
3313 |
and ynunit: "y \<notin> Units G" |
|
3314 |
and pfyx: "properfactor G y x" |
|
3315 |
by auto |
|
3316 |
||
3317 |
have ih': |
|
3318 |
"\<And>y. \<lbrakk>y \<in> carrier G; properfactor G y x\<rbrakk> |
|
3319 |
\<Longrightarrow> \<exists>as. set as \<subseteq> carrier G \<and> wfactors G as y" |
|
3320 |
by (rule ih[rule_format, simplified]) (simp add: xcarr)+ |
|
3321 |
||
3322 |
from ycarr pfyx |
|
3323 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as y" |
|
3324 |
by (rule ih') |
|
3325 |
from this obtain ys |
|
3326 |
where yscarr: "set ys \<subseteq> carrier G" |
|
3327 |
and yfs: "wfactors G ys y" |
|
3328 |
by auto |
|
3329 |
||
3330 |
from pfyx |
|
3331 |
have "y divides x" |
|
3332 |
and nyx: "\<not> y \<sim> x" |
|
3333 |
by - (fast elim: properfactorE2)+ |
|
3334 |
hence "\<exists>z. z \<in> carrier G \<and> x = y \<otimes> z" |
|
3335 |
by (fast elim: dividesE) |
|
3336 |
||
3337 |
from this obtain z |
|
3338 |
where zcarr: "z \<in> carrier G" |
|
3339 |
and x: "x = y \<otimes> z" |
|
3340 |
by auto |
|
3341 |
||
3342 |
from zcarr ycarr |
|
3343 |
have "properfactor G z x" |
|
3344 |
apply (subst x) |
|
3345 |
apply (intro properfactorI3[of _ _ y]) |
|
3346 |
apply (simp add: m_comm) |
|
3347 |
apply (simp add: ynunit)+ |
|
3348 |
done |
|
3349 |
with zcarr |
|
3350 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as z" |
|
3351 |
by (rule ih') |
|
3352 |
from this obtain zs |
|
3353 |
where zscarr: "set zs \<subseteq> carrier G" |
|
3354 |
and zfs: "wfactors G zs z" |
|
3355 |
by auto |
|
3356 |
||
3357 |
from yscarr zscarr |
|
3358 |
have xscarr: "set (ys@zs) \<subseteq> carrier G" by simp |
|
3359 |
from yfs zfs ycarr zcarr yscarr zscarr |
|
3360 |
have "wfactors G (ys@zs) (y\<otimes>z)" by (rule wfactors_mult) |
|
3361 |
hence "wfactors G (ys@zs) x" by (simp add: x) |
|
3362 |
||
3363 |
from xscarr this |
|
3364 |
show "\<exists>xs. set xs \<subseteq> carrier G \<and> wfactors G xs x" by fast |
|
3365 |
qed |
|
3366 |
qed |
|
3367 |
||
3368 |
from acarr |
|
3369 |
show ?thesis by (rule r) |
|
3370 |
qed |
|
3371 |
||
3372 |
||
3373 |
subsubsection {* Primeness condition *} |
|
3374 |
||
3375 |
lemma (in comm_monoid_cancel) multlist_prime_pos: |
|
3376 |
assumes carr: "a \<in> carrier G" "set as \<subseteq> carrier G" |
|
3377 |
and aprime: "prime G a" |
|
3378 |
and "a divides (foldr (op \<otimes>) as \<one>)" |
|
3379 |
shows "\<exists>i<length as. a divides (as!i)" |
|
3380 |
proof - |
|
3381 |
have r[rule_format]: |
|
3382 |
"set as \<subseteq> carrier G \<and> a divides (foldr (op \<otimes>) as \<one>) |
|
3383 |
\<longrightarrow> (\<exists>i. i < length as \<and> a divides (as!i))" |
|
3384 |
apply (induct as) |
|
3385 |
apply clarsimp defer 1 |
|
3386 |
apply clarsimp defer 1 |
|
3387 |
proof - |
|
3388 |
assume "a divides \<one>" |
|
3389 |
with carr |
|
3390 |
have "a \<in> Units G" |
|
3391 |
by (fast intro: divides_unit[of a \<one>]) |
|
3392 |
with aprime |
|
3393 |
show "False" by (elim primeE, simp) |
|
3394 |
next |
|
3395 |
fix aa as |
|
3396 |
assume ih[rule_format]: "a divides foldr op \<otimes> as \<one> \<longrightarrow> (\<exists>i<length as. a divides as ! i)" |
|
3397 |
and carr': "aa \<in> carrier G" "set as \<subseteq> carrier G" |
|
3398 |
and "a divides aa \<otimes> foldr op \<otimes> as \<one>" |
|
3399 |
with carr aprime |
|
3400 |
have "a divides aa \<or> a divides foldr op \<otimes> as \<one>" |
|
3401 |
by (intro prime_divides) simp+ |
|
3402 |
moreover { |
|
3403 |
assume "a divides aa" |
|
3404 |
hence p1: "a divides (aa#as)!0" by simp |
|
3405 |
have "0 < Suc (length as)" by simp |
|
3406 |
with p1 have "\<exists>i<Suc (length as). a divides (aa # as) ! i" by fast |
|
3407 |
} |
|
3408 |
moreover { |
|
3409 |
assume "a divides foldr op \<otimes> as \<one>" |
|
3410 |
hence "\<exists>i. i < length as \<and> a divides as ! i" by (rule ih) |
|
3411 |
from this obtain i where "a divides as ! i" and len: "i < length as" by auto |
|
3412 |
hence p1: "a divides (aa#as) ! (Suc i)" by simp |
|
3413 |
from len have "Suc i < Suc (length as)" by simp |
|
3414 |
with p1 have "\<exists>i<Suc (length as). a divides (aa # as) ! i" by force |
|
3415 |
} |
|
3416 |
ultimately |
|
3417 |
show "\<exists>i<Suc (length as). a divides (aa # as) ! i" by fast |
|
3418 |
qed |
|
3419 |
||
3420 |
from assms |
|
3421 |
show ?thesis |
|
3422 |
by (intro r, safe) |
|
3423 |
qed |
|
3424 |
||
3425 |
lemma (in primeness_condition_monoid) wfactors_unique__hlp_induct: |
|
3426 |
"\<forall>a as'. a \<in> carrier G \<and> set as \<subseteq> carrier G \<and> set as' \<subseteq> carrier G \<and> |
|
3427 |
wfactors G as a \<and> wfactors G as' a \<longrightarrow> essentially_equal G as as'" |
|
3428 |
apply (induct as) |
|
3429 |
apply clarsimp defer 1 |
|
3430 |
apply clarsimp defer 1 |
|
3431 |
proof - |
|
3432 |
fix a as' |
|
3433 |
assume acarr: "a \<in> carrier G" |
|
3434 |
and "wfactors G [] a" |
|
3435 |
hence aunit: "a \<in> Units G" |
|
3436 |
apply (elim wfactorsE) |
|
3437 |
apply (simp, rule assoc_unit_r[of "\<one>"], simp+) |
|
3438 |
done |
|
3439 |
||
3440 |
assume "set as' \<subseteq> carrier G" "wfactors G as' a" |
|
3441 |
with aunit |
|
3442 |
have "as' = []" |
|
3443 |
by (intro unit_wfactors_empty[of a]) |
|
3444 |
thus "essentially_equal G [] as'" by simp |
|
3445 |
next |
|
3446 |
fix a as ah as' |
|
3447 |
assume ih[rule_format]: |
|
3448 |
"\<forall>a as'. a \<in> carrier G \<and> set as' \<subseteq> carrier G \<and> |
|
3449 |
wfactors G as a \<and> wfactors G as' a \<longrightarrow> essentially_equal G as as'" |
|
3450 |
and acarr: "a \<in> carrier G" and ahcarr: "ah \<in> carrier G" |
|
3451 |
and ascarr: "set as \<subseteq> carrier G" and as'carr: "set as' \<subseteq> carrier G" |
|
3452 |
and afs: "wfactors G (ah # as) a" |
|
3453 |
and afs': "wfactors G as' a" |
|
3454 |
hence ahdvda: "ah divides a" |
|
3455 |
by (intro wfactors_dividesI[of "ah#as" "a"], simp+) |
|
3456 |
hence "\<exists>a'\<in> carrier G. a = ah \<otimes> a'" by (fast elim: dividesE) |
|
3457 |
from this obtain a' |
|
3458 |
where a'carr: "a' \<in> carrier G" |
|
3459 |
and a: "a = ah \<otimes> a'" |
|
3460 |
by auto |
|
3461 |
have a'fs: "wfactors G as a'" |
|
3462 |
apply (rule wfactorsE[OF afs], rule wfactorsI, simp) |
|
3463 |
apply (simp add: a, insert ascarr a'carr) |
|
3464 |
apply (intro assoc_l_cancel[of ah _ a'] multlist_closed ahcarr, assumption+) |
|
3465 |
done |
|
3466 |
||
3467 |
from afs have ahirr: "irreducible G ah" by (elim wfactorsE, simp) |
|
3468 |
with ascarr have ahprime: "prime G ah" by (intro irreducible_prime ahcarr) |
|
3469 |
||
3470 |
note carr [simp] = acarr ahcarr ascarr as'carr a'carr |
|
3471 |
||
3472 |
note ahdvda |
|
3473 |
also from afs' |
|
3474 |
have "a divides (foldr (op \<otimes>) as' \<one>)" |
|
3475 |
by (elim wfactorsE associatedE, simp) |
|
3476 |
finally have "ah divides (foldr (op \<otimes>) as' \<one>)" by simp |
|
3477 |
||
3478 |
with ahprime |
|
3479 |
have "\<exists>i<length as'. ah divides as'!i" |
|
3480 |
by (intro multlist_prime_pos, simp+) |
|
3481 |
from this obtain i |
|
3482 |
where len: "i<length as'" and ahdvd: "ah divides as'!i" |
|
3483 |
by auto |
|
3484 |
from afs' carr have irrasi: "irreducible G (as'!i)" |
|
3485 |
by (fast intro: nth_mem[OF len] elim: wfactorsE) |
|
3486 |
from len carr |
|
3487 |
have asicarr[simp]: "as'!i \<in> carrier G" by (unfold set_conv_nth, force) |
|
3488 |
note carr = carr asicarr |
|
3489 |
||
3490 |
from ahdvd have "\<exists>x \<in> carrier G. as'!i = ah \<otimes> x" by (fast elim: dividesE) |
|
3491 |
from this obtain x where "x \<in> carrier G" and asi: "as'!i = ah \<otimes> x" by auto |
|
3492 |
||
3493 |
with carr irrasi[simplified asi] |
|
3494 |
have asiah: "as'!i \<sim> ah" apply - |
|
3495 |
apply (elim irreducible_prodE[of "ah" "x"], assumption+) |
|
3496 |
apply (rule associatedI2[of x], assumption+) |
|
3497 |
apply (rule irreducibleE[OF ahirr], simp) |
|
3498 |
done |
|
3499 |
||
3500 |
note setparts = set_take_subset[of i as'] set_drop_subset[of "Suc i" as'] |
|
3501 |
note partscarr [simp] = setparts[THEN subset_trans[OF _ as'carr]] |
|
3502 |
note carr = carr partscarr |
|
3503 |
||
3504 |
have "\<exists>aa_1. aa_1 \<in> carrier G \<and> wfactors G (take i as') aa_1" |
|
3505 |
apply (intro wfactors_prod_exists) |
|
3506 |
using setparts afs' by (fast elim: wfactorsE, simp) |
|
3507 |
from this obtain aa_1 |
|
3508 |
where aa1carr: "aa_1 \<in> carrier G" |
|
3509 |
and aa1fs: "wfactors G (take i as') aa_1" |
|
3510 |
by auto |
|
3511 |
||
3512 |
have "\<exists>aa_2. aa_2 \<in> carrier G \<and> wfactors G (drop (Suc i) as') aa_2" |
|
3513 |
apply (intro wfactors_prod_exists) |
|
3514 |
using setparts afs' by (fast elim: wfactorsE, simp) |
|
3515 |
from this obtain aa_2 |
|
3516 |
where aa2carr: "aa_2 \<in> carrier G" |
|
3517 |
and aa2fs: "wfactors G (drop (Suc i) as') aa_2" |
|
3518 |
by auto |
|
3519 |
||
3520 |
note carr = carr aa1carr[simp] aa2carr[simp] |
|
3521 |
||
3522 |
from aa1fs aa2fs |
|
3523 |
have v1: "wfactors G (take i as' @ drop (Suc i) as') (aa_1 \<otimes> aa_2)" |
|
3524 |
by (intro wfactors_mult, simp+) |
|
3525 |
hence v1': "wfactors G (as'!i # take i as' @ drop (Suc i) as') (as'!i \<otimes> (aa_1 \<otimes> aa_2))" |
|
3526 |
apply (intro wfactors_mult_single) |
|
3527 |
using setparts afs' |
|
3528 |
by (fast intro: nth_mem[OF len] elim: wfactorsE, simp+) |
|
3529 |
||
3530 |
from aa2carr carr aa1fs aa2fs |
|
3531 |
have "wfactors G (as'!i # drop (Suc i) as') (as'!i \<otimes> aa_2)" |
|
3532 |
apply (intro wfactors_mult_single) |
|
3533 |
apply (rule wfactorsE[OF afs'], fast intro: nth_mem[OF len]) |
|
3534 |
apply (fast intro: nth_mem[OF len]) |
|
3535 |
apply fast |
|
3536 |
apply fast |
|
3537 |
apply assumption |
|
3538 |
done |
|
3539 |
with len carr aa1carr aa2carr aa1fs |
|
3540 |
have v2: "wfactors G (take i as' @ as'!i # drop (Suc i) as') (aa_1 \<otimes> (as'!i \<otimes> aa_2))" |
|
3541 |
apply (intro wfactors_mult) |
|
3542 |
apply fast |
|
3543 |
apply (simp, (fast intro: nth_mem[OF len])?)+ |
|
3544 |
done |
|
3545 |
||
3546 |
from len |
|
3547 |
have as': "as' = (take i as' @ as'!i # drop (Suc i) as')" |
|
3548 |
by (simp add: drop_Suc_conv_tl) |
|
3549 |
with carr |
|
3550 |
have eer: "essentially_equal G (take i as' @ as'!i # drop (Suc i) as') as'" |
|
3551 |
by simp |
|
3552 |
||
3553 |
with v2 afs' carr aa1carr aa2carr nth_mem[OF len] |
|
3554 |
have "aa_1 \<otimes> (as'!i \<otimes> aa_2) \<sim> a" |
|
3555 |
apply (intro ee_wfactorsD[of "take i as' @ as'!i # drop (Suc i) as'" "as'"]) |
|
3556 |
apply fast+ |
|
3557 |
apply (simp, fast) |
|
3558 |
done |
|
3559 |
then |
|
3560 |
have t1: "as'!i \<otimes> (aa_1 \<otimes> aa_2) \<sim> a" |
|
3561 |
apply (simp add: m_assoc[symmetric]) |
|
3562 |
apply (simp add: m_comm) |
|
3563 |
done |
|
3564 |
from carr asiah |
|
3565 |
have "ah \<otimes> (aa_1 \<otimes> aa_2) \<sim> as'!i \<otimes> (aa_1 \<otimes> aa_2)" |
|
3566 |
apply (intro mult_cong_l) |
|
3567 |
apply (fast intro: associated_sym, simp+) |
|
3568 |
done |
|
3569 |
also note t1 |
|
3570 |
finally |
|
3571 |
have "ah \<otimes> (aa_1 \<otimes> aa_2) \<sim> a" by simp |
|
3572 |
||
3573 |
with carr aa1carr aa2carr a'carr nth_mem[OF len] |
|
3574 |
have a': "aa_1 \<otimes> aa_2 \<sim> a'" |
|
3575 |
by (simp add: a, fast intro: assoc_l_cancel[of ah _ a']) |
|
3576 |
||
3577 |
note v1 |
|
3578 |
also note a' |
|
3579 |
finally have "wfactors G (take i as' @ drop (Suc i) as') a'" by simp |
|
3580 |
||
3581 |
from a'fs this carr |
|
3582 |
have "essentially_equal G as (take i as' @ drop (Suc i) as')" |
|
3583 |
by (intro ih[of a']) simp |
|
3584 |
||
3585 |
hence ee1: "essentially_equal G (ah # as) (ah # take i as' @ drop (Suc i) as')" |
|
3586 |
apply (elim essentially_equalE) apply (fastsimp intro: essentially_equalI) |
|
3587 |
done |
|
3588 |
||
3589 |
from carr |
|
3590 |
have ee2: "essentially_equal G (ah # take i as' @ drop (Suc i) as') |
|
3591 |
(as' ! i # take i as' @ drop (Suc i) as')" |
|
3592 |
proof (intro essentially_equalI) |
|
3593 |
show "ah # take i as' @ drop (Suc i) as' <~~> ah # take i as' @ drop (Suc i) as'" |
|
3594 |
by simp |
|
3595 |
next show "ah # take i as' @ drop (Suc i) as' [\<sim>] |
|
3596 |
as' ! i # take i as' @ drop (Suc i) as'" |
|
3597 |
apply (simp add: list_all2_append) |
|
3598 |
apply (simp add: asiah[symmetric] ahcarr asicarr) |
|
3599 |
done |
|
3600 |
qed |
|
3601 |
||
3602 |
note ee1 |
|
3603 |
also note ee2 |
|
3604 |
also have "essentially_equal G (as' ! i # take i as' @ drop (Suc i) as') |
|
3605 |
(take i as' @ as' ! i # drop (Suc i) as')" |
|
3606 |
apply (intro essentially_equalI) |
|
3607 |
apply (subgoal_tac "as' ! i # take i as' @ drop (Suc i) as' <~~> |
|
3608 |
take i as' @ as' ! i # drop (Suc i) as'") |
|
3609 |
apply simp |
|
3610 |
apply (rule perm_append_Cons) |
|
3611 |
apply simp |
|
3612 |
done |
|
3613 |
finally |
|
3614 |
have "essentially_equal G (ah # as) |
|
3615 |
(take i as' @ as' ! i # drop (Suc i) as')" by simp |
|
3616 |
||
3617 |
thus "essentially_equal G (ah # as) as'" by (subst as', assumption) |
|
3618 |
qed |
|
3619 |
||
3620 |
lemma (in primeness_condition_monoid) wfactors_unique: |
|
3621 |
assumes "wfactors G as a" "wfactors G as' a" |
|
3622 |
and "a \<in> carrier G" "set as \<subseteq> carrier G" "set as' \<subseteq> carrier G" |
|
3623 |
shows "essentially_equal G as as'" |
|
3624 |
apply (rule wfactors_unique__hlp_induct[rule_format, of a]) |
|
3625 |
apply (simp add: assms) |
|
3626 |
done |
|
3627 |
||
3628 |
||
3629 |
subsubsection {* Application to factorial monoids *} |
|
3630 |
||
3631 |
text {* Number of factors for wellfoundedness *} |
|
3632 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
35272
diff
changeset
|
3633 |
definition factorcount :: "_ \<Rightarrow> 'a \<Rightarrow> nat" where |
27701 | 3634 |
"factorcount G a == THE c. (ALL as. set as \<subseteq> carrier G \<and> |
3635 |
wfactors G as a \<longrightarrow> c = length as)" |
|
3636 |
||
3637 |
lemma (in monoid) ee_length: |
|
3638 |
assumes ee: "essentially_equal G as bs" |
|
3639 |
shows "length as = length bs" |
|
3640 |
apply (rule essentially_equalE[OF ee]) |
|
3641 |
apply (subgoal_tac "length as = length fs1'") |
|
3642 |
apply (simp add: list_all2_lengthD) |
|
3643 |
apply (simp add: perm_length) |
|
3644 |
done |
|
3645 |
||
3646 |
lemma (in factorial_monoid) factorcount_exists: |
|
3647 |
assumes carr[simp]: "a \<in> carrier G" |
|
3648 |
shows "EX c. ALL as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> c = length as" |
|
3649 |
proof - |
|
3650 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" by (intro wfactors_exist, simp) |
|
3651 |
from this obtain as |
|
3652 |
where ascarr[simp]: "set as \<subseteq> carrier G" |
|
3653 |
and afs: "wfactors G as a" |
|
3654 |
by (auto simp del: carr) |
|
3655 |
||
3656 |
have "ALL as'. set as' \<subseteq> carrier G \<and> wfactors G as' a \<longrightarrow> length as = length as'" |
|
3657 |
proof clarify |
|
3658 |
fix as' |
|
3659 |
assume [simp]: "set as' \<subseteq> carrier G" |
|
3660 |
and bfs: "wfactors G as' a" |
|
3661 |
from afs bfs |
|
3662 |
have "essentially_equal G as as'" |
|
3663 |
by (intro ee_wfactorsI[of a a as as'], simp+) |
|
3664 |
thus "length as = length as'" by (rule ee_length) |
|
3665 |
qed |
|
3666 |
thus "EX c. ALL as'. set as' \<subseteq> carrier G \<and> wfactors G as' a \<longrightarrow> c = length as'" .. |
|
3667 |
qed |
|
3668 |
||
3669 |
lemma (in factorial_monoid) factorcount_unique: |
|
3670 |
assumes afs: "wfactors G as a" |
|
3671 |
and acarr[simp]: "a \<in> carrier G" and ascarr[simp]: "set as \<subseteq> carrier G" |
|
3672 |
shows "factorcount G a = length as" |
|
3673 |
proof - |
|
3674 |
have "EX ac. ALL as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> ac = length as" by (rule factorcount_exists, simp) |
|
3675 |
from this obtain ac where |
|
3676 |
alen: "ALL as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> ac = length as" |
|
3677 |
by auto |
|
3678 |
have ac: "ac = factorcount G a" |
|
3679 |
apply (simp add: factorcount_def) |
|
3680 |
apply (rule theI2) |
|
3681 |
apply (rule alen) |
|
3682 |
apply (elim allE[of _ "as"], rule allE[OF alen, of "as"], simp add: ascarr afs) |
|
3683 |
apply (elim allE[of _ "as"], rule allE[OF alen, of "as"], simp add: ascarr afs) |
|
3684 |
done |
|
3685 |
||
3686 |
from ascarr afs have "ac = length as" by (iprover intro: alen[rule_format]) |
|
3687 |
with ac show ?thesis by simp |
|
3688 |
qed |
|
3689 |
||
3690 |
lemma (in factorial_monoid) divides_fcount: |
|
3691 |
assumes dvd: "a divides b" |
|
3692 |
and acarr: "a \<in> carrier G" and bcarr:"b \<in> carrier G" |
|
3693 |
shows "factorcount G a <= factorcount G b" |
|
3694 |
apply (rule dividesE[OF dvd]) |
|
3695 |
proof - |
|
3696 |
fix c |
|
3697 |
from assms |
|
3698 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" by fast |
|
3699 |
from this obtain as |
|
3700 |
where ascarr: "set as \<subseteq> carrier G" |
|
3701 |
and afs: "wfactors G as a" |
|
3702 |
by auto |
|
3703 |
with acarr have fca: "factorcount G a = length as" by (intro factorcount_unique) |
|
3704 |
||
3705 |
assume ccarr: "c \<in> carrier G" |
|
3706 |
hence "\<exists>cs. set cs \<subseteq> carrier G \<and> wfactors G cs c" by fast |
|
3707 |
from this obtain cs |
|
3708 |
where cscarr: "set cs \<subseteq> carrier G" |
|
3709 |
and cfs: "wfactors G cs c" |
|
3710 |
by auto |
|
3711 |
||
3712 |
note [simp] = acarr bcarr ccarr ascarr cscarr |
|
3713 |
||
3714 |
assume b: "b = a \<otimes> c" |
|
3715 |
from afs cfs |
|
3716 |
have "wfactors G (as@cs) (a \<otimes> c)" by (intro wfactors_mult, simp+) |
|
3717 |
with b have "wfactors G (as@cs) b" by simp |
|
3718 |
hence "factorcount G b = length (as@cs)" by (intro factorcount_unique, simp+) |
|
3719 |
hence "factorcount G b = length as + length cs" by simp |
|
3720 |
with fca show ?thesis by simp |
|
3721 |
qed |
|
3722 |
||
3723 |
lemma (in factorial_monoid) associated_fcount: |
|
3724 |
assumes acarr: "a \<in> carrier G" and bcarr:"b \<in> carrier G" |
|
3725 |
and asc: "a \<sim> b" |
|
3726 |
shows "factorcount G a = factorcount G b" |
|
3727 |
apply (rule associatedE[OF asc]) |
|
3728 |
apply (drule divides_fcount[OF _ acarr bcarr]) |
|
3729 |
apply (drule divides_fcount[OF _ bcarr acarr]) |
|
3730 |
apply simp |
|
3731 |
done |
|
3732 |
||
3733 |
lemma (in factorial_monoid) properfactor_fcount: |
|
3734 |
assumes acarr: "a \<in> carrier G" and bcarr:"b \<in> carrier G" |
|
3735 |
and pf: "properfactor G a b" |
|
3736 |
shows "factorcount G a < factorcount G b" |
|
3737 |
apply (rule properfactorE[OF pf], elim dividesE) |
|
3738 |
proof - |
|
3739 |
fix c |
|
3740 |
from assms |
|
3741 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" by fast |
|
3742 |
from this obtain as |
|
3743 |
where ascarr: "set as \<subseteq> carrier G" |
|
3744 |
and afs: "wfactors G as a" |
|
3745 |
by auto |
|
3746 |
with acarr have fca: "factorcount G a = length as" by (intro factorcount_unique) |
|
3747 |
||
3748 |
assume ccarr: "c \<in> carrier G" |
|
3749 |
hence "\<exists>cs. set cs \<subseteq> carrier G \<and> wfactors G cs c" by fast |
|
3750 |
from this obtain cs |
|
3751 |
where cscarr: "set cs \<subseteq> carrier G" |
|
3752 |
and cfs: "wfactors G cs c" |
|
3753 |
by auto |
|
3754 |
||
3755 |
assume b: "b = a \<otimes> c" |
|
3756 |
||
3757 |
have "wfactors G (as@cs) (a \<otimes> c)" by (rule wfactors_mult) fact+ |
|
3758 |
with b |
|
3759 |
have "wfactors G (as@cs) b" by simp |
|
3760 |
with ascarr cscarr bcarr |
|
3761 |
have "factorcount G b = length (as@cs)" by (simp add: factorcount_unique) |
|
3762 |
hence fcb: "factorcount G b = length as + length cs" by simp |
|
3763 |
||
3764 |
assume nbdvda: "\<not> b divides a" |
|
3765 |
have "c \<notin> Units G" |
|
3766 |
proof (rule ccontr, simp) |
|
3767 |
assume cunit:"c \<in> Units G" |
|
3768 |
||
3769 |
have "b \<otimes> inv c = a \<otimes> c \<otimes> inv c" by (simp add: b) |
|
3770 |
also with ccarr acarr cunit |
|
3771 |
have "\<dots> = a \<otimes> (c \<otimes> inv c)" by (fast intro: m_assoc) |
|
3772 |
also with ccarr cunit |
|
3773 |
have "\<dots> = a \<otimes> \<one>" by (simp add: Units_r_inv) |
|
3774 |
also with acarr |
|
3775 |
have "\<dots> = a" by simp |
|
3776 |
finally have "a = b \<otimes> inv c" by simp |
|
3777 |
with ccarr cunit |
|
3778 |
have "b divides a" by (fast intro: dividesI[of "inv c"]) |
|
3779 |
with nbdvda show False by simp |
|
3780 |
qed |
|
3781 |
||
3782 |
with cfs have "length cs > 0" |
|
3783 |
apply - |
|
3784 |
apply (rule ccontr, simp) |
|
3785 |
proof - |
|
3786 |
assume "wfactors G [] c" |
|
3787 |
hence "\<one> \<sim> c" by (elim wfactorsE, simp) |
|
3788 |
with ccarr |
|
3789 |
have cunit: "c \<in> Units G" by (intro assoc_unit_r[of "\<one>" "c"], simp+) |
|
3790 |
assume "c \<notin> Units G" |
|
3791 |
with cunit show "False" by simp |
|
3792 |
qed |
|
3793 |
||
3794 |
with fca fcb show ?thesis by simp |
|
3795 |
qed |
|
3796 |
||
29237 | 3797 |
sublocale factorial_monoid \<subseteq> divisor_chain_condition_monoid |
27701 | 3798 |
apply unfold_locales |
3799 |
apply (rule wfUNIVI) |
|
3800 |
apply (rule measure_induct[of "factorcount G"]) |
|
3801 |
apply simp (* slow *) (* |
|
3802 |
[1]Applying congruence rule: |
|
3803 |
\<lbrakk>factorcount G y < factorcount G xa \<equiv> ?P'; ?P' \<Longrightarrow> P y \<equiv> ?Q'\<rbrakk> \<Longrightarrow> factorcount G y < factorcount G xa \<longrightarrow> P y \<equiv> ?P' \<longrightarrow> ?Q' |
|
3804 |
||
3805 |
trace_simp_depth_limit exceeded! |
|
3806 |
*) |
|
3807 |
proof - |
|
3808 |
fix P x |
|
3809 |
assume r1[rule_format]: |
|
3810 |
"\<forall>y. (\<forall>z. z \<in> carrier G \<and> y \<in> carrier G \<and> properfactor G z y \<longrightarrow> P z) \<longrightarrow> P y" |
|
3811 |
and r2[rule_format]: "\<forall>y. factorcount G y < factorcount G x \<longrightarrow> P y" |
|
3812 |
show "P x" |
|
3813 |
apply (rule r1) |
|
3814 |
apply (rule r2) |
|
3815 |
apply (rule properfactor_fcount, simp+) |
|
3816 |
done |
|
3817 |
qed |
|
3818 |
||
29237 | 3819 |
sublocale factorial_monoid \<subseteq> primeness_condition_monoid |
28823 | 3820 |
proof qed (rule irreducible_is_prime) |
27701 | 3821 |
|
3822 |
||
3823 |
lemma (in factorial_monoid) primeness_condition: |
|
3824 |
shows "primeness_condition_monoid G" |
|
28823 | 3825 |
.. |
27701 | 3826 |
|
3827 |
lemma (in factorial_monoid) gcd_condition [simp]: |
|
3828 |
shows "gcd_condition_monoid G" |
|
28823 | 3829 |
proof qed (rule gcdof_exists) |
27701 | 3830 |
|
29237 | 3831 |
sublocale factorial_monoid \<subseteq> gcd_condition_monoid |
28823 | 3832 |
proof qed (rule gcdof_exists) |
27701 | 3833 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3834 |
lemma (in factorial_monoid) division_weak_lattice [simp]: |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3835 |
shows "weak_lattice (division_rel G)" |
27701 | 3836 |
proof - |
29237 | 3837 |
interpret weak_lower_semilattice "division_rel G" by simp |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3838 |
|
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3839 |
show "weak_lattice (division_rel G)" |
27701 | 3840 |
apply (unfold_locales, simp_all) |
3841 |
proof - |
|
3842 |
fix x y |
|
3843 |
assume carr: "x \<in> carrier G" "y \<in> carrier G" |
|
3844 |
||
3845 |
hence "\<exists>z. z \<in> carrier G \<and> z lcmof x y" by (rule lcmof_exists) |
|
3846 |
from this obtain z |
|
3847 |
where zcarr: "z \<in> carrier G" |
|
3848 |
and isgcd: "z lcmof x y" |
|
3849 |
by auto |
|
3850 |
with carr |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3851 |
have "least (division_rel G) z (Upper (division_rel G) {x, y})" |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3852 |
by (simp add: lcmof_leastUpper[symmetric]) |
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
3853 |
thus "\<exists>z. least (division_rel G) z (Upper (division_rel G) {x, y})" by fast |
27701 | 3854 |
qed |
3855 |
qed |
|
3856 |
||
3857 |
||
27717
21bbd410ba04
Generalised polynomial lemmas from cring to ring.
ballarin
parents:
27713
diff
changeset
|
3858 |
subsection {* Factoriality Theorems *} |
27701 | 3859 |
|
3860 |
theorem factorial_condition_one: (* Jacobson theorem 2.21 *) |
|
3861 |
shows "(divisor_chain_condition_monoid G \<and> primeness_condition_monoid G) = |
|
3862 |
factorial_monoid G" |
|
3863 |
apply rule |
|
3864 |
proof clarify |
|
3865 |
assume dcc: "divisor_chain_condition_monoid G" |
|
3866 |
and pc: "primeness_condition_monoid G" |
|
29237 | 3867 |
interpret divisor_chain_condition_monoid "G" by (rule dcc) |
3868 |
interpret primeness_condition_monoid "G" by (rule pc) |
|
27701 | 3869 |
|
3870 |
show "factorial_monoid G" |
|
3871 |
by (fast intro: factorial_monoidI wfactors_exist wfactors_unique) |
|
3872 |
next |
|
3873 |
assume fm: "factorial_monoid G" |
|
29237 | 3874 |
interpret factorial_monoid "G" by (rule fm) |
27701 | 3875 |
show "divisor_chain_condition_monoid G \<and> primeness_condition_monoid G" |
3876 |
by rule unfold_locales |
|
3877 |
qed |
|
3878 |
||
3879 |
theorem factorial_condition_two: (* Jacobson theorem 2.22 *) |
|
3880 |
shows "(divisor_chain_condition_monoid G \<and> gcd_condition_monoid G) = factorial_monoid G" |
|
3881 |
apply rule |
|
3882 |
proof clarify |
|
3883 |
assume dcc: "divisor_chain_condition_monoid G" |
|
3884 |
and gc: "gcd_condition_monoid G" |
|
29237 | 3885 |
interpret divisor_chain_condition_monoid "G" by (rule dcc) |
3886 |
interpret gcd_condition_monoid "G" by (rule gc) |
|
27701 | 3887 |
show "factorial_monoid G" |
3888 |
by (simp add: factorial_condition_one[symmetric], rule, unfold_locales) |
|
3889 |
next |
|
3890 |
assume fm: "factorial_monoid G" |
|
29237 | 3891 |
interpret factorial_monoid "G" by (rule fm) |
27701 | 3892 |
show "divisor_chain_condition_monoid G \<and> gcd_condition_monoid G" |
3893 |
by rule unfold_locales |
|
3894 |
qed |
|
3895 |
||
3896 |
end |