# HG changeset patch # User paulson # Date 1289311177 0 # Node ID e876e95588cea5f14d1be0e1aafc2be1e403d2a7 # Parent 65bd37d7d5010d8e158214887539a3afa1da8a65 tidied using metis diff -r 65bd37d7d501 -r e876e95588ce src/HOL/Number_Theory/Primes.thy --- a/src/HOL/Number_Theory/Primes.thy Mon Nov 08 23:02:20 2010 +0100 +++ b/src/HOL/Number_Theory/Primes.thy Tue Nov 09 13:59:37 2010 +0000 @@ -88,11 +88,7 @@ lemma prime_odd_nat: "prime (p::nat) \ p > 2 \ odd p" unfolding prime_nat_def - apply (subst even_mult_two_ex) - apply clarify - apply (drule_tac x = 2 in spec) - apply auto -done + by (metis gcd_lcm_complete_lattice_nat.bot_least nat_even_iff_2_dvd nat_neq_iff odd_1_nat) lemma prime_odd_int: "prime (p::int) \ p > 2 \ odd p" unfolding prime_int_def @@ -275,10 +271,8 @@ lemma primes_coprime_int: "prime (p::int) \ prime q \ p \ q \ coprime p q" apply (rule prime_imp_coprime_int, assumption) - apply (unfold prime_int_altdef, clarify) - apply (drule_tac x = q in spec) - apply (drule_tac x = p in spec) - apply auto + apply (unfold prime_int_altdef) + apply (metis int_one_le_iff_zero_less zless_le) done lemma primes_imp_powers_coprime_nat: "prime (p::nat) \ prime q \ p ~= q \ coprime (p^m) (q^n)" @@ -291,11 +285,8 @@ apply (induct n rule: nat_less_induct) apply (case_tac "n = 0") using two_is_prime_nat apply blast - apply (case_tac "prime n") - apply blast - apply (subgoal_tac "n > 1") - apply (frule (1) not_prime_eq_prod_nat) - apply (auto intro: dvd_mult dvd_mult2) + apply (metis One_nat_def dvd.order_trans dvd_refl less_Suc0 linorder_neqE_nat nat_dvd_not_less + neq0_conv prime_nat_def) done (* An Isar version: diff -r 65bd37d7d501 -r e876e95588ce src/HOL/Number_Theory/UniqueFactorization.thy --- a/src/HOL/Number_Theory/UniqueFactorization.thy Mon Nov 08 23:02:20 2010 +0100 +++ b/src/HOL/Number_Theory/UniqueFactorization.thy Tue Nov 09 13:59:37 2010 +0000 @@ -691,14 +691,9 @@ apply (frule multiplicity_prod_prime_powers_nat [where f = "%x. f(int x)" and S = "nat ` S", transferred]) apply auto - apply (subst prime_int_def [symmetric]) - apply auto - apply (subgoal_tac "xb >= 0") - apply force - apply (rule prime_ge_0_int) - apply force - apply (subst transfer_nat_int_set_return_embed) - apply (unfold nat_set_def, auto) + apply (metis prime_int_def) + apply (metis prime_ge_0_int) + apply (metis nat_set_def prime_ge_0_int transfer_nat_int_set_return_embed) done lemma multiplicity_distinct_prime_power_nat: "prime (p::nat) \ prime q \ @@ -739,19 +734,13 @@ "0 < (y::nat) \ x dvd y \ prime_factors x <= prime_factors y" apply (simp only: prime_factors_altdef_nat) apply auto - apply (frule dvd_multiplicity_nat) - apply auto -(* It is a shame that auto and arith don't get this. *) - apply (erule order_less_le_trans)back - apply assumption + apply (metis dvd_multiplicity_nat le_0_eq neq_zero_eq_gt_zero_nat) done lemma dvd_prime_factors_int [intro]: "0 < (y::int) \ 0 <= x \ x dvd y \ prime_factors x <= prime_factors y" apply (auto simp add: prime_factors_altdef_int) - apply (erule order_less_le_trans) - apply (rule dvd_multiplicity_int) - apply auto + apply (metis dvd_multiplicity_int le_0_eq neq_zero_eq_gt_zero_nat) done lemma multiplicity_dvd_nat: "0 < (x::nat) \ 0 < y \ @@ -763,10 +752,8 @@ apply force apply (subst prime_factors_altdef_nat)+ apply auto -(* Again, a shame that auto and arith don't get this. *) - apply (drule_tac x = xa in spec, auto) - apply (rule le_imp_power_dvd) - apply blast + apply (metis gr0I le_0_eq less_not_refl) + apply (metis le_imp_power_dvd) done lemma multiplicity_dvd_int: "0 < (x::int) \ 0 < y \ @@ -778,30 +765,18 @@ apply force apply (subst prime_factors_altdef_int)+ apply auto - apply (rule dvd_power_le) - apply auto - apply (drule_tac x = xa in spec) - apply (erule impE) - apply auto + apply (metis le_imp_power_dvd prime_factors_ge_0_int) done lemma multiplicity_dvd'_nat: "(0::nat) < x \ \p. prime p \ multiplicity p x \ multiplicity p y \ x dvd y" - apply (cases "y = 0") - apply auto - apply (rule multiplicity_dvd_nat, auto) - apply (case_tac "prime p") - apply auto -done +by (metis gcd_lcm_complete_lattice_nat.top_greatest le_refl multiplicity_dvd_nat + multiplicity_nonprime_nat neq0_conv) lemma multiplicity_dvd'_int: "(0::int) < x \ 0 <= y \ \p. prime p \ multiplicity p x \ multiplicity p y \ x dvd y" - apply (cases "y = 0") - apply auto - apply (rule multiplicity_dvd_int, auto) - apply (case_tac "prime p") - apply auto -done +by (metis eq_imp_le gcd_lcm_complete_lattice_nat.top_greatest int_eq_0_conv multiplicity_dvd_int + multiplicity_nonprime_int nat_int transfer_nat_int_relations(4) zless_le) lemma dvd_multiplicity_eq_nat: "0 < (x::nat) \ 0 < y \ (x dvd y) = (ALL p. multiplicity p x <= multiplicity p y)" @@ -820,12 +795,8 @@ apply (rule dvd_power [where x = p and n = "multiplicity p n"]) apply (subst (asm) prime_factors_altdef_nat, force) apply (rule dvd_setprod) - apply auto - apply (subst prime_factors_altdef_nat) - apply (subst (asm) dvd_multiplicity_eq_nat) apply auto - apply (drule spec [where x = p]) - apply auto + apply (metis One_nat_def Zero_not_Suc dvd_multiplicity_nat le0 le_antisym multiplicity_not_factor_nat multiplicity_prime_nat) done lemma prime_factors_altdef2_int: