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