equal
deleted
inserted
replaced
105 apply auto |
105 apply auto |
106 done |
106 done |
107 ultimately have "a ^ count M a dvd a ^ count N a" |
107 ultimately have "a ^ count M a dvd a ^ count N a" |
108 by (elim coprime_dvd_mult_nat) |
108 by (elim coprime_dvd_mult_nat) |
109 with a show ?thesis |
109 with a show ?thesis |
110 apply (intro power_dvd_imp_le) |
110 using power_dvd_imp_le prime_def by blast |
111 apply auto |
|
112 done |
|
113 next |
111 next |
114 case False |
112 case False |
115 then show ?thesis |
113 then show ?thesis |
116 by auto |
114 by auto |
117 qed |
115 qed |
245 shows "prime p" |
243 shows "prime p" |
246 apply (rule prime_factors_prime_nat [transferred, of n p, simplified]) |
244 apply (rule prime_factors_prime_nat [transferred, of n p, simplified]) |
247 using assms apply auto |
245 using assms apply auto |
248 done |
246 done |
249 |
247 |
250 lemma prime_factors_gt_0_nat [elim]: |
248 lemma prime_factors_gt_0_nat: |
251 fixes p :: nat |
249 fixes p :: nat |
252 shows "p \<in> prime_factors x \<Longrightarrow> p > 0" |
250 shows "p \<in> prime_factors x \<Longrightarrow> p > 0" |
253 by (auto dest!: prime_factors_prime_nat) |
251 using prime_factors_prime_nat by force |
254 |
252 |
255 lemma prime_factors_gt_0_int [elim]: |
253 lemma prime_factors_gt_0_int: |
256 shows "x \<ge> 0 \<Longrightarrow> p \<in> prime_factors x \<Longrightarrow> int p > (0::int)" |
254 shows "x \<ge> 0 \<Longrightarrow> p \<in> prime_factors x \<Longrightarrow> int p > (0::int)" |
257 by auto |
255 by (simp add: prime_factors_gt_0_nat) |
258 |
256 |
259 lemma prime_factors_finite_nat [iff]: |
257 lemma prime_factors_finite_nat [iff]: |
260 fixes n :: nat |
258 fixes n :: nat |
261 shows "finite (prime_factors n)" |
259 shows "finite (prime_factors n)" |
262 unfolding prime_factors_nat_def by auto |
260 unfolding prime_factors_nat_def by auto |
301 and S: "\<forall>p\<in>S. prime p" "n = (\<Prod>p\<in>S. p ^ f p)" |
299 and S: "\<forall>p\<in>S. prime p" "n = (\<Prod>p\<in>S. p ^ f p)" |
302 shows "S = prime_factors n \<and> (\<forall>p. f p = multiplicity p n)" |
300 shows "S = prime_factors n \<and> (\<forall>p. f p = multiplicity p n)" |
303 proof - |
301 proof - |
304 from assms have "f \<in> multiset" |
302 from assms have "f \<in> multiset" |
305 by (auto simp add: multiset_def) |
303 by (auto simp add: multiset_def) |
306 moreover from assms have "n > 0" by force |
304 moreover from assms have "n > 0" |
|
305 by (auto intro: prime_gt_0_nat) |
307 ultimately have "multiset_prime_factorization n = Abs_multiset f" |
306 ultimately have "multiset_prime_factorization n = Abs_multiset f" |
308 apply (unfold multiset_prime_factorization_def) |
307 apply (unfold multiset_prime_factorization_def) |
309 apply (subst if_P, assumption) |
308 apply (subst if_P, assumption) |
310 apply (rule the1_equality) |
309 apply (rule the1_equality) |
311 apply (rule ex_ex1I) |
310 apply (rule ex_ex1I) |
721 assumes pos [arith]: "x > 0" "y > 0" |
720 assumes pos [arith]: "x > 0" "y > 0" |
722 shows "gcd x y = |
721 shows "gcd x y = |
723 (\<Prod>p \<in> prime_factors x \<union> prime_factors y. p ^ min (multiplicity p x) (multiplicity p y))" |
722 (\<Prod>p \<in> prime_factors x \<union> prime_factors y. p ^ min (multiplicity p x) (multiplicity p y))" |
724 (is "_ = ?z") |
723 (is "_ = ?z") |
725 proof - |
724 proof - |
726 have [arith]: "?z > 0" |
725 have [arith]: "?z > 0" |
727 by auto |
726 using prime_factors_gt_0_nat by auto |
728 have aux: "\<And>p. prime p \<Longrightarrow> multiplicity p ?z = min (multiplicity p x) (multiplicity p y)" |
727 have aux: "\<And>p. prime p \<Longrightarrow> multiplicity p ?z = min (multiplicity p x) (multiplicity p y)" |
729 apply (subst multiplicity_prod_prime_powers_nat) |
728 apply (subst multiplicity_prod_prime_powers_nat) |
730 apply auto |
729 apply auto |
731 done |
730 done |
732 have "?z dvd x" |
731 have "?z dvd x" |
733 by (intro multiplicity_dvd'_nat) (auto simp add: aux) |
732 by (intro multiplicity_dvd'_nat) (auto simp add: aux intro: prime_gt_0_nat) |
734 moreover have "?z dvd y" |
733 moreover have "?z dvd y" |
735 by (intro multiplicity_dvd'_nat) (auto simp add: aux) |
734 by (intro multiplicity_dvd'_nat) (auto simp add: aux intro: prime_gt_0_nat) |
736 moreover have "w dvd x \<and> w dvd y \<longrightarrow> w dvd ?z" for w |
735 moreover have "w dvd x \<and> w dvd y \<longrightarrow> w dvd ?z" for w |
737 proof (cases "w = 0") |
736 proof (cases "w = 0") |
738 case True |
737 case True |
739 then show ?thesis by simp |
738 then show ?thesis by simp |
740 next |
739 next |
756 shows "lcm (x::nat) y = |
755 shows "lcm (x::nat) y = |
757 (\<Prod>p \<in> prime_factors x \<union> prime_factors y. p ^ max (multiplicity p x) (multiplicity p y))" |
756 (\<Prod>p \<in> prime_factors x \<union> prime_factors y. p ^ max (multiplicity p x) (multiplicity p y))" |
758 (is "_ = ?z") |
757 (is "_ = ?z") |
759 proof - |
758 proof - |
760 have [arith]: "?z > 0" |
759 have [arith]: "?z > 0" |
761 by auto |
760 by (auto intro: prime_gt_0_nat) |
762 have aux: "\<And>p. prime p \<Longrightarrow> multiplicity p ?z = max (multiplicity p x) (multiplicity p y)" |
761 have aux: "\<And>p. prime p \<Longrightarrow> multiplicity p ?z = max (multiplicity p x) (multiplicity p y)" |
763 apply (subst multiplicity_prod_prime_powers_nat) |
762 apply (subst multiplicity_prod_prime_powers_nat) |
764 apply auto |
763 apply auto |
765 done |
764 done |
766 have "x dvd ?z" |
765 have "x dvd ?z" |
774 next |
773 next |
775 case False |
774 case False |
776 then show ?thesis |
775 then show ?thesis |
777 apply auto |
776 apply auto |
778 apply (rule multiplicity_dvd'_nat) |
777 apply (rule multiplicity_dvd'_nat) |
779 apply (auto intro: dvd_multiplicity_nat simp add: aux) |
778 apply (auto intro: prime_gt_0_nat dvd_multiplicity_nat simp add: aux) |
780 done |
779 done |
781 qed |
780 qed |
782 ultimately have "?z = lcm x y" |
781 ultimately have "?z = lcm x y" |
783 by (subst lcm_unique_nat [symmetric], blast) |
782 by (subst lcm_unique_nat [symmetric], blast) |
784 then show ?thesis |
783 then show ?thesis |