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