author | wenzelm |
Sun, 20 May 2012 11:34:33 +0200 | |
changeset 47884 | 21c42b095c84 |
parent 44872 | a98ef45122f3 |
child 48822 | 21d4ed91912f |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Number_Theory/UniqueFactorization.thy |
31719 | 2 |
Author: Jeremy Avigad |
3 |
||
41541 | 4 |
Unique factorization for the natural numbers and the integers. |
31719 | 5 |
|
41541 | 6 |
Note: there were previous Isabelle formalizations of unique |
7 |
factorization due to Thomas Marthedal Rasmussen, and, building on |
|
8 |
that, by Jeremy Avigad and David Gray. |
|
31719 | 9 |
*) |
10 |
||
11 |
header {* UniqueFactorization *} |
|
12 |
||
13 |
theory UniqueFactorization |
|
41413
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
wenzelm
parents:
40461
diff
changeset
|
14 |
imports Cong "~~/src/HOL/Library/Multiset" |
31719 | 15 |
begin |
16 |
||
17 |
(* inherited from Multiset *) |
|
18 |
declare One_nat_def [simp del] |
|
19 |
||
20 |
(* As a simp or intro rule, |
|
21 |
||
22 |
prime p \<Longrightarrow> p > 0 |
|
23 |
||
24 |
wreaks havoc here. When the premise includes ALL x :# M. prime x, it |
|
25 |
leads to the backchaining |
|
26 |
||
27 |
x > 0 |
|
28 |
prime x |
|
29 |
x :# M which is, unfortunately, |
|
30 |
count M x > 0 |
|
31 |
*) |
|
32 |
||
33 |
||
34 |
(* useful facts *) |
|
35 |
||
36 |
lemma setsum_Un2: "finite (A Un B) \<Longrightarrow> |
|
37 |
setsum f (A Un B) = setsum f (A - B) + setsum f (B - A) + |
|
38 |
setsum f (A Int B)" |
|
39 |
apply (subgoal_tac "A Un B = (A - B) Un (B - A) Un (A Int B)") |
|
40 |
apply (erule ssubst) |
|
41 |
apply (subst setsum_Un_disjoint) |
|
42 |
apply auto |
|
43 |
apply (subst setsum_Un_disjoint) |
|
44 |
apply auto |
|
44872 | 45 |
done |
31719 | 46 |
|
47 |
lemma setprod_Un2: "finite (A Un B) \<Longrightarrow> |
|
48 |
setprod f (A Un B) = setprod f (A - B) * setprod f (B - A) * |
|
49 |
setprod f (A Int B)" |
|
50 |
apply (subgoal_tac "A Un B = (A - B) Un (B - A) Un (A Int B)") |
|
51 |
apply (erule ssubst) |
|
52 |
apply (subst setprod_Un_disjoint) |
|
53 |
apply auto |
|
54 |
apply (subst setprod_Un_disjoint) |
|
55 |
apply auto |
|
44872 | 56 |
done |
31719 | 57 |
|
58 |
(* Here is a version of set product for multisets. Is it worth moving |
|
59 |
to multiset.thy? If so, one should similarly define msetsum for abelian |
|
60 |
semirings, using of_nat. Also, is it worth developing bounded quantifiers |
|
61 |
"ALL i :# M. P i"? |
|
62 |
*) |
|
63 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
35054
diff
changeset
|
64 |
definition msetprod :: "('a => ('b::{power,comm_monoid_mult})) => 'a multiset => 'b" where |
31719 | 65 |
"msetprod f M == setprod (%x. (f x)^(count M x)) (set_of M)" |
66 |
||
67 |
syntax |
|
68 |
"_msetprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" |
|
69 |
("(3PROD _:#_. _)" [0, 51, 10] 10) |
|
70 |
||
71 |
translations |
|
35054 | 72 |
"PROD i :# A. b" == "CONST msetprod (%i. b) A" |
31719 | 73 |
|
44872 | 74 |
lemma msetprod_empty: "msetprod f {#} = 1" |
37290 | 75 |
by (simp add: msetprod_def) |
76 |
||
44872 | 77 |
lemma msetprod_singleton: "msetprod f {#x#} = f x" |
37290 | 78 |
by (simp add: msetprod_def) |
79 |
||
31719 | 80 |
lemma msetprod_Un: "msetprod f (A+B) = msetprod f A * msetprod f B" |
81 |
apply (simp add: msetprod_def power_add) |
|
82 |
apply (subst setprod_Un2) |
|
83 |
apply auto |
|
84 |
apply (subgoal_tac |
|
85 |
"(PROD x:set_of A - set_of B. f x ^ count A x * f x ^ count B x) = |
|
86 |
(PROD x:set_of A - set_of B. f x ^ count A x)") |
|
87 |
apply (erule ssubst) |
|
88 |
apply (subgoal_tac |
|
89 |
"(PROD x:set_of B - set_of A. f x ^ count A x * f x ^ count B x) = |
|
90 |
(PROD x:set_of B - set_of A. f x ^ count B x)") |
|
91 |
apply (erule ssubst) |
|
92 |
apply (subgoal_tac "(PROD x:set_of A. f x ^ count A x) = |
|
93 |
(PROD x:set_of A - set_of B. f x ^ count A x) * |
|
94 |
(PROD x:set_of A Int set_of B. f x ^ count A x)") |
|
95 |
apply (erule ssubst) |
|
96 |
apply (subgoal_tac "(PROD x:set_of B. f x ^ count B x) = |
|
97 |
(PROD x:set_of B - set_of A. f x ^ count B x) * |
|
98 |
(PROD x:set_of A Int set_of B. f x ^ count B x)") |
|
99 |
apply (erule ssubst) |
|
100 |
apply (subst setprod_timesf) |
|
101 |
apply (force simp add: mult_ac) |
|
102 |
apply (subst setprod_Un_disjoint [symmetric]) |
|
103 |
apply (auto intro: setprod_cong) |
|
104 |
apply (subst setprod_Un_disjoint [symmetric]) |
|
105 |
apply (auto intro: setprod_cong) |
|
44872 | 106 |
done |
31719 | 107 |
|
108 |
||
109 |
subsection {* unique factorization: multiset version *} |
|
110 |
||
111 |
lemma multiset_prime_factorization_exists [rule_format]: "n > 0 --> |
|
112 |
(EX M. (ALL (p::nat) : set_of M. prime p) & n = (PROD i :# M. i))" |
|
113 |
proof (rule nat_less_induct, clarify) |
|
114 |
fix n :: nat |
|
115 |
assume ih: "ALL m < n. 0 < m --> (EX M. (ALL p : set_of M. prime p) & m = |
|
116 |
(PROD i :# M. i))" |
|
117 |
assume "(n::nat) > 0" |
|
118 |
then have "n = 1 | (n > 1 & prime n) | (n > 1 & ~ prime n)" |
|
119 |
by arith |
|
44872 | 120 |
moreover { |
31719 | 121 |
assume "n = 1" |
122 |
then have "(ALL p : set_of {#}. prime p) & n = (PROD i :# {#}. i)" |
|
123 |
by (auto simp add: msetprod_def) |
|
44872 | 124 |
} moreover { |
31719 | 125 |
assume "n > 1" and "prime n" |
126 |
then have "(ALL p : set_of {# n #}. prime p) & n = (PROD i :# {# n #}. i)" |
|
127 |
by (auto simp add: msetprod_def) |
|
44872 | 128 |
} moreover { |
31719 | 129 |
assume "n > 1" and "~ prime n" |
44872 | 130 |
with not_prime_eq_prod_nat |
131 |
obtain m k where n: "n = m * k & 1 < m & m < n & 1 < k & k < n" |
|
132 |
by blast |
|
31719 | 133 |
with ih obtain Q R where "(ALL p : set_of Q. prime p) & m = (PROD i:#Q. i)" |
134 |
and "(ALL p: set_of R. prime p) & k = (PROD i:#R. i)" |
|
135 |
by blast |
|
44872 | 136 |
then have "(ALL p: set_of (Q + R). prime p) & n = (PROD i :# Q + R. i)" |
41541 | 137 |
by (auto simp add: n msetprod_Un) |
31719 | 138 |
then have "EX M. (ALL p : set_of M. prime p) & n = (PROD i :# M. i)".. |
139 |
} |
|
140 |
ultimately show "EX M. (ALL p : set_of M. prime p) & n = (PROD i::nat:#M. i)" |
|
141 |
by blast |
|
142 |
qed |
|
143 |
||
144 |
lemma multiset_prime_factorization_unique_aux: |
|
145 |
fixes a :: nat |
|
146 |
assumes "(ALL p : set_of M. prime p)" and |
|
147 |
"(ALL p : set_of N. prime p)" and |
|
148 |
"(PROD i :# M. i) dvd (PROD i:# N. i)" |
|
149 |
shows |
|
150 |
"count M a <= count N a" |
|
151 |
proof cases |
|
41541 | 152 |
assume M: "a : set_of M" |
153 |
with assms have a: "prime a" by auto |
|
154 |
with M have "a ^ count M a dvd (PROD i :# M. i)" |
|
31719 | 155 |
by (auto intro: dvd_setprod simp add: msetprod_def) |
41541 | 156 |
also have "... dvd (PROD i :# N. i)" by (rule assms) |
31719 | 157 |
also have "... = (PROD i : (set_of N). i ^ (count N i))" |
158 |
by (simp add: msetprod_def) |
|
44872 | 159 |
also have "... = a^(count N a) * (PROD i : (set_of N - {a}). i ^ (count N i))" |
160 |
proof (cases) |
|
161 |
assume "a : set_of N" |
|
162 |
then have b: "set_of N = {a} Un (set_of N - {a})" |
|
163 |
by auto |
|
164 |
then show ?thesis |
|
165 |
by (subst (1) b, subst setprod_Un_disjoint, auto) |
|
166 |
next |
|
167 |
assume "a ~: set_of N" |
|
168 |
then show ?thesis by auto |
|
169 |
qed |
|
31719 | 170 |
finally have "a ^ count M a dvd |
171 |
a^(count N a) * (PROD i : (set_of N - {a}). i ^ (count N i))". |
|
44872 | 172 |
moreover |
173 |
have "coprime (a ^ count M a) (PROD i : (set_of N - {a}). i ^ (count N i))" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
174 |
apply (subst gcd_commute_nat) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
175 |
apply (rule setprod_coprime_nat) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
176 |
apply (rule primes_imp_powers_coprime_nat) |
41541 | 177 |
using assms M |
178 |
apply auto |
|
31719 | 179 |
done |
180 |
ultimately have "a ^ count M a dvd a^(count N a)" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
181 |
by (elim coprime_dvd_mult_nat) |
31719 | 182 |
with a show ?thesis |
44872 | 183 |
apply (intro power_dvd_imp_le) |
184 |
apply auto |
|
185 |
done |
|
31719 | 186 |
next |
187 |
assume "a ~: set_of M" |
|
44872 | 188 |
then show ?thesis by auto |
31719 | 189 |
qed |
190 |
||
191 |
lemma multiset_prime_factorization_unique: |
|
192 |
assumes "(ALL (p::nat) : set_of M. prime p)" and |
|
193 |
"(ALL p : set_of N. prime p)" and |
|
194 |
"(PROD i :# M. i) = (PROD i:# N. i)" |
|
195 |
shows |
|
196 |
"M = N" |
|
197 |
proof - |
|
198 |
{ |
|
199 |
fix a |
|
41541 | 200 |
from assms have "count M a <= count N a" |
31719 | 201 |
by (intro multiset_prime_factorization_unique_aux, auto) |
41541 | 202 |
moreover from assms have "count N a <= count M a" |
31719 | 203 |
by (intro multiset_prime_factorization_unique_aux, auto) |
204 |
ultimately have "count M a = count N a" |
|
205 |
by auto |
|
206 |
} |
|
44872 | 207 |
then show ?thesis by (simp add:multiset_eq_iff) |
31719 | 208 |
qed |
209 |
||
44872 | 210 |
definition multiset_prime_factorization :: "nat => nat multiset" |
211 |
where |
|
31719 | 212 |
"multiset_prime_factorization n == |
213 |
if n > 0 then (THE M. ((ALL p : set_of M. prime p) & |
|
214 |
n = (PROD i :# M. i))) |
|
215 |
else {#}" |
|
216 |
||
217 |
lemma multiset_prime_factorization: "n > 0 ==> |
|
218 |
(ALL p : set_of (multiset_prime_factorization n). prime p) & |
|
219 |
n = (PROD i :# (multiset_prime_factorization n). i)" |
|
220 |
apply (unfold multiset_prime_factorization_def) |
|
221 |
apply clarsimp |
|
222 |
apply (frule multiset_prime_factorization_exists) |
|
223 |
apply clarify |
|
224 |
apply (rule theI) |
|
225 |
apply (insert multiset_prime_factorization_unique, blast)+ |
|
226 |
done |
|
227 |
||
228 |
||
229 |
subsection {* Prime factors and multiplicity for nats and ints *} |
|
230 |
||
231 |
class unique_factorization = |
|
44872 | 232 |
fixes multiplicity :: "'a \<Rightarrow> 'a \<Rightarrow> nat" |
233 |
and prime_factors :: "'a \<Rightarrow> 'a set" |
|
31719 | 234 |
|
235 |
(* definitions for the natural numbers *) |
|
236 |
||
237 |
instantiation nat :: unique_factorization |
|
238 |
begin |
|
239 |
||
44872 | 240 |
definition multiplicity_nat :: "nat \<Rightarrow> nat \<Rightarrow> nat" |
241 |
where "multiplicity_nat p n = count (multiset_prime_factorization n) p" |
|
31719 | 242 |
|
44872 | 243 |
definition prime_factors_nat :: "nat \<Rightarrow> nat set" |
244 |
where "prime_factors_nat n = set_of (multiset_prime_factorization n)" |
|
31719 | 245 |
|
44872 | 246 |
instance .. |
31719 | 247 |
|
248 |
end |
|
249 |
||
250 |
(* definitions for the integers *) |
|
251 |
||
252 |
instantiation int :: unique_factorization |
|
253 |
begin |
|
254 |
||
44872 | 255 |
definition multiplicity_int :: "int \<Rightarrow> int \<Rightarrow> nat" |
256 |
where "multiplicity_int p n = multiplicity (nat p) (nat n)" |
|
31719 | 257 |
|
44872 | 258 |
definition prime_factors_int :: "int \<Rightarrow> int set" |
259 |
where "prime_factors_int n = int ` (prime_factors (nat n))" |
|
31719 | 260 |
|
44872 | 261 |
instance .. |
31719 | 262 |
|
263 |
end |
|
264 |
||
265 |
||
266 |
subsection {* Set up transfer *} |
|
267 |
||
44872 | 268 |
lemma transfer_nat_int_prime_factors: "prime_factors (nat n) = nat ` prime_factors n" |
269 |
unfolding prime_factors_int_def |
|
270 |
apply auto |
|
271 |
apply (subst transfer_int_nat_set_return_embed) |
|
272 |
apply assumption |
|
273 |
done |
|
31719 | 274 |
|
44872 | 275 |
lemma transfer_nat_int_prime_factors_closure: "n >= 0 \<Longrightarrow> nat_set (prime_factors n)" |
31719 | 276 |
by (auto simp add: nat_set_def prime_factors_int_def) |
277 |
||
278 |
lemma transfer_nat_int_multiplicity: "p >= 0 \<Longrightarrow> n >= 0 \<Longrightarrow> |
|
44872 | 279 |
multiplicity (nat p) (nat n) = multiplicity p n" |
31719 | 280 |
by (auto simp add: multiplicity_int_def) |
281 |
||
35644 | 282 |
declare transfer_morphism_nat_int[transfer add return: |
31719 | 283 |
transfer_nat_int_prime_factors transfer_nat_int_prime_factors_closure |
284 |
transfer_nat_int_multiplicity] |
|
285 |
||
286 |
||
44872 | 287 |
lemma transfer_int_nat_prime_factors: "prime_factors (int n) = int ` prime_factors n" |
31719 | 288 |
unfolding prime_factors_int_def by auto |
289 |
||
290 |
lemma transfer_int_nat_prime_factors_closure: "is_nat n \<Longrightarrow> |
|
291 |
nat_set (prime_factors n)" |
|
292 |
by (simp only: transfer_nat_int_prime_factors_closure is_nat_def) |
|
293 |
||
294 |
lemma transfer_int_nat_multiplicity: |
|
295 |
"multiplicity (int p) (int n) = multiplicity p n" |
|
296 |
by (auto simp add: multiplicity_int_def) |
|
297 |
||
35644 | 298 |
declare transfer_morphism_int_nat[transfer add return: |
31719 | 299 |
transfer_int_nat_prime_factors transfer_int_nat_prime_factors_closure |
300 |
transfer_int_nat_multiplicity] |
|
301 |
||
302 |
||
303 |
subsection {* Properties of prime factors and multiplicity for nats and ints *} |
|
304 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
305 |
lemma prime_factors_ge_0_int [elim]: "p : prime_factors (n::int) \<Longrightarrow> p >= 0" |
44872 | 306 |
unfolding prime_factors_int_def by auto |
31719 | 307 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
308 |
lemma prime_factors_prime_nat [intro]: "p : prime_factors (n::nat) \<Longrightarrow> prime p" |
44872 | 309 |
apply (cases "n = 0") |
31719 | 310 |
apply (simp add: prime_factors_nat_def multiset_prime_factorization_def) |
311 |
apply (auto simp add: prime_factors_nat_def multiset_prime_factorization) |
|
41541 | 312 |
done |
31719 | 313 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
314 |
lemma prime_factors_prime_int [intro]: |
31719 | 315 |
assumes "n >= 0" and "p : prime_factors (n::int)" |
316 |
shows "prime p" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
317 |
apply (rule prime_factors_prime_nat [transferred, of n p]) |
41541 | 318 |
using assms apply auto |
319 |
done |
|
31719 | 320 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
321 |
lemma prime_factors_gt_0_nat [elim]: "p : prime_factors x \<Longrightarrow> p > (0::nat)" |
44872 | 322 |
apply (frule prime_factors_prime_nat) |
323 |
apply auto |
|
324 |
done |
|
31719 | 325 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
326 |
lemma prime_factors_gt_0_int [elim]: "x >= 0 \<Longrightarrow> p : prime_factors x \<Longrightarrow> |
31719 | 327 |
p > (0::int)" |
44872 | 328 |
apply (frule (1) prime_factors_prime_int) |
329 |
apply auto |
|
330 |
done |
|
31719 | 331 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
332 |
lemma prime_factors_finite_nat [iff]: "finite (prime_factors (n::nat))" |
44872 | 333 |
unfolding prime_factors_nat_def by auto |
31719 | 334 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
335 |
lemma prime_factors_finite_int [iff]: "finite (prime_factors (n::int))" |
44872 | 336 |
unfolding prime_factors_int_def by auto |
31719 | 337 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
338 |
lemma prime_factors_altdef_nat: "prime_factors (n::nat) = |
31719 | 339 |
{p. multiplicity p n > 0}" |
340 |
by (force simp add: prime_factors_nat_def multiplicity_nat_def) |
|
341 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
342 |
lemma prime_factors_altdef_int: "prime_factors (n::int) = |
31719 | 343 |
{p. p >= 0 & multiplicity p n > 0}" |
344 |
apply (unfold prime_factors_int_def multiplicity_int_def) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
345 |
apply (subst prime_factors_altdef_nat) |
31719 | 346 |
apply (auto simp add: image_def) |
41541 | 347 |
done |
31719 | 348 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
349 |
lemma prime_factorization_nat: "(n::nat) > 0 \<Longrightarrow> |
31719 | 350 |
n = (PROD p : prime_factors n. p^(multiplicity p n))" |
44872 | 351 |
apply (frule multiset_prime_factorization) |
352 |
apply (simp add: prime_factors_nat_def multiplicity_nat_def msetprod_def) |
|
353 |
done |
|
31719 | 354 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
355 |
lemma prime_factorization_int: |
31719 | 356 |
assumes "(n::int) > 0" |
357 |
shows "n = (PROD p : prime_factors n. p^(multiplicity p n))" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
358 |
apply (rule prime_factorization_nat [transferred, of n]) |
41541 | 359 |
using assms apply auto |
360 |
done |
|
31719 | 361 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
362 |
lemma neq_zero_eq_gt_zero_nat: "((x::nat) ~= 0) = (x > 0)" |
31719 | 363 |
by auto |
364 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
365 |
lemma prime_factorization_unique_nat: |
31719 | 366 |
"S = { (p::nat) . f p > 0} \<Longrightarrow> finite S \<Longrightarrow> (ALL p : S. prime p) \<Longrightarrow> |
367 |
n = (PROD p : S. p^(f p)) \<Longrightarrow> |
|
368 |
S = prime_factors n & (ALL p. f p = multiplicity p n)" |
|
44872 | 369 |
apply (subgoal_tac "multiset_prime_factorization n = Abs_multiset f") |
31719 | 370 |
apply (unfold prime_factors_nat_def multiplicity_nat_def) |
34947 | 371 |
apply (simp add: set_of_def Abs_multiset_inverse multiset_def) |
31719 | 372 |
apply (unfold multiset_prime_factorization_def) |
373 |
apply (subgoal_tac "n > 0") |
|
374 |
prefer 2 |
|
375 |
apply force |
|
376 |
apply (subst if_P, assumption) |
|
377 |
apply (rule the1_equality) |
|
378 |
apply (rule ex_ex1I) |
|
379 |
apply (rule multiset_prime_factorization_exists, assumption) |
|
380 |
apply (rule multiset_prime_factorization_unique) |
|
381 |
apply force |
|
382 |
apply force |
|
383 |
apply force |
|
34947 | 384 |
unfolding set_of_def msetprod_def |
31719 | 385 |
apply (subgoal_tac "f : multiset") |
386 |
apply (auto simp only: Abs_multiset_inverse) |
|
387 |
unfolding multiset_def apply force |
|
44872 | 388 |
done |
31719 | 389 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
390 |
lemma prime_factors_characterization_nat: "S = {p. 0 < f (p::nat)} \<Longrightarrow> |
31719 | 391 |
finite S \<Longrightarrow> (ALL p:S. prime p) \<Longrightarrow> n = (PROD p:S. p ^ f p) \<Longrightarrow> |
392 |
prime_factors n = S" |
|
44872 | 393 |
apply (rule prime_factorization_unique_nat [THEN conjunct1, symmetric]) |
394 |
apply assumption+ |
|
395 |
done |
|
31719 | 396 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
397 |
lemma prime_factors_characterization'_nat: |
31719 | 398 |
"finite {p. 0 < f (p::nat)} \<Longrightarrow> |
399 |
(ALL p. 0 < f p \<longrightarrow> prime p) \<Longrightarrow> |
|
400 |
prime_factors (PROD p | 0 < f p . p ^ f p) = {p. 0 < f p}" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
401 |
apply (rule prime_factors_characterization_nat) |
31719 | 402 |
apply auto |
44872 | 403 |
done |
31719 | 404 |
|
405 |
(* A minor glitch:*) |
|
406 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
407 |
thm prime_factors_characterization'_nat |
31719 | 408 |
[where f = "%x. f (int (x::nat))", |
409 |
transferred direction: nat "op <= (0::int)", rule_format] |
|
410 |
||
411 |
(* |
|
412 |
Transfer isn't smart enough to know that the "0 < f p" should |
|
413 |
remain a comparison between nats. But the transfer still works. |
|
414 |
*) |
|
415 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
416 |
lemma primes_characterization'_int [rule_format]: |
31719 | 417 |
"finite {p. p >= 0 & 0 < f (p::int)} \<Longrightarrow> |
418 |
(ALL p. 0 < f p \<longrightarrow> prime p) \<Longrightarrow> |
|
419 |
prime_factors (PROD p | p >=0 & 0 < f p . p ^ f p) = |
|
420 |
{p. p >= 0 & 0 < f p}" |
|
421 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
422 |
apply (insert prime_factors_characterization'_nat |
31719 | 423 |
[where f = "%x. f (int (x::nat))", |
424 |
transferred direction: nat "op <= (0::int)"]) |
|
425 |
apply auto |
|
44872 | 426 |
done |
31719 | 427 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
428 |
lemma prime_factors_characterization_int: "S = {p. 0 < f (p::int)} \<Longrightarrow> |
31719 | 429 |
finite S \<Longrightarrow> (ALL p:S. prime p) \<Longrightarrow> n = (PROD p:S. p ^ f p) \<Longrightarrow> |
430 |
prime_factors n = S" |
|
431 |
apply simp |
|
432 |
apply (subgoal_tac "{p. 0 < f p} = {p. 0 <= p & 0 < f p}") |
|
433 |
apply (simp only:) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
434 |
apply (subst primes_characterization'_int) |
31719 | 435 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
436 |
apply (auto simp add: prime_ge_0_int) |
44872 | 437 |
done |
31719 | 438 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
439 |
lemma multiplicity_characterization_nat: "S = {p. 0 < f (p::nat)} \<Longrightarrow> |
31719 | 440 |
finite S \<Longrightarrow> (ALL p:S. prime p) \<Longrightarrow> n = (PROD p:S. p ^ f p) \<Longrightarrow> |
441 |
multiplicity p n = f p" |
|
44872 | 442 |
apply (frule prime_factorization_unique_nat [THEN conjunct2, rule_format, symmetric]) |
443 |
apply auto |
|
444 |
done |
|
31719 | 445 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
446 |
lemma multiplicity_characterization'_nat: "finite {p. 0 < f (p::nat)} \<longrightarrow> |
31719 | 447 |
(ALL p. 0 < f p \<longrightarrow> prime p) \<longrightarrow> |
448 |
multiplicity p (PROD p | 0 < f p . p ^ f p) = f p" |
|
44872 | 449 |
apply (intro impI) |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
450 |
apply (rule multiplicity_characterization_nat) |
31719 | 451 |
apply auto |
44872 | 452 |
done |
31719 | 453 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
454 |
lemma multiplicity_characterization'_int [rule_format]: |
31719 | 455 |
"finite {p. p >= 0 & 0 < f (p::int)} \<Longrightarrow> |
456 |
(ALL p. 0 < f p \<longrightarrow> prime p) \<Longrightarrow> p >= 0 \<Longrightarrow> |
|
457 |
multiplicity p (PROD p | p >= 0 & 0 < f p . p ^ f p) = f p" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
458 |
apply (insert multiplicity_characterization'_nat |
31719 | 459 |
[where f = "%x. f (int (x::nat))", |
460 |
transferred direction: nat "op <= (0::int)", rule_format]) |
|
461 |
apply auto |
|
44872 | 462 |
done |
31719 | 463 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
464 |
lemma multiplicity_characterization_int: "S = {p. 0 < f (p::int)} \<Longrightarrow> |
31719 | 465 |
finite S \<Longrightarrow> (ALL p:S. prime p) \<Longrightarrow> n = (PROD p:S. p ^ f p) \<Longrightarrow> |
466 |
p >= 0 \<Longrightarrow> multiplicity p n = f p" |
|
467 |
apply simp |
|
468 |
apply (subgoal_tac "{p. 0 < f p} = {p. 0 <= p & 0 < f p}") |
|
469 |
apply (simp only:) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
470 |
apply (subst multiplicity_characterization'_int) |
31719 | 471 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
472 |
apply (auto simp add: prime_ge_0_int) |
44872 | 473 |
done |
31719 | 474 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
475 |
lemma multiplicity_zero_nat [simp]: "multiplicity (p::nat) 0 = 0" |
31719 | 476 |
by (simp add: multiplicity_nat_def multiset_prime_factorization_def) |
477 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
478 |
lemma multiplicity_zero_int [simp]: "multiplicity (p::int) 0 = 0" |
31719 | 479 |
by (simp add: multiplicity_int_def) |
480 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
481 |
lemma multiplicity_one_nat [simp]: "multiplicity p (1::nat) = 0" |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
482 |
by (subst multiplicity_characterization_nat [where f = "%x. 0"], auto) |
31719 | 483 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
484 |
lemma multiplicity_one_int [simp]: "multiplicity p (1::int) = 0" |
31719 | 485 |
by (simp add: multiplicity_int_def) |
486 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
487 |
lemma multiplicity_prime_nat [simp]: "prime (p::nat) \<Longrightarrow> multiplicity p p = 1" |
44872 | 488 |
apply (subst multiplicity_characterization_nat [where f = "(%q. if q = p then 1 else 0)"]) |
31719 | 489 |
apply auto |
490 |
apply (case_tac "x = p") |
|
491 |
apply auto |
|
44872 | 492 |
done |
31719 | 493 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
494 |
lemma multiplicity_prime_int [simp]: "prime (p::int) \<Longrightarrow> multiplicity p p = 1" |
31719 | 495 |
unfolding prime_int_def multiplicity_int_def by auto |
496 |
||
44872 | 497 |
lemma multiplicity_prime_power_nat [simp]: "prime (p::nat) \<Longrightarrow> multiplicity p (p^n) = n" |
498 |
apply (cases "n = 0") |
|
31719 | 499 |
apply auto |
44872 | 500 |
apply (subst multiplicity_characterization_nat [where f = "(%q. if q = p then n else 0)"]) |
31719 | 501 |
apply auto |
502 |
apply (case_tac "x = p") |
|
503 |
apply auto |
|
44872 | 504 |
done |
31719 | 505 |
|
44872 | 506 |
lemma multiplicity_prime_power_int [simp]: "prime (p::int) \<Longrightarrow> multiplicity p (p^n) = n" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
507 |
apply (frule prime_ge_0_int) |
31719 | 508 |
apply (auto simp add: prime_int_def multiplicity_int_def nat_power_eq) |
44872 | 509 |
done |
31719 | 510 |
|
44872 | 511 |
lemma multiplicity_nonprime_nat [simp]: "~ prime (p::nat) \<Longrightarrow> multiplicity p n = 0" |
512 |
apply (cases "n = 0") |
|
31719 | 513 |
apply auto |
514 |
apply (frule multiset_prime_factorization) |
|
515 |
apply (auto simp add: set_of_def multiplicity_nat_def) |
|
44872 | 516 |
done |
31719 | 517 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
518 |
lemma multiplicity_nonprime_int [simp]: "~ prime (p::int) \<Longrightarrow> multiplicity p n = 0" |
44872 | 519 |
unfolding multiplicity_int_def prime_int_def by auto |
31719 | 520 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
521 |
lemma multiplicity_not_factor_nat [simp]: |
31719 | 522 |
"p ~: prime_factors (n::nat) \<Longrightarrow> multiplicity p n = 0" |
44872 | 523 |
apply (subst (asm) prime_factors_altdef_nat) |
524 |
apply auto |
|
525 |
done |
|
31719 | 526 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
527 |
lemma multiplicity_not_factor_int [simp]: |
31719 | 528 |
"p >= 0 \<Longrightarrow> p ~: prime_factors (n::int) \<Longrightarrow> multiplicity p n = 0" |
44872 | 529 |
apply (subst (asm) prime_factors_altdef_int) |
530 |
apply auto |
|
531 |
done |
|
31719 | 532 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
533 |
lemma multiplicity_product_aux_nat: "(k::nat) > 0 \<Longrightarrow> l > 0 \<Longrightarrow> |
31719 | 534 |
(prime_factors k) Un (prime_factors l) = prime_factors (k * l) & |
535 |
(ALL p. multiplicity p k + multiplicity p l = multiplicity p (k * l))" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
536 |
apply (rule prime_factorization_unique_nat) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
537 |
apply (simp only: prime_factors_altdef_nat) |
31719 | 538 |
apply auto |
539 |
apply (subst power_add) |
|
540 |
apply (subst setprod_timesf) |
|
541 |
apply (rule arg_cong2)back back |
|
542 |
apply (subgoal_tac "prime_factors k Un prime_factors l = prime_factors k Un |
|
543 |
(prime_factors l - prime_factors k)") |
|
544 |
apply (erule ssubst) |
|
545 |
apply (subst setprod_Un_disjoint) |
|
546 |
apply auto |
|
547 |
apply (subgoal_tac "(\<Prod>p\<in>prime_factors l - prime_factors k. p ^ multiplicity p k) = |
|
548 |
(\<Prod>p\<in>prime_factors l - prime_factors k. 1)") |
|
549 |
apply (erule ssubst) |
|
550 |
apply (simp add: setprod_1) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
551 |
apply (erule prime_factorization_nat) |
31719 | 552 |
apply (rule setprod_cong, auto) |
553 |
apply (subgoal_tac "prime_factors k Un prime_factors l = prime_factors l Un |
|
554 |
(prime_factors k - prime_factors l)") |
|
555 |
apply (erule ssubst) |
|
556 |
apply (subst setprod_Un_disjoint) |
|
557 |
apply auto |
|
558 |
apply (subgoal_tac "(\<Prod>p\<in>prime_factors k - prime_factors l. p ^ multiplicity p l) = |
|
559 |
(\<Prod>p\<in>prime_factors k - prime_factors l. 1)") |
|
560 |
apply (erule ssubst) |
|
561 |
apply (simp add: setprod_1) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
562 |
apply (erule prime_factorization_nat) |
31719 | 563 |
apply (rule setprod_cong, auto) |
44872 | 564 |
done |
31719 | 565 |
|
566 |
(* transfer doesn't have the same problem here with the right |
|
567 |
choice of rules. *) |
|
568 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
569 |
lemma multiplicity_product_aux_int: |
31719 | 570 |
assumes "(k::int) > 0" and "l > 0" |
571 |
shows |
|
572 |
"(prime_factors k) Un (prime_factors l) = prime_factors (k * l) & |
|
573 |
(ALL p >= 0. multiplicity p k + multiplicity p l = multiplicity p (k * l))" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
574 |
apply (rule multiplicity_product_aux_nat [transferred, of l k]) |
41541 | 575 |
using assms apply auto |
576 |
done |
|
31719 | 577 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
578 |
lemma prime_factors_product_nat: "(k::nat) > 0 \<Longrightarrow> l > 0 \<Longrightarrow> prime_factors (k * l) = |
31719 | 579 |
prime_factors k Un prime_factors l" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
580 |
by (rule multiplicity_product_aux_nat [THEN conjunct1, symmetric]) |
31719 | 581 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
582 |
lemma prime_factors_product_int: "(k::int) > 0 \<Longrightarrow> l > 0 \<Longrightarrow> prime_factors (k * l) = |
31719 | 583 |
prime_factors k Un prime_factors l" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
584 |
by (rule multiplicity_product_aux_int [THEN conjunct1, symmetric]) |
31719 | 585 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
586 |
lemma multiplicity_product_nat: "(k::nat) > 0 \<Longrightarrow> l > 0 \<Longrightarrow> multiplicity p (k * l) = |
31719 | 587 |
multiplicity p k + multiplicity p l" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
588 |
by (rule multiplicity_product_aux_nat [THEN conjunct2, rule_format, |
31719 | 589 |
symmetric]) |
590 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
591 |
lemma multiplicity_product_int: "(k::int) > 0 \<Longrightarrow> l > 0 \<Longrightarrow> p >= 0 \<Longrightarrow> |
31719 | 592 |
multiplicity p (k * l) = multiplicity p k + multiplicity p l" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
593 |
by (rule multiplicity_product_aux_int [THEN conjunct2, rule_format, |
31719 | 594 |
symmetric]) |
595 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
596 |
lemma multiplicity_setprod_nat: "finite S \<Longrightarrow> (ALL x : S. f x > 0) \<Longrightarrow> |
31719 | 597 |
multiplicity (p::nat) (PROD x : S. f x) = |
598 |
(SUM x : S. multiplicity p (f x))" |
|
599 |
apply (induct set: finite) |
|
600 |
apply auto |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
601 |
apply (subst multiplicity_product_nat) |
31719 | 602 |
apply auto |
44872 | 603 |
done |
31719 | 604 |
|
605 |
(* Transfer is delicate here for two reasons: first, because there is |
|
606 |
an implicit quantifier over functions (f), and, second, because the |
|
607 |
product over the multiplicity should not be translated to an integer |
|
608 |
product. |
|
609 |
||
610 |
The way to handle the first is to use quantifier rules for functions. |
|
611 |
The way to handle the second is to turn off the offending rule. |
|
612 |
*) |
|
613 |
||
614 |
lemma transfer_nat_int_sum_prod_closure3: |
|
615 |
"(SUM x : A. int (f x)) >= 0" |
|
616 |
"(PROD x : A. int (f x)) >= 0" |
|
617 |
apply (rule setsum_nonneg, auto) |
|
618 |
apply (rule setprod_nonneg, auto) |
|
44872 | 619 |
done |
31719 | 620 |
|
35644 | 621 |
declare transfer_morphism_nat_int[transfer |
31719 | 622 |
add return: transfer_nat_int_sum_prod_closure3 |
623 |
del: transfer_nat_int_sum_prod2 (1)] |
|
624 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
625 |
lemma multiplicity_setprod_int: "p >= 0 \<Longrightarrow> finite S \<Longrightarrow> |
31719 | 626 |
(ALL x : S. f x > 0) \<Longrightarrow> |
627 |
multiplicity (p::int) (PROD x : S. f x) = |
|
628 |
(SUM x : S. multiplicity p (f x))" |
|
629 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
630 |
apply (frule multiplicity_setprod_nat |
31719 | 631 |
[where f = "%x. nat(int(nat(f x)))", |
632 |
transferred direction: nat "op <= (0::int)"]) |
|
633 |
apply auto |
|
634 |
apply (subst (asm) setprod_cong) |
|
635 |
apply (rule refl) |
|
636 |
apply (rule if_P) |
|
637 |
apply auto |
|
638 |
apply (rule setsum_cong) |
|
639 |
apply auto |
|
44872 | 640 |
done |
31719 | 641 |
|
35644 | 642 |
declare transfer_morphism_nat_int[transfer |
31719 | 643 |
add return: transfer_nat_int_sum_prod2 (1)] |
644 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
645 |
lemma multiplicity_prod_prime_powers_nat: |
31719 | 646 |
"finite S \<Longrightarrow> (ALL p : S. prime (p::nat)) \<Longrightarrow> |
647 |
multiplicity p (PROD p : S. p ^ f p) = (if p : S then f p else 0)" |
|
648 |
apply (subgoal_tac "(PROD p : S. p ^ f p) = |
|
649 |
(PROD p : S. p ^ (%x. if x : S then f x else 0) p)") |
|
650 |
apply (erule ssubst) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
651 |
apply (subst multiplicity_characterization_nat) |
31719 | 652 |
prefer 5 apply (rule refl) |
653 |
apply (rule refl) |
|
654 |
apply auto |
|
655 |
apply (subst setprod_mono_one_right) |
|
656 |
apply assumption |
|
657 |
prefer 3 |
|
658 |
apply (rule setprod_cong) |
|
659 |
apply (rule refl) |
|
660 |
apply auto |
|
661 |
done |
|
662 |
||
663 |
(* Here the issue with transfer is the implicit quantifier over S *) |
|
664 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
665 |
lemma multiplicity_prod_prime_powers_int: |
31719 | 666 |
"(p::int) >= 0 \<Longrightarrow> finite S \<Longrightarrow> (ALL p : S. prime p) \<Longrightarrow> |
667 |
multiplicity p (PROD p : S. p ^ f p) = (if p : S then f p else 0)" |
|
668 |
apply (subgoal_tac "int ` nat ` S = S") |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
669 |
apply (frule multiplicity_prod_prime_powers_nat [where f = "%x. f(int x)" |
31719 | 670 |
and S = "nat ` S", transferred]) |
671 |
apply auto |
|
40461 | 672 |
apply (metis prime_int_def) |
673 |
apply (metis prime_ge_0_int) |
|
674 |
apply (metis nat_set_def prime_ge_0_int transfer_nat_int_set_return_embed) |
|
44872 | 675 |
done |
31719 | 676 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
677 |
lemma multiplicity_distinct_prime_power_nat: "prime (p::nat) \<Longrightarrow> prime q \<Longrightarrow> |
31719 | 678 |
p ~= q \<Longrightarrow> multiplicity p (q^n) = 0" |
679 |
apply (subgoal_tac "q^n = setprod (%x. x^n) {q}") |
|
680 |
apply (erule ssubst) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
681 |
apply (subst multiplicity_prod_prime_powers_nat) |
31719 | 682 |
apply auto |
44872 | 683 |
done |
31719 | 684 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
685 |
lemma multiplicity_distinct_prime_power_int: "prime (p::int) \<Longrightarrow> prime q \<Longrightarrow> |
31719 | 686 |
p ~= q \<Longrightarrow> multiplicity p (q^n) = 0" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
687 |
apply (frule prime_ge_0_int [of q]) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
688 |
apply (frule multiplicity_distinct_prime_power_nat [transferred leaving: n]) |
31719 | 689 |
prefer 4 |
690 |
apply assumption |
|
691 |
apply auto |
|
44872 | 692 |
done |
31719 | 693 |
|
44872 | 694 |
lemma dvd_multiplicity_nat: |
31719 | 695 |
"(0::nat) < y \<Longrightarrow> x dvd y \<Longrightarrow> multiplicity p x <= multiplicity p y" |
44872 | 696 |
apply (cases "x = 0") |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
697 |
apply (auto simp add: dvd_def multiplicity_product_nat) |
44872 | 698 |
done |
31719 | 699 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
700 |
lemma dvd_multiplicity_int: |
31719 | 701 |
"(0::int) < y \<Longrightarrow> 0 <= x \<Longrightarrow> x dvd y \<Longrightarrow> p >= 0 \<Longrightarrow> |
702 |
multiplicity p x <= multiplicity p y" |
|
44872 | 703 |
apply (cases "x = 0") |
31719 | 704 |
apply (auto simp add: dvd_def) |
705 |
apply (subgoal_tac "0 < k") |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
706 |
apply (auto simp add: multiplicity_product_int) |
31719 | 707 |
apply (erule zero_less_mult_pos) |
708 |
apply arith |
|
44872 | 709 |
done |
31719 | 710 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
711 |
lemma dvd_prime_factors_nat [intro]: |
31719 | 712 |
"0 < (y::nat) \<Longrightarrow> x dvd y \<Longrightarrow> prime_factors x <= prime_factors y" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
713 |
apply (simp only: prime_factors_altdef_nat) |
31719 | 714 |
apply auto |
40461 | 715 |
apply (metis dvd_multiplicity_nat le_0_eq neq_zero_eq_gt_zero_nat) |
44872 | 716 |
done |
31719 | 717 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
718 |
lemma dvd_prime_factors_int [intro]: |
31719 | 719 |
"0 < (y::int) \<Longrightarrow> 0 <= x \<Longrightarrow> x dvd y \<Longrightarrow> prime_factors x <= prime_factors y" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
720 |
apply (auto simp add: prime_factors_altdef_int) |
40461 | 721 |
apply (metis dvd_multiplicity_int le_0_eq neq_zero_eq_gt_zero_nat) |
44872 | 722 |
done |
31719 | 723 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
724 |
lemma multiplicity_dvd_nat: "0 < (x::nat) \<Longrightarrow> 0 < y \<Longrightarrow> |
44872 | 725 |
ALL p. multiplicity p x <= multiplicity p y \<Longrightarrow> x dvd y" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
726 |
apply (subst prime_factorization_nat [of x], assumption) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
727 |
apply (subst prime_factorization_nat [of y], assumption) |
31719 | 728 |
apply (rule setprod_dvd_setprod_subset2) |
729 |
apply force |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
730 |
apply (subst prime_factors_altdef_nat)+ |
31719 | 731 |
apply auto |
40461 | 732 |
apply (metis gr0I le_0_eq less_not_refl) |
733 |
apply (metis le_imp_power_dvd) |
|
44872 | 734 |
done |
31719 | 735 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
736 |
lemma multiplicity_dvd_int: "0 < (x::int) \<Longrightarrow> 0 < y \<Longrightarrow> |
44872 | 737 |
ALL p >= 0. multiplicity p x <= multiplicity p y \<Longrightarrow> x dvd y" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
738 |
apply (subst prime_factorization_int [of x], assumption) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
739 |
apply (subst prime_factorization_int [of y], assumption) |
31719 | 740 |
apply (rule setprod_dvd_setprod_subset2) |
741 |
apply force |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
742 |
apply (subst prime_factors_altdef_int)+ |
31719 | 743 |
apply auto |
40461 | 744 |
apply (metis le_imp_power_dvd prime_factors_ge_0_int) |
44872 | 745 |
done |
31719 | 746 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
747 |
lemma multiplicity_dvd'_nat: "(0::nat) < x \<Longrightarrow> |
31719 | 748 |
\<forall>p. prime p \<longrightarrow> multiplicity p x \<le> multiplicity p y \<Longrightarrow> x dvd y" |
44872 | 749 |
by (metis gcd_lcm_complete_lattice_nat.top_greatest le_refl multiplicity_dvd_nat |
750 |
multiplicity_nonprime_nat neq0_conv) |
|
31719 | 751 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
752 |
lemma multiplicity_dvd'_int: "(0::int) < x \<Longrightarrow> 0 <= y \<Longrightarrow> |
31719 | 753 |
\<forall>p. prime p \<longrightarrow> multiplicity p x \<le> multiplicity p y \<Longrightarrow> x dvd y" |
44872 | 754 |
by (metis eq_imp_le gcd_lcm_complete_lattice_nat.top_greatest int_eq_0_conv |
755 |
multiplicity_dvd_int multiplicity_nonprime_int nat_int transfer_nat_int_relations(4) |
|
756 |
less_le) |
|
31719 | 757 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
758 |
lemma dvd_multiplicity_eq_nat: "0 < (x::nat) \<Longrightarrow> 0 < y \<Longrightarrow> |
31719 | 759 |
(x dvd y) = (ALL p. multiplicity p x <= multiplicity p y)" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
760 |
by (auto intro: dvd_multiplicity_nat multiplicity_dvd_nat) |
31719 | 761 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
762 |
lemma dvd_multiplicity_eq_int: "0 < (x::int) \<Longrightarrow> 0 < y \<Longrightarrow> |
31719 | 763 |
(x dvd y) = (ALL p >= 0. multiplicity p x <= multiplicity p y)" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
764 |
by (auto intro: dvd_multiplicity_int multiplicity_dvd_int) |
31719 | 765 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
766 |
lemma prime_factors_altdef2_nat: "(n::nat) > 0 \<Longrightarrow> |
31719 | 767 |
(p : prime_factors n) = (prime p & p dvd n)" |
44872 | 768 |
apply (cases "prime p") |
31719 | 769 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
770 |
apply (subst prime_factorization_nat [where n = n], assumption) |
31719 | 771 |
apply (rule dvd_trans) |
772 |
apply (rule dvd_power [where x = p and n = "multiplicity p n"]) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
773 |
apply (subst (asm) prime_factors_altdef_nat, force) |
31719 | 774 |
apply (rule dvd_setprod) |
775 |
apply auto |
|
40461 | 776 |
apply (metis One_nat_def Zero_not_Suc dvd_multiplicity_nat le0 le_antisym multiplicity_not_factor_nat multiplicity_prime_nat) |
44872 | 777 |
done |
31719 | 778 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
779 |
lemma prime_factors_altdef2_int: |
31719 | 780 |
assumes "(n::int) > 0" |
781 |
shows "(p : prime_factors n) = (prime p & p dvd n)" |
|
44872 | 782 |
apply (cases "p >= 0") |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
783 |
apply (rule prime_factors_altdef2_nat [transferred]) |
41541 | 784 |
using assms apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
785 |
apply (auto simp add: prime_ge_0_int prime_factors_ge_0_int) |
41541 | 786 |
done |
31719 | 787 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
788 |
lemma multiplicity_eq_nat: |
31719 | 789 |
fixes x and y::nat |
790 |
assumes [arith]: "x > 0" "y > 0" and |
|
791 |
mult_eq [simp]: "!!p. prime p \<Longrightarrow> multiplicity p x = multiplicity p y" |
|
792 |
shows "x = y" |
|
33657 | 793 |
apply (rule dvd_antisym) |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
794 |
apply (auto intro: multiplicity_dvd'_nat) |
44872 | 795 |
done |
31719 | 796 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
797 |
lemma multiplicity_eq_int: |
31719 | 798 |
fixes x and y::int |
799 |
assumes [arith]: "x > 0" "y > 0" and |
|
800 |
mult_eq [simp]: "!!p. prime p \<Longrightarrow> multiplicity p x = multiplicity p y" |
|
801 |
shows "x = y" |
|
33657 | 802 |
apply (rule dvd_antisym [transferred]) |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
803 |
apply (auto intro: multiplicity_dvd'_int) |
44872 | 804 |
done |
31719 | 805 |
|
806 |
||
807 |
subsection {* An application *} |
|
808 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
809 |
lemma gcd_eq_nat: |
31719 | 810 |
assumes pos [arith]: "x > 0" "y > 0" |
811 |
shows "gcd (x::nat) y = |
|
812 |
(PROD p: prime_factors x Un prime_factors y. |
|
813 |
p ^ (min (multiplicity p x) (multiplicity p y)))" |
|
814 |
proof - |
|
815 |
def z == "(PROD p: prime_factors (x::nat) Un prime_factors y. |
|
816 |
p ^ (min (multiplicity p x) (multiplicity p y)))" |
|
817 |
have [arith]: "z > 0" |
|
818 |
unfolding z_def by (rule setprod_pos_nat, auto) |
|
819 |
have aux: "!!p. prime p \<Longrightarrow> multiplicity p z = |
|
820 |
min (multiplicity p x) (multiplicity p y)" |
|
821 |
unfolding z_def |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
822 |
apply (subst multiplicity_prod_prime_powers_nat) |
41541 | 823 |
apply auto |
31719 | 824 |
done |
825 |
have "z dvd x" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
826 |
by (intro multiplicity_dvd'_nat, auto simp add: aux) |
31719 | 827 |
moreover have "z dvd y" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
828 |
by (intro multiplicity_dvd'_nat, auto simp add: aux) |
31719 | 829 |
moreover have "ALL w. w dvd x & w dvd y \<longrightarrow> w dvd z" |
830 |
apply auto |
|
831 |
apply (case_tac "w = 0", auto) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
832 |
apply (erule multiplicity_dvd'_nat) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
833 |
apply (auto intro: dvd_multiplicity_nat simp add: aux) |
31719 | 834 |
done |
835 |
ultimately have "z = gcd x y" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
836 |
by (subst gcd_unique_nat [symmetric], blast) |
44872 | 837 |
then show ?thesis |
31719 | 838 |
unfolding z_def by auto |
839 |
qed |
|
840 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
841 |
lemma lcm_eq_nat: |
31719 | 842 |
assumes pos [arith]: "x > 0" "y > 0" |
843 |
shows "lcm (x::nat) y = |
|
844 |
(PROD p: prime_factors x Un prime_factors y. |
|
845 |
p ^ (max (multiplicity p x) (multiplicity p y)))" |
|
846 |
proof - |
|
847 |
def z == "(PROD p: prime_factors (x::nat) Un prime_factors y. |
|
848 |
p ^ (max (multiplicity p x) (multiplicity p y)))" |
|
849 |
have [arith]: "z > 0" |
|
850 |
unfolding z_def by (rule setprod_pos_nat, auto) |
|
851 |
have aux: "!!p. prime p \<Longrightarrow> multiplicity p z = |
|
852 |
max (multiplicity p x) (multiplicity p y)" |
|
853 |
unfolding z_def |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
854 |
apply (subst multiplicity_prod_prime_powers_nat) |
41541 | 855 |
apply auto |
31719 | 856 |
done |
857 |
have "x dvd z" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
858 |
by (intro multiplicity_dvd'_nat, auto simp add: aux) |
31719 | 859 |
moreover have "y dvd z" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
860 |
by (intro multiplicity_dvd'_nat, auto simp add: aux) |
31719 | 861 |
moreover have "ALL w. x dvd w & y dvd w \<longrightarrow> z dvd w" |
862 |
apply auto |
|
863 |
apply (case_tac "w = 0", auto) |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
864 |
apply (rule multiplicity_dvd'_nat) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
865 |
apply (auto intro: dvd_multiplicity_nat simp add: aux) |
31719 | 866 |
done |
867 |
ultimately have "z = lcm x y" |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
868 |
by (subst lcm_unique_nat [symmetric], blast) |
44872 | 869 |
then show ?thesis |
31719 | 870 |
unfolding z_def by auto |
871 |
qed |
|
872 |
||
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
873 |
lemma multiplicity_gcd_nat: |
31719 | 874 |
assumes [arith]: "x > 0" "y > 0" |
44872 | 875 |
shows "multiplicity (p::nat) (gcd x y) = min (multiplicity p x) (multiplicity p y)" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
876 |
apply (subst gcd_eq_nat) |
31719 | 877 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
878 |
apply (subst multiplicity_prod_prime_powers_nat) |
31719 | 879 |
apply auto |
44872 | 880 |
done |
31719 | 881 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
882 |
lemma multiplicity_lcm_nat: |
31719 | 883 |
assumes [arith]: "x > 0" "y > 0" |
44872 | 884 |
shows "multiplicity (p::nat) (lcm x y) = max (multiplicity p x) (multiplicity p y)" |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
885 |
apply (subst lcm_eq_nat) |
31719 | 886 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
887 |
apply (subst multiplicity_prod_prime_powers_nat) |
31719 | 888 |
apply auto |
44872 | 889 |
done |
31719 | 890 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
891 |
lemma gcd_lcm_distrib_nat: "gcd (x::nat) (lcm y z) = lcm (gcd x y) (gcd x z)" |
44872 | 892 |
apply (cases "x = 0 | y = 0 | z = 0") |
31719 | 893 |
apply auto |
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
894 |
apply (rule multiplicity_eq_nat) |
44872 | 895 |
apply (auto simp add: multiplicity_gcd_nat multiplicity_lcm_nat lcm_pos_nat) |
896 |
done |
|
31719 | 897 |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
898 |
lemma gcd_lcm_distrib_int: "gcd (x::int) (lcm y z) = lcm (gcd x y) (gcd x z)" |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
899 |
apply (subst (1 2 3) gcd_abs_int) |
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
900 |
apply (subst lcm_abs_int) |
31719 | 901 |
apply (subst (2) abs_of_nonneg) |
902 |
apply force |
|
31952
40501bb2d57c
renamed lemmas: nat_xyz/int_xyz -> xyz_nat/xyz_int
nipkow
parents:
31719
diff
changeset
|
903 |
apply (rule gcd_lcm_distrib_nat [transferred]) |
31719 | 904 |
apply auto |
44872 | 905 |
done |
31719 | 906 |
|
907 |
end |