1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / Matita is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
16 include "nat/pi_p.ma".
17 include "nat/factorization.ma".
18 include "nat/factorial2.ma".
20 definition prim: nat \to nat \def
21 \lambda n. sigma_p (S n) primeb (\lambda p.1).
23 theorem le_prim_n: \forall n. prim n \le n.
24 intros.unfold prim. elim n
26 |apply (bool_elim ? (primeb (S n1)));intro
27 [rewrite > true_to_sigma_p_Sn
31 apply le_S_S.assumption
34 |rewrite > false_to_sigma_p_Sn
35 [apply le_S.assumption
42 theorem not_prime_times_SSO: \forall n. 1 < n \to \lnot prime (2*n).
46 [apply (witness ? ? n).reflexivity
50 rewrite > times_n_SO in ⊢ (? % ?).
56 theorem eq_prim_prim_pred: \forall n. 1 < n \to
57 (prim (2*n)) = (prim (pred (2*n))).
60 [rewrite > false_to_sigma_p_Sn
62 |apply not_prime_to_primeb_false.
63 apply not_prime_times_SSO.
66 |apply (trans_lt ? (2*1))
67 [simplify.apply lt_O_S
74 theorem le_prim_n1: \forall n. 4 \le n \to prim (S(2*n)) \le n.
75 intros.unfold prim. elim H
77 |cut (sigma_p (2*S n1) primeb (λp:nat.1) = sigma_p (S (2*S n1)) primeb (λp:nat.1))
78 [apply (bool_elim ? (primeb (S(2*(S n1)))));intro
79 [rewrite > true_to_sigma_p_Sn
89 |rewrite > false_to_sigma_p_Sn
97 |apply sym_eq.apply (eq_prim_prim_pred (S n1)).
98 apply le_S_S.apply (trans_le ? 4)
99 [apply leb_true_to_le.reflexivity
106 (* usefull to kill a successor in bertrand *)
107 theorem le_prim_n2: \forall n. 7 \le n \to prim (S(2*n)) \le pred n.
108 intros.unfold prim. elim H
109 [apply leb_true_to_le.reflexivity.
110 |cut (sigma_p (2*S n1) primeb (λp:nat.1) = sigma_p (S (2*S n1)) primeb (λp:nat.1))
111 [apply (bool_elim ? (primeb (S(2*(S n1)))));intro
112 [rewrite > true_to_sigma_p_Sn
116 simplify in ⊢ (? ? %).
117 rewrite > S_pred in ⊢ (? ? %)
122 |apply (ltn_to_ltO ? ? H1)
126 |rewrite > false_to_sigma_p_Sn
127 [simplify in ⊢ (? ? %).
128 apply (trans_le ? ? ? ? (le_pred_n n1)).
135 |apply sym_eq.apply (eq_prim_prim_pred (S n1)).
136 apply le_S_S.apply (trans_le ? 4)
137 [apply leb_true_to_le.reflexivity
138 |apply (trans_le ? ? ? ? H1).
139 apply leb_true_to_le.reflexivity
146 theorem le_pred: \forall n,m. n \le m \to pred n \le pred m.
147 apply nat_elim2;intros
149 |apply False_ind.apply (le_to_not_lt ? ? H).
151 |simplify.apply le_S_S_to_le.assumption
155 (* la prova potrebbe essere migliorata *)
156 theorem le_prim_n3: \forall n. 15 \le n \to
157 prim n \le pred (n/2).
159 elim (or_eq_eq_S (pred n)).
163 apply (trans_le ? (pred a))
165 apply (le_times_to_le 2)
172 apply le_times_to_le_div
179 apply (ltn_to_ltO ? ? H)
183 rewrite > eq_prim_prim_pred
184 [rewrite > times_SSO in ⊢ (? % ?).
185 change in ⊢ (? (? %) ?) with (S (2*a)).
186 rewrite > sym_times in ⊢ (? ? (? (? % ?))).
187 rewrite > lt_O_to_div_times
188 [apply (trans_le ? (pred a))
191 apply (lt_times_to_lt 2)
204 apply not_lt_to_le.intro.
205 apply (le_to_not_lt ? ? H).
207 lapply (le_S_S_to_le ? ? H3) as H4.
208 apply (le_n_O_elim ? H4).
209 apply leb_true_to_le.reflexivity
211 |rewrite > times_SSO.
213 [apply eq_f.assumption
214 |apply (ltn_to_ltO ? ? H)
220 (* This is chebishev psi function *)
221 definition A: nat \to nat \def
222 \lambda n. pi_p (S n) primeb (\lambda p.exp p (log p n)).
224 theorem le_Al1: \forall n.
225 A n \le pi_p (S n) primeb (\lambda p.n).
236 theorem le_Al: \forall n.
237 A n \le exp n (prim n).
239 rewrite < exp_sigma_p.
243 theorem leA_r2: \forall n.
244 exp n (prim n) \le A n * A n.
246 elim (le_to_or_lt_eq ? ? (le_O_n n))
247 [rewrite < (exp_sigma_p (S n) n primeb).
249 rewrite < times_pi_p.
252 rewrite < exp_plus_times.
253 apply (trans_le ? (exp i (S(log i n))))
256 apply prime_to_lt_SO.
257 apply primeb_true_to_prime.
260 [apply prime_to_lt_O.
261 apply primeb_true_to_prime.
274 |rewrite < H. apply le_n
278 (* an equivalent formulation for psi *)
279 definition A': nat \to nat \def
280 \lambda n. pi_p (S n) primeb
281 (\lambda p.(pi_p (log p n) (\lambda i.true) (\lambda i.p))).
283 theorem eq_A_A': \forall n.A n = A' n.
284 intro.unfold A.unfold A'.
288 apply (trans_eq ? ? (exp x (sigma_p (log x n) (λi:nat.true) (λi:nat.(S O)))))
289 [apply eq_f.apply sym_eq.apply sigma_p_true
290 |apply sym_eq.apply exp_sigma_p
295 theorem eq_pi_p_primeb_divides_b: \forall n,m.
296 pi_p n (\lambda p.primeb p \land divides_b p m) (\lambda p.exp p (ord m p))
297 = pi_p n primeb (\lambda p.exp p (ord m p)).
301 |apply (bool_elim ? (primeb n1));intro
302 [rewrite > true_to_pi_p_Sn in ⊢ (? ? ? %)
303 [apply (bool_elim ? (divides_b n1 m));intro
304 [rewrite > true_to_pi_p_Sn
307 |apply true_to_true_to_andb_true;assumption
309 |rewrite > false_to_pi_p_Sn
310 [rewrite > not_divides_to_ord_O
311 [simplify in ⊢ (? ? ? (? % ?)).
313 rewrite < times_n_SO.
315 |apply primeb_true_to_prime.assumption
316 |apply divides_b_false_to_not_divides.
319 |rewrite > H1.rewrite > H2.reflexivity
324 |rewrite > false_to_pi_p_Sn
325 [rewrite > false_to_pi_p_Sn
329 |rewrite > H1.reflexivity
335 theorem lt_max_to_pi_p_primeb: \forall q,m. O < m \to max m (\lambda i.primeb i \land divides_b i m) < q \to
336 m = pi_p q (\lambda i.primeb i \land divides_b i m) (\lambda p.exp p (ord m p)).
339 apply (not_le_Sn_O ? H1)
340 |apply (bool_elim ? (primeb n∧divides_b n m));intro
341 [rewrite > true_to_pi_p_Sn
342 [rewrite > (exp_ord n m) in ⊢ (? ? % ?)
344 rewrite > (H (ord_rem m n))
347 apply (bool_elim ? (primeb x));intro
349 apply (bool_elim ? (divides_b x (ord_rem m n)));intro
351 apply divides_to_divides_b_true
352 [apply prime_to_lt_O.
353 apply primeb_true_to_prime.
355 |apply (trans_divides ? (ord_rem m n))
356 [apply divides_b_true_to_divides.
358 |apply divides_ord_rem
359 [apply (trans_lt ? x)
360 [apply prime_to_lt_SO.
361 apply primeb_true_to_prime.
370 apply not_divides_to_divides_b_false
371 [apply prime_to_lt_O.
372 apply primeb_true_to_prime.
374 |apply ord_O_to_not_divides
376 |apply primeb_true_to_prime.
378 |rewrite < (ord_ord_rem n)
379 [apply not_divides_to_ord_O
380 [apply primeb_true_to_prime.
382 |apply divides_b_false_to_not_divides.
386 |apply primeb_true_to_prime.
387 apply (andb_true_true ? ? H3)
388 |apply primeb_true_to_prime.
401 |apply primeb_true_to_prime.
402 apply (andb_true_true ? ? H3)
403 |apply primeb_true_to_prime.
404 apply (andb_true_true ? ? H5)
409 [apply prime_to_lt_SO.
410 apply primeb_true_to_prime.
411 apply (andb_true_true ? ? H3)
414 |apply not_eq_to_le_to_lt
415 [elim (exists_max_forall_false (λi:nat.primeb i∧divides_b i (ord_rem m n)) (ord_rem m n))
417 intro.rewrite > H7 in H6.simplify in H6.
418 apply (not_divides_ord_rem m n)
420 |apply prime_to_lt_SO.
421 apply primeb_true_to_prime.
422 apply (andb_true_true ? ? H3)
423 |apply divides_b_true_to_divides.
424 apply (andb_true_true_r ? ? H6)
426 |elim H4.rewrite > H6.
429 apply primeb_true_to_prime.
430 apply (andb_true_true ? ? H3)
432 |apply (trans_le ? (max m (λi:nat.primeb i∧divides_b i (ord_rem m n))))
436 |apply divides_ord_rem
437 [apply prime_to_lt_SO.
438 apply primeb_true_to_prime.
439 apply (andb_true_true ? ? H3)
443 |apply (trans_le ? (max m (λi:nat.primeb i∧divides_b i m)))
444 [apply le_max_f_max_g.
446 apply (bool_elim ? (primeb i));intro
448 apply divides_to_divides_b_true
449 [apply prime_to_lt_O.
450 apply primeb_true_to_prime.
452 |apply (trans_divides ? (ord_rem m n))
453 [apply divides_b_true_to_divides.
454 apply (andb_true_true_r ? ? H5)
455 |apply divides_ord_rem
456 [apply prime_to_lt_SO.
457 apply primeb_true_to_prime.
458 apply (andb_true_true ? ? H3)
472 |apply prime_to_lt_SO.
473 apply primeb_true_to_prime.
474 apply (andb_true_true ? ? H3)
479 |elim (le_to_or_lt_eq ? ? H1)
480 [rewrite > false_to_pi_p_Sn
483 |apply false_to_lt_max
484 [apply (lt_to_le_to_lt ? (max m (λi:nat.primeb i∧divides_b i m)))
486 apply lt_SO_max_prime.
499 rewrite < (pi_p_false (λp:nat.p\sup(ord (S O) p)) (S n) ) in ⊢ (? ? % ?).
502 apply (bool_elim ? (primeb x));intro
504 change with (divides_b x (S O) =false).
505 apply not_divides_to_divides_b_false
506 [apply prime_to_lt_O.
507 apply primeb_true_to_prime.
510 apply (le_to_not_lt x (S O))
512 [apply lt_O_S.assumption
515 |elim (primeb_true_to_prime ? H6).
528 (* factorization of n into primes *)
529 theorem pi_p_primeb_divides_b: \forall n. O < n \to
530 n = pi_p (S n) (\lambda i.primeb i \land divides_b i n) (\lambda p.exp p (ord n p)).
532 apply lt_max_to_pi_p_primeb
539 theorem pi_p_primeb: \forall n. O < n \to
540 n = pi_p (S n) primeb (\lambda p.exp p (ord n p)).
542 rewrite < eq_pi_p_primeb_divides_b.
543 apply pi_p_primeb_divides_b.
547 theorem le_ord_log: \forall n,p. O < n \to 1 < p \to
550 rewrite > (exp_ord p) in ⊢ (? ? (? ? %))
554 |apply lt_O_ord_rem;assumption
561 theorem sigma_p_divides_b:
562 \forall m,n,p. O < n \to prime p \to \lnot divides p n \to
563 m = sigma_p m (λi:nat.divides_b (p\sup (S i)) ((exp p m)*n)) (λx:nat.S O).
566 |simplify in ⊢ (? ? ? (? % ? ?)).
567 rewrite > true_to_sigma_p_Sn
568 [rewrite > sym_plus.rewrite < plus_n_SO.
570 rewrite > (H n1 p H1 H2 H3) in ⊢ (? ? % ?).
573 apply (bool_elim ? (divides_b (p\sup(S x)) (p\sup n*n1)));intro
575 apply divides_to_divides_b_true
579 |apply (witness ? ? ((exp p (n - x))*n1)).
580 rewrite < assoc_times.
581 rewrite < exp_plus_times.
583 [apply eq_f.simplify.
586 apply plus_minus_m_m.
587 apply lt_to_le.assumption
593 apply (divides_b_false_to_not_divides ? ? H5).
594 apply (witness ? ? ((exp p (n - S x))*n1)).
595 rewrite < assoc_times.
596 rewrite < exp_plus_times.
600 apply plus_minus_m_m.
607 |apply divides_to_divides_b_true
609 apply prime_to_lt_O.assumption
610 |apply (witness ? ? n1).reflexivity
616 theorem sigma_p_divides_b1:
617 \forall m,n,p,k. O < n \to prime p \to \lnot divides p n \to m \le k \to
618 m = sigma_p k (λi:nat.divides_b (p\sup (S i)) ((exp p m)*n)) (λx:nat.S O).
620 lapply (prime_to_lt_SO ? H1) as H4.
621 lapply (prime_to_lt_O ? H1) as H5.
622 rewrite > (false_to_eq_sigma_p m k)
623 [apply sigma_p_divides_b;assumption
626 apply not_divides_to_divides_b_false
627 [apply lt_O_exp.assumption
628 |intro.apply (le_to_not_lt ? ? H6).
630 rewrite < (ord_exp p)
631 [rewrite > (plus_n_O m).
632 rewrite < (not_divides_to_ord_O ? ? H1 H2).
633 rewrite < (ord_exp p ? H4) in ⊢ (? ? (? % ?)).
635 [apply divides_to_le_ord
636 [apply lt_O_exp.assumption
637 |rewrite > (times_n_O O).
639 [apply lt_O_exp.assumption
645 |apply lt_O_exp.assumption
655 theorem eq_ord_sigma_p:
656 \forall n,m,x. O < n \to prime x \to
657 exp x m \le n \to n < exp x (S m) \to
658 ord n x=sigma_p m (λi:nat.divides_b (x\sup (S i)) n) (λx:nat.1).
660 lapply (prime_to_lt_SO ? H1).
661 rewrite > (exp_ord x n) in ⊢ (? ? ? (? ? (λi:?.? ? %) ?))
662 [apply sigma_p_divides_b1
663 [apply lt_O_ord_rem;assumption
665 |apply not_divides_ord_rem;assumption
667 apply (le_to_lt_to_lt ? (log x n))
668 [apply le_ord_log;assumption
669 |apply (lt_exp_to_lt x)
671 |apply (le_to_lt_to_lt ? n ? ? H3).
682 theorem pi_p_primeb1: \forall n. O < n \to
683 n = pi_p (S n) primeb
684 (\lambda p.(pi_p (log p n)
685 (\lambda i.divides_b (exp p (S i)) n) (\lambda i.p))).
687 rewrite > (pi_p_primeb n H) in ⊢ (? ? % ?).
691 rewrite > exp_sigma_p.
695 |apply primeb_true_to_prime.
697 |apply le_exp_log.assumption
699 apply prime_to_lt_SO.
700 apply primeb_true_to_prime.
706 (* the factorial function *)
707 theorem eq_fact_pi_p:\forall n. fact n =
708 pi_p (S n) (\lambda i.leb (S O) i) (\lambda i.i).
711 |change with ((S n1)*n1! = pi_p (S (S n1)) (λi:nat.leb (S O) i) (λi:nat.i)).
712 rewrite > true_to_pi_p_Sn
713 [apply eq_f.assumption
719 theorem eq_sigma_p_div: \forall n,q.O < q \to
720 sigma_p (S n) (λm:nat.leb (S O) m∧divides_b q m) (λx:nat.S O)
723 apply (div_mod_spec_to_eq n q ? (n \mod q) ? (n \mod q))
724 [apply div_mod_spec_intro
725 [apply lt_mod_m_m.assumption
727 [simplify.elim q;reflexivity
728 |elim (or_div_mod1 n1 q)
730 rewrite > divides_to_mod_O
732 rewrite > true_to_sigma_p_Sn
733 [rewrite > H4 in ⊢ (? ? % ?).
738 apply (div_mod_spec_to_eq n1 q (div n1 q) (mod n1 q) ? (mod n1 q))
739 [apply div_mod_spec_div_mod.
741 |apply div_mod_spec_intro
742 [apply lt_mod_m_m.assumption
748 |apply true_to_true_to_andb_true
750 |apply divides_to_divides_b_true;assumption
757 rewrite > false_to_sigma_p_Sn
759 [rewrite < plus_n_Sm.
763 |elim (le_to_or_lt_eq (S (mod n1 q)) q)
767 apply (witness ? ? (S(div n1 q))).
768 rewrite < times_n_Sm.
770 rewrite < H2 in ⊢ (? ? ? (? ? %)).
777 |rewrite > not_divides_to_divides_b_false
778 [rewrite < andb_sym in ⊢ (? ? % ?).reflexivity
787 |apply div_mod_spec_div_mod.
792 (* still another characterization of the factorial *)
793 theorem fact_pi_p: \forall n. fact n =
795 (\lambda p.(pi_p (log p n)
796 (\lambda i.true) (\lambda i.(exp p (n /(exp p (S i))))))).
798 rewrite > eq_fact_pi_p.
800 (pi_p (S n) (λm:nat.leb (S O) m)
801 (λm.pi_p (S m) primeb
802 (\lambda p.(pi_p (log p m)
803 (\lambda i.divides_b (exp p (S i)) m) (\lambda i.p))))))
804 [apply eq_pi_p1;intros
807 apply leb_true_to_le.assumption
810 (pi_p (S n) (λm:nat.leb (S O) m)
812 .pi_p (S m) (\lambda p.primeb p\land leb p m)
813 (λp:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))))
816 |intros.apply eq_pi_p1
817 [intros.elim (primeb x1)
818 [simplify.apply sym_eq.
819 apply le_to_leb_true.
828 (pi_p (S n) (λm:nat.leb (S O) m)
830 .pi_p (S n) (λp:nat.primeb p∧leb p m)
831 (λp:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))))
836 apply false_to_eq_pi_p
838 |intros.rewrite > lt_to_leb_false
839 [elim primeb;reflexivity|assumption]
842 |(* make a general theorem *)
846 .pi_p (S n) (λm.leb p m)
847 (λm:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))
851 apply (bool_elim ? (primeb y \land leb y x));intros
852 [rewrite > (le_to_leb_true (S O) x)
854 |apply (trans_le ? y)
855 [apply prime_to_lt_O.
856 apply primeb_true_to_prime.
857 apply (andb_true_true ? ? H2)
858 |apply leb_true_to_le.
859 apply (andb_true_true_r ? ? H2)
862 |elim (leb (S O) x);reflexivity
868 (pi_p (S n) (λm:nat.leb x m)
869 (λm:nat.pi_p (log x n) (λi:nat.divides_b (x\sup(S i)) m) (λi:nat.x))))
874 apply false_to_eq_pi_p
876 [apply prime_to_lt_SO.
877 apply primeb_true_to_prime.
883 apply not_divides_to_divides_b_false
886 apply primeb_true_to_prime.
889 apply (lt_to_not_le x1 (exp x (S i)))
890 [apply (lt_to_le_to_lt ? (exp x (S(log x x1))))
892 apply prime_to_lt_SO.
893 apply primeb_true_to_prime.
896 [apply prime_to_lt_O.
897 apply primeb_true_to_prime.
904 [apply (lt_to_le_to_lt ? x)
905 [apply prime_to_lt_O.
906 apply primeb_true_to_prime.
908 |apply leb_true_to_le.
919 (pi_p (log x n) (λi:nat.true)
920 (λi:nat.pi_p (S n) (λm:nat.leb x m \land divides_b (x\sup(S i)) m) (λm:nat.x))))
921 [apply (pi_p_pi_p1 (\lambda m,i.x)).
927 rewrite > exp_sigma_p.
930 (sigma_p (S n) (λm:nat.leb (S O) m∧divides_b (x\sup(S x1)) m) (λx:nat.S O)))
933 apply (bool_elim ? (divides_b (x\sup(S x1)) x2));intro
934 [apply (bool_elim ? (leb x x2));intro
935 [rewrite > le_to_leb_true
937 |apply (trans_le ? x)
938 [apply prime_to_lt_O.
939 apply primeb_true_to_prime.
941 |apply leb_true_to_le.
945 |rewrite > lt_to_leb_false
947 |apply not_le_to_lt.intro.
948 apply (leb_false_to_not_le ? ? H6).
949 apply (trans_le ? (exp x (S x1)))
950 [rewrite > times_n_SO in ⊢ (? % ?).
951 change with (exp x (S O) \le exp x (S x1)).
953 [apply prime_to_lt_O.
954 apply primeb_true_to_prime.
956 |apply le_S_S.apply le_O_n.
960 |apply divides_b_true_to_divides.
967 rewrite < andb_sym in ⊢ (? ? ? %).
972 |apply eq_sigma_p_div.
975 apply primeb_true_to_prime.
988 (* odd n is just mod n (S(S O))
992 | S m \Rightarrow (S O) - odd m
995 theorem le_odd_SO: \forall n. odd n \le S O.
998 |simplify.cases (odd n1)
999 [simplify.apply le_n.
1005 theorem SSO_odd: \forall n. n = (n/(S(S O)))*(S(S O)) + odd n.
1007 [apply (lt_O_n_elim ? H).
1008 intro.simplify.reflexivity
1012 theorem fact_pi_p2: \forall n. fact (2*n) =
1013 pi_p (S (2*n)) primeb
1014 (\lambda p.(pi_p (log p (2*n))
1015 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))*(exp p (mod (2*n /(exp p (S i))) 2)))))).
1016 intros.rewrite > fact_pi_p.
1019 |intros.apply eq_pi_p
1022 rewrite < exp_plus_times.
1024 rewrite > sym_times in ⊢ (? ? ? (? % ?)).
1027 apply prime_to_lt_O.
1028 apply primeb_true_to_prime.
1034 theorem fact_pi_p3: \forall n. fact (2*n) =
1035 pi_p (S (2*n)) primeb
1036 (\lambda p.(pi_p (log p (2*n))
1037 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))*
1038 pi_p (S (2*n)) primeb
1039 (\lambda p.(pi_p (log p (2*n))
1040 (\lambda i.true) (\lambda i.(exp p (mod (2*n /(exp p (S i))) 2))))).
1042 rewrite < times_pi_p.
1043 rewrite > fact_pi_p2.
1044 apply eq_pi_p;intros
1050 theorem pi_p_primeb4: \forall n. 1 < n \to
1051 pi_p (S (2*n)) primeb
1052 (\lambda p.(pi_p (log p (2*n))
1053 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))
1056 (\lambda p.(pi_p (log p (2*n))
1057 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1059 apply or_false_eq_SO_to_eq_pi_p
1065 rewrite > log_i_SSOn
1066 [change with (i\sup((S(S O))*(n/i\sup(S O)))*(S O) = S O).
1067 rewrite < times_n_SO.
1070 |simplify.rewrite < times_n_SO.assumption
1074 |apply le_S_S_to_le.assumption
1079 theorem pi_p_primeb5: \forall n. 1 < n \to
1080 pi_p (S (2*n)) primeb
1081 (\lambda p.(pi_p (log p ((S(S O))*n))
1082 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))
1085 (\lambda p.(pi_p (log p n)
1086 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1088 rewrite > (pi_p_primeb4 ? H).
1089 apply eq_pi_p1;intros
1091 |apply or_false_eq_SO_to_eq_pi_p
1093 [apply prime_to_lt_SO.
1094 apply primeb_true_to_prime.
1101 [simplify.reflexivity
1102 |apply (lt_to_le_to_lt ? (exp x (S(log x n))))
1104 apply prime_to_lt_SO.
1105 apply primeb_true_to_prime.
1108 [apply prime_to_lt_O.
1109 apply primeb_true_to_prime.
1120 theorem exp_fact_SSO: \forall n.
1124 (\lambda p.(pi_p (log p n)
1125 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1127 rewrite > fact_pi_p.
1129 apply eq_pi_p;intros
1132 apply exp_times_pi_p
1139 (\lambda p.(pi_p (log p n)
1140 (\lambda i.true) (\lambda i.(exp p (mod (n /(exp p (S i))) (S(S O))))))).
1142 theorem B_SSSO: B 3 = 6.
1146 theorem B_SSSSO: B 4 = 6.
1150 theorem B_SSSSSO: B 5 = 30.
1154 theorem B_SSSSSSO: B 6 = 20.
1158 theorem B_SSSSSSSO: B 7 = 140.
1162 theorem B_SSSSSSSSO: B 8 = 70.
1166 theorem eq_fact_B:\forall n.S O < n \to
1167 fact (2*n) = exp (fact n) 2 * B(2*n).
1169 rewrite > fact_pi_p3.
1172 rewrite > pi_p_primeb5
1180 theorem le_B_A: \forall n. B n \le A n.
1184 apply le_pi_p.intros.
1185 apply le_pi_p.intros.
1186 rewrite > exp_n_SO in ⊢ (? ? %).
1188 [apply prime_to_lt_O.
1189 apply primeb_true_to_prime.
1191 |apply le_S_S_to_le.
1197 theorem le_B_A4: \forall n. O < n \to (S(S O))* B ((S(S(S(S O))))*n) \le A ((S(S(S(S O))))*n).
1201 cut ((S(S O)) < (S ((S(S(S(S O))))*n)))
1202 [cut (O<log (S(S O)) ((S(S(S(S O))))*n))
1203 [rewrite > (pi_p_gi ? ? (S(S O)))
1204 [rewrite > (pi_p_gi ? ? (S(S O))) in ⊢ (? ? %)
1205 [rewrite < assoc_times.
1207 [rewrite > (pi_p_gi ? ? O)
1208 [rewrite > (pi_p_gi ? ? O) in ⊢ (? ? %)
1209 [rewrite < assoc_times.
1211 [rewrite < exp_n_SO.
1212 change in ⊢ (? (? ? (? ? (? (? (? % ?) ?) ?))) ?)
1213 with ((S(S O))*(S(S O))).
1214 rewrite > assoc_times.
1215 rewrite > sym_times in ⊢ (? (? ? (? ? (? (? % ?) ?))) ?).
1216 rewrite > lt_O_to_div_times
1217 [rewrite > divides_to_mod_O
1220 |apply (witness ? ? n).reflexivity
1224 |apply le_pi_p.intros.
1225 rewrite > exp_n_SO in ⊢ (? ? %).
1228 |apply le_S_S_to_le.
1239 |apply le_pi_p.intros.
1240 apply le_pi_p.intros.
1241 rewrite > exp_n_SO in ⊢ (? ? %).
1243 [apply prime_to_lt_O.
1244 apply primeb_true_to_prime.
1245 apply (andb_true_true ? ? H2)
1246 |apply le_S_S_to_le.
1258 [rewrite > (times_n_O (S(S(S(S O))))) in ⊢ (? % ?).
1263 |rewrite > times_n_SO in ⊢ (? % ?).
1265 [apply le_S.apply le_S.apply le_n
1271 rewrite > times_n_SO in ⊢ (? % ?).
1273 [apply le_S.apply le_n_Sn
1280 theorem le_fact_A:\forall n.S O < n \to
1281 fact (2*n) \le exp (fact n) 2 * A (2*n).
1290 theorem lt_SO_to_le_B_exp: \forall n.S O < n \to
1291 B (2*n) \le exp 2 (pred (2*n)).
1293 apply (le_times_to_le (exp (fact n) (S(S O))))
1296 |rewrite < eq_fact_B
1297 [rewrite < sym_times in ⊢ (? ? %).
1299 rewrite < assoc_times.
1306 theorem le_B_exp: \forall n.
1307 B (2*n) \le exp 2 (pred (2*n)).
1311 [simplify.apply le_n
1312 |apply lt_SO_to_le_B_exp.
1313 apply le_S_S.apply lt_O_S.
1318 theorem lt_SSSSO_to_le_B_exp: \forall n.4 < n \to
1319 B (2*n) \le exp 2 ((2*n)-2).
1321 apply (le_times_to_le (exp (fact n) (S(S O))))
1324 |rewrite < eq_fact_B
1325 [rewrite < sym_times in ⊢ (? ? %).
1327 rewrite < assoc_times.
1328 apply lt_SSSSO_to_fact.assumption
1329 |apply lt_to_le.apply lt_to_le.
1330 apply lt_to_le.assumption
1335 theorem lt_SO_to_le_exp_B: \forall n. 1 < n \to
1336 exp 2 (2*n) \le 2 * n * B (2*n).
1338 apply (le_times_to_le (exp (fact n) (S(S O))))
1341 |rewrite < assoc_times in ⊢ (? ? %).
1342 rewrite > sym_times in ⊢ (? ? (? % ?)).
1343 rewrite > assoc_times in ⊢ (? ? %).
1345 [rewrite < sym_times.
1347 apply lt_to_le.assumption
1353 theorem le_exp_B: \forall n. O < n \to
1354 exp 2 (2*n) \le 2 * n * B (2*n).
1358 |apply lt_SO_to_le_exp_B.
1359 apply le_S_S.assumption
1363 theorem eq_A_SSO_n: \forall n.O < n \to
1365 pi_p (S (2*n)) primeb
1366 (\lambda p.(pi_p (log p (2*n) )
1367 (\lambda i.true) (\lambda i.(exp p (bool_to_nat (leb (S n) (exp p (S i))))))))
1370 rewrite > eq_A_A'.rewrite > eq_A_A'.
1373 pi_p (S n) primeb (λp:nat.pi_p (log p n) (λi:nat.true) (λi:nat.p))
1374 = pi_p (S ((S(S O))*n)) primeb
1375 (λp:nat.pi_p (log p ((S(S O))*n)) (λi:nat.true) (λi:nat.(p)\sup(bool_to_nat (\lnot (leb (S n) (exp p (S i))))))))
1377 rewrite < times_pi_p.
1378 apply eq_pi_p1;intros
1380 |rewrite < times_pi_p.
1381 apply eq_pi_p;intros
1383 |apply (bool_elim ? (leb (S n) (exp x (S x1))));intro
1384 [simplify.rewrite < times_n_SO.apply times_n_SO
1385 |simplify.rewrite < plus_n_O.apply times_n_SO
1389 |apply (trans_eq ? ? (pi_p (S n) primeb
1390 (\lambda p:nat.pi_p (log p n) (\lambda i:nat.true) (\lambda i:nat.(p)\sup(bool_to_nat (¬leb (S n) (exp p (S i))))))))
1391 [apply eq_pi_p1;intros
1393 |apply eq_pi_p1;intros
1395 |rewrite > lt_to_leb_false
1396 [simplify.apply times_n_SO
1398 apply (trans_le ? (exp x (log x n)))
1400 [apply prime_to_lt_O.
1401 apply primeb_true_to_prime.
1411 |apply (trans_eq ? ?
1412 (pi_p (S ((S(S O))*n)) primeb
1413 (λp:nat.pi_p (log p n) (λi:nat.true)
1414 (λi:nat.(p)\sup(bool_to_nat (¬leb (S n) ((p)\sup(S i))))))))
1416 apply or_false_eq_SO_to_eq_pi_p
1421 rewrite > lt_to_log_O
1427 |apply eq_pi_p1;intros
1430 apply or_false_eq_SO_to_eq_pi_p
1432 [apply prime_to_lt_SO.
1433 apply primeb_true_to_prime.
1439 rewrite > le_to_leb_true
1440 [simplify.reflexivity
1441 |apply (lt_to_le_to_lt ? (exp x (S (log x n))))
1443 apply prime_to_lt_SO.
1444 apply primeb_true_to_prime.
1447 [apply prime_to_lt_O.
1448 apply primeb_true_to_prime.
1450 |apply le_S_S.assumption
1461 theorem le_A_BA1: \forall n. O < n \to
1462 A(2*n) \le B(2*n)*A n.
1464 rewrite > eq_A_SSO_n
1467 apply le_pi_p.intros.
1468 apply le_pi_p.intros.
1470 [apply prime_to_lt_O.
1471 apply primeb_true_to_prime.
1473 |apply (bool_elim ? (leb (S n) (exp i (S i1))));intro
1474 [simplify in ⊢ (? % ?).
1475 cut ((S(S O))*n/i\sup(S i1) = S O)
1476 [rewrite > Hcut.apply le_n
1477 |apply (div_mod_spec_to_eq
1478 ((S(S O))*n) (exp i (S i1))
1479 ? (mod ((S(S O))*n) (exp i (S i1)))
1480 ? (minus ((S(S O))*n) (exp i (S i1))) )
1481 [apply div_mod_spec_div_mod.
1483 apply prime_to_lt_O.
1484 apply primeb_true_to_prime.
1486 |cut (i\sup(S i1)≤(S(S O))*n)
1487 [apply div_mod_spec_intro
1488 [apply lt_plus_to_lt_minus
1490 |simplify in ⊢ (? % ?).
1493 [apply leb_true_to_le.assumption
1494 |apply leb_true_to_le.assumption
1497 |rewrite > sym_plus.
1498 rewrite > sym_times in ⊢ (? ? ? (? ? %)).
1499 rewrite < times_n_SO.
1500 apply plus_minus_m_m.
1503 |apply (trans_le ? (exp i (log i ((S(S O))*n))))
1505 [apply prime_to_lt_O.
1506 apply primeb_true_to_prime.
1511 rewrite > (times_n_O O) in ⊢ (? % ?).
1527 theorem le_A_BA: \forall n. A((S(S O))*n) \le B((S(S O))*n)*A n.
1530 |apply le_A_BA1.apply lt_O_S
1534 theorem le_A_exp: \forall n.
1535 A(2*n) \le (exp 2 (pred (2*n)))*A n.
1537 apply (trans_le ? (B(2*n)*A n))
1544 theorem lt_SSSSO_to_le_A_exp: \forall n. 4 < n \to
1545 A(2*n) \le exp 2 ((2*n)-2)*A n.
1547 apply (trans_le ? (B(2*n)*A n))
1550 apply lt_SSSSO_to_le_B_exp.assumption
1554 theorem times_SSO_pred: \forall n. 2*(pred n) \le pred (2*n).
1557 |simplify.apply le_plus_r.
1562 theorem le_S_times_SSO: \forall n. O < n \to S n \le 2*n.
1566 |rewrite > times_SSO.
1568 apply (trans_le ? (2*n1))
1575 theorem le_A_exp1: \forall n.
1576 A(exp 2 n) \le (exp 2 ((2*(exp 2 n)-(S(S n))))).
1578 [simplify.apply le_n
1579 |change in ⊢ (? % ?) with (A(2*(exp 2 n1))).
1580 apply (trans_le ? ((exp 2 (pred(2*(exp (S(S O)) n1))))*A (exp (S(S O)) n1)))
1582 |apply (trans_le ? ((2)\sup(pred (2*(2)\sup(n1)))*(2)\sup(2*(2)\sup(n1)-S (S n1))))
1585 |rewrite < exp_plus_times.
1588 |cut (S(S n1) \le 2*(exp 2 n1))
1589 [apply le_S_S_to_le.
1590 change in ⊢ (? % ?) with (S(pred (2*(2)\sup(n1)))+(2*(2)\sup(n1)-S (S n1))).
1592 [rewrite > eq_minus_S_pred in ⊢ (? ? %).
1594 [rewrite < eq_minus_plus_plus_minus
1595 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1599 |apply lt_to_lt_O_minus.
1600 apply (lt_to_le_to_lt ? (2*(S(S n1))))
1601 [rewrite > times_n_SO in ⊢ (? % ?).
1602 rewrite > sym_times.
1611 |unfold.rewrite > times_n_SO in ⊢ (? % ?).
1620 |apply (trans_le ? (2*(S(S n2))))
1621 [apply le_S_times_SSO.
1634 theorem monotonic_A: monotonic nat le A.
1638 |apply (trans_le ? (A n1))
1641 cut (pi_p (S n1) primeb (λp:nat.(p)\sup(log p n1))
1642 ≤pi_p (S n1) primeb (λp:nat.(p)\sup(log p (S n1))))
1643 [apply (bool_elim ? (primeb (S n1)));intro
1644 [rewrite > (true_to_pi_p_Sn ? ? ? H3).
1645 rewrite > times_n_SO in ⊢ (? % ?).
1646 rewrite > sym_times.
1648 [apply lt_O_exp.apply lt_O_S
1651 |rewrite > (false_to_pi_p_Sn ? ? ? H3).
1654 |apply le_pi_p.intros.
1656 [apply prime_to_lt_O.
1657 apply primeb_true_to_prime.
1660 [apply prime_to_lt_SO.
1661 apply primeb_true_to_prime.
1663 |apply le_S.apply le_n
1672 theorem le_A_exp2: \forall n. O < n \to
1673 A(n) \le (exp (S(S O)) ((S(S O)) * (S(S O)) * n)).
1675 apply (trans_le ? (A (exp (S(S O)) (S(log (S(S O)) n)))))
1680 |apply (trans_le ? ((exp (S(S O)) ((S(S O))*(exp (S(S O)) (S(log (S(S O)) n)))))))
1684 |rewrite > assoc_times.apply le_times_r.
1685 change with ((S(S O))*((S(S O))\sup(log (S(S O)) n))≤(S(S O))*n).
1696 theorem A_SO: A (S O) = S O.
1700 theorem A_SSO: A (S(S O)) = S (S O).
1704 theorem A_SSSO: A (S(S(S O))) = S(S(S(S(S(S O))))).
1708 theorem A_SSSSO: A (S(S(S(S O)))) = S(S(S(S(S(S(S(S(S(S(S(S O))))))))))).
1713 (* a better result *)
1714 theorem le_A_exp3: \forall n. S O < n \to
1715 A(n) \le exp (pred n) (2*(exp 2 (2 * n)).
1717 apply (nat_elim1 n).
1719 elim (or_eq_eq_S m).
1721 [elim (le_to_or_lt_eq (S O) a)
1722 [rewrite > H3 in ⊢ (? % ?).
1723 apply (trans_le ? ((exp (S(S O)) ((S(S O)*a)))*A a))
1725 |apply (trans_le ? (((S(S O)))\sup((S(S O))*a)*
1726 ((pred a)\sup((S(S O)))*((S(S O)))\sup((S(S O))*a))))
1730 rewrite > times_n_SO in ⊢ (? % ?).
1731 rewrite > sym_times.
1733 [apply lt_to_le.assumption
1738 |rewrite > sym_times.
1739 rewrite > assoc_times.
1740 rewrite < exp_plus_times.
1742 (pred a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1743 [rewrite > assoc_times.
1745 rewrite < exp_plus_times.
1751 apply le_S.apply le_S.
1755 rewrite > times_exp.
1756 apply monotonic_exp1.
1758 rewrite > sym_times.
1762 rewrite < plus_n_Sm.
1769 |rewrite < H4 in H3.
1773 apply le_S_S.apply le_S_S.apply le_O_n
1774 |apply not_lt_to_le.intro.
1775 apply (lt_to_not_le ? ? H1).
1777 apply (le_n_O_elim a)
1778 [apply le_S_S_to_le.assumption
1782 |elim (le_to_or_lt_eq O a (le_O_n ?))
1783 [apply (trans_le ? (A ((S(S O))*(S a))))
1786 rewrite > times_SSO.
1788 |apply (trans_le ? ((exp (S(S O)) ((S(S O)*(S a))))*A (S a)))
1790 |apply (trans_le ? (((S(S O)))\sup((S(S O))*S a)*
1791 (a\sup((S(S O)))*((S(S O)))\sup((S(S O))*(S a)))))
1797 rewrite > plus_n_SO.
1801 |apply le_S_S.assumption
1803 |rewrite > sym_times.
1804 rewrite > assoc_times.
1805 rewrite < exp_plus_times.
1807 (a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1808 [rewrite > assoc_times.
1810 rewrite < exp_plus_times.
1813 |rewrite > times_SSO.
1816 rewrite < plus_n_Sm.
1821 rewrite > times_exp.
1822 apply monotonic_exp1.
1824 rewrite > sym_times.
1830 |rewrite < H4 in H3.simplify in H3.
1832 apply (lt_to_not_le ? ? H1).
1840 theorem le_A_exp4: \forall n. S O < n \to
1841 A(n) \le (pred n)*exp 2 ((2 * n) -3).
1843 apply (nat_elim1 n).
1845 elim (or_eq_eq_S m).
1847 [elim (le_to_or_lt_eq (S O) a)
1848 [rewrite > H3 in ⊢ (? % ?).
1849 apply (trans_le ? (exp 2 (pred(2*a))*A a))
1851 |apply (trans_le ? (2\sup(pred(2*a))*((pred a)*2\sup((2*a)-3))))
1855 rewrite > times_n_SO in ⊢ (? % ?).
1856 rewrite > sym_times.
1858 [apply lt_to_le.assumption
1864 rewrite < assoc_times.
1865 rewrite > sym_times in ⊢ (? (? % ?) ?).
1866 rewrite > assoc_times.
1869 elim a[apply le_n|simplify.apply le_plus_n_r]
1870 |rewrite < exp_plus_times.
1873 |apply (trans_le ? (m+(m-3)))
1875 cases m[apply le_n|apply le_n_Sn]
1876 |simplify.rewrite < plus_n_O.
1877 rewrite > eq_minus_plus_plus_minus
1880 apply (trans_le ? (2*2))
1881 [simplify.apply (le_n_Sn 3)
1882 |apply le_times_r.assumption
1890 |rewrite > H3.rewrite < H4.simplify.
1891 apply le_S_S.apply lt_O_S
1892 |apply not_lt_to_le.intro.
1893 apply (lt_to_not_le ? ? H1).
1895 apply (le_n_O_elim a)
1896 [apply le_S_S_to_le.assumption
1900 |elim (le_to_or_lt_eq O a (le_O_n ?))
1901 [apply (trans_le ? (A ((S(S O))*(S a))))
1904 rewrite > times_SSO.
1906 |apply (trans_le ? ((exp 2 (pred(2*(S a))))*A (S a)))
1908 |apply (trans_le ? ((2\sup(pred (2*S a)))*(a*(exp 2 ((2*(S a))-3)))))
1913 apply le_S_times_SSO.
1915 |apply le_S_S.assumption
1918 change in ⊢ (? ? (? % ?)) with (2*a).
1919 rewrite > times_SSO.
1920 change in ⊢ (? (? (? ? %) ?) ?) with (S(2*a)).
1921 rewrite > minus_Sn_m
1922 [change in ⊢ (? (? ? (? ? %)) ?) with (2*(exp 2 (S(2*a)-3))).
1923 rewrite < assoc_times in ⊢ (? (? ? %) ?).
1924 rewrite < assoc_times.
1925 rewrite > sym_times in ⊢ (? (? % ?) ?).
1926 rewrite > sym_times in ⊢ (? (? (? % ?) ?) ?).
1927 rewrite > assoc_times.
1929 rewrite < exp_plus_times.
1932 |rewrite < eq_minus_plus_plus_minus
1933 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1936 apply O_lt_const_to_le_times_const.
1941 apply O_lt_const_to_le_times_const.
1947 |rewrite < H4 in H3.simplify in H3.
1949 apply (lt_to_not_le ? ? H1).
1956 theorem le_n_SSSSSSSSO_to_le_A_exp:
1957 \forall n. n \le 8 \to A(n) \le exp 2 ((2 * n) -3).
1965 [intro.apply leb_true_to_le.reflexivity
1967 [intro.apply leb_true_to_le.reflexivity
1969 [intro.apply leb_true_to_le.reflexivity
1971 [intro.apply leb_true_to_le.reflexivity
1973 [intro.apply leb_true_to_le.reflexivity
1975 [intro.apply leb_true_to_le.reflexivity
1976 |intro.apply False_ind.
1977 apply (lt_to_not_le ? ? H).
1978 apply leb_true_to_le.reflexivity
1990 theorem le_A_exp5: \forall n. A(n) \le exp 2 ((2 * n) -3).
1992 apply (nat_elim1 n).
1994 elim (decidable_le 9 m)
1995 [elim (or_eq_eq_S m).
1997 [rewrite > H3 in ⊢ (? % ?).
1998 apply (trans_le ? (exp 2 (pred(2*a))*A a))
2000 |apply (trans_le ? (2\sup(pred(2*a))*(2\sup((2*a)-3))))
2005 [apply (trans_lt ? 4)
2007 |apply (lt_times_to_lt 2)
2009 |rewrite < H3.assumption
2015 rewrite < exp_plus_times.
2018 |simplify.rewrite < plus_n_O.
2019 rewrite > eq_minus_plus_plus_minus
2022 |apply (trans_le ? 9)
2023 [apply leb_true_to_le. reflexivity
2030 |apply (trans_le ? (A (2*(S a))))
2033 rewrite > times_SSO.
2035 |apply (trans_le ? ((exp 2 ((2*(S a))-2))*A (S a)))
2036 [apply lt_SSSSO_to_le_A_exp.
2038 apply (le_times_to_le 2)
2040 |apply le_S_S_to_le.rewrite < H3.assumption
2042 |apply (trans_le ? ((2\sup((2*S a)-2))*(exp 2 ((2*(S a))-3))))
2048 [apply (lt_to_le_to_lt ? 4)
2050 |apply (le_times_to_le 2)
2052 |apply le_S_S_to_le.
2053 rewrite < H3.assumption
2058 |rewrite > times_SSO.
2060 rewrite < exp_plus_times.
2068 rewrite < minus_n_O.
2070 rewrite < plus_n_Sm.
2071 simplify.rewrite < minus_n_O.
2072 rewrite < plus_n_Sm.
2081 |apply le_n_SSSSSSSSO_to_le_A_exp.
2088 theorem le_exp_Al:\forall n. O < n \to exp 2 n \le A (2 * n).
2090 apply (trans_le ? ((exp 2 (2*n))/(2*n)))
2091 [apply le_times_to_le_div
2092 [rewrite > (times_n_O O) in ⊢ (? % ?).
2097 |simplify in ⊢ (? ? (? ? %)).
2099 rewrite > exp_plus_times.
2101 alias id "le_times_SSO_n_exp_SSO_n" = "cic:/matita/nat/o/le_times_SSO_n_exp_SSO_n.con".
2102 apply le_times_SSO_n_exp_SSO_n
2104 |apply le_times_to_le_div2
2105 [rewrite > (times_n_O O) in ⊢ (? % ?).
2110 |apply (trans_le ? ((B (2*n)*(2*n))))
2111 [rewrite < sym_times in ⊢ (? ? %).
2121 theorem le_exp_A2:\forall n. 1 < n \to exp 2 (n / 2) \le A n.
2123 apply (trans_le ? (A(n/2*2)))
2124 [rewrite > sym_times.
2126 elim (le_to_or_lt_eq ? ? (le_O_n (n/2)))
2129 apply (lt_to_not_le ? ? H).
2130 rewrite > (div_mod n 2)
2132 change in ⊢ (? % ?) with (n\mod 2).
2140 rewrite > (div_mod n 2) in ⊢ (? ? %).
2146 theorem eq_sigma_pi_SO_n: \forall n.
2147 sigma_p n (\lambda i.true) (\lambda i.S O) = n.
2150 |rewrite > true_to_sigma_p_Sn
2151 [rewrite > H.reflexivity
2157 theorem leA_prim: \forall n.
2158 exp n (prim n) \le A n * pi_p (S n) primeb (λp:nat.p).
2161 rewrite < (exp_sigma_p (S n) n primeb).
2163 rewrite < times_pi_p.
2166 rewrite > sym_times.
2167 change in ⊢ (? ? %) with (exp i (S (log i n))).
2170 apply prime_to_lt_SO.
2171 apply primeb_true_to_prime.
2176 theorem le_prim_log : \forall n,b.S O < b \to
2177 log b (A n) \leq prim n * (S (log b n)).
2178 intros;apply (trans_le ? ? ? ? (log_exp1 ? ? ? ?))
2186 (* the inequalities *)
2187 theorem le_exp_priml: \forall n. O < n \to
2188 exp 2 (2*n) \le exp (2*n) (S(prim (2*n))).
2190 apply (trans_le ? (((2*n*(B (2*n))))))
2191 [apply le_exp_B.assumption
2192 |change in ⊢ (? ? %) with (((2*n))*((2*n))\sup (prim (2*n))).
2194 apply (trans_le ? (A (2*n)))
2201 theorem le_exp_prim4l: \forall n. O < n \to
2202 exp 2 (S(4*n)) \le exp (4*n) (S(prim (4*n))).
2204 apply (trans_le ? (2*(4*n*(B (4*n)))))
2205 [change in ⊢ (? % ?) with (2*(exp 2 (4*n))).
2210 apply lt_to_le.unfold.
2211 rewrite > times_n_SO in ⊢ (? % ?).
2212 apply le_times_r.assumption
2213 |rewrite < assoc_times.
2216 |change in ⊢ (? ? %) with ((4*n)*(4*n)\sup (prim (4*n))).
2217 rewrite < assoc_times.
2218 rewrite > sym_times in ⊢ (? (? % ?) ?).
2219 rewrite > assoc_times.
2221 apply (trans_le ? (A (4*n)))
2222 [apply le_B_A4.assumption
2228 theorem le_priml: \forall n. O < n \to
2229 2*n \le (S (log 2 (2*n)))*S(prim (2*n)).
2231 rewrite < (eq_log_exp (S(S O))) in ⊢ (? % ?)
2232 [apply (trans_le ? ((log (S(S O)) (exp ((S(S O))*n) (S(prim ((S(S O))*n)))))))
2235 |apply le_exp_priml.assumption
2237 |rewrite > sym_times in ⊢ (? ? %).
2245 theorem le_exp_primr: \forall n.
2246 exp n (prim n) \le exp 2 (2*(2*n-3)).
2248 apply (trans_le ? (exp (A n) 2))
2249 [change in ⊢ (? ? %) with ((A n)*((A n)*(S O))).
2250 rewrite < times_n_SO.
2252 |rewrite > sym_times.
2253 rewrite < exp_exp_times.
2254 apply monotonic_exp1.
2260 theorem le_primr: \forall n. 1 < n \to prim n \le 2*(2*n-3)/log 2 n.
2262 apply le_times_to_le_div
2264 [apply lt_to_le.assumption
2267 |apply (trans_le ? (log 2 (exp n (prim n))))
2268 [rewrite > sym_times.
2271 |apply lt_to_le.assumption
2273 |rewrite < (eq_log_exp 2) in ⊢ (? ? %)
2284 theorem le_priml1: \forall n. O < n \to
2285 2*n/((log 2 n)+2) - 1 \le prim (2*n).
2287 apply le_plus_to_minus.
2288 apply le_times_to_le_div2
2289 [rewrite > sym_plus.
2290 simplify.apply lt_O_S
2291 |rewrite > sym_times in ⊢ (? ? %).
2292 rewrite < plus_n_Sm.
2293 rewrite < plus_n_Sm in ⊢ (? ? (? ? %)).
2297 [simplify in ⊢ (? ? (? (? (? ? (? % ?))) ?)).
2307 theorem prim_SSSSSSO: \forall n.30\le n \to O < prim (8*n) - prim n.
2309 apply lt_to_lt_O_minus.
2310 change in ⊢ (? ? (? (? % ?))) with (2*4).
2311 rewrite > assoc_times.
2312 apply (le_to_lt_to_lt ? (2*(2*n-3)/log 2 n))
2313 [apply le_primr.apply (trans_lt ? ? ? ? H).
2314 apply leb_true_to_le.reflexivity
2315 |apply (lt_to_le_to_lt ? (2*(4*n)/((log 2 (4*n))+2) - 1))
2318 normalize in ⊢ (%);simplify.