X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Flib%2Farithmetics%2Fprimes.ma;h=62c0a0081af5ecadfade0e7b0bbaa1ff4a3b216a;hb=cd2f5b59215ea771ac137b9a7b115a05175f45d5;hp=2e2ef98fbc18a2c113ddac96aa996cc96a2debfb;hpb=38bc223769400d37900d3e18d663eefebe5c1223;p=helm.git diff --git a/matita/matita/lib/arithmetics/primes.ma b/matita/matita/lib/arithmetics/primes.ma index 2e2ef98fb..62c0a0081 100644 --- a/matita/matita/lib/arithmetics/primes.ma +++ b/matita/matita/lib/arithmetics/primes.ma @@ -247,26 +247,24 @@ qed. (* smallest factor *) definition smallest_factor : nat → nat ≝ -λn:nat. if_then_else ? (leb n 1) n - (min n 2 (λm.(eqb (n \mod m) O))). +λn:nat. if leb n 1 then n else min n 2 (λm.(eqb (n \mod m) O)). theorem smallest_factor_to_min : ∀n. 1 < n → smallest_factor n = (min n 2 (λm.(eqb (n \mod m) O))). #n #lt1n normalize >lt_to_leb_false // qed. -(* it works ! -theorem example1 : smallest_factor 3 = 3. +example example1 : smallest_factor 3 = 3. normalize // qed. -theorem example2: smallest_factor 4 = 2. +example example2: smallest_factor 4 = 2. normalize // qed. -theorem example3 : smallest_factor 7 = 7. +example example3 : smallest_factor 7 = 7. normalize // -qed. *) +qed. theorem le_SO_smallest_factor: ∀n:nat. n ≤ 1 → smallest_factor n = n. @@ -312,7 +310,7 @@ qed. theorem prime_smallest_factor_n : ∀n. 1 < n → prime (smallest_factor n). -#n #lt1n (cut (0smallest_factor_to_min // @true_to_le_min // @@ -339,16 +337,16 @@ definition primeb ≝ λn:nat. (leb 2 n) ∧ (eqb (smallest_factor n) n). (* it works! *) -theorem example4 : primeb 3 = true. +example example4 : primeb 3 = true. normalize // qed. -theorem example5 : primeb 6 = false. +example example5 : primeb 6 = false. normalize // qed. -theorem example6 : primeb 11 = true. +example example6 : primeb 11 = true. normalize // qed. -theorem example7 : primeb 17 = true. +example example7 : primeb 17 = true. normalize // qed. theorem primeb_true_to_prime : ∀n:nat. @@ -440,20 +438,20 @@ let rec nth_prime n ≝ match n with min upper_bound (S previous_prime) primeb]. lemma nth_primeS: ∀n.nth_prime (S n) = - let previous_prime ≝ nth_prime n in + (let previous_prime ≝ nth_prime n in let upper_bound ≝ S previous_prime! in - min upper_bound (S previous_prime) primeb. + min upper_bound (S previous_prime) primeb). // qed. (* it works *) -theorem example11 : nth_prime 2 = 5. +example example11 : nth_prime 2 = 5. normalize // qed. -theorem example12: nth_prime 3 = 7. +example example12: nth_prime 3 = 7. normalize // qed. -theorem example13 : nth_prime 4 = 11. +example example13 : nth_prime 4 = 11. normalize // qed. (* done in 13.1369330883s -- qualcosa non va: // lentissimo @@ -481,7 +479,7 @@ change with (let previous_prime ≝ (nth_prime n) in let upper_bound ≝ S previous_prime! in S previous_prime ≤ min upper_bound (S previous_prime) primeb) -apply le_min_l +@le_min_l qed. theorem lt_SO_nth_prime_n : ∀n:nat. 1 < nth_prime n.