author | paulson <lp15@cam.ac.uk> |
Sun, 08 Jul 2018 16:07:26 +0100 | |
changeset 68604 | 57721285d4ef |
parent 68551 | b680e74eb6f2 |
child 68664 | bd0df72c16d5 |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Algebra/Divisibility.thy |
2 |
Author: Clemens Ballarin |
|
3 |
Author: Stephan Hohe |
|
27701 | 4 |
*) |
5 |
||
61382 | 6 |
section \<open>Divisibility in monoids and rings\<close> |
41959 | 7 |
|
27701 | 8 |
theory Divisibility |
66579 | 9 |
imports "HOL-Library.Permutation" Coset Group |
27701 | 10 |
begin |
11 |
||
61382 | 12 |
section \<open>Factorial Monoids\<close> |
13 |
||
14 |
subsection \<open>Monoids with Cancellation Law\<close> |
|
27701 | 15 |
|
16 |
locale monoid_cancel = monoid + |
|
63832 | 17 |
assumes l_cancel: "\<lbrakk>c \<otimes> a = c \<otimes> b; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
18 |
and r_cancel: "\<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b" |
|
27701 | 19 |
|
20 |
lemma (in monoid) monoid_cancelI: |
|
63832 | 21 |
assumes l_cancel: "\<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" |
22 |
and r_cancel: "\<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" |
|
27701 | 23 |
shows "monoid_cancel G" |
61169 | 24 |
by standard fact+ |
27701 | 25 |
|
63832 | 26 |
lemma (in monoid_cancel) is_monoid_cancel: "monoid_cancel G" .. |
27701 | 27 |
|
29237 | 28 |
sublocale group \<subseteq> monoid_cancel |
61169 | 29 |
by standard simp_all |
27701 | 30 |
|
31 |
||
32 |
locale comm_monoid_cancel = monoid_cancel + comm_monoid |
|
33 |
||
34 |
lemma comm_monoid_cancelI: |
|
28599 | 35 |
fixes G (structure) |
36 |
assumes "comm_monoid G" |
|
63832 | 37 |
assumes cancel: "\<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" |
27701 | 38 |
shows "comm_monoid_cancel G" |
28599 | 39 |
proof - |
29237 | 40 |
interpret comm_monoid G by fact |
28599 | 41 |
show "comm_monoid_cancel G" |
36278 | 42 |
by unfold_locales (metis assms(2) m_ac(2))+ |
28599 | 43 |
qed |
27701 | 44 |
|
63832 | 45 |
lemma (in comm_monoid_cancel) is_comm_monoid_cancel: "comm_monoid_cancel G" |
28823 | 46 |
by intro_locales |
27701 | 47 |
|
63832 | 48 |
sublocale comm_group \<subseteq> comm_monoid_cancel .. |
27701 | 49 |
|
50 |
||
61382 | 51 |
subsection \<open>Products of Units in Monoids\<close> |
27701 | 52 |
|
53 |
lemma (in monoid) prod_unit_l: |
|
63832 | 54 |
assumes abunit[simp]: "a \<otimes> b \<in> Units G" |
55 |
and aunit[simp]: "a \<in> Units G" |
|
27701 | 56 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
57 |
shows "b \<in> Units G" |
|
58 |
proof - |
|
59 |
have c: "inv (a \<otimes> b) \<otimes> a \<in> carrier G" by simp |
|
60 |
||
63832 | 61 |
have "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = inv (a \<otimes> b) \<otimes> (a \<otimes> b)" |
62 |
by (simp add: m_assoc) |
|
57865 | 63 |
also have "\<dots> = \<one>" by simp |
27701 | 64 |
finally have li: "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = \<one>" . |
65 |
||
66 |
have "\<one> = inv a \<otimes> a" by (simp add: Units_l_inv[symmetric]) |
|
67 |
also have "\<dots> = inv a \<otimes> \<one> \<otimes> a" by simp |
|
68 |
also have "\<dots> = inv a \<otimes> ((a \<otimes> b) \<otimes> inv (a \<otimes> b)) \<otimes> a" |
|
63832 | 69 |
by (simp add: Units_r_inv[OF abunit, symmetric] del: Units_r_inv) |
27701 | 70 |
also have "\<dots> = ((inv a \<otimes> a) \<otimes> b) \<otimes> inv (a \<otimes> b) \<otimes> a" |
71 |
by (simp add: m_assoc del: Units_l_inv) |
|
57865 | 72 |
also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by simp |
27701 | 73 |
also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> a)" by (simp add: m_assoc) |
74 |
finally have ri: "b \<otimes> (inv (a \<otimes> b) \<otimes> a) = \<one> " by simp |
|
75 |
||
63832 | 76 |
from c li ri show "b \<in> Units G" by (auto simp: Units_def) |
27701 | 77 |
qed |
78 |
||
79 |
lemma (in monoid) prod_unit_r: |
|
63832 | 80 |
assumes abunit[simp]: "a \<otimes> b \<in> Units G" |
81 |
and bunit[simp]: "b \<in> Units G" |
|
27701 | 82 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
83 |
shows "a \<in> Units G" |
|
84 |
proof - |
|
85 |
have c: "b \<otimes> inv (a \<otimes> b) \<in> carrier G" by simp |
|
86 |
||
87 |
have "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = (a \<otimes> b) \<otimes> inv (a \<otimes> b)" |
|
88 |
by (simp add: m_assoc del: Units_r_inv) |
|
89 |
also have "\<dots> = \<one>" by simp |
|
90 |
finally have li: "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = \<one>" . |
|
91 |
||
92 |
have "\<one> = b \<otimes> inv b" by (simp add: Units_r_inv[symmetric]) |
|
93 |
also have "\<dots> = b \<otimes> \<one> \<otimes> inv b" by simp |
|
63832 | 94 |
also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> (a \<otimes> b)) \<otimes> inv b" |
95 |
by (simp add: Units_l_inv[OF abunit, symmetric] del: Units_l_inv) |
|
27701 | 96 |
also have "\<dots> = (b \<otimes> inv (a \<otimes> b) \<otimes> a) \<otimes> (b \<otimes> inv b)" |
97 |
by (simp add: m_assoc del: Units_l_inv) |
|
98 |
also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by simp |
|
99 |
finally have ri: "(b \<otimes> inv (a \<otimes> b)) \<otimes> a = \<one> " by simp |
|
100 |
||
63832 | 101 |
from c li ri show "a \<in> Units G" by (auto simp: Units_def) |
27701 | 102 |
qed |
103 |
||
104 |
lemma (in comm_monoid) unit_factor: |
|
105 |
assumes abunit: "a \<otimes> b \<in> Units G" |
|
106 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
107 |
shows "a \<in> Units G" |
|
63832 | 108 |
using abunit[simplified Units_def] |
27701 | 109 |
proof clarsimp |
110 |
fix i |
|
111 |
assume [simp]: "i \<in> carrier G" |
|
112 |
||
113 |
have carr': "b \<otimes> i \<in> carrier G" by simp |
|
114 |
||
115 |
have "(b \<otimes> i) \<otimes> a = (i \<otimes> b) \<otimes> a" by (simp add: m_comm) |
|
116 |
also have "\<dots> = i \<otimes> (b \<otimes> a)" by (simp add: m_assoc) |
|
117 |
also have "\<dots> = i \<otimes> (a \<otimes> b)" by (simp add: m_comm) |
|
63832 | 118 |
also assume "i \<otimes> (a \<otimes> b) = \<one>" |
27701 | 119 |
finally have li': "(b \<otimes> i) \<otimes> a = \<one>" . |
120 |
||
121 |
have "a \<otimes> (b \<otimes> i) = a \<otimes> b \<otimes> i" by (simp add: m_assoc) |
|
63832 | 122 |
also assume "a \<otimes> b \<otimes> i = \<one>" |
27701 | 123 |
finally have ri': "a \<otimes> (b \<otimes> i) = \<one>" . |
124 |
||
125 |
from carr' li' ri' |
|
63832 | 126 |
show "a \<in> Units G" by (simp add: Units_def, fast) |
27701 | 127 |
qed |
128 |
||
35849 | 129 |
|
61382 | 130 |
subsection \<open>Divisibility and Association\<close> |
131 |
||
132 |
subsubsection \<open>Function definitions\<close> |
|
27701 | 133 |
|
63832 | 134 |
definition factor :: "[_, 'a, 'a] \<Rightarrow> bool" (infix "divides\<index>" 65) |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
135 |
where "a divides\<^bsub>G\<^esub> b \<longleftrightarrow> (\<exists>c\<in>carrier G. b = a \<otimes>\<^bsub>G\<^esub> c)" |
35847 | 136 |
|
63832 | 137 |
definition associated :: "[_, 'a, 'a] \<Rightarrow> bool" (infix "\<sim>\<index>" 55) |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
138 |
where "a \<sim>\<^bsub>G\<^esub> b \<longleftrightarrow> a divides\<^bsub>G\<^esub> b \<and> b divides\<^bsub>G\<^esub> a" |
27701 | 139 |
|
67399 | 140 |
abbreviation "division_rel G \<equiv> \<lparr>carrier = carrier G, eq = (\<sim>\<^bsub>G\<^esub>), le = (divides\<^bsub>G\<^esub>)\<rparr>" |
63832 | 141 |
|
142 |
definition properfactor :: "[_, 'a, 'a] \<Rightarrow> bool" |
|
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
143 |
where "properfactor G a b \<longleftrightarrow> a divides\<^bsub>G\<^esub> b \<and> \<not>(b divides\<^bsub>G\<^esub> a)" |
35847 | 144 |
|
63832 | 145 |
definition irreducible :: "[_, 'a] \<Rightarrow> bool" |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
146 |
where "irreducible G a \<longleftrightarrow> a \<notin> Units G \<and> (\<forall>b\<in>carrier G. properfactor G b a \<longrightarrow> b \<in> Units G)" |
35847 | 147 |
|
63832 | 148 |
definition prime :: "[_, 'a] \<Rightarrow> bool" |
149 |
where "prime G p \<longleftrightarrow> |
|
150 |
p \<notin> Units G \<and> |
|
35847 | 151 |
(\<forall>a\<in>carrier G. \<forall>b\<in>carrier G. p divides\<^bsub>G\<^esub> (a \<otimes>\<^bsub>G\<^esub> b) \<longrightarrow> p divides\<^bsub>G\<^esub> a \<or> p divides\<^bsub>G\<^esub> b)" |
27701 | 152 |
|
153 |
||
61382 | 154 |
subsubsection \<open>Divisibility\<close> |
27701 | 155 |
|
156 |
lemma dividesI: |
|
157 |
fixes G (structure) |
|
158 |
assumes carr: "c \<in> carrier G" |
|
159 |
and p: "b = a \<otimes> c" |
|
160 |
shows "a divides b" |
|
63832 | 161 |
unfolding factor_def using assms by fast |
27701 | 162 |
|
163 |
lemma dividesI' [intro]: |
|
63832 | 164 |
fixes G (structure) |
27701 | 165 |
assumes p: "b = a \<otimes> c" |
166 |
and carr: "c \<in> carrier G" |
|
167 |
shows "a divides b" |
|
63832 | 168 |
using assms by (fast intro: dividesI) |
27701 | 169 |
|
170 |
lemma dividesD: |
|
171 |
fixes G (structure) |
|
172 |
assumes "a divides b" |
|
173 |
shows "\<exists>c\<in>carrier G. b = a \<otimes> c" |
|
63832 | 174 |
using assms unfolding factor_def by fast |
27701 | 175 |
|
176 |
lemma dividesE [elim]: |
|
177 |
fixes G (structure) |
|
178 |
assumes d: "a divides b" |
|
179 |
and elim: "\<And>c. \<lbrakk>b = a \<otimes> c; c \<in> carrier G\<rbrakk> \<Longrightarrow> P" |
|
180 |
shows "P" |
|
181 |
proof - |
|
63846 | 182 |
from dividesD[OF d] obtain c where "c \<in> carrier G" and "b = a \<otimes> c" by auto |
63832 | 183 |
then show P by (elim elim) |
27701 | 184 |
qed |
185 |
||
186 |
lemma (in monoid) divides_refl[simp, intro!]: |
|
187 |
assumes carr: "a \<in> carrier G" |
|
188 |
shows "a divides a" |
|
63832 | 189 |
by (intro dividesI[of "\<one>"]) (simp_all add: carr) |
27701 | 190 |
|
191 |
lemma (in monoid) divides_trans [trans]: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
192 |
assumes dvds: "a divides b" "b divides c" |
27701 | 193 |
and acarr: "a \<in> carrier G" |
194 |
shows "a divides c" |
|
63832 | 195 |
using dvds[THEN dividesD] by (blast intro: dividesI m_assoc acarr) |
27701 | 196 |
|
197 |
lemma (in monoid) divides_mult_lI [intro]: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
198 |
assumes "a divides b" "a \<in> carrier G" "c \<in> carrier G" |
27701 | 199 |
shows "(c \<otimes> a) divides (c \<otimes> b)" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
200 |
by (metis assms factor_def m_assoc) |
27701 | 201 |
|
202 |
lemma (in monoid_cancel) divides_mult_l [simp]: |
|
203 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
204 |
shows "(c \<otimes> a) divides (c \<otimes> b) = a divides b" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
205 |
proof |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
206 |
show "c \<otimes> a divides c \<otimes> b \<Longrightarrow> a divides b" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
207 |
using carr monoid.m_assoc monoid_axioms monoid_cancel.l_cancel monoid_cancel_axioms by fastforce |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
208 |
show "a divides b \<Longrightarrow> c \<otimes> a divides c \<otimes> b" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
209 |
using carr(1) carr(3) by blast |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
210 |
qed |
27701 | 211 |
|
212 |
lemma (in comm_monoid) divides_mult_rI [intro]: |
|
213 |
assumes ab: "a divides b" |
|
214 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
215 |
shows "(a \<otimes> c) divides (b \<otimes> c)" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
216 |
using carr ab by (metis divides_mult_lI m_comm) |
27701 | 217 |
|
218 |
lemma (in comm_monoid_cancel) divides_mult_r [simp]: |
|
219 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
220 |
shows "(a \<otimes> c) divides (b \<otimes> c) = a divides b" |
|
63832 | 221 |
using carr by (simp add: m_comm[of a c] m_comm[of b c]) |
27701 | 222 |
|
223 |
lemma (in monoid) divides_prod_r: |
|
224 |
assumes ab: "a divides b" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
225 |
and carr: "a \<in> carrier G" "c \<in> carrier G" |
27701 | 226 |
shows "a divides (b \<otimes> c)" |
63832 | 227 |
using ab carr by (fast intro: m_assoc) |
27701 | 228 |
|
229 |
lemma (in comm_monoid) divides_prod_l: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
230 |
assumes "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" "a divides b" |
27701 | 231 |
shows "a divides (c \<otimes> b)" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
232 |
using assms by (simp add: divides_prod_r m_comm) |
27701 | 233 |
|
234 |
lemma (in monoid) unit_divides: |
|
235 |
assumes uunit: "u \<in> Units G" |
|
63832 | 236 |
and acarr: "a \<in> carrier G" |
27701 | 237 |
shows "u divides a" |
238 |
proof (intro dividesI[of "(inv u) \<otimes> a"], fast intro: uunit acarr) |
|
63832 | 239 |
from uunit acarr have xcarr: "inv u \<otimes> a \<in> carrier G" by fast |
240 |
from uunit acarr have "u \<otimes> (inv u \<otimes> a) = (u \<otimes> inv u) \<otimes> a" |
|
241 |
by (fast intro: m_assoc[symmetric]) |
|
27701 | 242 |
also have "\<dots> = \<one> \<otimes> a" by (simp add: Units_r_inv[OF uunit]) |
63832 | 243 |
also from acarr have "\<dots> = a" by simp |
244 |
finally show "a = u \<otimes> (inv u \<otimes> a)" .. |
|
27701 | 245 |
qed |
246 |
||
247 |
lemma (in comm_monoid) divides_unit: |
|
248 |
assumes udvd: "a divides u" |
|
63832 | 249 |
and carr: "a \<in> carrier G" "u \<in> Units G" |
27701 | 250 |
shows "a \<in> Units G" |
63832 | 251 |
using udvd carr by (blast intro: unit_factor) |
27701 | 252 |
|
253 |
lemma (in comm_monoid) Unit_eq_dividesone: |
|
254 |
assumes ucarr: "u \<in> carrier G" |
|
255 |
shows "u \<in> Units G = u divides \<one>" |
|
63832 | 256 |
using ucarr by (fast dest: divides_unit intro: unit_divides) |
27701 | 257 |
|
258 |
||
61382 | 259 |
subsubsection \<open>Association\<close> |
27701 | 260 |
|
261 |
lemma associatedI: |
|
262 |
fixes G (structure) |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
263 |
assumes "a divides b" "b divides a" |
27701 | 264 |
shows "a \<sim> b" |
63832 | 265 |
using assms by (simp add: associated_def) |
27701 | 266 |
|
267 |
lemma (in monoid) associatedI2: |
|
268 |
assumes uunit[simp]: "u \<in> Units G" |
|
269 |
and a: "a = b \<otimes> u" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
270 |
and bcarr: "b \<in> carrier G" |
27701 | 271 |
shows "a \<sim> b" |
63832 | 272 |
using uunit bcarr |
273 |
unfolding a |
|
274 |
apply (intro associatedI) |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
275 |
apply (metis Units_closed divides_mult_lI one_closed r_one unit_divides) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
276 |
by blast |
27701 | 277 |
|
278 |
lemma (in monoid) associatedI2': |
|
63832 | 279 |
assumes "a = b \<otimes> u" |
280 |
and "u \<in> Units G" |
|
281 |
and "b \<in> carrier G" |
|
27701 | 282 |
shows "a \<sim> b" |
63832 | 283 |
using assms by (intro associatedI2) |
27701 | 284 |
|
285 |
lemma associatedD: |
|
286 |
fixes G (structure) |
|
287 |
assumes "a \<sim> b" |
|
288 |
shows "a divides b" |
|
63832 | 289 |
using assms by (simp add: associated_def) |
27701 | 290 |
|
291 |
lemma (in monoid_cancel) associatedD2: |
|
292 |
assumes assoc: "a \<sim> b" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
293 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
27701 | 294 |
shows "\<exists>u\<in>Units G. a = b \<otimes> u" |
63832 | 295 |
using assoc |
296 |
unfolding associated_def |
|
27701 | 297 |
proof clarify |
298 |
assume "b divides a" |
|
63832 | 299 |
then obtain u where ucarr: "u \<in> carrier G" and a: "a = b \<otimes> u" |
63846 | 300 |
by (rule dividesE) |
27701 | 301 |
|
302 |
assume "a divides b" |
|
63832 | 303 |
then obtain u' where u'carr: "u' \<in> carrier G" and b: "b = a \<otimes> u'" |
63846 | 304 |
by (rule dividesE) |
27701 | 305 |
note carr = carr ucarr u'carr |
306 |
||
63832 | 307 |
from carr have "a \<otimes> \<one> = a" by simp |
27701 | 308 |
also have "\<dots> = b \<otimes> u" by (simp add: a) |
309 |
also have "\<dots> = a \<otimes> u' \<otimes> u" by (simp add: b) |
|
63832 | 310 |
also from carr have "\<dots> = a \<otimes> (u' \<otimes> u)" by (simp add: m_assoc) |
311 |
finally have "a \<otimes> \<one> = a \<otimes> (u' \<otimes> u)" . |
|
312 |
with carr have u1: "\<one> = u' \<otimes> u" by (fast dest: l_cancel) |
|
313 |
||
314 |
from carr have "b \<otimes> \<one> = b" by simp |
|
27701 | 315 |
also have "\<dots> = a \<otimes> u'" by (simp add: b) |
316 |
also have "\<dots> = b \<otimes> u \<otimes> u'" by (simp add: a) |
|
63832 | 317 |
also from carr have "\<dots> = b \<otimes> (u \<otimes> u')" by (simp add: m_assoc) |
318 |
finally have "b \<otimes> \<one> = b \<otimes> (u \<otimes> u')" . |
|
319 |
with carr have u2: "\<one> = u \<otimes> u'" by (fast dest: l_cancel) |
|
320 |
||
321 |
from u'carr u1[symmetric] u2[symmetric] have "\<exists>u'\<in>carrier G. u' \<otimes> u = \<one> \<and> u \<otimes> u' = \<one>" |
|
322 |
by fast |
|
323 |
then have "u \<in> Units G" |
|
324 |
by (simp add: Units_def ucarr) |
|
325 |
with ucarr a show "\<exists>u\<in>Units G. a = b \<otimes> u" by fast |
|
27701 | 326 |
qed |
327 |
||
328 |
lemma associatedE: |
|
329 |
fixes G (structure) |
|
330 |
assumes assoc: "a \<sim> b" |
|
331 |
and e: "\<lbrakk>a divides b; b divides a\<rbrakk> \<Longrightarrow> P" |
|
332 |
shows "P" |
|
333 |
proof - |
|
63832 | 334 |
from assoc have "a divides b" "b divides a" |
335 |
by (simp_all add: associated_def) |
|
336 |
then show P by (elim e) |
|
27701 | 337 |
qed |
338 |
||
339 |
lemma (in monoid_cancel) associatedE2: |
|
340 |
assumes assoc: "a \<sim> b" |
|
341 |
and e: "\<And>u. \<lbrakk>a = b \<otimes> u; u \<in> Units G\<rbrakk> \<Longrightarrow> P" |
|
342 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
|
343 |
shows "P" |
|
344 |
proof - |
|
63832 | 345 |
from assoc and carr have "\<exists>u\<in>Units G. a = b \<otimes> u" |
346 |
by (rule associatedD2) |
|
347 |
then obtain u where "u \<in> Units G" "a = b \<otimes> u" |
|
348 |
by auto |
|
349 |
then show P by (elim e) |
|
27701 | 350 |
qed |
351 |
||
352 |
lemma (in monoid) associated_refl [simp, intro!]: |
|
353 |
assumes "a \<in> carrier G" |
|
354 |
shows "a \<sim> a" |
|
63832 | 355 |
using assms by (fast intro: associatedI) |
27701 | 356 |
|
357 |
lemma (in monoid) associated_sym [sym]: |
|
358 |
assumes "a \<sim> b" |
|
359 |
shows "b \<sim> a" |
|
63832 | 360 |
using assms by (iprover intro: associatedI elim: associatedE) |
27701 | 361 |
|
362 |
lemma (in monoid) associated_trans [trans]: |
|
363 |
assumes "a \<sim> b" "b \<sim> c" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
364 |
and "a \<in> carrier G" "c \<in> carrier G" |
27701 | 365 |
shows "a \<sim> c" |
63832 | 366 |
using assms by (iprover intro: associatedI divides_trans elim: associatedE) |
367 |
||
368 |
lemma (in monoid) division_equiv [intro, simp]: "equivalence (division_rel G)" |
|
27701 | 369 |
apply unfold_locales |
63832 | 370 |
apply simp_all |
371 |
apply (metis associated_def) |
|
27701 | 372 |
apply (iprover intro: associated_trans) |
373 |
done |
|
374 |
||
375 |
||
61382 | 376 |
subsubsection \<open>Division and associativity\<close> |
27701 | 377 |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
378 |
lemmas divides_antisym = associatedI |
27701 | 379 |
|
380 |
lemma (in monoid) divides_cong_l [trans]: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
381 |
assumes "x \<sim> x'" "x' divides y" "x \<in> carrier G" |
27701 | 382 |
shows "x divides y" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
383 |
by (meson assms associatedD divides_trans) |
27701 | 384 |
|
385 |
lemma (in monoid) divides_cong_r [trans]: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
386 |
assumes "x divides y" "y \<sim> y'" "x \<in> carrier G" |
27701 | 387 |
shows "x divides y'" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
388 |
by (meson assms associatedD divides_trans) |
27701 | 389 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
390 |
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
|
391 |
"weak_partial_order (division_rel G)" |
27701 | 392 |
apply unfold_locales |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
393 |
apply (simp_all add: associated_sym divides_antisym) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
394 |
apply (metis associated_trans) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
395 |
apply (metis divides_trans) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
396 |
by (meson associated_def divides_trans) |
27701 | 397 |
|
63832 | 398 |
|
61382 | 399 |
subsubsection \<open>Multiplication and associativity\<close> |
27701 | 400 |
|
401 |
lemma (in monoid_cancel) mult_cong_r: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
402 |
assumes "b \<sim> b'" "a \<in> carrier G" "b \<in> carrier G" "b' \<in> carrier G" |
27701 | 403 |
shows "a \<otimes> b \<sim> a \<otimes> b'" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
404 |
by (meson assms associated_def divides_mult_lI) |
27701 | 405 |
|
406 |
lemma (in comm_monoid_cancel) mult_cong_l: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
407 |
assumes "a \<sim> a'" "a \<in> carrier G" "a' \<in> carrier G" "b \<in> carrier G" |
27701 | 408 |
shows "a \<otimes> b \<sim> a' \<otimes> b" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
409 |
using assms m_comm mult_cong_r by auto |
27701 | 410 |
|
411 |
lemma (in monoid_cancel) assoc_l_cancel: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
412 |
assumes "a \<in> carrier G" "b \<in> carrier G" "b' \<in> carrier G" "a \<otimes> b \<sim> a \<otimes> b'" |
27701 | 413 |
shows "b \<sim> b'" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
414 |
by (meson assms associated_def divides_mult_l) |
27701 | 415 |
|
416 |
lemma (in comm_monoid_cancel) assoc_r_cancel: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
417 |
assumes "a \<otimes> b \<sim> a' \<otimes> b" "a \<in> carrier G" "a' \<in> carrier G" "b \<in> carrier G" |
27701 | 418 |
shows "a \<sim> a'" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
419 |
using assms assoc_l_cancel m_comm by presburger |
27701 | 420 |
|
421 |
||
61382 | 422 |
subsubsection \<open>Units\<close> |
27701 | 423 |
|
424 |
lemma (in monoid_cancel) assoc_unit_l [trans]: |
|
63832 | 425 |
assumes "a \<sim> b" |
426 |
and "b \<in> Units G" |
|
427 |
and "a \<in> carrier G" |
|
27701 | 428 |
shows "a \<in> Units G" |
63832 | 429 |
using assms by (fast elim: associatedE2) |
27701 | 430 |
|
431 |
lemma (in monoid_cancel) assoc_unit_r [trans]: |
|
63832 | 432 |
assumes aunit: "a \<in> Units G" |
433 |
and asc: "a \<sim> b" |
|
27701 | 434 |
and bcarr: "b \<in> carrier G" |
435 |
shows "b \<in> Units G" |
|
63832 | 436 |
using aunit bcarr associated_sym[OF asc] by (blast intro: assoc_unit_l) |
27701 | 437 |
|
438 |
lemma (in comm_monoid) Units_cong: |
|
439 |
assumes aunit: "a \<in> Units G" and asc: "a \<sim> b" |
|
440 |
and bcarr: "b \<in> carrier G" |
|
441 |
shows "b \<in> Units G" |
|
63832 | 442 |
using assms by (blast intro: divides_unit elim: associatedE) |
27701 | 443 |
|
444 |
lemma (in monoid) Units_assoc: |
|
445 |
assumes units: "a \<in> Units G" "b \<in> Units G" |
|
446 |
shows "a \<sim> b" |
|
63832 | 447 |
using units by (fast intro: associatedI unit_divides) |
448 |
||
449 |
lemma (in monoid) Units_are_ones: "Units G {.=}\<^bsub>(division_rel G)\<^esub> {\<one>}" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
450 |
proof - |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
451 |
have "a .\<in>\<^bsub>division_rel G\<^esub> {\<one>}" if "a \<in> Units G" for a |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
452 |
proof - |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
453 |
have "a \<sim> \<one>" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
454 |
by (rule associatedI) (simp_all add: Units_closed that unit_divides) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
455 |
then show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
456 |
by (simp add: elem_def) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
457 |
qed |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
458 |
moreover have "\<one> .\<in>\<^bsub>division_rel G\<^esub> Units G" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
459 |
by (simp add: equivalence.mem_imp_elem) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
460 |
ultimately show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
461 |
by (auto simp: set_eq_def) |
27701 | 462 |
qed |
463 |
||
63832 | 464 |
lemma (in comm_monoid) Units_Lower: "Units G = Lower (division_rel G) (carrier G)" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
465 |
apply (auto simp add: Units_def Lower_def) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
466 |
apply (metis Units_one_closed unit_divides unit_factor) |
63832 | 467 |
apply (metis Unit_eq_dividesone Units_r_inv_ex m_ac(2) one_closed) |
468 |
done |
|
27701 | 469 |
|
470 |
||
61382 | 471 |
subsubsection \<open>Proper factors\<close> |
27701 | 472 |
|
473 |
lemma properfactorI: |
|
474 |
fixes G (structure) |
|
475 |
assumes "a divides b" |
|
476 |
and "\<not>(b divides a)" |
|
477 |
shows "properfactor G a b" |
|
63832 | 478 |
using assms unfolding properfactor_def by simp |
27701 | 479 |
|
480 |
lemma properfactorI2: |
|
481 |
fixes G (structure) |
|
482 |
assumes advdb: "a divides b" |
|
483 |
and neq: "\<not>(a \<sim> b)" |
|
484 |
shows "properfactor G a b" |
|
63846 | 485 |
proof (rule properfactorI, rule advdb, rule notI) |
27701 | 486 |
assume "b divides a" |
487 |
with advdb have "a \<sim> b" by (rule associatedI) |
|
488 |
with neq show "False" by fast |
|
489 |
qed |
|
490 |
||
491 |
lemma (in comm_monoid_cancel) properfactorI3: |
|
492 |
assumes p: "p = a \<otimes> b" |
|
493 |
and nunit: "b \<notin> Units G" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
494 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
27701 | 495 |
shows "properfactor G a p" |
63832 | 496 |
unfolding p |
497 |
using carr |
|
498 |
apply (intro properfactorI, fast) |
|
27701 | 499 |
proof (clarsimp, elim dividesE) |
500 |
fix c |
|
501 |
assume ccarr: "c \<in> carrier G" |
|
502 |
note [simp] = carr ccarr |
|
503 |
||
504 |
have "a \<otimes> \<one> = a" by simp |
|
505 |
also assume "a = a \<otimes> b \<otimes> c" |
|
506 |
also have "\<dots> = a \<otimes> (b \<otimes> c)" by (simp add: m_assoc) |
|
507 |
finally have "a \<otimes> \<one> = a \<otimes> (b \<otimes> c)" . |
|
508 |
||
63832 | 509 |
then have rinv: "\<one> = b \<otimes> c" by (intro l_cancel[of "a" "\<one>" "b \<otimes> c"], simp+) |
27701 | 510 |
also have "\<dots> = c \<otimes> b" by (simp add: m_comm) |
511 |
finally have linv: "\<one> = c \<otimes> b" . |
|
512 |
||
63832 | 513 |
from ccarr linv[symmetric] rinv[symmetric] have "b \<in> Units G" |
514 |
unfolding Units_def by fastforce |
|
515 |
with nunit show False .. |
|
27701 | 516 |
qed |
517 |
||
518 |
lemma properfactorE: |
|
519 |
fixes G (structure) |
|
520 |
assumes pf: "properfactor G a b" |
|
521 |
and r: "\<lbrakk>a divides b; \<not>(b divides a)\<rbrakk> \<Longrightarrow> P" |
|
522 |
shows "P" |
|
63832 | 523 |
using pf unfolding properfactor_def by (fast intro: r) |
27701 | 524 |
|
525 |
lemma properfactorE2: |
|
526 |
fixes G (structure) |
|
527 |
assumes pf: "properfactor G a b" |
|
528 |
and elim: "\<lbrakk>a divides b; \<not>(a \<sim> b)\<rbrakk> \<Longrightarrow> P" |
|
529 |
shows "P" |
|
63832 | 530 |
using pf unfolding properfactor_def by (fast elim: elim associatedE) |
27701 | 531 |
|
532 |
lemma (in monoid) properfactor_unitE: |
|
533 |
assumes uunit: "u \<in> Units G" |
|
534 |
and pf: "properfactor G a u" |
|
535 |
and acarr: "a \<in> carrier G" |
|
536 |
shows "P" |
|
63832 | 537 |
using pf unit_divides[OF uunit acarr] by (fast elim: properfactorE) |
27701 | 538 |
|
539 |
lemma (in monoid) properfactor_divides: |
|
540 |
assumes pf: "properfactor G a b" |
|
541 |
shows "a divides b" |
|
63832 | 542 |
using pf by (elim properfactorE) |
27701 | 543 |
|
544 |
lemma (in monoid) properfactor_trans1 [trans]: |
|
545 |
assumes dvds: "a divides b" "properfactor G b c" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
546 |
and carr: "a \<in> carrier G" "c \<in> carrier G" |
27701 | 547 |
shows "properfactor G a c" |
63832 | 548 |
using dvds carr |
549 |
apply (elim properfactorE, intro properfactorI) |
|
550 |
apply (iprover intro: divides_trans)+ |
|
551 |
done |
|
27701 | 552 |
|
553 |
lemma (in monoid) properfactor_trans2 [trans]: |
|
554 |
assumes dvds: "properfactor G a b" "b divides c" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
555 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
27701 | 556 |
shows "properfactor G a c" |
63832 | 557 |
using dvds carr |
558 |
apply (elim properfactorE, intro properfactorI) |
|
559 |
apply (iprover intro: divides_trans)+ |
|
560 |
done |
|
27701 | 561 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
562 |
lemma properfactor_lless: |
27701 | 563 |
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
|
564 |
shows "properfactor G = lless (division_rel G)" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
565 |
by (force simp: lless_def properfactor_def associated_def) |
27701 | 566 |
|
567 |
lemma (in monoid) properfactor_cong_l [trans]: |
|
568 |
assumes x'x: "x' \<sim> x" |
|
569 |
and pf: "properfactor G x y" |
|
570 |
and carr: "x \<in> carrier G" "x' \<in> carrier G" "y \<in> carrier G" |
|
571 |
shows "properfactor G x' y" |
|
63832 | 572 |
using pf |
573 |
unfolding properfactor_lless |
|
27701 | 574 |
proof - |
29237 | 575 |
interpret weak_partial_order "division_rel G" .. |
63832 | 576 |
from x'x have "x' .=\<^bsub>division_rel G\<^esub> x" by simp |
27701 | 577 |
also assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y" |
63832 | 578 |
finally show "x' \<sqsubset>\<^bsub>division_rel G\<^esub> y" by (simp add: carr) |
27701 | 579 |
qed |
580 |
||
581 |
lemma (in monoid) properfactor_cong_r [trans]: |
|
582 |
assumes pf: "properfactor G x y" |
|
583 |
and yy': "y \<sim> y'" |
|
584 |
and carr: "x \<in> carrier G" "y \<in> carrier G" "y' \<in> carrier G" |
|
585 |
shows "properfactor G x y'" |
|
63832 | 586 |
using pf |
587 |
unfolding properfactor_lless |
|
27701 | 588 |
proof - |
29237 | 589 |
interpret weak_partial_order "division_rel G" .. |
27701 | 590 |
assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y" |
591 |
also from yy' |
|
63832 | 592 |
have "y .=\<^bsub>division_rel G\<^esub> y'" by simp |
593 |
finally show "x \<sqsubset>\<^bsub>division_rel G\<^esub> y'" by (simp add: carr) |
|
27701 | 594 |
qed |
595 |
||
596 |
lemma (in monoid_cancel) properfactor_mult_lI [intro]: |
|
597 |
assumes ab: "properfactor G a b" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
598 |
and carr: "a \<in> carrier G" "c \<in> carrier G" |
27701 | 599 |
shows "properfactor G (c \<otimes> a) (c \<otimes> b)" |
63832 | 600 |
using ab carr by (fastforce elim: properfactorE intro: properfactorI) |
27701 | 601 |
|
602 |
lemma (in monoid_cancel) properfactor_mult_l [simp]: |
|
603 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
604 |
shows "properfactor G (c \<otimes> a) (c \<otimes> b) = properfactor G a b" |
|
63832 | 605 |
using carr by (fastforce elim: properfactorE intro: properfactorI) |
27701 | 606 |
|
607 |
lemma (in comm_monoid_cancel) properfactor_mult_rI [intro]: |
|
608 |
assumes ab: "properfactor G a b" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
609 |
and carr: "a \<in> carrier G" "c \<in> carrier G" |
27701 | 610 |
shows "properfactor G (a \<otimes> c) (b \<otimes> c)" |
63832 | 611 |
using ab carr by (fastforce elim: properfactorE intro: properfactorI) |
27701 | 612 |
|
613 |
lemma (in comm_monoid_cancel) properfactor_mult_r [simp]: |
|
614 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
615 |
shows "properfactor G (a \<otimes> c) (b \<otimes> c) = properfactor G a b" |
|
63832 | 616 |
using carr by (fastforce elim: properfactorE intro: properfactorI) |
27701 | 617 |
|
618 |
lemma (in monoid) properfactor_prod_r: |
|
619 |
assumes ab: "properfactor G a b" |
|
620 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
621 |
shows "properfactor G a (b \<otimes> c)" |
|
63832 | 622 |
by (intro properfactor_trans2[OF ab] divides_prod_r) simp_all |
27701 | 623 |
|
624 |
lemma (in comm_monoid) properfactor_prod_l: |
|
625 |
assumes ab: "properfactor G a b" |
|
626 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
627 |
shows "properfactor G a (c \<otimes> b)" |
|
63832 | 628 |
by (intro properfactor_trans2[OF ab] divides_prod_l) simp_all |
27701 | 629 |
|
630 |
||
61382 | 631 |
subsection \<open>Irreducible Elements and Primes\<close> |
632 |
||
633 |
subsubsection \<open>Irreducible elements\<close> |
|
27701 | 634 |
|
635 |
lemma irreducibleI: |
|
636 |
fixes G (structure) |
|
637 |
assumes "a \<notin> Units G" |
|
638 |
and "\<And>b. \<lbrakk>b \<in> carrier G; properfactor G b a\<rbrakk> \<Longrightarrow> b \<in> Units G" |
|
639 |
shows "irreducible G a" |
|
63832 | 640 |
using assms unfolding irreducible_def by blast |
27701 | 641 |
|
642 |
lemma irreducibleE: |
|
643 |
fixes G (structure) |
|
644 |
assumes irr: "irreducible G a" |
|
63832 | 645 |
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" |
27701 | 646 |
shows "P" |
63832 | 647 |
using assms unfolding irreducible_def by blast |
27701 | 648 |
|
649 |
lemma irreducibleD: |
|
650 |
fixes G (structure) |
|
651 |
assumes irr: "irreducible G a" |
|
63832 | 652 |
and pf: "properfactor G b a" |
653 |
and bcarr: "b \<in> carrier G" |
|
27701 | 654 |
shows "b \<in> Units G" |
63832 | 655 |
using assms by (fast elim: irreducibleE) |
27701 | 656 |
|
657 |
lemma (in monoid_cancel) irreducible_cong [trans]: |
|
658 |
assumes irred: "irreducible G a" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
659 |
and aa': "a \<sim> a'" "a \<in> carrier G" "a' \<in> carrier G" |
27701 | 660 |
shows "irreducible G a'" |
63832 | 661 |
using assms |
68478 | 662 |
apply (auto simp: irreducible_def assoc_unit_l) |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
663 |
apply (metis aa' associated_sym properfactor_cong_r) |
63832 | 664 |
done |
27701 | 665 |
|
666 |
lemma (in monoid) irreducible_prod_rI: |
|
667 |
assumes airr: "irreducible G a" |
|
668 |
and bunit: "b \<in> Units G" |
|
669 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
670 |
shows "irreducible G (a \<otimes> b)" |
|
63832 | 671 |
using airr carr bunit |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
672 |
apply (elim irreducibleE, intro irreducibleI) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
673 |
using prod_unit_r apply blast |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
674 |
using associatedI2' properfactor_cong_r by auto |
27701 | 675 |
|
676 |
lemma (in comm_monoid) irreducible_prod_lI: |
|
677 |
assumes birr: "irreducible G b" |
|
678 |
and aunit: "a \<in> Units G" |
|
679 |
and carr [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
680 |
shows "irreducible G (a \<otimes> b)" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
681 |
by (metis aunit birr carr irreducible_prod_rI m_comm) |
27701 | 682 |
|
683 |
lemma (in comm_monoid_cancel) irreducible_prodE [elim]: |
|
684 |
assumes irr: "irreducible G (a \<otimes> b)" |
|
685 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
686 |
and e1: "\<lbrakk>irreducible G a; b \<in> Units G\<rbrakk> \<Longrightarrow> P" |
|
687 |
and e2: "\<lbrakk>a \<in> Units G; irreducible G b\<rbrakk> \<Longrightarrow> P" |
|
63832 | 688 |
shows P |
689 |
using irr |
|
27701 | 690 |
proof (elim irreducibleE) |
691 |
assume abnunit: "a \<otimes> b \<notin> Units G" |
|
692 |
and isunit[rule_format]: "\<forall>ba. ba \<in> carrier G \<and> properfactor G ba (a \<otimes> b) \<longrightarrow> ba \<in> Units G" |
|
63832 | 693 |
show P |
27701 | 694 |
proof (cases "a \<in> Units G") |
63832 | 695 |
case aunit: True |
27701 | 696 |
have "irreducible G b" |
63846 | 697 |
proof (rule irreducibleI, rule notI) |
27701 | 698 |
assume "b \<in> Units G" |
699 |
with aunit have "(a \<otimes> b) \<in> Units G" by fast |
|
700 |
with abnunit show "False" .. |
|
701 |
next |
|
702 |
fix c |
|
703 |
assume ccarr: "c \<in> carrier G" |
|
704 |
and "properfactor G c b" |
|
63832 | 705 |
then have "properfactor G c (a \<otimes> b)" by (simp add: properfactor_prod_l[of c b a]) |
706 |
with ccarr show "c \<in> Units G" by (fast intro: isunit) |
|
27701 | 707 |
qed |
63832 | 708 |
with aunit show "P" by (rule e2) |
27701 | 709 |
next |
63832 | 710 |
case anunit: False |
27701 | 711 |
with carr have "properfactor G b (b \<otimes> a)" by (fast intro: properfactorI3) |
63832 | 712 |
then have bf: "properfactor G b (a \<otimes> b)" by (subst m_comm[of a b], simp+) |
713 |
then have bunit: "b \<in> Units G" by (intro isunit, simp) |
|
27701 | 714 |
|
715 |
have "irreducible G a" |
|
63846 | 716 |
proof (rule irreducibleI, rule notI) |
27701 | 717 |
assume "a \<in> Units G" |
718 |
with bunit have "(a \<otimes> b) \<in> Units G" by fast |
|
719 |
with abnunit show "False" .. |
|
720 |
next |
|
721 |
fix c |
|
722 |
assume ccarr: "c \<in> carrier G" |
|
723 |
and "properfactor G c a" |
|
63832 | 724 |
then have "properfactor G c (a \<otimes> b)" |
725 |
by (simp add: properfactor_prod_r[of c a b]) |
|
726 |
with ccarr show "c \<in> Units G" by (fast intro: isunit) |
|
27701 | 727 |
qed |
728 |
from this bunit show "P" by (rule e1) |
|
729 |
qed |
|
730 |
qed |
|
731 |
||
732 |
||
61382 | 733 |
subsubsection \<open>Prime elements\<close> |
27701 | 734 |
|
735 |
lemma primeI: |
|
736 |
fixes G (structure) |
|
737 |
assumes "p \<notin> Units G" |
|
738 |
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" |
|
739 |
shows "prime G p" |
|
63832 | 740 |
using assms unfolding prime_def by blast |
27701 | 741 |
|
742 |
lemma primeE: |
|
743 |
fixes G (structure) |
|
744 |
assumes pprime: "prime G p" |
|
745 |
and e: "\<lbrakk>p \<notin> Units G; \<forall>a\<in>carrier G. \<forall>b\<in>carrier G. |
|
63832 | 746 |
p divides a \<otimes> b \<longrightarrow> p divides a \<or> p divides b\<rbrakk> \<Longrightarrow> P" |
27701 | 747 |
shows "P" |
63832 | 748 |
using pprime unfolding prime_def by (blast dest: e) |
27701 | 749 |
|
750 |
lemma (in comm_monoid_cancel) prime_divides: |
|
751 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
752 |
and pprime: "prime G p" |
|
753 |
and pdvd: "p divides a \<otimes> b" |
|
754 |
shows "p divides a \<or> p divides b" |
|
63832 | 755 |
using assms by (blast elim: primeE) |
27701 | 756 |
|
757 |
lemma (in monoid_cancel) prime_cong [trans]: |
|
68478 | 758 |
assumes "prime G p" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
759 |
and pp': "p \<sim> p'" "p \<in> carrier G" "p' \<in> carrier G" |
27701 | 760 |
shows "prime G p'" |
68478 | 761 |
using assms |
762 |
apply (auto simp: prime_def assoc_unit_l) |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
763 |
apply (metis pp' associated_sym divides_cong_l) |
63832 | 764 |
done |
765 |
||
68551
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
766 |
(*by Paulo EmÃlio de Vilhena*) |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
767 |
lemma (in comm_monoid_cancel) prime_irreducible: |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
768 |
assumes "prime G p" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
769 |
shows "irreducible G p" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
770 |
proof (rule irreducibleI) |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
771 |
show "p \<notin> Units G" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
772 |
using assms unfolding prime_def by simp |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
773 |
next |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
774 |
fix b assume A: "b \<in> carrier G" "properfactor G b p" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
775 |
then obtain c where c: "c \<in> carrier G" "p = b \<otimes> c" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
776 |
unfolding properfactor_def factor_def by auto |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
777 |
hence "p divides c" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
778 |
using A assms unfolding prime_def properfactor_def by auto |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
779 |
then obtain b' where b': "b' \<in> carrier G" "c = p \<otimes> b'" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
780 |
unfolding factor_def by auto |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
781 |
hence "\<one> = b \<otimes> b'" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
782 |
by (metis A(1) l_cancel m_closed m_lcomm one_closed r_one c) |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
783 |
thus "b \<in> Units G" |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
784 |
using A(1) Units_one_closed b'(1) unit_factor by presburger |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
785 |
qed |
b680e74eb6f2
More on Algebra by Paulo and Martin
paulson <lp15@cam.ac.uk>
parents:
68488
diff
changeset
|
786 |
|
27701 | 787 |
|
61382 | 788 |
subsection \<open>Factorization and Factorial Monoids\<close> |
789 |
||
790 |
subsubsection \<open>Function definitions\<close> |
|
27701 | 791 |
|
63832 | 792 |
definition factors :: "[_, 'a list, 'a] \<Rightarrow> bool" |
67399 | 793 |
where "factors G fs a \<longleftrightarrow> (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (\<otimes>\<^bsub>G\<^esub>) fs \<one>\<^bsub>G\<^esub> = a" |
35847 | 794 |
|
63832 | 795 |
definition wfactors ::"[_, 'a list, 'a] \<Rightarrow> bool" |
67399 | 796 |
where "wfactors G fs a \<longleftrightarrow> (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (\<otimes>\<^bsub>G\<^esub>) fs \<one>\<^bsub>G\<^esub> \<sim>\<^bsub>G\<^esub> a" |
27701 | 797 |
|
63832 | 798 |
abbreviation list_assoc :: "('a,_) monoid_scheme \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "[\<sim>]\<index>" 44) |
67399 | 799 |
where "list_assoc G \<equiv> list_all2 (\<sim>\<^bsub>G\<^esub>)" |
63832 | 800 |
|
801 |
definition essentially_equal :: "[_, 'a list, 'a list] \<Rightarrow> bool" |
|
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
802 |
where "essentially_equal G fs1 fs2 \<longleftrightarrow> (\<exists>fs1'. fs1 <~~> fs1' \<and> fs1' [\<sim>]\<^bsub>G\<^esub> fs2)" |
27701 | 803 |
|
804 |
||
805 |
locale factorial_monoid = comm_monoid_cancel + |
|
63832 | 806 |
assumes factors_exist: "\<lbrakk>a \<in> carrier G; a \<notin> Units G\<rbrakk> \<Longrightarrow> \<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" |
807 |
and factors_unique: |
|
808 |
"\<lbrakk>factors G fs a; factors G fs' a; a \<in> carrier G; a \<notin> Units G; |
|
809 |
set fs \<subseteq> carrier G; set fs' \<subseteq> carrier G\<rbrakk> \<Longrightarrow> essentially_equal G fs fs'" |
|
27701 | 810 |
|
811 |
||
61382 | 812 |
subsubsection \<open>Comparing lists of elements\<close> |
813 |
||
814 |
text \<open>Association on lists\<close> |
|
27701 | 815 |
|
816 |
lemma (in monoid) listassoc_refl [simp, intro]: |
|
817 |
assumes "set as \<subseteq> carrier G" |
|
818 |
shows "as [\<sim>] as" |
|
63832 | 819 |
using assms by (induct as) simp_all |
27701 | 820 |
|
821 |
lemma (in monoid) listassoc_sym [sym]: |
|
822 |
assumes "as [\<sim>] bs" |
|
63832 | 823 |
and "set as \<subseteq> carrier G" |
824 |
and "set bs \<subseteq> carrier G" |
|
27701 | 825 |
shows "bs [\<sim>] as" |
63832 | 826 |
using assms |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
827 |
proof (induction as arbitrary: bs) |
27701 | 828 |
case Cons |
63832 | 829 |
then show ?case |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
830 |
by (induction bs) (use associated_sym in auto) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
831 |
qed auto |
27701 | 832 |
|
833 |
lemma (in monoid) listassoc_trans [trans]: |
|
834 |
assumes "as [\<sim>] bs" and "bs [\<sim>] cs" |
|
835 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" and "set cs \<subseteq> carrier G" |
|
836 |
shows "as [\<sim>] cs" |
|
63832 | 837 |
using assms |
838 |
apply (simp add: list_all2_conv_all_nth set_conv_nth, safe) |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
839 |
by (metis (mono_tags, lifting) associated_trans nth_mem subsetCE) |
27701 | 840 |
|
841 |
lemma (in monoid_cancel) irrlist_listassoc_cong: |
|
842 |
assumes "\<forall>a\<in>set as. irreducible G a" |
|
843 |
and "as [\<sim>] bs" |
|
844 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
845 |
shows "\<forall>a\<in>set bs. irreducible G a" |
|
63832 | 846 |
using assms |
847 |
apply (clarsimp simp add: list_all2_conv_all_nth set_conv_nth) |
|
848 |
apply (blast intro: irreducible_cong) |
|
849 |
done |
|
27701 | 850 |
|
851 |
||
61382 | 852 |
text \<open>Permutations\<close> |
27701 | 853 |
|
854 |
lemma perm_map [intro]: |
|
855 |
assumes p: "a <~~> b" |
|
856 |
shows "map f a <~~> map f b" |
|
63832 | 857 |
using p by induct auto |
27701 | 858 |
|
859 |
lemma perm_map_switch: |
|
860 |
assumes m: "map f a = map f b" and p: "b <~~> c" |
|
861 |
shows "\<exists>d. a <~~> d \<and> map f d = map f c" |
|
63832 | 862 |
using p m by (induct arbitrary: a) (simp, force, force, blast) |
27701 | 863 |
|
864 |
lemma (in monoid) perm_assoc_switch: |
|
63832 | 865 |
assumes a:"as [\<sim>] bs" and p: "bs <~~> cs" |
866 |
shows "\<exists>bs'. as <~~> bs' \<and> bs' [\<sim>] cs" |
|
867 |
using p a |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
868 |
proof (induction bs cs arbitrary: as) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
869 |
case (swap y x l) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
870 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
871 |
by (metis (no_types, hide_lams) list_all2_Cons2 perm.swap) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
872 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
873 |
case (Cons xs ys z) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
874 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
875 |
by (metis list_all2_Cons2 perm.Cons) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
876 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
877 |
case (trans xs ys zs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
878 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
879 |
by (meson perm.trans) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
880 |
qed auto |
27701 | 881 |
|
882 |
lemma (in monoid) perm_assoc_switch_r: |
|
63832 | 883 |
assumes p: "as <~~> bs" and a:"bs [\<sim>] cs" |
884 |
shows "\<exists>bs'. as [\<sim>] bs' \<and> bs' <~~> cs" |
|
885 |
using p a |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
886 |
proof (induction as bs arbitrary: cs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
887 |
case Nil |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
888 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
889 |
by auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
890 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
891 |
case (swap y x l) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
892 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
893 |
by (metis (no_types, hide_lams) list_all2_Cons1 perm.swap) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
894 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
895 |
case (Cons xs ys z) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
896 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
897 |
by (metis list_all2_Cons1 perm.Cons) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
898 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
899 |
case (trans xs ys zs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
900 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
901 |
by (blast intro: elim: ) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
902 |
qed |
27701 | 903 |
|
904 |
declare perm_sym [sym] |
|
905 |
||
906 |
lemma perm_setP: |
|
907 |
assumes perm: "as <~~> bs" |
|
908 |
and as: "P (set as)" |
|
909 |
shows "P (set bs)" |
|
910 |
proof - |
|
63832 | 911 |
from perm have "mset as = mset bs" |
912 |
by (simp add: mset_eq_perm) |
|
913 |
then have "set as = set bs" |
|
914 |
by (rule mset_eq_setD) |
|
915 |
with as show "P (set bs)" |
|
916 |
by simp |
|
27701 | 917 |
qed |
918 |
||
63832 | 919 |
lemmas (in monoid) perm_closed = perm_setP[of _ _ "\<lambda>as. as \<subseteq> carrier G"] |
920 |
||
921 |
lemmas (in monoid) irrlist_perm_cong = perm_setP[of _ _ "\<lambda>as. \<forall>a\<in>as. irreducible G a"] |
|
27701 | 922 |
|
923 |
||
61382 | 924 |
text \<open>Essentially equal factorizations\<close> |
27701 | 925 |
|
926 |
lemma (in monoid) essentially_equalI: |
|
927 |
assumes ex: "fs1 <~~> fs1'" "fs1' [\<sim>] fs2" |
|
928 |
shows "essentially_equal G fs1 fs2" |
|
63832 | 929 |
using ex unfolding essentially_equal_def by fast |
27701 | 930 |
|
931 |
lemma (in monoid) essentially_equalE: |
|
932 |
assumes ee: "essentially_equal G fs1 fs2" |
|
933 |
and e: "\<And>fs1'. \<lbrakk>fs1 <~~> fs1'; fs1' [\<sim>] fs2\<rbrakk> \<Longrightarrow> P" |
|
934 |
shows "P" |
|
63832 | 935 |
using ee unfolding essentially_equal_def by (fast intro: e) |
27701 | 936 |
|
937 |
lemma (in monoid) ee_refl [simp,intro]: |
|
938 |
assumes carr: "set as \<subseteq> carrier G" |
|
939 |
shows "essentially_equal G as as" |
|
63832 | 940 |
using carr by (fast intro: essentially_equalI) |
27701 | 941 |
|
942 |
lemma (in monoid) ee_sym [sym]: |
|
943 |
assumes ee: "essentially_equal G as bs" |
|
944 |
and carr: "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
945 |
shows "essentially_equal G bs as" |
|
63832 | 946 |
using ee |
27701 | 947 |
proof (elim essentially_equalE) |
948 |
fix fs |
|
949 |
assume "as <~~> fs" "fs [\<sim>] bs" |
|
63847 | 950 |
from perm_assoc_switch_r [OF this] obtain fs' where a: "as [\<sim>] fs'" and p: "fs' <~~> bs" |
951 |
by blast |
|
27701 | 952 |
from p have "bs <~~> fs'" by (rule perm_sym) |
63832 | 953 |
with a[symmetric] carr show ?thesis |
954 |
by (iprover intro: essentially_equalI perm_closed) |
|
27701 | 955 |
qed |
956 |
||
957 |
lemma (in monoid) ee_trans [trans]: |
|
958 |
assumes ab: "essentially_equal G as bs" and bc: "essentially_equal G bs cs" |
|
63832 | 959 |
and ascarr: "set as \<subseteq> carrier G" |
27701 | 960 |
and bscarr: "set bs \<subseteq> carrier G" |
961 |
and cscarr: "set cs \<subseteq> carrier G" |
|
962 |
shows "essentially_equal G as cs" |
|
63832 | 963 |
using ab bc |
27701 | 964 |
proof (elim essentially_equalE) |
965 |
fix abs bcs |
|
63847 | 966 |
assume "abs [\<sim>] bs" and pb: "bs <~~> bcs" |
967 |
from perm_assoc_switch [OF this] obtain bs' where p: "abs <~~> bs'" and a: "bs' [\<sim>] bcs" |
|
968 |
by blast |
|
27701 | 969 |
assume "as <~~> abs" |
63832 | 970 |
with p have pp: "as <~~> bs'" by fast |
27701 | 971 |
from pp ascarr have c1: "set bs' \<subseteq> carrier G" by (rule perm_closed) |
972 |
from pb bscarr have c2: "set bcs \<subseteq> carrier G" by (rule perm_closed) |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
973 |
assume "bcs [\<sim>] cs" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
974 |
then have "bs' [\<sim>] cs" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
975 |
using a c1 c2 cscarr listassoc_trans by blast |
63832 | 976 |
with pp show ?thesis |
977 |
by (rule essentially_equalI) |
|
27701 | 978 |
qed |
979 |
||
980 |
||
61382 | 981 |
subsubsection \<open>Properties of lists of elements\<close> |
982 |
||
983 |
text \<open>Multiplication of factors in a list\<close> |
|
27701 | 984 |
|
985 |
lemma (in monoid) multlist_closed [simp, intro]: |
|
986 |
assumes ascarr: "set fs \<subseteq> carrier G" |
|
67399 | 987 |
shows "foldr (\<otimes>) fs \<one> \<in> carrier G" |
63832 | 988 |
using ascarr by (induct fs) simp_all |
27701 | 989 |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
990 |
lemma (in comm_monoid) multlist_dividesI: |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
991 |
assumes "f \<in> set fs" and "set fs \<subseteq> carrier G" |
67399 | 992 |
shows "f divides (foldr (\<otimes>) fs \<one>)" |
63832 | 993 |
using assms |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
994 |
proof (induction fs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
995 |
case (Cons a fs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
996 |
then have f: "f \<in> carrier G" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
997 |
by blast |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
998 |
show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
999 |
proof (cases "f = a") |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1000 |
case True |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1001 |
then show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1002 |
using Cons.prems by auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1003 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1004 |
case False |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1005 |
with Cons show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1006 |
by clarsimp (metis f divides_prod_l multlist_closed) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1007 |
qed |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1008 |
qed auto |
27701 | 1009 |
|
1010 |
lemma (in comm_monoid_cancel) multlist_listassoc_cong: |
|
1011 |
assumes "fs [\<sim>] fs'" |
|
1012 |
and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G" |
|
67399 | 1013 |
shows "foldr (\<otimes>) fs \<one> \<sim> foldr (\<otimes>) fs' \<one>" |
63832 | 1014 |
using assms |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1015 |
proof (induct fs arbitrary: fs') |
27701 | 1016 |
case (Cons a as fs') |
63832 | 1017 |
then show ?case |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1018 |
proof (induction fs') |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1019 |
case (Cons b bs) |
67399 | 1020 |
then have p: "a \<otimes> foldr (\<otimes>) as \<one> \<sim> b \<otimes> foldr (\<otimes>) as \<one>" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1021 |
by (simp add: mult_cong_l) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1022 |
then have "foldr (\<otimes>) as \<one> \<sim> foldr (\<otimes>) bs \<one>" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1023 |
using Cons by auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1024 |
with Cons have "b \<otimes> foldr (\<otimes>) as \<one> \<sim> b \<otimes> foldr (\<otimes>) bs \<one>" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1025 |
by (simp add: mult_cong_r) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1026 |
then show ?case |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1027 |
using Cons.prems(3) Cons.prems(4) monoid.associated_trans monoid_axioms p by force |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1028 |
qed auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1029 |
qed auto |
27701 | 1030 |
|
1031 |
lemma (in comm_monoid) multlist_perm_cong: |
|
1032 |
assumes prm: "as <~~> bs" |
|
1033 |
and ascarr: "set as \<subseteq> carrier G" |
|
67399 | 1034 |
shows "foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>" |
63832 | 1035 |
using prm ascarr |
68478 | 1036 |
proof induction |
1037 |
case (swap y x l) then show ?case |
|
1038 |
by (simp add: m_lcomm) |
|
1039 |
next |
|
1040 |
case (trans xs ys zs) then show ?case |
|
1041 |
using perm_closed by auto |
|
1042 |
qed auto |
|
27701 | 1043 |
|
1044 |
lemma (in comm_monoid_cancel) multlist_ee_cong: |
|
1045 |
assumes "essentially_equal G fs fs'" |
|
1046 |
and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G" |
|
67399 | 1047 |
shows "foldr (\<otimes>) fs \<one> \<sim> foldr (\<otimes>) fs' \<one>" |
63832 | 1048 |
using assms |
1049 |
apply (elim essentially_equalE) |
|
1050 |
apply (simp add: multlist_perm_cong multlist_listassoc_cong perm_closed) |
|
1051 |
done |
|
27701 | 1052 |
|
1053 |
||
61382 | 1054 |
subsubsection \<open>Factorization in irreducible elements\<close> |
27701 | 1055 |
|
1056 |
lemma wfactorsI: |
|
28599 | 1057 |
fixes G (structure) |
27701 | 1058 |
assumes "\<forall>f\<in>set fs. irreducible G f" |
67399 | 1059 |
and "foldr (\<otimes>) fs \<one> \<sim> a" |
27701 | 1060 |
shows "wfactors G fs a" |
63832 | 1061 |
using assms unfolding wfactors_def by simp |
27701 | 1062 |
|
1063 |
lemma wfactorsE: |
|
28599 | 1064 |
fixes G (structure) |
27701 | 1065 |
assumes wf: "wfactors G fs a" |
67399 | 1066 |
and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (\<otimes>) fs \<one> \<sim> a\<rbrakk> \<Longrightarrow> P" |
27701 | 1067 |
shows "P" |
63832 | 1068 |
using wf unfolding wfactors_def by (fast dest: e) |
27701 | 1069 |
|
1070 |
lemma (in monoid) factorsI: |
|
1071 |
assumes "\<forall>f\<in>set fs. irreducible G f" |
|
67399 | 1072 |
and "foldr (\<otimes>) fs \<one> = a" |
27701 | 1073 |
shows "factors G fs a" |
63832 | 1074 |
using assms unfolding factors_def by simp |
27701 | 1075 |
|
1076 |
lemma factorsE: |
|
28599 | 1077 |
fixes G (structure) |
27701 | 1078 |
assumes f: "factors G fs a" |
67399 | 1079 |
and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (\<otimes>) fs \<one> = a\<rbrakk> \<Longrightarrow> P" |
27701 | 1080 |
shows "P" |
63832 | 1081 |
using f unfolding factors_def by (simp add: e) |
27701 | 1082 |
|
1083 |
lemma (in monoid) factors_wfactors: |
|
1084 |
assumes "factors G as a" and "set as \<subseteq> carrier G" |
|
1085 |
shows "wfactors G as a" |
|
63832 | 1086 |
using assms by (blast elim: factorsE intro: wfactorsI) |
27701 | 1087 |
|
1088 |
lemma (in monoid) wfactors_factors: |
|
1089 |
assumes "wfactors G as a" and "set as \<subseteq> carrier G" |
|
1090 |
shows "\<exists>a'. factors G as a' \<and> a' \<sim> a" |
|
63832 | 1091 |
using assms by (blast elim: wfactorsE intro: factorsI) |
27701 | 1092 |
|
1093 |
lemma (in monoid) factors_closed [dest]: |
|
1094 |
assumes "factors G fs a" and "set fs \<subseteq> carrier G" |
|
1095 |
shows "a \<in> carrier G" |
|
63832 | 1096 |
using assms by (elim factorsE, clarsimp) |
27701 | 1097 |
|
1098 |
lemma (in monoid) nunit_factors: |
|
1099 |
assumes anunit: "a \<notin> Units G" |
|
1100 |
and fs: "factors G as a" |
|
1101 |
shows "length as > 0" |
|
46129 | 1102 |
proof - |
1103 |
from anunit Units_one_closed have "a \<noteq> \<one>" by auto |
|
1104 |
with fs show ?thesis by (auto elim: factorsE) |
|
1105 |
qed |
|
27701 | 1106 |
|
1107 |
lemma (in monoid) unit_wfactors [simp]: |
|
1108 |
assumes aunit: "a \<in> Units G" |
|
1109 |
shows "wfactors G [] a" |
|
63832 | 1110 |
using aunit by (intro wfactorsI) (simp, simp add: Units_assoc) |
27701 | 1111 |
|
1112 |
lemma (in comm_monoid_cancel) unit_wfactors_empty: |
|
1113 |
assumes aunit: "a \<in> Units G" |
|
1114 |
and wf: "wfactors G fs a" |
|
1115 |
and carr[simp]: "set fs \<subseteq> carrier G" |
|
1116 |
shows "fs = []" |
|
63846 | 1117 |
proof (cases fs) |
1118 |
case Nil |
|
1119 |
then show ?thesis . |
|
1120 |
next |
|
1121 |
case fs: (Cons f fs') |
|
63832 | 1122 |
from carr have fcarr[simp]: "f \<in> carrier G" and carr'[simp]: "set fs' \<subseteq> carrier G" |
1123 |
by (simp_all add: fs) |
|
1124 |
||
1125 |
from fs wf have "irreducible G f" by (simp add: wfactors_def) |
|
1126 |
then have fnunit: "f \<notin> Units G" by (fast elim: irreducibleE) |
|
1127 |
||
67399 | 1128 |
from fs wf have a: "f \<otimes> foldr (\<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def) |
27701 | 1129 |
|
1130 |
note aunit |
|
1131 |
also from fs wf |
|
67399 | 1132 |
have a: "f \<otimes> foldr (\<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def) |
1133 |
have "a \<sim> f \<otimes> foldr (\<otimes>) fs' \<one>" |
|
63832 | 1134 |
by (simp add: Units_closed[OF aunit] a[symmetric]) |
67399 | 1135 |
finally have "f \<otimes> foldr (\<otimes>) fs' \<one> \<in> Units G" by simp |
63832 | 1136 |
then have "f \<in> Units G" by (intro unit_factor[of f], simp+) |
63846 | 1137 |
with fnunit show ?thesis by contradiction |
27701 | 1138 |
qed |
1139 |
||
1140 |
||
61382 | 1141 |
text \<open>Comparing wfactors\<close> |
27701 | 1142 |
|
1143 |
lemma (in comm_monoid_cancel) wfactors_listassoc_cong_l: |
|
1144 |
assumes fact: "wfactors G fs a" |
|
1145 |
and asc: "fs [\<sim>] fs'" |
|
1146 |
and carr: "a \<in> carrier G" "set fs \<subseteq> carrier G" "set fs' \<subseteq> carrier G" |
|
1147 |
shows "wfactors G fs' a" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1148 |
proof - |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1149 |
{ from asc[symmetric] have "foldr (\<otimes>) fs' \<one> \<sim> foldr (\<otimes>) fs \<one>" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1150 |
by (simp add: multlist_listassoc_cong carr) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1151 |
also assume "foldr (\<otimes>) fs \<one> \<sim> a" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1152 |
finally have "foldr (\<otimes>) fs' \<one> \<sim> a" by (simp add: carr) } |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1153 |
then show ?thesis |
63832 | 1154 |
using fact |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1155 |
by (meson asc carr(2) carr(3) irrlist_listassoc_cong wfactors_def) |
27701 | 1156 |
qed |
1157 |
||
1158 |
lemma (in comm_monoid) wfactors_perm_cong_l: |
|
1159 |
assumes "wfactors G fs a" |
|
1160 |
and "fs <~~> fs'" |
|
1161 |
and "set fs \<subseteq> carrier G" |
|
1162 |
shows "wfactors G fs' a" |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1163 |
using assms irrlist_perm_cong multlist_perm_cong wfactors_def by fastforce |
27701 | 1164 |
|
1165 |
lemma (in comm_monoid_cancel) wfactors_ee_cong_l [trans]: |
|
1166 |
assumes ee: "essentially_equal G as bs" |
|
1167 |
and bfs: "wfactors G bs b" |
|
1168 |
and carr: "b \<in> carrier G" "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1169 |
shows "wfactors G as b" |
|
63832 | 1170 |
using ee |
27701 | 1171 |
proof (elim essentially_equalE) |
1172 |
fix fs |
|
1173 |
assume prm: "as <~~> fs" |
|
63832 | 1174 |
with carr have fscarr: "set fs \<subseteq> carrier G" by (simp add: perm_closed) |
27701 | 1175 |
|
1176 |
note bfs |
|
1177 |
also assume [symmetric]: "fs [\<sim>] bs" |
|
1178 |
also (wfactors_listassoc_cong_l) |
|
63832 | 1179 |
note prm[symmetric] |
27701 | 1180 |
finally (wfactors_perm_cong_l) |
63832 | 1181 |
show "wfactors G as b" by (simp add: carr fscarr) |
27701 | 1182 |
qed |
1183 |
||
1184 |
lemma (in monoid) wfactors_cong_r [trans]: |
|
1185 |
assumes fac: "wfactors G fs a" and aa': "a \<sim> a'" |
|
1186 |
and carr[simp]: "a \<in> carrier G" "a' \<in> carrier G" "set fs \<subseteq> carrier G" |
|
1187 |
shows "wfactors G fs a'" |
|
63832 | 1188 |
using fac |
27701 | 1189 |
proof (elim wfactorsE, intro wfactorsI) |
67399 | 1190 |
assume "foldr (\<otimes>) fs \<one> \<sim> a" also note aa' |
1191 |
finally show "foldr (\<otimes>) fs \<one> \<sim> a'" by simp |
|
27701 | 1192 |
qed |
1193 |
||
1194 |
||
61382 | 1195 |
subsubsection \<open>Essentially equal factorizations\<close> |
27701 | 1196 |
|
1197 |
lemma (in comm_monoid_cancel) unitfactor_ee: |
|
1198 |
assumes uunit: "u \<in> Units G" |
|
1199 |
and carr: "set as \<subseteq> carrier G" |
|
63832 | 1200 |
shows "essentially_equal G (as[0 := (as!0 \<otimes> u)]) as" |
1201 |
(is "essentially_equal G ?as' as") |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1202 |
proof - |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1203 |
have "as[0 := as ! 0 \<otimes> u] [\<sim>] as" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1204 |
proof (cases as) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1205 |
case (Cons a as') |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1206 |
then show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1207 |
using associatedI2 carr uunit by auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1208 |
qed auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1209 |
then show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1210 |
using essentially_equal_def by blast |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1211 |
qed |
27701 | 1212 |
|
1213 |
lemma (in comm_monoid_cancel) factors_cong_unit: |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1214 |
assumes u: "u \<in> Units G" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1215 |
and a: "a \<notin> Units G" |
27701 | 1216 |
and afs: "factors G as a" |
1217 |
and ascarr: "set as \<subseteq> carrier G" |
|
63832 | 1218 |
shows "factors G (as[0 := (as!0 \<otimes> u)]) (a \<otimes> u)" |
1219 |
(is "factors G ?as' ?a'") |
|
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1220 |
proof (cases as) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1221 |
case Nil |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1222 |
then show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1223 |
using afs a nunit_factors by auto |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1224 |
next |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1225 |
case (Cons b bs) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1226 |
have *: "\<forall>f\<in>set as. irreducible G f" "foldr (\<otimes>) as \<one> = a" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1227 |
using afs by (auto simp: factors_def) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1228 |
show ?thesis |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1229 |
proof (intro factorsI) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1230 |
show "foldr (\<otimes>) (as[0 := as ! 0 \<otimes> u]) \<one> = a \<otimes> u" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1231 |
using Cons u ascarr * by (auto simp add: m_ac Units_closed) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1232 |
show "\<forall>f\<in>set (as[0 := as ! 0 \<otimes> u]). irreducible G f" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1233 |
using Cons u ascarr * by (force intro: irreducible_prod_rI) |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1234 |
qed |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1235 |
qed |
27701 | 1236 |
|
1237 |
lemma (in comm_monoid) perm_wfactorsD: |
|
1238 |
assumes prm: "as <~~> bs" |
|
63832 | 1239 |
and afs: "wfactors G as a" |
1240 |
and bfs: "wfactors G bs b" |
|
27701 | 1241 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
63832 | 1242 |
and ascarr [simp]: "set as \<subseteq> carrier G" |
27701 | 1243 |
shows "a \<sim> b" |
63832 | 1244 |
using afs bfs |
27701 | 1245 |
proof (elim wfactorsE) |
1246 |
from prm have [simp]: "set bs \<subseteq> carrier G" by (simp add: perm_closed) |
|
67399 | 1247 |
assume "foldr (\<otimes>) as \<one> \<sim> a" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1248 |
then have "a \<sim> foldr (\<otimes>) as \<one>" |
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1249 |
by (simp add: associated_sym) |
27701 | 1250 |
also from prm |
67399 | 1251 |
have "foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>" by (rule multlist_perm_cong, simp) |
1252 |
also assume "foldr (\<otimes>) bs \<one> \<sim> b" |
|
63832 | 1253 |
finally show "a \<sim> b" by simp |
27701 | 1254 |
qed |
1255 |
||
1256 |
lemma (in comm_monoid_cancel) listassoc_wfactorsD: |
|
1257 |
assumes assoc: "as [\<sim>] bs" |
|
63832 | 1258 |
and afs: "wfactors G as a" |
1259 |
and bfs: "wfactors G bs b" |
|
27701 | 1260 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
1261 |
and [simp]: "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1262 |
shows "a \<sim> b" |
|
63832 | 1263 |
using afs bfs |
27701 | 1264 |
proof (elim wfactorsE) |
67399 | 1265 |
assume "foldr (\<otimes>) as \<one> \<sim> a" |
68470
7ddcce75c3ee
Partial de-apply of Divisibility
paulson <lp15@cam.ac.uk>
parents:
68399
diff
changeset
|
1266 |
then have "a \<sim> foldr (\<otimes>) as \<one>" by (simp add: associated_sym) |
27701 | 1267 |
also from assoc |
67399 | 1268 |
have "foldr (\<otimes>) as \<one> \<sim> foldr (\<otimes>) bs \<one>" by (rule multlist_listassoc_cong, simp+) |
1269 |
also assume "foldr (\<otimes>) bs \<one> \<sim> b" |
|
63832 | 1270 |
finally show "a \<sim> b" by simp |
27701 | 1271 |
qed |
1272 |
||
1273 |
lemma (in comm_monoid_cancel) ee_wfactorsD: |
|
1274 |
assumes ee: "essentially_equal G as bs" |
|
1275 |
and afs: "wfactors G as a" and bfs: "wfactors G bs b" |
|
1276 |
and [simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
1277 |
and ascarr[simp]: "set as \<subseteq> carrier G" and bscarr[simp]: "set bs \<subseteq> carrier G" |
|
1278 |
shows "a \<sim> b" |
|
63832 | 1279 |
using ee |
27701 | 1280 |
proof (elim essentially_equalE) |
1281 |
fix fs |
|
1282 |
assume prm: "as <~~> fs" |
|
63832 | 1283 |
then have as'carr[simp]: "set fs \<subseteq> carrier G" |
1284 |
by (simp add: perm_closed) |
|
1285 |
from afs prm have afs': "wfactors G fs a" |
|
1286 |
by (rule wfactors_perm_cong_l) simp |
|
27701 | 1287 |
assume "fs [\<sim>] bs" |
63832 | 1288 |
from this afs' bfs show "a \<sim> b" |
1289 |
by (rule listassoc_wfactorsD) simp_all |
|
27701 | 1290 |
qed |
1291 |
||
1292 |
lemma (in comm_monoid_cancel) ee_factorsD: |
|
1293 |
assumes ee: "essentially_equal G as bs" |
|
1294 |
and afs: "factors G as a" and bfs:"factors G bs b" |
|
1295 |
and "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
|
1296 |
shows "a \<sim> b" |
|
63832 | 1297 |
using assms by (blast intro: factors_wfactors dest: ee_wfactorsD) |
27701 | 1298 |
|
1299 |
lemma (in factorial_monoid) ee_factorsI: |
|
1300 |
assumes ab: "a \<sim> b" |
|
1301 |
and afs: "factors G as a" and anunit: "a \<notin> Units G" |
|
1302 |
and bfs: "factors G bs b" and bnunit: "b \<notin> Units G" |
|
1303 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1304 |
shows "essentially_equal G as bs" |
|
1305 |
proof - |
|
1306 |
note carr[simp] = factors_closed[OF afs ascarr] ascarr[THEN subsetD] |
|
63832 | 1307 |
factors_closed[OF bfs bscarr] bscarr[THEN subsetD] |
1308 |
||
63847 | 1309 |
from ab carr obtain u where uunit: "u \<in> Units G" and a: "a = b \<otimes> u" |
1310 |
by (elim associatedE2) |
|
63832 | 1311 |
|
1312 |
from uunit bscarr have ee: "essentially_equal G (bs[0 := (bs!0 \<otimes> u)]) bs" |
|
1313 |
(is "essentially_equal G ?bs' bs") |
|
1314 |
by (rule unitfactor_ee) |
|
1315 |
||
1316 |
from bscarr uunit have bs'carr: "set ?bs' \<subseteq> carrier G" |
|
1317 |
by (cases bs) (simp_all add: Units_closed) |
|
1318 |
||
1319 |
from uunit bnunit bfs bscarr have fac: "factors G ?bs' (b \<otimes> u)" |
|
1320 |
by (rule factors_cong_unit) |
|
27701 | 1321 |
|
1322 |
from afs fac[simplified a[symmetric]] ascarr bs'carr anunit |
|
63832 | 1323 |
have "essentially_equal G as ?bs'" |
1324 |
by (blast intro: factors_unique) |
|
27701 | 1325 |
also note ee |
63832 | 1326 |
finally show "essentially_equal G as bs" |
1327 |
by (simp add: ascarr bscarr bs'carr) |
|
27701 | 1328 |
qed |
1329 |
||
1330 |
lemma (in factorial_monoid) ee_wfactorsI: |
|
1331 |
assumes asc: "a \<sim> b" |
|
1332 |
and asf: "wfactors G as a" and bsf: "wfactors G bs b" |
|
1333 |
and acarr[simp]: "a \<in> carrier G" and bcarr[simp]: "b \<in> carrier G" |
|
1334 |
and ascarr[simp]: "set as \<subseteq> carrier G" and bscarr[simp]: "set bs \<subseteq> carrier G" |
|
1335 |
shows "essentially_equal G as bs" |
|
63832 | 1336 |
using assms |
27701 | 1337 |
proof (cases "a \<in> Units G") |
63832 | 1338 |
case aunit: True |
27701 | 1339 |
also note asc |
1340 |
finally have bunit: "b \<in> Units G" by simp |
|
1341 |
||
63832 | 1342 |
from aunit asf ascarr have e: "as = []" |
1343 |
by (rule unit_wfactors_empty) |
|
1344 |
from bunit bsf bscarr have e': "bs = []" |
|
1345 |
by (rule unit_wfactors_empty) |
|
27701 | 1346 |
|
1347 |
have "essentially_equal G [] []" |
|
63832 | 1348 |
by (fast intro: essentially_equalI) |
1349 |
then show ?thesis |
|
1350 |
by (simp add: e e') |
|
27701 | 1351 |
next |
63832 | 1352 |
case anunit: False |
27701 | 1353 |
have bnunit: "b \<notin> Units G" |
1354 |
proof clarify |
|
1355 |
assume "b \<in> Units G" |
|
1356 |
also note asc[symmetric] |
|
1357 |
finally have "a \<in> Units G" by simp |
|
63832 | 1358 |
with anunit show False .. |
27701 | 1359 |
qed |
1360 |
||
63847 | 1361 |
from wfactors_factors[OF asf ascarr] obtain a' where fa': "factors G as a'" and a': "a' \<sim> a" |
1362 |
by blast |
|
63832 | 1363 |
from fa' ascarr have a'carr[simp]: "a' \<in> carrier G" |
1364 |
by fast |
|
27701 | 1365 |
|
1366 |
have a'nunit: "a' \<notin> Units G" |
|
63832 | 1367 |
proof clarify |
27701 | 1368 |
assume "a' \<in> Units G" |
1369 |
also note a' |
|
1370 |
finally have "a \<in> Units G" by simp |
|
1371 |
with anunit |
|
63832 | 1372 |
show "False" .. |
27701 | 1373 |
qed |
1374 |
||
63847 | 1375 |
from wfactors_factors[OF bsf bscarr] obtain b' where fb': "factors G bs b'" and b': "b' \<sim> b" |
1376 |
by blast |
|
63832 | 1377 |
from fb' bscarr have b'carr[simp]: "b' \<in> carrier G" |
1378 |
by fast |
|
27701 | 1379 |
|
1380 |
have b'nunit: "b' \<notin> Units G" |
|
63832 | 1381 |
proof clarify |
27701 | 1382 |
assume "b' \<in> Units G" |
1383 |
also note b' |
|
1384 |
finally have "b \<in> Units G" by simp |
|
63832 | 1385 |
with bnunit show False .. |
27701 | 1386 |
qed |
1387 |
||
1388 |
note a' |
|
1389 |
also note asc |
|
1390 |
also note b'[symmetric] |
|
63832 | 1391 |
finally have "a' \<sim> b'" by simp |
1392 |
from this fa' a'nunit fb' b'nunit ascarr bscarr show "essentially_equal G as bs" |
|
1393 |
by (rule ee_factorsI) |
|
27701 | 1394 |
qed |
1395 |
||
1396 |
lemma (in factorial_monoid) ee_wfactors: |
|
1397 |
assumes asf: "wfactors G as a" |
|
1398 |
and bsf: "wfactors G bs b" |
|
1399 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1400 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1401 |
shows asc: "a \<sim> b = essentially_equal G as bs" |
|
63832 | 1402 |
using assms by (fast intro: ee_wfactorsI ee_wfactorsD) |
27701 | 1403 |
|
1404 |
lemma (in factorial_monoid) wfactors_exist [intro, simp]: |
|
1405 |
assumes acarr[simp]: "a \<in> carrier G" |
|
1406 |
shows "\<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs a" |
|
1407 |
proof (cases "a \<in> Units G") |
|
63832 | 1408 |
case True |
1409 |
then have "wfactors G [] a" by (rule unit_wfactors) |
|
1410 |
then show ?thesis by (intro exI) force |
|
27701 | 1411 |
next |
63832 | 1412 |
case False |
63847 | 1413 |
with factors_exist [OF acarr] obtain fs where fscarr: "set fs \<subseteq> carrier G" and f: "factors G fs a" |
1414 |
by blast |
|
27701 | 1415 |
from f have "wfactors G fs a" by (rule factors_wfactors) fact |
63832 | 1416 |
with fscarr show ?thesis by fast |
27701 | 1417 |
qed |
1418 |
||
1419 |
lemma (in monoid) wfactors_prod_exists [intro, simp]: |
|
1420 |
assumes "\<forall>a \<in> set as. irreducible G a" and "set as \<subseteq> carrier G" |
|
1421 |
shows "\<exists>a. a \<in> carrier G \<and> wfactors G as a" |
|
63832 | 1422 |
unfolding wfactors_def using assms by blast |
27701 | 1423 |
|
1424 |
lemma (in factorial_monoid) wfactors_unique: |
|
63832 | 1425 |
assumes "wfactors G fs a" |
1426 |
and "wfactors G fs' a" |
|
27701 | 1427 |
and "a \<in> carrier G" |
63832 | 1428 |
and "set fs \<subseteq> carrier G" |
1429 |
and "set fs' \<subseteq> carrier G" |
|
27701 | 1430 |
shows "essentially_equal G fs fs'" |
63832 | 1431 |
using assms by (fast intro: ee_wfactorsI[of a a]) |
27701 | 1432 |
|
1433 |
lemma (in monoid) factors_mult_single: |
|
1434 |
assumes "irreducible G a" and "factors G fb b" and "a \<in> carrier G" |
|
1435 |
shows "factors G (a # fb) (a \<otimes> b)" |
|
63832 | 1436 |
using assms unfolding factors_def by simp |
27701 | 1437 |
|
1438 |
lemma (in monoid_cancel) wfactors_mult_single: |
|
1439 |
assumes f: "irreducible G a" "wfactors G fb b" |
|
63832 | 1440 |
"a \<in> carrier G" "b \<in> carrier G" "set fb \<subseteq> carrier G" |
27701 | 1441 |
shows "wfactors G (a # fb) (a \<otimes> b)" |
63832 | 1442 |
using assms unfolding wfactors_def by (simp add: mult_cong_r) |
27701 | 1443 |
|
1444 |
lemma (in monoid) factors_mult: |
|
1445 |
assumes factors: "factors G fa a" "factors G fb b" |
|
63832 | 1446 |
and ascarr: "set fa \<subseteq> carrier G" |
1447 |
and bscarr: "set fb \<subseteq> carrier G" |
|
27701 | 1448 |
shows "factors G (fa @ fb) (a \<otimes> b)" |
68474 | 1449 |
proof - |
1450 |
have "foldr (\<otimes>) (fa @ fb) \<one> = foldr (\<otimes>) fa \<one> \<otimes> foldr (\<otimes>) fb \<one>" if "set fa \<subseteq> carrier G" |
|
1451 |
"Ball (set fa) (irreducible G)" |
|
1452 |
using that bscarr by (induct fa) (simp_all add: m_assoc) |
|
1453 |
then show ?thesis |
|
1454 |
using assms unfolding factors_def by force |
|
1455 |
qed |
|
27701 | 1456 |
|
1457 |
lemma (in comm_monoid_cancel) wfactors_mult [intro]: |
|
1458 |
assumes asf: "wfactors G as a" and bsf:"wfactors G bs b" |
|
1459 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1460 |
and ascarr: "set as \<subseteq> carrier G" and bscarr:"set bs \<subseteq> carrier G" |
|
1461 |
shows "wfactors G (as @ bs) (a \<otimes> b)" |
|
63832 | 1462 |
using wfactors_factors[OF asf ascarr] and wfactors_factors[OF bsf bscarr] |
1463 |
proof clarsimp |
|
27701 | 1464 |
fix a' b' |
1465 |
assume asf': "factors G as a'" and a'a: "a' \<sim> a" |
|
63832 | 1466 |
and bsf': "factors G bs b'" and b'b: "b' \<sim> b" |
27701 | 1467 |
from asf' have a'carr: "a' \<in> carrier G" by (rule factors_closed) fact |
1468 |
from bsf' have b'carr: "b' \<in> carrier G" by (rule factors_closed) fact |
|
1469 |
||
1470 |
note carr = acarr bcarr a'carr b'carr ascarr bscarr |
|
1471 |
||
63832 | 1472 |
from asf' bsf' have "factors G (as @ bs) (a' \<otimes> b')" |
1473 |
by (rule factors_mult) fact+ |
|
1474 |
||
1475 |
with carr have abf': "wfactors G (as @ bs) (a' \<otimes> b')" |
|
1476 |
by (intro factors_wfactors) simp_all |
|
1477 |
also from b'b carr have trb: "a' \<otimes> b' \<sim> a' \<otimes> b" |
|
1478 |
by (intro mult_cong_r) |
|
1479 |
also from a'a carr have tra: "a' \<otimes> b \<sim> a \<otimes> b" |
|
1480 |
by (intro mult_cong_l) |
|
1481 |
finally show "wfactors G (as @ bs) (a \<otimes> b)" |
|
1482 |
by (simp add: carr) |
|
27701 | 1483 |
qed |
1484 |
||
1485 |
lemma (in comm_monoid) factors_dividesI: |
|
63832 | 1486 |
assumes "factors G fs a" |
1487 |
and "f \<in> set fs" |
|
27701 | 1488 |
and "set fs \<subseteq> carrier G" |
1489 |
shows "f divides a" |
|
63832 | 1490 |
using assms by (fast elim: factorsE intro: multlist_dividesI) |
27701 | 1491 |
|
1492 |
lemma (in comm_monoid) wfactors_dividesI: |
|
1493 |
assumes p: "wfactors G fs a" |
|
1494 |
and fscarr: "set fs \<subseteq> carrier G" and acarr: "a \<in> carrier G" |
|
1495 |
and f: "f \<in> set fs" |
|
1496 |
shows "f divides a" |
|
63832 | 1497 |
using wfactors_factors[OF p fscarr] |
1498 |
proof clarsimp |
|
27701 | 1499 |
fix a' |
63832 | 1500 |
assume fsa': "factors G fs a'" and a'a: "a' \<sim> a" |
1501 |
with fscarr have a'carr: "a' \<in> carrier G" |
|
1502 |
by (simp add: factors_closed) |
|
1503 |
||
1504 |
from fsa' fscarr f have "f divides a'" |
|
1505 |
by (fast intro: factors_dividesI) |
|
27701 | 1506 |
also note a'a |
63832 | 1507 |
finally show "f divides a" |
1508 |
by (simp add: f fscarr[THEN subsetD] acarr a'carr) |
|
27701 | 1509 |
qed |
1510 |
||
1511 |
||
61382 | 1512 |
subsubsection \<open>Factorial monoids and wfactors\<close> |
27701 | 1513 |
|
1514 |
lemma (in comm_monoid_cancel) factorial_monoidI: |
|
63832 | 1515 |
assumes wfactors_exists: "\<And>a. a \<in> carrier G \<Longrightarrow> \<exists>fs. set fs \<subseteq> carrier G \<and> wfactors G fs a" |
1516 |
and wfactors_unique: |
|
1517 |
"\<And>a fs fs'. \<lbrakk>a \<in> carrier G; set fs \<subseteq> carrier G; set fs' \<subseteq> carrier G; |
|
1518 |
wfactors G fs a; wfactors G fs' a\<rbrakk> \<Longrightarrow> essentially_equal G fs fs'" |
|
27701 | 1519 |
shows "factorial_monoid G" |
28823 | 1520 |
proof |
27701 | 1521 |
fix a |
1522 |
assume acarr: "a \<in> carrier G" and anunit: "a \<notin> Units G" |
|
1523 |
||
1524 |
from wfactors_exists[OF acarr] |
|
63832 | 1525 |
obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
63847 | 1526 |
by blast |
1527 |
from wfactors_factors [OF afs ascarr] obtain a' where afs': "factors G as a'" and a'a: "a' \<sim> a" |
|
1528 |
by blast |
|
63832 | 1529 |
from afs' ascarr have a'carr: "a' \<in> carrier G" |
1530 |
by fast |
|
27701 | 1531 |
have a'nunit: "a' \<notin> Units G" |
1532 |
proof clarify |
|
1533 |
assume "a' \<in> Units G" |
|
1534 |
also note a'a |
|
1535 |
finally have "a \<in> Units G" by (simp add: acarr) |
|
63832 | 1536 |
with anunit show False .. |
27701 | 1537 |
qed |
1538 |
||
63847 | 1539 |
from a'carr acarr a'a obtain u where uunit: "u \<in> Units G" and a': "a' = a \<otimes> u" |
63832 | 1540 |
by (blast elim: associatedE2) |
27701 | 1541 |
|
1542 |
note [simp] = acarr Units_closed[OF uunit] Units_inv_closed[OF uunit] |
|
1543 |
||
1544 |
have "a = a \<otimes> \<one>" by simp |
|
57865 | 1545 |
also have "\<dots> = a \<otimes> (u \<otimes> inv u)" by (simp add: uunit) |
27701 | 1546 |
also have "\<dots> = a' \<otimes> inv u" by (simp add: m_assoc[symmetric] a'[symmetric]) |
63832 | 1547 |
finally have a: "a = a' \<otimes> inv u" . |
1548 |
||
1549 |
from ascarr uunit have cr: "set (as[0:=(as!0 \<otimes> inv u)]) \<subseteq> carrier G" |
|
1550 |
by (cases as) auto |
|
1551 |
||
1552 |
from afs' uunit a'nunit acarr ascarr have "factors G (as[0:=(as!0 \<otimes> inv u)]) a" |
|
1553 |
by (simp add: a factors_cong_unit) |
|
1554 |
with cr show "\<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a" |
|
1555 |
by fast |
|
27701 | 1556 |
qed (blast intro: factors_wfactors wfactors_unique) |
1557 |
||
1558 |
||
61382 | 1559 |
subsection \<open>Factorizations as Multisets\<close> |
1560 |
||
1561 |
text \<open>Gives useful operations like intersection\<close> |
|
27701 | 1562 |
|
1563 |
(* FIXME: use class_of x instead of closure_of {x} *) |
|
1564 |
||
63832 | 1565 |
abbreviation "assocs G x \<equiv> eq_closure_of (division_rel G) {x}" |
1566 |
||
1567 |
definition "fmset G as = mset (map (\<lambda>a. assocs G a) as)" |
|
27701 | 1568 |
|
1569 |
||
61382 | 1570 |
text \<open>Helper lemmas\<close> |
27701 | 1571 |
|
1572 |
lemma (in monoid) assocs_repr_independence: |
|
68474 | 1573 |
assumes "y \<in> assocs G x" "x \<in> carrier G" |
27701 | 1574 |
shows "assocs G x = assocs G y" |
63832 | 1575 |
using assms |
68474 | 1576 |
by (simp add: eq_closure_of_def elem_def) (use associated_sym associated_trans in \<open>blast+\<close>) |
27701 | 1577 |
|
1578 |
lemma (in monoid) assocs_self: |
|
1579 |
assumes "x \<in> carrier G" |
|
1580 |
shows "x \<in> assocs G x" |
|
63832 | 1581 |
using assms by (fastforce intro: closure_ofI2) |
27701 | 1582 |
|
1583 |
lemma (in monoid) assocs_repr_independenceD: |
|
68474 | 1584 |
assumes repr: "assocs G x = assocs G y" and ycarr: "y \<in> carrier G" |
27701 | 1585 |
shows "y \<in> assocs G x" |
63832 | 1586 |
unfolding repr using ycarr by (intro assocs_self) |
27701 | 1587 |
|
1588 |
lemma (in comm_monoid) assocs_assoc: |
|
68474 | 1589 |
assumes "a \<in> assocs G b" "b \<in> carrier G" |
27701 | 1590 |
shows "a \<sim> b" |
63832 | 1591 |
using assms by (elim closure_ofE2) simp |
1592 |
||
1593 |
lemmas (in comm_monoid) assocs_eqD = assocs_repr_independenceD[THEN assocs_assoc] |
|
27701 | 1594 |
|
1595 |
||
61382 | 1596 |
subsubsection \<open>Comparing multisets\<close> |
27701 | 1597 |
|
1598 |
lemma (in monoid) fmset_perm_cong: |
|
1599 |
assumes prm: "as <~~> bs" |
|
1600 |
shows "fmset G as = fmset G bs" |
|
63832 | 1601 |
using perm_map[OF prm] unfolding mset_eq_perm fmset_def by blast |
27701 | 1602 |
|
1603 |
lemma (in comm_monoid_cancel) eqc_listassoc_cong: |
|
68474 | 1604 |
assumes "as [\<sim>] bs" and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
27701 | 1605 |
shows "map (assocs G) as = map (assocs G) bs" |
63832 | 1606 |
using assms |
68474 | 1607 |
proof (induction as arbitrary: bs) |
1608 |
case Nil |
|
1609 |
then show ?case by simp |
|
27701 | 1610 |
next |
68474 | 1611 |
case (Cons a as) |
1612 |
then show ?case |
|
1613 |
proof (clarsimp simp add: Cons_eq_map_conv list_all2_Cons1) |
|
1614 |
fix z zs |
|
1615 |
assume zzs: "a \<in> carrier G" "set as \<subseteq> carrier G" "bs = z # zs" "a \<sim> z" |
|
1616 |
"as [\<sim>] zs" "z \<in> carrier G" "set zs \<subseteq> carrier G" |
|
1617 |
then show "assocs G a = assocs G z" |
|
1618 |
apply (simp add: eq_closure_of_def elem_def) |
|
1619 |
using \<open>a \<in> carrier G\<close> \<open>z \<in> carrier G\<close> \<open>a \<sim> z\<close> associated_sym associated_trans by blast+ |
|
1620 |
qed |
|
27701 | 1621 |
qed |
1622 |
||
1623 |
lemma (in comm_monoid_cancel) fmset_listassoc_cong: |
|
63832 | 1624 |
assumes "as [\<sim>] bs" |
27701 | 1625 |
and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
1626 |
shows "fmset G as = fmset G bs" |
|
63832 | 1627 |
using assms unfolding fmset_def by (simp add: eqc_listassoc_cong) |
27701 | 1628 |
|
1629 |
lemma (in comm_monoid_cancel) ee_fmset: |
|
63832 | 1630 |
assumes ee: "essentially_equal G as bs" |
27701 | 1631 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
1632 |
shows "fmset G as = fmset G bs" |
|
63832 | 1633 |
using ee |
27701 | 1634 |
proof (elim essentially_equalE) |
1635 |
fix as' |
|
1636 |
assume prm: "as <~~> as'" |
|
63832 | 1637 |
from prm ascarr have as'carr: "set as' \<subseteq> carrier G" |
1638 |
by (rule perm_closed) |
|
1639 |
from prm have "fmset G as = fmset G as'" |
|
1640 |
by (rule fmset_perm_cong) |
|
27701 | 1641 |
also assume "as' [\<sim>] bs" |
63832 | 1642 |
with as'carr bscarr have "fmset G as' = fmset G bs" |
1643 |
by (simp add: fmset_listassoc_cong) |
|
1644 |
finally show "fmset G as = fmset G bs" . |
|
27701 | 1645 |
qed |
1646 |
||
68474 | 1647 |
lemma (in monoid_cancel) fmset_ee_aux: |
1648 |
assumes "cas <~~> cbs" "cas = map (assocs G) as" "cbs = map (assocs G) bs" |
|
1649 |
shows "\<exists>as'. as <~~> as' \<and> map (assocs G) as' = cbs" |
|
1650 |
using assms |
|
1651 |
proof (induction cas cbs arbitrary: as bs rule: perm.induct) |
|
1652 |
case (Cons xs ys z) |
|
1653 |
then show ?case |
|
1654 |
by (clarsimp simp add: map_eq_Cons_conv) blast |
|
1655 |
next |
|
1656 |
case (trans xs ys zs) |
|
68604 | 1657 |
then obtain as' where " as <~~> as' \<and> map (assocs G) as' = ys" |
1658 |
by (metis (no_types, lifting) ex_map_conv mset_eq_perm set_mset_mset) |
|
68474 | 1659 |
then show ?case |
68604 | 1660 |
using trans.IH(2) trans.prems(2) by blast |
68474 | 1661 |
qed auto |
27701 | 1662 |
|
1663 |
lemma (in comm_monoid_cancel) fmset_ee: |
|
1664 |
assumes mset: "fmset G as = fmset G bs" |
|
1665 |
and ascarr: "set as \<subseteq> carrier G" and bscarr: "set bs \<subseteq> carrier G" |
|
1666 |
shows "essentially_equal G as bs" |
|
1667 |
proof - |
|
68474 | 1668 |
from mset have "map (assocs G) as <~~> map (assocs G) bs" |
63832 | 1669 |
by (simp add: fmset_def mset_eq_perm del: mset_map) |
1670 |
then obtain as' where tp: "as <~~> as'" and tm: "map (assocs G) as' = map (assocs G) bs" |
|
68474 | 1671 |
using fmset_ee_aux by blast |
63832 | 1672 |
with ascarr have as'carr: "set as' \<subseteq> carrier G" |
68474 | 1673 |
using perm_closed by blast |
63847 | 1674 |
from tm as'carr[THEN subsetD] bscarr[THEN subsetD] have "as' [\<sim>] bs" |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
44655
diff
changeset
|
1675 |
by (induct as' arbitrary: bs) (simp, fastforce dest: assocs_eqD[THEN associated_sym]) |
63832 | 1676 |
with tp show "essentially_equal G as bs" |
1677 |
by (fast intro: essentially_equalI) |
|
27701 | 1678 |
qed |
1679 |
||
1680 |
lemma (in comm_monoid_cancel) ee_is_fmset: |
|
1681 |
assumes "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" |
|
1682 |
shows "essentially_equal G as bs = (fmset G as = fmset G bs)" |
|
63832 | 1683 |
using assms by (fast intro: ee_fmset fmset_ee) |
27701 | 1684 |
|
1685 |
||
61382 | 1686 |
subsubsection \<open>Interpreting multisets as factorizations\<close> |
27701 | 1687 |
|
1688 |
lemma (in monoid) mset_fmsetEx: |
|
60495 | 1689 |
assumes elems: "\<And>X. X \<in> set_mset Cs \<Longrightarrow> \<exists>x. P x \<and> X = assocs G x" |
27701 | 1690 |
shows "\<exists>cs. (\<forall>c \<in> set cs. P c) \<and> fmset G cs = Cs" |
1691 |
proof - |
|
63847 | 1692 |
from surjE[OF surj_mset] obtain Cs' where Cs: "Cs = mset Cs'" |
1693 |
by blast |
|
60515 | 1694 |
have "\<exists>cs. (\<forall>c \<in> set cs. P c) \<and> mset (map (assocs G) cs) = Cs" |
68478 | 1695 |
using elems unfolding Cs |
1696 |
proof (induction Cs') |
|
1697 |
case (Cons a Cs') |
|
1698 |
then obtain c cs where csP: "\<forall>x\<in>set cs. P x" and mset: "mset (map (assocs G) cs) = mset Cs'" |
|
1699 |
and cP: "P c" and a: "a = assocs G c" |
|
1700 |
by force |
|
1701 |
then have tP: "\<forall>x\<in>set (c#cs). P x" |
|
63847 | 1702 |
by simp |
68478 | 1703 |
show ?case |
1704 |
using tP mset a by fastforce |
|
1705 |
qed auto |
|
63832 | 1706 |
then show ?thesis by (simp add: fmset_def) |
27701 | 1707 |
qed |
1708 |
||
1709 |
lemma (in monoid) mset_wfactorsEx: |
|
63832 | 1710 |
assumes elems: "\<And>X. X \<in> set_mset Cs \<Longrightarrow> \<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" |
27701 | 1711 |
shows "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> fmset G cs = Cs" |
1712 |
proof - |
|
1713 |
have "\<exists>cs. (\<forall>c\<in>set cs. c \<in> carrier G \<and> irreducible G c) \<and> fmset G cs = Cs" |
|
63832 | 1714 |
by (intro mset_fmsetEx, rule elems) |
1715 |
then obtain cs where p[rule_format]: "\<forall>c\<in>set cs. c \<in> carrier G \<and> irreducible G c" |
|
1716 |
and Cs[symmetric]: "fmset G cs = Cs" by auto |
|
1717 |
from p have cscarr: "set cs \<subseteq> carrier G" by fast |
|
1718 |
from p have "\<exists>c. c \<in> carrier G \<and> wfactors G cs c" |
|
1719 |
by (intro wfactors_prod_exists) auto |
|
1720 |
then obtain c where ccarr: "c \<in> carrier G" and cfs: "wfactors G cs c" by auto |
|
1721 |
with cscarr Cs show ?thesis by fast |
|
27701 | 1722 |
qed |
1723 |
||
1724 |
||
61382 | 1725 |
subsubsection \<open>Multiplication on multisets\<close> |
27701 | 1726 |
|
1727 |
lemma (in factorial_monoid) mult_wfactors_fmset: |
|
63832 | 1728 |
assumes afs: "wfactors G as a" |
1729 |
and bfs: "wfactors G bs b" |
|
1730 |
and cfs: "wfactors G cs (a \<otimes> b)" |
|
27701 | 1731 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
1732 |
"set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
|
1733 |
shows "fmset G cs = fmset G as + fmset G bs" |
|
1734 |
proof - |
|
63832 | 1735 |
from assms have "wfactors G (as @ bs) (a \<otimes> b)" |
1736 |
by (intro wfactors_mult) |
|
1737 |
with carr cfs have "essentially_equal G cs (as@bs)" |
|
1738 |
by (intro ee_wfactorsI[of "a\<otimes>b" "a\<otimes>b"]) simp_all |
|
1739 |
with carr have "fmset G cs = fmset G (as@bs)" |
|
1740 |
by (intro ee_fmset) simp_all |
|
1741 |
also have "fmset G (as@bs) = fmset G as + fmset G bs" |
|
1742 |
by (simp add: fmset_def) |
|
27701 | 1743 |
finally show "fmset G cs = fmset G as + fmset G bs" . |
1744 |
qed |
|
1745 |
||
1746 |
lemma (in factorial_monoid) mult_factors_fmset: |
|
63832 | 1747 |
assumes afs: "factors G as a" |
1748 |
and bfs: "factors G bs b" |
|
1749 |
and cfs: "factors G cs (a \<otimes> b)" |
|
27701 | 1750 |
and "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
1751 |
shows "fmset G cs = fmset G as + fmset G bs" |
|
63832 | 1752 |
using assms by (blast intro: factors_wfactors mult_wfactors_fmset) |
27701 | 1753 |
|
1754 |
lemma (in comm_monoid_cancel) fmset_wfactors_mult: |
|
1755 |
assumes mset: "fmset G cs = fmset G as + fmset G bs" |
|
1756 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
63832 | 1757 |
"set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" "set cs \<subseteq> carrier G" |
27701 | 1758 |
and fs: "wfactors G as a" "wfactors G bs b" "wfactors G cs c" |
1759 |
shows "c \<sim> a \<otimes> b" |
|
1760 |
proof - |
|
63832 | 1761 |
from carr fs have m: "wfactors G (as @ bs) (a \<otimes> b)" |
1762 |
by (intro wfactors_mult) |
|
1763 |
||
1764 |
from mset have "fmset G cs = fmset G (as@bs)" |
|
1765 |
by (simp add: fmset_def) |
|
1766 |
then have "essentially_equal G cs (as@bs)" |
|
1767 |
by (rule fmset_ee) (simp_all add: carr) |
|
1768 |
then show "c \<sim> a \<otimes> b" |
|
1769 |
by (rule ee_wfactorsD[of "cs" "as@bs"]) (simp_all add: assms m) |
|
27701 | 1770 |
qed |
1771 |
||
1772 |
||
61382 | 1773 |
subsubsection \<open>Divisibility on multisets\<close> |
27701 | 1774 |
|
1775 |
lemma (in factorial_monoid) divides_fmsubset: |
|
1776 |
assumes ab: "a divides b" |
|
63832 | 1777 |
and afs: "wfactors G as a" |
1778 |
and bfs: "wfactors G bs b" |
|
27701 | 1779 |
and carr: "a \<in> carrier G" "b \<in> carrier G" "set as \<subseteq> carrier G" "set bs \<subseteq> carrier G" |
64587 | 1780 |
shows "fmset G as \<subseteq># fmset G bs" |
63832 | 1781 |
using ab |
27701 | 1782 |
proof (elim dividesE) |
1783 |
fix c |
|
1784 |
assume ccarr: "c \<in> carrier G" |
|
63847 | 1785 |
from wfactors_exist [OF this] |
1786 |
obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfs: "wfactors G cs c" |
|
1787 |
by blast |
|
27701 | 1788 |
note carr = carr ccarr cscarr |
1789 |
||
1790 |
assume "b = a \<otimes> c" |
|
63832 | 1791 |
with afs bfs cfs carr have "fmset G bs = fmset G as + fmset G cs" |
1792 |
by (intro mult_wfactors_fmset[OF afs cfs]) simp_all |
|
1793 |
then show ?thesis by simp |
|
27701 | 1794 |
qed |
1795 |
||
1796 |
lemma (in comm_monoid_cancel) fmsubset_divides: |
|
64587 | 1797 |
assumes msubset: "fmset G as \<subseteq># fmset G bs" |
63832 | 1798 |
and afs: "wfactors G as a" |
1799 |
and bfs: "wfactors G bs b" |
|
1800 |
and acarr: "a \<in> carrier G" |
|
1801 |
and bcarr: "b \<in> carrier G" |
|
1802 |
and ascarr: "set as \<subseteq> carrier G" |
|
1803 |
and bscarr: "set bs \<subseteq> carrier G" |
|
27701 | 1804 |
shows "a divides b" |
1805 |
proof - |
|
1806 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" by (fast elim: wfactorsE) |
|
1807 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" by (fast elim: wfactorsE) |
|
1808 |
||
1809 |
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" |
|
1810 |
proof (intro mset_wfactorsEx, simp) |
|
1811 |
fix X |
|
62430
9527ff088c15
more succint formulation of membership for multisets, similar to lists;
haftmann
parents:
61382
diff
changeset
|
1812 |
assume "X \<in># fmset G bs - fmset G as" |
63832 | 1813 |
then have "X \<in># fmset G bs" by (rule in_diffD) |
1814 |
then have "X \<in> set (map (assocs G) bs)" by (simp add: fmset_def) |
|
1815 |
then have "\<exists>x. x \<in> set bs \<and> X = assocs G x" by (induct bs) auto |
|
1816 |
then obtain x where xbs: "x \<in> set bs" and X: "X = assocs G x" by auto |
|
27701 | 1817 |
with bscarr have xcarr: "x \<in> carrier G" by fast |
1818 |
from xbs birr have xirr: "irreducible G x" by simp |
|
1819 |
||
63832 | 1820 |
from xcarr and xirr and X show "\<exists>x. x \<in> carrier G \<and> irreducible G x \<and> X = assocs G x" |
1821 |
by fast |
|
27701 | 1822 |
qed |
63832 | 1823 |
then obtain c cs |
1824 |
where ccarr: "c \<in> carrier G" |
|
1825 |
and cscarr: "set cs \<subseteq> carrier G" |
|
27701 | 1826 |
and csf: "wfactors G cs c" |
1827 |
and csmset: "fmset G cs = fmset G bs - fmset G as" by auto |
|
1828 |
||
1829 |
from csmset msubset |
|
63832 | 1830 |
have "fmset G bs = fmset G as + fmset G cs" |
1831 |
by (simp add: multiset_eq_iff subseteq_mset_def) |
|
1832 |
then have basc: "b \<sim> a \<otimes> c" |
|
1833 |
by (rule fmset_wfactors_mult) fact+ |
|
1834 |
then show ?thesis |
|
27701 | 1835 |
proof (elim associatedE2) |
1836 |
fix u |
|
1837 |
assume "u \<in> Units G" "b = a \<otimes> c \<otimes> u" |
|
63832 | 1838 |
with acarr ccarr show "a divides b" |
1839 |
by (fast intro: dividesI[of "c \<otimes> u"] m_assoc) |
|
1840 |
qed (simp_all add: acarr bcarr ccarr) |
|
27701 | 1841 |
qed |
1842 |
||
1843 |
lemma (in factorial_monoid) divides_as_fmsubset: |
|
63832 | 1844 |
assumes "wfactors G as a" |
1845 |
and "wfactors G bs b" |
|
1846 |
and "a \<in> carrier G" |
|
1847 |
and "b \<in> carrier G" |
|
1848 |
and "set as \<subseteq> carrier G" |
|
1849 |
and "set bs \<subseteq> carrier G" |
|
64587 | 1850 |
shows "a divides b = (fmset G as \<subseteq># fmset G bs)" |
63832 | 1851 |
using assms |
1852 |
by (blast intro: divides_fmsubset fmsubset_divides) |
|
27701 | 1853 |
|
1854 |
||
61382 | 1855 |
text \<open>Proper factors on multisets\<close> |
27701 | 1856 |
|
1857 |
lemma (in factorial_monoid) fmset_properfactor: |
|
64587 | 1858 |
assumes asubb: "fmset G as \<subseteq># fmset G bs" |
27701 | 1859 |
and anb: "fmset G as \<noteq> fmset G bs" |
63832 | 1860 |
and "wfactors G as a" |
1861 |
and "wfactors G bs b" |
|
1862 |
and "a \<in> carrier G" |
|
1863 |
and "b \<in> carrier G" |
|
1864 |
and "set as \<subseteq> carrier G" |
|
1865 |
and "set bs \<subseteq> carrier G" |
|
27701 | 1866 |
shows "properfactor G a b" |
68478 | 1867 |
proof (rule properfactorI) |
1868 |
show "a divides b" |
|
1869 |
using assms asubb fmsubset_divides by blast |
|
1870 |
show "\<not> b divides a" |
|
1871 |
by (meson anb assms asubb factorial_monoid.divides_fmsubset factorial_monoid_axioms subset_mset.antisym) |
|
27701 | 1872 |
qed |
1873 |
||
1874 |
lemma (in factorial_monoid) properfactor_fmset: |
|
1875 |
assumes pf: "properfactor G a b" |
|
63832 | 1876 |
and "wfactors G as a" |
1877 |
and "wfactors G bs b" |
|
1878 |
and "a \<in> carrier G" |
|
1879 |
and "b \<in> carrier G" |
|
1880 |
and "set as \<subseteq> carrier G" |
|
1881 |
and "set bs \<subseteq> carrier G" |
|
64587 | 1882 |
shows "fmset G as \<subseteq># fmset G bs \<and> fmset G as \<noteq> fmset G bs" |
63832 | 1883 |
using pf |
68474 | 1884 |
apply safe |
1885 |
apply (meson assms divides_as_fmsubset monoid.properfactor_divides monoid_axioms) |
|
1886 |
by (meson assms associated_def comm_monoid_cancel.ee_wfactorsD comm_monoid_cancel.fmset_ee factorial_monoid_axioms factorial_monoid_def properfactorE) |
|
27701 | 1887 |
|
61382 | 1888 |
subsection \<open>Irreducible Elements are Prime\<close> |
27701 | 1889 |
|
63633 | 1890 |
lemma (in factorial_monoid) irreducible_prime: |
68478 | 1891 |
assumes pirr: "irreducible G p" and pcarr: "p \<in> carrier G" |
27701 | 1892 |
shows "prime G p" |
63832 | 1893 |
using pirr |
27701 | 1894 |
proof (elim irreducibleE, intro primeI) |
1895 |
fix a b |
|
1896 |
assume acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" |
|
1897 |
and pdvdab: "p divides (a \<otimes> b)" |
|
1898 |
and pnunit: "p \<notin> Units G" |
|
1899 |
assume irreduc[rule_format]: |
|
63832 | 1900 |
"\<forall>b. b \<in> carrier G \<and> properfactor G b p \<longrightarrow> b \<in> Units G" |
63847 | 1901 |
from pdvdab obtain c where ccarr: "c \<in> carrier G" and abpc: "a \<otimes> b = p \<otimes> c" |
1902 |
by (rule dividesE) |
|
1903 |
obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
|
68478 | 1904 |
using wfactors_exist [OF acarr] by blast |
63847 | 1905 |
obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfs: "wfactors G bs b" |
68478 | 1906 |
using wfactors_exist [OF bcarr] by blast |
63847 | 1907 |
obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfs: "wfactors G cs c" |
68478 | 1908 |
using wfactors_exist [OF ccarr] by blast |
27701 | 1909 |
note carr[simp] = pcarr acarr bcarr ccarr ascarr bscarr cscarr |
68478 | 1910 |
from pirr cfs abpc have "wfactors G (p # cs) (a \<otimes> b)" |
1911 |
by (simp add: wfactors_mult_single) |
|
1912 |
moreover have "wfactors G (as @ bs) (a \<otimes> b)" |
|
1913 |
by (rule wfactors_mult [OF afs bfs]) fact+ |
|
1914 |
ultimately have "essentially_equal G (p # cs) (as @ bs)" |
|
63832 | 1915 |
by (rule wfactors_unique) simp+ |
63847 | 1916 |
then obtain ds where "p # cs <~~> ds" and dsassoc: "ds [\<sim>] (as @ bs)" |
63832 | 1917 |
by (fast elim: essentially_equalE) |
27701 | 1918 |
then have "p \<in> set ds" |
63832 | 1919 |
by (simp add: perm_set_eq[symmetric]) |
63847 | 1920 |
with dsassoc obtain p' where "p' \<in> set (as@bs)" and pp': "p \<sim> p'" |
63832 | 1921 |
unfolding list_all2_conv_all_nth set_conv_nth by force |
1922 |
then consider "p' \<in> set as" | "p' \<in> set bs" by auto |
|
1923 |
then show "p divides a \<or> p divides b" |
|
68478 | 1924 |
using afs bfs divides_cong_l pp' wfactors_dividesI |
1925 |
by (meson acarr ascarr bcarr bscarr pcarr) |
|
27701 | 1926 |
qed |
1927 |
||
1928 |
||
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
67399
diff
changeset
|
1929 |
\<comment> \<open>A version using @{const factors}, more complicated\<close> |
63633 | 1930 |
lemma (in factorial_monoid) factors_irreducible_prime: |
68478 | 1931 |
assumes pirr: "irreducible G p" and pcarr: "p \<in> carrier G" |
27701 | 1932 |
shows "prime G p" |
68478 | 1933 |
proof (rule primeI) |
1934 |
show "p \<notin> Units G" |
|
1935 |
by (meson irreducibleE pirr) |
|
1936 |
have irreduc: "\<And>b. \<lbrakk>b \<in> carrier G; properfactor G b p\<rbrakk> \<Longrightarrow> b \<in> Units G" |
|
1937 |
using pirr by (auto simp: irreducible_def) |
|
1938 |
show "p divides a \<or> p divides b" |
|
1939 |
if acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" and pdvdab: "p divides (a \<otimes> b)" for a b |
|
1940 |
proof - |
|
1941 |
from pdvdab obtain c where ccarr: "c \<in> carrier G" and abpc: "a \<otimes> b = p \<otimes> c" |
|
1942 |
by (rule dividesE) |
|
1943 |
note [simp] = pcarr acarr bcarr ccarr |
|
1944 |
||
1945 |
show "p divides a \<or> p divides b" |
|
1946 |
proof (cases "a \<in> Units G") |
|
1947 |
case True |
|
1948 |
then have "p divides b" |
|
1949 |
by (metis acarr associatedI2' associated_def bcarr divides_trans m_comm pcarr pdvdab) |
|
63832 | 1950 |
then show ?thesis .. |
27701 | 1951 |
next |
68478 | 1952 |
case anunit: False |
1953 |
show ?thesis |
|
1954 |
proof (cases "b \<in> Units G") |
|
1955 |
case True |
|
1956 |
then have "p divides a" |
|
1957 |
by (meson acarr bcarr divides_unit irreducible_prime pcarr pdvdab pirr prime_def) |
|
63832 | 1958 |
then show ?thesis .. |
1959 |
next |
|
68478 | 1960 |
case bnunit: False |
1961 |
then have cnunit: "c \<notin> Units G" |
|
1962 |
by (metis abpc acarr anunit bcarr ccarr irreducible_prodE irreducible_prod_rI pcarr pirr) |
|
1963 |
then have abnunit: "a \<otimes> b \<notin> Units G" |
|
1964 |
using acarr anunit bcarr unit_factor by blast |
|
1965 |
obtain as where ascarr: "set as \<subseteq> carrier G" and afac: "factors G as a" |
|
1966 |
using factors_exist [OF acarr anunit] by blast |
|
1967 |
obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfac: "factors G bs b" |
|
1968 |
using factors_exist [OF bcarr bnunit] by blast |
|
1969 |
obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfac: "factors G cs c" |
|
1970 |
using factors_exist [OF ccarr cnunit] by auto |
|
1971 |
note [simp] = ascarr bscarr cscarr |
|
1972 |
from pirr cfac abpc have abfac': "factors G (p # cs) (a \<otimes> b)" |
|
1973 |
by (simp add: factors_mult_single) |
|
1974 |
from afac and bfac have "factors G (as @ bs) (a \<otimes> b)" |
|
1975 |
by (rule factors_mult) fact+ |
|
1976 |
with abfac' have "essentially_equal G (p # cs) (as @ bs)" |
|
1977 |
using abnunit factors_unique by auto |
|
1978 |
then obtain ds where "p # cs <~~> ds" and dsassoc: "ds [\<sim>] (as @ bs)" |
|
1979 |
by (fast elim: essentially_equalE) |
|
1980 |
then have "p \<in> set ds" |
|
1981 |
by (simp add: perm_set_eq[symmetric]) |
|
1982 |
with dsassoc obtain p' where "p' \<in> set (as@bs)" and pp': "p \<sim> p'" |
|
1983 |
unfolding list_all2_conv_all_nth set_conv_nth by force |
|
1984 |
then consider "p' \<in> set as" | "p' \<in> set bs" by auto |
|
1985 |
then show "p divides a \<or> p divides b" |
|
1986 |
by (meson afac bfac divides_cong_l factors_dividesI pp' ascarr bscarr pcarr) |
|
63832 | 1987 |
qed |
27701 | 1988 |
qed |
1989 |
qed |
|
1990 |
qed |
|
1991 |
||
1992 |
||
61382 | 1993 |
subsection \<open>Greatest Common Divisors and Lowest Common Multiples\<close> |
1994 |
||
1995 |
subsubsection \<open>Definitions\<close> |
|
27701 | 1996 |
|
63832 | 1997 |
definition isgcd :: "[('a,_) monoid_scheme, 'a, 'a, 'a] \<Rightarrow> bool" ("(_ gcdof\<index> _ _)" [81,81,81] 80) |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
1998 |
where "x gcdof\<^bsub>G\<^esub> a b \<longleftrightarrow> x divides\<^bsub>G\<^esub> a \<and> x divides\<^bsub>G\<^esub> b \<and> |
35847 | 1999 |
(\<forall>y\<in>carrier G. (y divides\<^bsub>G\<^esub> a \<and> y divides\<^bsub>G\<^esub> b \<longrightarrow> y divides\<^bsub>G\<^esub> x))" |
2000 |
||
63832 | 2001 |
definition islcm :: "[_, 'a, 'a, 'a] \<Rightarrow> bool" ("(_ lcmof\<index> _ _)" [81,81,81] 80) |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
2002 |
where "x lcmof\<^bsub>G\<^esub> a b \<longleftrightarrow> a divides\<^bsub>G\<^esub> x \<and> b divides\<^bsub>G\<^esub> x \<and> |
35847 | 2003 |
(\<forall>y\<in>carrier G. (a divides\<^bsub>G\<^esub> y \<and> b divides\<^bsub>G\<^esub> y \<longrightarrow> x divides\<^bsub>G\<^esub> y))" |
2004 |
||
63832 | 2005 |
definition somegcd :: "('a,_) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
2006 |
where "somegcd G a b = (SOME x. x \<in> carrier G \<and> x gcdof\<^bsub>G\<^esub> a b)" |
35847 | 2007 |
|
63832 | 2008 |
definition somelcm :: "('a,_) monoid_scheme \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" |
35848
5443079512ea
slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents:
35847
diff
changeset
|
2009 |
where "somelcm G a b = (SOME x. x \<in> carrier G \<and> x lcmof\<^bsub>G\<^esub> a b)" |
35847 | 2010 |
|
63832 | 2011 |
definition "SomeGcd G A = inf (division_rel G) A" |
27701 | 2012 |
|
2013 |
||
2014 |
locale gcd_condition_monoid = comm_monoid_cancel + |
|
63832 | 2015 |
assumes gcdof_exists: "\<lbrakk>a \<in> carrier G; b \<in> carrier G\<rbrakk> \<Longrightarrow> \<exists>c. c \<in> carrier G \<and> c gcdof a b" |
27701 | 2016 |
|
2017 |
locale primeness_condition_monoid = comm_monoid_cancel + |
|
63832 | 2018 |
assumes irreducible_prime: "\<lbrakk>a \<in> carrier G; irreducible G a\<rbrakk> \<Longrightarrow> prime G a" |
27701 | 2019 |
|
2020 |
locale divisor_chain_condition_monoid = comm_monoid_cancel + |
|
63832 | 2021 |
assumes division_wellfounded: "wf {(x, y). x \<in> carrier G \<and> y \<in> carrier G \<and> properfactor G x y}" |
27701 | 2022 |
|
2023 |
||
61382 | 2024 |
subsubsection \<open>Connections to \texttt{Lattice.thy}\<close> |
27701 | 2025 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2026 |
lemma gcdof_greatestLower: |
27701 | 2027 |
fixes G (structure) |
2028 |
assumes carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
63832 | 2029 |
shows "(x \<in> carrier G \<and> x gcdof a b) = greatest (division_rel G) x (Lower (division_rel G) {a, b})" |
2030 |
by (auto simp: isgcd_def greatest_def Lower_def elem_def) |
|
27701 | 2031 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2032 |
lemma lcmof_leastUpper: |
27701 | 2033 |
fixes G (structure) |
2034 |
assumes carr[simp]: "a \<in> carrier G" "b \<in> carrier G" |
|
63832 | 2035 |
shows "(x \<in> carrier G \<and> x lcmof a b) = least (division_rel G) x (Upper (division_rel G) {a, b})" |
2036 |
by (auto simp: islcm_def least_def Upper_def elem_def) |
|
27701 | 2037 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2038 |
lemma somegcd_meet: |
27701 | 2039 |
fixes G (structure) |
2040 |
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
|
2041 |
shows "somegcd G a b = meet (division_rel G) a b" |
63832 | 2042 |
by (simp add: somegcd_def meet_def inf_def gcdof_greatestLower[OF carr]) |
27701 | 2043 |
|
2044 |
lemma (in monoid) isgcd_divides_l: |
|
2045 |
assumes "a divides b" |
|
2046 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
2047 |
shows "a gcdof a b" |
|
63832 | 2048 |
using assms unfolding isgcd_def by fast |
27701 | 2049 |
|
2050 |
lemma (in monoid) isgcd_divides_r: |
|
2051 |
assumes "b divides a" |
|
2052 |
and "a \<in> carrier G" "b \<in> carrier G" |
|
2053 |
shows "b gcdof a b" |
|
63832 | 2054 |
using assms unfolding isgcd_def by fast |
27701 | 2055 |
|
2056 |
||
61382 | 2057 |
subsubsection \<open>Existence of gcd and lcm\<close> |
27701 | 2058 |
|
2059 |
lemma (in factorial_monoid) gcdof_exists: |
|
63832 | 2060 |
assumes acarr: "a \<in> carrier G" |
2061 |
and bcarr: "b \<in> carrier G" |
|
27701 | 2062 |
shows "\<exists>c. c \<in> carrier G \<and> c gcdof a b" |
2063 |
proof - |
|
63847 | 2064 |
from wfactors_exist [OF acarr] |
2065 |
obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
|
2066 |
by blast |
|
63832 | 2067 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" |
2068 |
by (fast elim: wfactorsE) |
|
2069 |
||
63847 | 2070 |
from wfactors_exist [OF bcarr] |
2071 |
obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfs: "wfactors G bs b" |
|
2072 |
by blast |
|
63832 | 2073 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" |
2074 |
by (fast elim: wfactorsE) |
|
2075 |
||
2076 |
have "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> |
|
63919
9aed2da07200
# after multiset intersection and union symbol
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63847
diff
changeset
|
2077 |
fmset G cs = fmset G as \<inter># fmset G bs" |
27701 | 2078 |
proof (intro mset_wfactorsEx) |
2079 |
fix X |
|
63919
9aed2da07200
# after multiset intersection and union symbol
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63847
diff
changeset
|
2080 |
assume "X \<in># fmset G as \<inter># fmset G bs" |
63832 | 2081 |
then have "X \<in># fmset G as" by simp |
2082 |
then have "X \<in> set (map (assocs G) as)" |
|
2083 |
by (simp add: fmset_def) |
|
2084 |
then have "\<exists>x. X = assocs G x \<and> x \<in> set as" |
|
2085 |
by (induct as) auto |
|
2086 |
then obtain x where X: "X = assocs G x" and xas: "x \<in> set as" |
|
63847 | 2087 |
by blast |
63832 | 2088 |
with ascarr have xcarr: "x \<in> carrier G" |
63847 | 2089 |
by blast |
63832 | 2090 |
from xas airr have xirr: "irreducible G x" |
2091 |
by simp |
|
2092 |
from xcarr and xirr and X show "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" |
|
63847 | 2093 |
by blast |
27701 | 2094 |
qed |
63832 | 2095 |
then obtain c cs |
2096 |
where ccarr: "c \<in> carrier G" |
|
2097 |
and cscarr: "set cs \<subseteq> carrier G" |
|
27701 | 2098 |
and csirr: "wfactors G cs c" |
63919
9aed2da07200
# after multiset intersection and union symbol
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63847
diff
changeset
|
2099 |
and csmset: "fmset G cs = fmset G as \<inter># fmset G bs" |
63832 | 2100 |
by auto |
27701 | 2101 |
|
2102 |
have "c gcdof a b" |
|
2103 |
proof (simp add: isgcd_def, safe) |
|
2104 |
from csmset |
|
64587 | 2105 |
have "fmset G cs \<subseteq># fmset G as" |
63832 | 2106 |
by (simp add: multiset_inter_def subset_mset_def) |
2107 |
then show "c divides a" by (rule fmsubset_divides) fact+ |
|
27701 | 2108 |
next |
64587 | 2109 |
from csmset have "fmset G cs \<subseteq># fmset G bs" |
63832 | 2110 |
by (simp add: multiset_inter_def subseteq_mset_def, force) |
2111 |
then show "c divides b" |
|
2112 |
by (rule fmsubset_divides) fact+ |
|
27701 | 2113 |
next |
2114 |
fix y |
|
63847 | 2115 |
assume "y \<in> carrier G" |
2116 |
from wfactors_exist [OF this] |
|
2117 |
obtain ys where yscarr: "set ys \<subseteq> carrier G" and yfs: "wfactors G ys y" |
|
2118 |
by blast |
|
27701 | 2119 |
|
2120 |
assume "y divides a" |
|
64587 | 2121 |
then have ya: "fmset G ys \<subseteq># fmset G as" |
63832 | 2122 |
by (rule divides_fmsubset) fact+ |
27701 | 2123 |
|
2124 |
assume "y divides b" |
|
64587 | 2125 |
then have yb: "fmset G ys \<subseteq># fmset G bs" |
63832 | 2126 |
by (rule divides_fmsubset) fact+ |
2127 |
||
64587 | 2128 |
from ya yb csmset have "fmset G ys \<subseteq># fmset G cs" |
63832 | 2129 |
by (simp add: subset_mset_def) |
2130 |
then show "y divides c" |
|
2131 |
by (rule fmsubset_divides) fact+ |
|
27701 | 2132 |
qed |
63832 | 2133 |
with ccarr show "\<exists>c. c \<in> carrier G \<and> c gcdof a b" |
2134 |
by fast |
|
27701 | 2135 |
qed |
2136 |
||
2137 |
lemma (in factorial_monoid) lcmof_exists: |
|
63832 | 2138 |
assumes acarr: "a \<in> carrier G" |
2139 |
and bcarr: "b \<in> carrier G" |
|
27701 | 2140 |
shows "\<exists>c. c \<in> carrier G \<and> c lcmof a b" |
2141 |
proof - |
|
63847 | 2142 |
from wfactors_exist [OF acarr] |
2143 |
obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
|
2144 |
by blast |
|
63832 | 2145 |
from afs have airr: "\<forall>a \<in> set as. irreducible G a" |
2146 |
by (fast elim: wfactorsE) |
|
2147 |
||
63847 | 2148 |
from wfactors_exist [OF bcarr] |
2149 |
obtain bs where bscarr: "set bs \<subseteq> carrier G" and bfs: "wfactors G bs b" |
|
2150 |
by blast |
|
63832 | 2151 |
from bfs have birr: "\<forall>b \<in> set bs. irreducible G b" |
2152 |
by (fast elim: wfactorsE) |
|
2153 |
||
2154 |
have "\<exists>c cs. c \<in> carrier G \<and> set cs \<subseteq> carrier G \<and> wfactors G cs c \<and> |
|
2155 |
fmset G cs = (fmset G as - fmset G bs) + fmset G bs" |
|
27701 | 2156 |
proof (intro mset_wfactorsEx) |
2157 |
fix X |
|
62430
9527ff088c15
more succint formulation of membership for multisets, similar to lists;
haftmann
parents:
61382
diff
changeset
|
2158 |
assume "X \<in># (fmset G as - fmset G bs) + fmset G bs" |
63832 | 2159 |
then have "X \<in># fmset G as \<or> X \<in># fmset G bs" |
62430
9527ff088c15
more succint formulation of membership for multisets, similar to lists;
haftmann
parents:
61382
diff
changeset
|
2160 |
by (auto dest: in_diffD) |
63832 | 2161 |
then consider "X \<in> set_mset (fmset G as)" | "X \<in> set_mset (fmset G bs)" |
2162 |
by fast |
|
2163 |
then show "\<exists>x. (x \<in> carrier G \<and> irreducible G x) \<and> X = assocs G x" |
|
2164 |
proof cases |
|
2165 |
case 1 |
|
2166 |
then have "X \<in> set (map (assocs G) as)" by (simp add: fmset_def) |
|
2167 |
then have "\<exists>x. x \<in> set as \<and> X = assocs G x" by (induct as) auto |
|
2168 |
then obtain x where xas: "x \<in> set as" and X: "X = assocs G x" by auto |
|
27701 | 2169 |
with ascarr have xcarr: "x \<in> carrier G" by fast |
2170 |
from xas airr have xirr: "irreducible G x" by simp |
|
63832 | 2171 |
from xcarr and xirr and X show ?thesis by fast |
2172 |
next |
|
2173 |
case 2 |
|
2174 |
then have "X \<in> set (map (assocs G) bs)" by (simp add: fmset_def) |
|
2175 |
then have "\<exists>x. x \<in> set bs \<and> X = assocs G x" by (induct as) auto |
|
2176 |
then obtain x where xbs: "x \<in> set bs" and X: "X = assocs G x" by auto |
|
27701 | 2177 |
with bscarr have xcarr: "x \<in> carrier G" by fast |
2178 |
from xbs birr have xirr: "irreducible G x" by simp |
|
63832 | 2179 |
from xcarr and xirr and X show ?thesis by fast |
2180 |
qed |
|
27701 | 2181 |
qed |
63832 | 2182 |
then obtain c cs |
2183 |
where ccarr: "c \<in> carrier G" |
|
2184 |
and cscarr: "set cs \<subseteq> carrier G" |
|
27701 | 2185 |
and csirr: "wfactors G cs c" |
63832 | 2186 |
and csmset: "fmset G cs = fmset G as - fmset G bs + fmset G bs" |
2187 |
by auto |
|
27701 | 2188 |
|
2189 |
have "c lcmof a b" |
|
2190 |
proof (simp add: islcm_def, safe) |
|
64587 | 2191 |
from csmset have "fmset G as \<subseteq># fmset G cs" |
63832 | 2192 |
by (simp add: subseteq_mset_def, force) |
2193 |
then show "a divides c" |
|
2194 |
by (rule fmsubset_divides) fact+ |
|
27701 | 2195 |
next |
64587 | 2196 |
from csmset have "fmset G bs \<subseteq># fmset G cs" |
63832 | 2197 |
by (simp add: subset_mset_def) |
2198 |
then show "b divides c" |
|
2199 |
by (rule fmsubset_divides) fact+ |
|
27701 | 2200 |
next |
2201 |
fix y |
|
63847 | 2202 |
assume "y \<in> carrier G" |
2203 |
from wfactors_exist [OF this] |
|
2204 |
obtain ys where yscarr: "set ys \<subseteq> carrier G" and yfs: "wfactors G ys y" |
|
2205 |
by blast |
|
27701 | 2206 |
|
2207 |
assume "a divides y" |
|
64587 | 2208 |
then have ya: "fmset G as \<subseteq># fmset G ys" |
63832 | 2209 |
by (rule divides_fmsubset) fact+ |
27701 | 2210 |
|
2211 |
assume "b divides y" |
|
64587 | 2212 |
then have yb: "fmset G bs \<subseteq># fmset G ys" |
63832 | 2213 |
by (rule divides_fmsubset) fact+ |
2214 |
||
64587 | 2215 |
from ya yb csmset have "fmset G cs \<subseteq># fmset G ys" |
68474 | 2216 |
using subset_eq_diff_conv subset_mset.le_diff_conv2 by fastforce |
63832 | 2217 |
then show "c divides y" |
2218 |
by (rule fmsubset_divides) fact+ |
|
27701 | 2219 |
qed |
63832 | 2220 |
with ccarr show "\<exists>c. c \<in> carrier G \<and> c lcmof a b" |
2221 |
by fast |
|
27701 | 2222 |
qed |
2223 |
||
2224 |
||
61382 | 2225 |
subsection \<open>Conditions for Factoriality\<close> |
2226 |
||
2227 |
subsubsection \<open>Gcd condition\<close> |
|
27701 | 2228 |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2229 |
lemma (in gcd_condition_monoid) division_weak_lower_semilattice [simp]: |
63832 | 2230 |
"weak_lower_semilattice (division_rel G)" |
27701 | 2231 |
proof - |
29237 | 2232 |
interpret weak_partial_order "division_rel G" .. |
27701 | 2233 |
show ?thesis |
68474 | 2234 |
proof (unfold_locales, simp_all) |
27701 | 2235 |
fix x y |
2236 |
assume carr: "x \<in> carrier G" "y \<in> carrier G" |
|
63847 | 2237 |
from gcdof_exists [OF this] obtain z where zcarr: "z \<in> carrier G" and isgcd: "z gcdof x y" |
2238 |
by blast |
|
63832 | 2239 |
with carr have "greatest (division_rel G) z (Lower (division_rel G) {x, y})" |
2240 |
by (subst gcdof_greatestLower[symmetric], simp+) |
|
2241 |
then show "\<exists>z. greatest (division_rel G) z (Lower (division_rel G) {x, y})" |
|
2242 |
by fast |
|
27701 | 2243 |
qed |
2244 |
qed |
|
2245 |
||
2246 |
lemma (in gcd_condition_monoid) gcdof_cong_l: |
|
2247 |
assumes a'a: "a' \<sim> a" |
|
2248 |
and agcd: "a gcdof b c" |
|
2249 |
and a'carr: "a' \<in> carrier G" and carr': "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
2250 |
shows "a' gcdof b c" |
|
2251 |
proof - |
|
2252 |
note carr = a'carr carr' |
|
29237 | 2253 |
interpret weak_lower_semilattice "division_rel G" by simp |
68474 | 2254 |
have "is_glb (division_rel G) a' {b, c}" |
2255 |
by (subst greatest_Lower_cong_l[of _ a]) (simp_all add: a'a carr gcdof_greatestLower[symmetric] agcd) |
|
2256 |
then have "a' \<in> carrier G \<and> a' gcdof b c" |
|
2257 |
by (simp add: gcdof_greatestLower carr') |
|
63832 | 2258 |
then show ?thesis .. |
27701 | 2259 |
qed |
2260 |
||
2261 |
lemma (in gcd_condition_monoid) gcd_closed [simp]: |
|
2262 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2263 |
shows "somegcd G a b \<in> carrier G" |
|
2264 |
proof - |
|
29237 | 2265 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2266 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2267 |
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
|
2268 |
apply (rule meet_closed[simplified], fact+) |
63832 | 2269 |
done |
27701 | 2270 |
qed |
2271 |
||
2272 |
lemma (in gcd_condition_monoid) gcd_isgcd: |
|
2273 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2274 |
shows "(somegcd G a b) gcdof a b" |
|
2275 |
proof - |
|
63832 | 2276 |
interpret weak_lower_semilattice "division_rel G" |
2277 |
by simp |
|
2278 |
from carr have "somegcd G a b \<in> carrier G \<and> (somegcd G a b) gcdof a b" |
|
68474 | 2279 |
by (simp add: gcdof_greatestLower inf_of_two_greatest meet_def somegcd_meet) |
63832 | 2280 |
then show "(somegcd G a b) gcdof a b" |
2281 |
by simp |
|
27701 | 2282 |
qed |
2283 |
||
2284 |
lemma (in gcd_condition_monoid) gcd_exists: |
|
2285 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2286 |
shows "\<exists>x\<in>carrier G. x = somegcd G a b" |
|
2287 |
proof - |
|
63832 | 2288 |
interpret weak_lower_semilattice "division_rel G" |
2289 |
by simp |
|
27701 | 2290 |
show ?thesis |
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2291 |
by (metis carr(1) carr(2) gcd_closed) |
27701 | 2292 |
qed |
2293 |
||
2294 |
lemma (in gcd_condition_monoid) gcd_divides_l: |
|
2295 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2296 |
shows "(somegcd G a b) divides a" |
|
2297 |
proof - |
|
63832 | 2298 |
interpret weak_lower_semilattice "division_rel G" |
2299 |
by simp |
|
27701 | 2300 |
show ?thesis |
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2301 |
by (metis carr(1) carr(2) gcd_isgcd isgcd_def) |
27701 | 2302 |
qed |
2303 |
||
2304 |
lemma (in gcd_condition_monoid) gcd_divides_r: |
|
2305 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" |
|
2306 |
shows "(somegcd G a b) divides b" |
|
2307 |
proof - |
|
63832 | 2308 |
interpret weak_lower_semilattice "division_rel G" |
2309 |
by simp |
|
27701 | 2310 |
show ?thesis |
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2311 |
by (metis carr gcd_isgcd isgcd_def) |
27701 | 2312 |
qed |
2313 |
||
2314 |
lemma (in gcd_condition_monoid) gcd_divides: |
|
2315 |
assumes sub: "z divides x" "z divides y" |
|
2316 |
and L: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G" |
|
2317 |
shows "z divides (somegcd G x y)" |
|
2318 |
proof - |
|
63832 | 2319 |
interpret weak_lower_semilattice "division_rel G" |
2320 |
by simp |
|
27701 | 2321 |
show ?thesis |
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2322 |
by (metis gcd_isgcd isgcd_def assms) |
27701 | 2323 |
qed |
2324 |
||
2325 |
lemma (in gcd_condition_monoid) gcd_cong_l: |
|
2326 |
assumes xx': "x \<sim> x'" |
|
2327 |
and carr: "x \<in> carrier G" "x' \<in> carrier G" "y \<in> carrier G" |
|
2328 |
shows "somegcd G x y \<sim> somegcd G x' y" |
|
2329 |
proof - |
|
63832 | 2330 |
interpret weak_lower_semilattice "division_rel G" |
2331 |
by simp |
|
27701 | 2332 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2333 |
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
|
2334 |
apply (rule meet_cong_l[simplified], fact+) |
63832 | 2335 |
done |
27701 | 2336 |
qed |
2337 |
||
2338 |
lemma (in gcd_condition_monoid) gcd_cong_r: |
|
2339 |
assumes carr: "x \<in> carrier G" "y \<in> carrier G" "y' \<in> carrier G" |
|
2340 |
and yy': "y \<sim> y'" |
|
2341 |
shows "somegcd G x y \<sim> somegcd G x y'" |
|
2342 |
proof - |
|
29237 | 2343 |
interpret weak_lower_semilattice "division_rel G" by simp |
27701 | 2344 |
show ?thesis |
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2345 |
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
|
2346 |
apply (rule meet_cong_r[simplified], fact+) |
63832 | 2347 |
done |
27701 | 2348 |
qed |
2349 |
||
2350 |
(* |
|
2351 |
lemma (in gcd_condition_monoid) asc_cong_gcd_l [intro]: |
|
2352 |
assumes carr: "b \<in> carrier G" |
|
2353 |
shows "asc_cong (\<lambda>a. somegcd G a b)" |
|
2354 |
using carr |
|
2355 |
unfolding CONG_def |
|
2356 |
by clarsimp (blast intro: gcd_cong_l) |
|
2357 |
||
2358 |
lemma (in gcd_condition_monoid) asc_cong_gcd_r [intro]: |
|
2359 |
assumes carr: "a \<in> carrier G" |
|
2360 |
shows "asc_cong (\<lambda>b. somegcd G a b)" |
|
2361 |
using carr |
|
2362 |
unfolding CONG_def |
|
2363 |
by clarsimp (blast intro: gcd_cong_r) |
|
2364 |
||
63832 | 2365 |
lemmas (in gcd_condition_monoid) asc_cong_gcd_split [simp] = |
27701 | 2366 |
assoc_split[OF _ asc_cong_gcd_l] assoc_split[OF _ asc_cong_gcd_r] |
2367 |
*) |
|
2368 |
||
2369 |
lemma (in gcd_condition_monoid) gcdI: |
|
2370 |
assumes dvd: "a divides b" "a divides c" |
|
68474 | 2371 |
and others: "\<And>y. \<lbrakk>y\<in>carrier G; y divides b; y divides c\<rbrakk> \<Longrightarrow> y divides a" |
27701 | 2372 |
and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" and ccarr: "c \<in> carrier G" |
2373 |
shows "a \<sim> somegcd G b c" |
|
68474 | 2374 |
proof - |
2375 |
have "\<exists>a. a \<in> carrier G \<and> a gcdof b c" |
|
2376 |
by (simp add: bcarr ccarr gcdof_exists) |
|
2377 |
moreover have "\<And>x. x \<in> carrier G \<and> x gcdof b c \<Longrightarrow> a \<sim> x" |
|
2378 |
by (simp add: acarr associated_def dvd isgcd_def others) |
|
2379 |
ultimately show ?thesis |
|
2380 |
unfolding somegcd_def by (blast intro: someI2_ex) |
|
2381 |
qed |
|
27701 | 2382 |
|
2383 |
lemma (in gcd_condition_monoid) gcdI2: |
|
63832 | 2384 |
assumes "a gcdof b c" and "a \<in> carrier G" and "b \<in> carrier G" and "c \<in> carrier G" |
27701 | 2385 |
shows "a \<sim> somegcd G b c" |
68474 | 2386 |
using assms unfolding isgcd_def |
2387 |
by (simp add: gcdI) |
|
27701 | 2388 |
|
2389 |
lemma (in gcd_condition_monoid) SomeGcd_ex: |
|
2390 |
assumes "finite A" "A \<subseteq> carrier G" "A \<noteq> {}" |
|
2391 |
shows "\<exists>x\<in> carrier G. x = SomeGcd G A" |
|
2392 |
proof - |
|
63832 | 2393 |
interpret weak_lower_semilattice "division_rel G" |
2394 |
by simp |
|
27701 | 2395 |
show ?thesis |
2396 |
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
|
2397 |
apply (rule finite_inf_closed[simplified], fact+) |
63832 | 2398 |
done |
27701 | 2399 |
qed |
2400 |
||
2401 |
lemma (in gcd_condition_monoid) gcd_assoc: |
|
2402 |
assumes carr: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
|
2403 |
shows "somegcd G (somegcd G a b) c \<sim> somegcd G a (somegcd G b c)" |
|
2404 |
proof - |
|
63832 | 2405 |
interpret weak_lower_semilattice "division_rel G" |
2406 |
by simp |
|
27701 | 2407 |
show ?thesis |
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2408 |
unfolding associated_def |
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2409 |
by (meson carr divides_trans gcd_divides gcd_divides_l gcd_divides_r gcd_exists) |
27701 | 2410 |
qed |
2411 |
||
2412 |
lemma (in gcd_condition_monoid) gcd_mult: |
|
2413 |
assumes acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G" and ccarr: "c \<in> carrier G" |
|
2414 |
shows "c \<otimes> somegcd G a b \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
2415 |
proof - (* following Jacobson, Basic Algebra, p.140 *) |
|
2416 |
let ?d = "somegcd G a b" |
|
2417 |
let ?e = "somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
2418 |
note carr[simp] = acarr bcarr ccarr |
|
2419 |
have dcarr: "?d \<in> carrier G" by simp |
|
2420 |
have ecarr: "?e \<in> carrier G" by simp |
|
2421 |
note carr = carr dcarr ecarr |
|
2422 |
||
2423 |
have "?d divides a" by (simp add: gcd_divides_l) |
|
63832 | 2424 |
then have cd'ca: "c \<otimes> ?d divides (c \<otimes> a)" by (simp add: divides_mult_lI) |
27701 | 2425 |
|
2426 |
have "?d divides b" by (simp add: gcd_divides_r) |
|
63832 | 2427 |
then have cd'cb: "c \<otimes> ?d divides (c \<otimes> b)" by (simp add: divides_mult_lI) |
2428 |
||
2429 |
from cd'ca cd'cb have cd'e: "c \<otimes> ?d divides ?e" |
|
2430 |
by (rule gcd_divides) simp_all |
|
2431 |
then obtain u where ucarr[simp]: "u \<in> carrier G" and e_cdu: "?e = c \<otimes> ?d \<otimes> u" |
|
63847 | 2432 |
by blast |
27701 | 2433 |
|
2434 |
note carr = carr ucarr |
|
2435 |
||
63832 | 2436 |
have "?e divides c \<otimes> a" by (rule gcd_divides_l) simp_all |
2437 |
then obtain x where xcarr: "x \<in> carrier G" and ca_ex: "c \<otimes> a = ?e \<otimes> x" |
|
63847 | 2438 |
by blast |
63832 | 2439 |
with e_cdu have ca_cdux: "c \<otimes> a = c \<otimes> ?d \<otimes> u \<otimes> x" |
2440 |
by simp |
|
2441 |
||
2442 |
from ca_cdux xcarr have "c \<otimes> a = c \<otimes> (?d \<otimes> u \<otimes> x)" |
|
2443 |
by (simp add: m_assoc) |
|
2444 |
then have "a = ?d \<otimes> u \<otimes> x" |
|
2445 |
by (rule l_cancel[of c a]) (simp add: xcarr)+ |
|
2446 |
then have du'a: "?d \<otimes> u divides a" |
|
2447 |
by (rule dividesI[OF xcarr]) |
|
2448 |
||
2449 |
have "?e divides c \<otimes> b" by (intro gcd_divides_r) simp_all |
|
2450 |
then obtain x where xcarr: "x \<in> carrier G" and cb_ex: "c \<otimes> b = ?e \<otimes> x" |
|
63847 | 2451 |
by blast |
63832 | 2452 |
with e_cdu have cb_cdux: "c \<otimes> b = c \<otimes> ?d \<otimes> u \<otimes> x" |
2453 |
by simp |
|
2454 |
||
2455 |
from cb_cdux xcarr have "c \<otimes> b = c \<otimes> (?d \<otimes> u \<otimes> x)" |
|
2456 |
by (simp add: m_assoc) |
|
2457 |
with xcarr have "b = ?d \<otimes> u \<otimes> x" |
|
2458 |
by (intro l_cancel[of c b]) simp_all |
|
2459 |
then have du'b: "?d \<otimes> u divides b" |
|
2460 |
by (intro dividesI[OF xcarr]) |
|
2461 |
||
2462 |
from du'a du'b carr have du'd: "?d \<otimes> u divides ?d" |
|
2463 |
by (intro gcd_divides) simp_all |
|
2464 |
then have uunit: "u \<in> Units G" |
|
27701 | 2465 |
proof (elim dividesE) |
2466 |
fix v |
|
2467 |
assume vcarr[simp]: "v \<in> carrier G" |
|
2468 |
assume d: "?d = ?d \<otimes> u \<otimes> v" |
|
2469 |
have "?d \<otimes> \<one> = ?d \<otimes> u \<otimes> v" by simp fact |
|
2470 |
also have "?d \<otimes> u \<otimes> v = ?d \<otimes> (u \<otimes> v)" by (simp add: m_assoc) |
|
2471 |
finally have "?d \<otimes> \<one> = ?d \<otimes> (u \<otimes> v)" . |
|
63832 | 2472 |
then have i2: "\<one> = u \<otimes> v" by (rule l_cancel) simp_all |
2473 |
then have i1: "\<one> = v \<otimes> u" by (simp add: m_comm) |
|
2474 |
from vcarr i1[symmetric] i2[symmetric] show "u \<in> Units G" |
|
2475 |
by (auto simp: Units_def) |
|
27701 | 2476 |
qed |
2477 |
||
63832 | 2478 |
from e_cdu uunit have "somegcd G (c \<otimes> a) (c \<otimes> b) \<sim> c \<otimes> somegcd G a b" |
2479 |
by (intro associatedI2[of u]) simp_all |
|
2480 |
from this[symmetric] show "c \<otimes> somegcd G a b \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
2481 |
by simp |
|
27701 | 2482 |
qed |
2483 |
||
2484 |
lemma (in monoid) assoc_subst: |
|
2485 |
assumes ab: "a \<sim> b" |
|
63832 | 2486 |
and cP: "\<forall>a b. a \<in> carrier G \<and> b \<in> carrier G \<and> a \<sim> b |
2487 |
\<longrightarrow> f a \<in> carrier G \<and> f b \<in> carrier G \<and> f a \<sim> f b" |
|
27701 | 2488 |
and carr: "a \<in> carrier G" "b \<in> carrier G" |
2489 |
shows "f a \<sim> f b" |
|
2490 |
using assms by auto |
|
2491 |
||
2492 |
lemma (in gcd_condition_monoid) relprime_mult: |
|
63832 | 2493 |
assumes abrelprime: "somegcd G a b \<sim> \<one>" |
2494 |
and acrelprime: "somegcd G a c \<sim> \<one>" |
|
27701 | 2495 |
and carr[simp]: "a \<in> carrier G" "b \<in> carrier G" "c \<in> carrier G" |
2496 |
shows "somegcd G a (b \<otimes> c) \<sim> \<one>" |
|
2497 |
proof - |
|
2498 |
have "c = c \<otimes> \<one>" by simp |
|
2499 |
also from abrelprime[symmetric] |
|
63832 | 2500 |
have "\<dots> \<sim> c \<otimes> somegcd G a b" |
2501 |
by (rule assoc_subst) (simp add: mult_cong_r)+ |
|
2502 |
also have "\<dots> \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
2503 |
by (rule gcd_mult) fact+ |
|
2504 |
finally have c: "c \<sim> somegcd G (c \<otimes> a) (c \<otimes> b)" |
|
2505 |
by simp |
|
2506 |
||
2507 |
from carr have a: "a \<sim> somegcd G a (c \<otimes> a)" |
|
2508 |
by (fast intro: gcdI divides_prod_l) |
|
2509 |
||
2510 |
have "somegcd G a (b \<otimes> c) \<sim> somegcd G a (c \<otimes> b)" |
|
2511 |
by (simp add: m_comm) |
|
2512 |
also from a have "\<dots> \<sim> somegcd G (somegcd G a (c \<otimes> a)) (c \<otimes> b)" |
|
2513 |
by (rule assoc_subst) (simp add: gcd_cong_l)+ |
|
2514 |
also from gcd_assoc have "\<dots> \<sim> somegcd G a (somegcd G (c \<otimes> a) (c \<otimes> b))" |
|
2515 |
by (rule assoc_subst) simp+ |
|
2516 |
also from c[symmetric] have "\<dots> \<sim> somegcd G a c" |
|
2517 |
by (rule assoc_subst) (simp add: gcd_cong_r)+ |
|
27701 | 2518 |
also note acrelprime |
63832 | 2519 |
finally show "somegcd G a (b \<otimes> c) \<sim> \<one>" |
2520 |
by simp |
|
27701 | 2521 |
qed |
2522 |
||
63832 | 2523 |
lemma (in gcd_condition_monoid) primeness_condition: "primeness_condition_monoid G" |
27701 | 2524 |
proof - |
68478 | 2525 |
have *: "p divides a \<or> p divides b" |
2526 |
if pcarr[simp]: "p \<in> carrier G" and acarr[simp]: "a \<in> carrier G" and bcarr[simp]: "b \<in> carrier G" |
|
2527 |
and pirr: "irreducible G p" and pdvdab: "p divides a \<otimes> b" |
|
2528 |
for p a b |
|
2529 |
proof - |
|
2530 |
from pirr have pnunit: "p \<notin> Units G" |
|
2531 |
and r: "\<And>b. \<lbrakk>b \<in> carrier G; properfactor G b p\<rbrakk> \<Longrightarrow> b \<in> Units G" |
|
2532 |
by (fast elim: irreducibleE)+ |
|
2533 |
show "p divides a \<or> p divides b" |
|
2534 |
proof (rule ccontr, clarsimp) |
|
2535 |
assume npdvda: "\<not> p divides a" and npdvdb: "\<not> p divides b" |
|
2536 |
have "\<one> \<sim> somegcd G p a" |
|
2537 |
proof (intro gcdI unit_divides) |
|
2538 |
show "\<And>y. \<lbrakk>y \<in> carrier G; y divides p; y divides a\<rbrakk> \<Longrightarrow> y \<in> Units G" |
|
2539 |
by (meson divides_trans npdvda pcarr properfactorI r) |
|
2540 |
qed auto |
|
2541 |
with pcarr acarr have pa: "somegcd G p a \<sim> \<one>" |
|
2542 |
by (fast intro: associated_sym[of "\<one>"] gcd_closed) |
|
2543 |
have "\<one> \<sim> somegcd G p b" |
|
2544 |
proof (intro gcdI unit_divides) |
|
2545 |
show "\<And>y. \<lbrakk>y \<in> carrier G; y divides p; y divides b\<rbrakk> \<Longrightarrow> y \<in> Units G" |
|
2546 |
by (meson divides_trans npdvdb pcarr properfactorI r) |
|
2547 |
qed auto |
|
2548 |
with pcarr bcarr have pb: "somegcd G p b \<sim> \<one>" |
|
2549 |
by (fast intro: associated_sym[of "\<one>"] gcd_closed) |
|
2550 |
have "p \<sim> somegcd G p (a \<otimes> b)" |
|
2551 |
using pdvdab by (simp add: gcdI2 isgcd_divides_l) |
|
2552 |
also from pa pb pcarr acarr bcarr have "somegcd G p (a \<otimes> b) \<sim> \<one>" |
|
2553 |
by (rule relprime_mult) |
|
2554 |
finally have "p \<sim> \<one>" |
|
2555 |
by simp |
|
2556 |
with pcarr have "p \<in> Units G" |
|
2557 |
by (fast intro: assoc_unit_l) |
|
2558 |
with pnunit show False .. |
|
2559 |
qed |
|
27701 | 2560 |
qed |
68478 | 2561 |
show ?thesis |
2562 |
by unfold_locales (metis * primeI irreducibleE) |
|
2563 |
qed |
|
2564 |
||
27701 | 2565 |
|
29237 | 2566 |
sublocale gcd_condition_monoid \<subseteq> primeness_condition_monoid |
27701 | 2567 |
by (rule primeness_condition) |
2568 |
||
2569 |
||
61382 | 2570 |
subsubsection \<open>Divisor chain condition\<close> |
27701 | 2571 |
|
2572 |
lemma (in divisor_chain_condition_monoid) wfactors_exist: |
|
2573 |
assumes acarr: "a \<in> carrier G" |
|
2574 |
shows "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" |
|
2575 |
proof - |
|
68478 | 2576 |
have r: "a \<in> carrier G \<Longrightarrow> (\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a)" |
2577 |
using division_wellfounded |
|
2578 |
proof (induction rule: wf_induct_rule) |
|
2579 |
case (less x) |
|
2580 |
then have xcarr: "x \<in> carrier G" |
|
2581 |
by auto |
|
2582 |
show ?case |
|
2583 |
proof (cases "x \<in> Units G") |
|
2584 |
case True |
|
2585 |
then show ?thesis |
|
2586 |
by (metis bot.extremum list.set(1) unit_wfactors) |
|
2587 |
next |
|
2588 |
case xnunit: False |
|
2589 |
show ?thesis |
|
2590 |
proof (cases "irreducible G x") |
|
2591 |
case True |
|
2592 |
then show ?thesis |
|
2593 |
by (rule_tac x="[x]" in exI) (simp add: wfactors_def xcarr) |
|
2594 |
next |
|
2595 |
case False |
|
2596 |
then obtain y where ycarr: "y \<in> carrier G" and ynunit: "y \<notin> Units G" and pfyx: "properfactor G y x" |
|
2597 |
by (meson irreducible_def xnunit) |
|
2598 |
obtain ys where yscarr: "set ys \<subseteq> carrier G" and yfs: "wfactors G ys y" |
|
2599 |
using less ycarr pfyx by blast |
|
2600 |
then obtain z where zcarr: "z \<in> carrier G" and x: "x = y \<otimes> z" |
|
2601 |
by (meson dividesE pfyx properfactorE2) |
|
2602 |
from zcarr ycarr have "properfactor G z x" |
|
2603 |
using m_comm properfactorI3 x ynunit by blast |
|
2604 |
with less zcarr obtain zs where zscarr: "set zs \<subseteq> carrier G" and zfs: "wfactors G zs z" |
|
2605 |
by blast |
|
2606 |
from yscarr zscarr have xscarr: "set (ys@zs) \<subseteq> carrier G" |
|
2607 |
by simp |
|
2608 |
have "wfactors G (ys@zs) (y\<otimes>z)" |
|
2609 |
using xscarr ycarr yfs zcarr zfs by auto |
|
2610 |
then have "wfactors G (ys@zs) x" |
|
2611 |
by (simp add: x) |
|
2612 |
with xscarr show "\<exists>xs. set xs \<subseteq> carrier G \<and> wfactors G xs x" |
|
2613 |
by fast |
|
2614 |
qed |
|
27701 | 2615 |
qed |
2616 |
qed |
|
63832 | 2617 |
from acarr show ?thesis by (rule r) |
27701 | 2618 |
qed |
2619 |
||
2620 |
||
61382 | 2621 |
subsubsection \<open>Primeness condition\<close> |
27701 | 2622 |
|
2623 |
lemma (in comm_monoid_cancel) multlist_prime_pos: |
|
68478 | 2624 |
assumes aprime: "prime G a" and carr: "a \<in> carrier G" |
2625 |
and as: "set as \<subseteq> carrier G" "a divides (foldr (\<otimes>) as \<one>)" |
|
2626 |
shows "\<exists>i<length as. a divides (as!i)" |
|
2627 |
using as |
|
2628 |
proof (induction as) |
|
2629 |
case Nil |
|
2630 |
then show ?case |
|
2631 |
by simp (meson Units_one_closed aprime carr divides_unit primeE) |
|
2632 |
next |
|
2633 |
case (Cons x as) |
|
2634 |
then have "x \<in> carrier G" "set as \<subseteq> carrier G" and "a divides x \<otimes> foldr (\<otimes>) as \<one>" |
|
2635 |
by (auto simp: ) |
|
2636 |
with carr aprime have "a divides x \<or> a divides foldr (\<otimes>) as \<one>" |
|
2637 |
by (intro prime_divides) simp+ |
|
2638 |
then show ?case |
|
2639 |
using Cons.IH Cons.prems(1) by force |
|
27701 | 2640 |
qed |
2641 |
||
68478 | 2642 |
|
27701 | 2643 |
lemma (in primeness_condition_monoid) wfactors_unique__hlp_induct: |
63832 | 2644 |
"\<forall>a as'. a \<in> carrier G \<and> set as \<subseteq> carrier G \<and> set as' \<subseteq> carrier G \<and> |
27701 | 2645 |
wfactors G as a \<and> wfactors G as' a \<longrightarrow> essentially_equal G as as'" |
46129 | 2646 |
proof (induct as) |
63832 | 2647 |
case Nil |
2648 |
show ?case |
|
68478 | 2649 |
apply (clarsimp simp: wfactors_def) |
2650 |
by (metis Units_one_closed assoc_unit_r list_update_nonempty unit_wfactors_empty unitfactor_ee wfactorsI) |
|
46129 | 2651 |
next |
63832 | 2652 |
case (Cons ah as) |
2653 |
then show ?case |
|
2654 |
proof clarsimp |
|
46129 | 2655 |
fix a as' |
63832 | 2656 |
assume ih [rule_format]: |
46129 | 2657 |
"\<forall>a as'. a \<in> carrier G \<and> set as' \<subseteq> carrier G \<and> wfactors G as a \<and> |
2658 |
wfactors G as' a \<longrightarrow> essentially_equal G as as'" |
|
2659 |
and acarr: "a \<in> carrier G" and ahcarr: "ah \<in> carrier G" |
|
2660 |
and ascarr: "set as \<subseteq> carrier G" and as'carr: "set as' \<subseteq> carrier G" |
|
2661 |
and afs: "wfactors G (ah # as) a" |
|
2662 |
and afs': "wfactors G as' a" |
|
63832 | 2663 |
then have ahdvda: "ah divides a" |
63847 | 2664 |
by (intro wfactors_dividesI[of "ah#as" "a"]) simp_all |
63832 | 2665 |
then obtain a' where a'carr: "a' \<in> carrier G" and a: "a = ah \<otimes> a'" |
63847 | 2666 |
by blast |
46129 | 2667 |
have a'fs: "wfactors G as a'" |
2668 |
apply (rule wfactorsE[OF afs], rule wfactorsI, simp) |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2669 |
by (metis a a'carr ahcarr ascarr assoc_l_cancel factorsI factors_def factors_mult_single list.set_intros(1) list.set_intros(2) multlist_closed) |
63832 | 2670 |
from afs have ahirr: "irreducible G ah" |
2671 |
by (elim wfactorsE) simp |
|
2672 |
with ascarr have ahprime: "prime G ah" |
|
2673 |
by (intro irreducible_prime ahcarr) |
|
46129 | 2674 |
|
2675 |
note carr [simp] = acarr ahcarr ascarr as'carr a'carr |
|
2676 |
||
2677 |
note ahdvda |
|
67399 | 2678 |
also from afs' have "a divides (foldr (\<otimes>) as' \<one>)" |
46129 | 2679 |
by (elim wfactorsE associatedE, simp) |
67399 | 2680 |
finally have "ah divides (foldr (\<otimes>) as' \<one>)" |
63832 | 2681 |
by simp |
2682 |
with ahprime have "\<exists>i<length as'. ah divides as'!i" |
|
63847 | 2683 |
by (intro multlist_prime_pos) simp_all |
63832 | 2684 |
then obtain i where len: "i<length as'" and ahdvd: "ah divides as'!i" |
63847 | 2685 |
by blast |
46129 | 2686 |
from afs' carr have irrasi: "irreducible G (as'!i)" |
27701 | 2687 |
by (fast intro: nth_mem[OF len] elim: wfactorsE) |
63832 | 2688 |
from len carr have asicarr[simp]: "as'!i \<in> carrier G" |
2689 |
unfolding set_conv_nth by force |
|
46129 | 2690 |
note carr = carr asicarr |
2691 |
||
63847 | 2692 |
from ahdvd obtain x where "x \<in> carrier G" and asi: "as'!i = ah \<otimes> x" |
2693 |
by blast |
|
63832 | 2694 |
with carr irrasi[simplified asi] have asiah: "as'!i \<sim> ah" |
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2695 |
by (metis ahprime associatedI2 irreducible_prodE primeE) |
46129 | 2696 |
note setparts = set_take_subset[of i as'] set_drop_subset[of "Suc i" as'] |
2697 |
note partscarr [simp] = setparts[THEN subset_trans[OF _ as'carr]] |
|
2698 |
note carr = carr partscarr |
|
2699 |
||
2700 |
have "\<exists>aa_1. aa_1 \<in> carrier G \<and> wfactors G (take i as') aa_1" |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2701 |
by (meson afs' in_set_takeD partscarr(1) wfactorsE wfactors_prod_exists) |
63832 | 2702 |
then obtain aa_1 where aa1carr: "aa_1 \<in> carrier G" and aa1fs: "wfactors G (take i as') aa_1" |
2703 |
by auto |
|
46129 | 2704 |
|
2705 |
have "\<exists>aa_2. aa_2 \<in> carrier G \<and> wfactors G (drop (Suc i) as') aa_2" |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2706 |
by (meson afs' in_set_dropD partscarr(2) wfactors_def wfactors_prod_exists) |
63832 | 2707 |
then obtain aa_2 where aa2carr: "aa_2 \<in> carrier G" |
2708 |
and aa2fs: "wfactors G (drop (Suc i) as') aa_2" |
|
2709 |
by auto |
|
46129 | 2710 |
|
2711 |
note carr = carr aa1carr[simp] aa2carr[simp] |
|
2712 |
||
2713 |
from aa1fs aa2fs |
|
63832 | 2714 |
have v1: "wfactors G (take i as' @ drop (Suc i) as') (aa_1 \<otimes> aa_2)" |
27701 | 2715 |
by (intro wfactors_mult, simp+) |
63832 | 2716 |
then have v1': "wfactors G (as'!i # take i as' @ drop (Suc i) as') (as'!i \<otimes> (aa_1 \<otimes> aa_2))" |
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2717 |
using irrasi wfactors_mult_single by auto |
63832 | 2718 |
from aa2carr carr aa1fs aa2fs have "wfactors G (as'!i # drop (Suc i) as') (as'!i \<otimes> aa_2)" |
2719 |
by (metis irrasi wfactors_mult_single) |
|
46129 | 2720 |
with len carr aa1carr aa2carr aa1fs |
63832 | 2721 |
have v2: "wfactors G (take i as' @ as'!i # drop (Suc i) as') (aa_1 \<otimes> (as'!i \<otimes> aa_2))" |
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2722 |
using wfactors_mult by auto |
63832 | 2723 |
from len have as': "as' = (take i as' @ as'!i # drop (Suc i) as')" |
58247
98d0f85d247f
enamed drop_Suc_conv_tl and nth_drop' to Cons_nth_drop_Suc
nipkow
parents:
57865
diff
changeset
|
2724 |
by (simp add: Cons_nth_drop_Suc) |
63832 | 2725 |
with carr have eer: "essentially_equal G (take i as' @ as'!i # drop (Suc i) as') as'" |
27701 | 2726 |
by simp |
63832 | 2727 |
with v2 afs' carr aa1carr aa2carr nth_mem[OF len] have "aa_1 \<otimes> (as'!i \<otimes> aa_2) \<sim> a" |
2728 |
by (metis as' ee_wfactorsD m_closed) |
|
2729 |
then have t1: "as'!i \<otimes> (aa_1 \<otimes> aa_2) \<sim> a" |
|
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2730 |
by (metis aa1carr aa2carr asicarr m_lcomm) |
63832 | 2731 |
from carr asiah have "ah \<otimes> (aa_1 \<otimes> aa_2) \<sim> as'!i \<otimes> (aa_1 \<otimes> aa_2)" |
55242
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
paulson <lp15@cam.ac.uk>
parents:
53374
diff
changeset
|
2732 |
by (metis associated_sym m_closed mult_cong_l) |
46129 | 2733 |
also note t1 |
63832 | 2734 |
finally have "ah \<otimes> (aa_1 \<otimes> aa_2) \<sim> a" by simp |
2735 |
||
2736 |
with carr aa1carr aa2carr a'carr nth_mem[OF len] have a': "aa_1 \<otimes> aa_2 \<sim> a'" |
|
27701 | 2737 |
by (simp add: a, fast intro: assoc_l_cancel[of ah _ a']) |
2738 |
||
46129 | 2739 |
note v1 |
2740 |
also note a' |
|
63832 | 2741 |
finally have "wfactors G (take i as' @ drop (Suc i) as') a'" |
2742 |
by simp |
|
2743 |
||
2744 |
from a'fs this carr have "essentially_equal G as (take i as' @ drop (Suc i) as')" |
|
27701 | 2745 |
by (intro ih[of a']) simp |
63832 | 2746 |
then have ee1: "essentially_equal G (ah # as) (ah # take i as' @ drop (Suc i) as')" |
2747 |
by (elim essentially_equalE) (fastforce intro: essentially_equalI) |
|
2748 |
||
2749 |
from carr have ee2: "essentially_equal G (ah # take i as' @ drop (Suc i) as') |
|
46129 | 2750 |
(as' ! i # take i as' @ drop (Suc i) as')" |
2751 |
proof (intro essentially_equalI) |
|
2752 |
show "ah # take i as' @ drop (Suc i) as' <~~> ah # take i as' @ drop (Suc i) as'" |
|
27701 | 2753 |
by simp |
46129 | 2754 |
next |
2755 |
show "ah # take i as' @ drop (Suc i) as' [\<sim>] as' ! i # take i as' @ drop (Suc i) as'" |
|
63832 | 2756 |
by (simp add: list_all2_append) (simp add: asiah[symmetric]) |
46129 | 2757 |
qed |
2758 |
||
2759 |
note ee1 |
|
2760 |
also note ee2 |
|
2761 |
also have "essentially_equal G (as' ! i # take i as' @ drop (Suc i) as') |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2762 |
(take i as' @ as' ! i # drop (Suc i) as')" |
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2763 |
by (metis as' as'carr listassoc_refl essentially_equalI perm_append_Cons) |
63832 | 2764 |
finally have "essentially_equal G (ah # as) (take i as' @ as' ! i # drop (Suc i) as')" |
2765 |
by simp |
|
2766 |
then show "essentially_equal G (ah # as) as'" |
|
2767 |
by (subst as') |
|
27701 | 2768 |
qed |
2769 |
qed |
|
2770 |
||
2771 |
lemma (in primeness_condition_monoid) wfactors_unique: |
|
2772 |
assumes "wfactors G as a" "wfactors G as' a" |
|
2773 |
and "a \<in> carrier G" "set as \<subseteq> carrier G" "set as' \<subseteq> carrier G" |
|
2774 |
shows "essentially_equal G as as'" |
|
63832 | 2775 |
by (rule wfactors_unique__hlp_induct[rule_format, of a]) (simp add: assms) |
27701 | 2776 |
|
2777 |
||
61382 | 2778 |
subsubsection \<open>Application to factorial monoids\<close> |
2779 |
||
2780 |
text \<open>Number of factors for wellfoundedness\<close> |
|
27701 | 2781 |
|
63832 | 2782 |
definition factorcount :: "_ \<Rightarrow> 'a \<Rightarrow> nat" |
2783 |
where "factorcount G a = |
|
2784 |
(THE c. \<forall>as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> c = length as)" |
|
27701 | 2785 |
|
2786 |
lemma (in monoid) ee_length: |
|
2787 |
assumes ee: "essentially_equal G as bs" |
|
2788 |
shows "length as = length bs" |
|
63832 | 2789 |
by (rule essentially_equalE[OF ee]) (metis list_all2_conv_all_nth perm_length) |
27701 | 2790 |
|
2791 |
lemma (in factorial_monoid) factorcount_exists: |
|
2792 |
assumes carr[simp]: "a \<in> carrier G" |
|
63832 | 2793 |
shows "\<exists>c. \<forall>as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> c = length as" |
27701 | 2794 |
proof - |
63832 | 2795 |
have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" |
2796 |
by (intro wfactors_exist) simp |
|
2797 |
then obtain as where ascarr[simp]: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
|
2798 |
by (auto simp del: carr) |
|
2799 |
have "\<forall>as'. set as' \<subseteq> carrier G \<and> wfactors G as' a \<longrightarrow> length as = length as'" |
|
36278 | 2800 |
by (metis afs ascarr assms ee_length wfactors_unique) |
63832 | 2801 |
then show "\<exists>c. \<forall>as'. set as' \<subseteq> carrier G \<and> wfactors G as' a \<longrightarrow> c = length as'" .. |
27701 | 2802 |
qed |
2803 |
||
2804 |
lemma (in factorial_monoid) factorcount_unique: |
|
2805 |
assumes afs: "wfactors G as a" |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2806 |
and acarr[simp]: "a \<in> carrier G" and ascarr: "set as \<subseteq> carrier G" |
27701 | 2807 |
shows "factorcount G a = length as" |
2808 |
proof - |
|
63832 | 2809 |
have "\<exists>ac. \<forall>as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> ac = length as" |
2810 |
by (rule factorcount_exists) simp |
|
2811 |
then obtain ac where alen: "\<forall>as. set as \<subseteq> carrier G \<and> wfactors G as a \<longrightarrow> ac = length as" |
|
2812 |
by auto |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2813 |
then have ac: "ac = factorcount G a" |
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2814 |
unfolding factorcount_def using ascarr by (blast intro: theI2 afs) |
63832 | 2815 |
from ascarr afs have "ac = length as" |
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2816 |
by (simp add: alen) |
63832 | 2817 |
with ac show ?thesis |
2818 |
by simp |
|
27701 | 2819 |
qed |
2820 |
||
2821 |
lemma (in factorial_monoid) divides_fcount: |
|
2822 |
assumes dvd: "a divides b" |
|
63832 | 2823 |
and acarr: "a \<in> carrier G" |
2824 |
and bcarr:"b \<in> carrier G" |
|
2825 |
shows "factorcount G a \<le> factorcount G b" |
|
2826 |
proof (rule dividesE[OF dvd]) |
|
27701 | 2827 |
fix c |
63832 | 2828 |
from assms have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" |
63847 | 2829 |
by blast |
63832 | 2830 |
then obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
63847 | 2831 |
by blast |
63832 | 2832 |
with acarr have fca: "factorcount G a = length as" |
2833 |
by (intro factorcount_unique) |
|
27701 | 2834 |
|
2835 |
assume ccarr: "c \<in> carrier G" |
|
63832 | 2836 |
then have "\<exists>cs. set cs \<subseteq> carrier G \<and> wfactors G cs c" |
63847 | 2837 |
by blast |
63832 | 2838 |
then obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfs: "wfactors G cs c" |
63847 | 2839 |
by blast |
27701 | 2840 |
|
2841 |
note [simp] = acarr bcarr ccarr ascarr cscarr |
|
2842 |
||
2843 |
assume b: "b = a \<otimes> c" |
|
63832 | 2844 |
from afs cfs have "wfactors G (as@cs) (a \<otimes> c)" |
2845 |
by (intro wfactors_mult) simp_all |
|
2846 |
with b have "wfactors G (as@cs) b" |
|
2847 |
by simp |
|
2848 |
then have "factorcount G b = length (as@cs)" |
|
2849 |
by (intro factorcount_unique) simp_all |
|
2850 |
then have "factorcount G b = length as + length cs" |
|
2851 |
by simp |
|
2852 |
with fca show ?thesis |
|
2853 |
by simp |
|
27701 | 2854 |
qed |
2855 |
||
2856 |
lemma (in factorial_monoid) associated_fcount: |
|
63832 | 2857 |
assumes acarr: "a \<in> carrier G" |
2858 |
and bcarr: "b \<in> carrier G" |
|
27701 | 2859 |
and asc: "a \<sim> b" |
2860 |
shows "factorcount G a = factorcount G b" |
|
68488
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2861 |
using assms |
dfbd80c3d180
more modernisaton and de-applying
paulson <lp15@cam.ac.uk>
parents:
68478
diff
changeset
|
2862 |
by (auto simp: associated_def factorial_monoid.divides_fcount factorial_monoid_axioms le_antisym) |
27701 | 2863 |
|
2864 |
lemma (in factorial_monoid) properfactor_fcount: |
|
2865 |
assumes acarr: "a \<in> carrier G" and bcarr:"b \<in> carrier G" |
|
2866 |
and pf: "properfactor G a b" |
|
2867 |
shows "factorcount G a < factorcount G b" |
|
63832 | 2868 |
proof (rule properfactorE[OF pf], elim dividesE) |
27701 | 2869 |
fix c |
63832 | 2870 |
from assms have "\<exists>as. set as \<subseteq> carrier G \<and> wfactors G as a" |
63847 | 2871 |
by blast |
63832 | 2872 |
then obtain as where ascarr: "set as \<subseteq> carrier G" and afs: "wfactors G as a" |
63847 | 2873 |
by blast |
63832 | 2874 |
with acarr have fca: "factorcount G a = length as" |
2875 |
by (intro factorcount_unique) |
|
27701 | 2876 |
|
2877 |
assume ccarr: "c \<in> carrier G" |
|
63832 | 2878 |
then have "\<exists>cs. set cs \<subseteq> carrier G \<and> wfactors G cs c" |
63847 | 2879 |
by blast |
63832 | 2880 |
then obtain cs where cscarr: "set cs \<subseteq> carrier G" and cfs: "wfactors G cs c" |
63847 | 2881 |
by blast |
27701 | 2882 |
|
2883 |
assume b: "b = a \<otimes> c" |
|
2884 |
||
63832 | 2885 |
have "wfactors G (as@cs) (a \<otimes> c)" |
2886 |
by (rule wfactors_mult) fact+ |
|
2887 |
with b have "wfactors G (as@cs) b" |
|
2888 |
by simp |
|
2889 |
with ascarr cscarr bcarr have "factorcount G b = length (as@cs)" |
|
2890 |
by (simp add: factorcount_unique) |
|
2891 |
then have fcb: "factorcount G b = length as + length cs" |
|
2892 |
by simp |
|
27701 | 2893 |
|
2894 |
assume nbdvda: "\<not> b divides a" |
|
2895 |
have "c \<notin> Units G" |
|
63846 | 2896 |
proof |
27701 | 2897 |
assume cunit:"c \<in> Units G" |
63832 | 2898 |
have "b \<otimes> inv c = a \<otimes> c \<otimes> inv c" |
2899 |
by (simp add: b) |
|
2900 |
also from ccarr acarr cunit have "\<dots> = a \<otimes> (c \<otimes> inv c)" |
|
2901 |
by (fast intro: m_assoc) |
|
2902 |
also from ccarr cunit have "\<dots> = a \<otimes> \<one>" by simp |
|
2903 |
also from acarr have "\<dots> = a" by simp |
|
27701 | 2904 |
finally have "a = b \<otimes> inv c" by simp |
63832 | 2905 |
with ccarr cunit have "b divides a" |
2906 |
by (fast intro: dividesI[of "inv c"]) |
|
27701 | 2907 |
with nbdvda show False by simp |
2908 |
qed |
|
2909 |
with cfs have "length cs > 0" |
|
68474 | 2910 |
by (metis Units_one_closed assoc_unit_r ccarr foldr.simps(1) id_apply length_greater_0_conv wfactors_def) |
63832 | 2911 |
with fca fcb show ?thesis |
2912 |
by simp |
|
27701 | 2913 |
qed |
2914 |
||
29237 | 2915 |
sublocale factorial_monoid \<subseteq> divisor_chain_condition_monoid |
63832 | 2916 |
apply unfold_locales |
2917 |
apply (rule wfUNIVI) |
|
2918 |
apply (rule measure_induct[of "factorcount G"]) |
|
2919 |
apply simp |
|
2920 |
apply (metis properfactor_fcount) |
|
2921 |
done |
|
27701 | 2922 |
|
29237 | 2923 |
sublocale factorial_monoid \<subseteq> primeness_condition_monoid |
63633 | 2924 |
by standard (rule irreducible_prime) |
27701 | 2925 |
|
2926 |
||
63832 | 2927 |
lemma (in factorial_monoid) primeness_condition: "primeness_condition_monoid G" .. |
2928 |
||
2929 |
lemma (in factorial_monoid) gcd_condition [simp]: "gcd_condition_monoid G" |
|
61169 | 2930 |
by standard (rule gcdof_exists) |
27701 | 2931 |
|
29237 | 2932 |
sublocale factorial_monoid \<subseteq> gcd_condition_monoid |
61169 | 2933 |
by standard (rule gcdof_exists) |
27701 | 2934 |
|
63832 | 2935 |
lemma (in factorial_monoid) division_weak_lattice [simp]: "weak_lattice (division_rel G)" |
27701 | 2936 |
proof - |
63832 | 2937 |
interpret weak_lower_semilattice "division_rel G" |
2938 |
by simp |
|
27713
95b36bfe7fc4
New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents:
27701
diff
changeset
|
2939 |
show "weak_lattice (division_rel G)" |
63832 | 2940 |
proof (unfold_locales, simp_all) |
27701 | 2941 |
fix x y |
2942 |
assume carr: "x \<in> carrier G" "y \<in> carrier G" |
|
63847 | 2943 |
from lcmof_exists [OF this] obtain z where zcarr: "z \<in> carrier G" and isgcd: "z lcmof x y" |
2944 |
by blast |
|
63832 | 2945 |
with carr have "least (division_rel G) z (Upper (division_rel G) {x, y})" |
2946 |
by (simp add: lcmof_leastUpper[symmetric]) |
|
2947 |
then show "\<exists>z. least (division_rel G) z (Upper (division_rel G) {x, y})" |
|
63847 | 2948 |
by blast |
27701 | 2949 |
qed |
2950 |
qed |
|
2951 |
||
2952 |
||
61382 | 2953 |
subsection \<open>Factoriality Theorems\<close> |
27701 | 2954 |
|
2955 |
theorem factorial_condition_one: (* Jacobson theorem 2.21 *) |
|
63847 | 2956 |
"divisor_chain_condition_monoid G \<and> primeness_condition_monoid G \<longleftrightarrow> factorial_monoid G" |
2957 |
proof (rule iffI, clarify) |
|
27701 | 2958 |
assume dcc: "divisor_chain_condition_monoid G" |
63832 | 2959 |
and pc: "primeness_condition_monoid G" |
29237 | 2960 |
interpret divisor_chain_condition_monoid "G" by (rule dcc) |
2961 |
interpret primeness_condition_monoid "G" by (rule pc) |
|
27701 | 2962 |
show "factorial_monoid G" |
63832 | 2963 |
by (fast intro: factorial_monoidI wfactors_exist wfactors_unique) |
27701 | 2964 |
next |
63847 | 2965 |
assume "factorial_monoid G" |
2966 |
then interpret factorial_monoid "G" . |
|
27701 | 2967 |
show "divisor_chain_condition_monoid G \<and> primeness_condition_monoid G" |
63832 | 2968 |
by rule unfold_locales |
27701 | 2969 |
qed |
2970 |
||
2971 |
theorem factorial_condition_two: (* Jacobson theorem 2.22 *) |
|
63847 | 2972 |
"divisor_chain_condition_monoid G \<and> gcd_condition_monoid G \<longleftrightarrow> factorial_monoid G" |
2973 |
proof (rule iffI, clarify) |
|
57865 | 2974 |
assume dcc: "divisor_chain_condition_monoid G" |
63832 | 2975 |
and gc: "gcd_condition_monoid G" |
29237 | 2976 |
interpret divisor_chain_condition_monoid "G" by (rule dcc) |
2977 |
interpret gcd_condition_monoid "G" by (rule gc) |
|
27701 | 2978 |
show "factorial_monoid G" |
63832 | 2979 |
by (simp add: factorial_condition_one[symmetric], rule, unfold_locales) |
27701 | 2980 |
next |
63847 | 2981 |
assume "factorial_monoid G" |
2982 |
then interpret factorial_monoid "G" . |
|
27701 | 2983 |
show "divisor_chain_condition_monoid G \<and> gcd_condition_monoid G" |
63832 | 2984 |
by rule unfold_locales |
27701 | 2985 |
qed |
2986 |
||
2987 |
end |