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".
21 definition prim: nat \to nat \def
22 \lambda n. sigma_p (S n) primeb (\lambda p.1).
24 theorem le_prim_n: \forall n. prim n \le n.
25 intros.unfold prim. elim n
27 |apply (bool_elim ? (primeb (S n1)));intro
28 [rewrite > true_to_sigma_p_Sn
32 apply le_S_S.assumption
35 |rewrite > false_to_sigma_p_Sn
36 [apply le_S.assumption
43 theorem not_prime_times_SSO: \forall n. 1 < n \to \lnot prime (2*n).
47 [apply (witness ? ? n).reflexivity
51 rewrite > times_n_SO in ⊢ (? % ?).
57 theorem eq_prim_prim_pred: \forall n. 1 < n \to
58 (prim (2*n)) = (prim (pred (2*n))).
61 [rewrite > false_to_sigma_p_Sn
63 |apply not_prime_to_primeb_false.
64 apply not_prime_times_SSO.
67 |apply (trans_lt ? (2*1))
68 [simplify.apply lt_O_S
75 theorem le_prim_n1: \forall n. 4 \le n \to prim (S(2*n)) \le n.
76 intros.unfold prim. elim H
78 |cut (sigma_p (2*S n1) primeb (λp:nat.1) = sigma_p (S (2*S n1)) primeb (λp:nat.1))
79 [apply (bool_elim ? (primeb (S(2*(S n1)))));intro
80 [rewrite > true_to_sigma_p_Sn
90 |rewrite > false_to_sigma_p_Sn
98 |apply sym_eq.apply (eq_prim_prim_pred (S n1)).
99 apply le_S_S.apply (trans_le ? 4)
100 [apply leb_true_to_le.reflexivity
107 (* usefull to kill a successor in bertrand *)
108 theorem le_prim_n2: \forall n. 7 \le n \to prim (S(2*n)) \le pred n.
109 intros.unfold prim. elim H
110 [apply leb_true_to_le.reflexivity.
111 |cut (sigma_p (2*S n1) primeb (λp:nat.1) = sigma_p (S (2*S n1)) primeb (λp:nat.1))
112 [apply (bool_elim ? (primeb (S(2*(S n1)))));intro
113 [rewrite > true_to_sigma_p_Sn
117 simplify in ⊢ (? ? %).
118 rewrite > S_pred in ⊢ (? ? %)
123 |apply (ltn_to_ltO ? ? H1)
127 |rewrite > false_to_sigma_p_Sn
128 [simplify in ⊢ (? ? %).
129 apply (trans_le ? ? ? ? (le_pred_n n1)).
136 |apply sym_eq.apply (eq_prim_prim_pred (S n1)).
137 apply le_S_S.apply (trans_le ? 4)
138 [apply leb_true_to_le.reflexivity
139 |apply (trans_le ? ? ? ? H1).
140 apply leb_true_to_le.reflexivity
147 theorem le_pred: \forall n,m. n \le m \to pred n \le pred m.
148 apply nat_elim2;intros
150 |apply False_ind.apply (le_to_not_lt ? ? H).
152 |simplify.apply le_S_S_to_le.assumption
156 (* la prova potrebbe essere migliorata *)
157 theorem le_prim_n3: \forall n. 15 \le n \to
158 prim n \le pred (n/2).
160 elim (or_eq_eq_S (pred n)).
164 apply (trans_le ? (pred a))
166 apply (le_times_to_le 2)
173 apply le_times_to_le_div
180 apply (ltn_to_ltO ? ? H)
184 rewrite > eq_prim_prim_pred
185 [rewrite > times_SSO in ⊢ (? % ?).
186 change in ⊢ (? (? %) ?) with (S (2*a)).
187 rewrite > sym_times in ⊢ (? ? (? (? % ?))).
188 rewrite > lt_O_to_div_times
189 [apply (trans_le ? (pred a))
192 apply (lt_times_to_lt 2)
205 apply not_lt_to_le.intro.
206 apply (le_to_not_lt ? ? H).
208 lapply (le_S_S_to_le ? ? H3) as H4.
209 apply (le_n_O_elim ? H4).
210 apply leb_true_to_le.reflexivity
212 |rewrite > times_SSO.
214 [apply eq_f.assumption
215 |apply (ltn_to_ltO ? ? H)
221 (* This is chebishev psi function *)
222 definition A: nat \to nat \def
223 \lambda n. pi_p (S n) primeb (\lambda p.exp p (log p n)).
225 theorem le_Al1: \forall n.
226 A n \le pi_p (S n) primeb (\lambda p.n).
237 theorem le_Al: \forall n.
238 A n \le exp n (prim n).
240 rewrite < exp_sigma_p.
244 theorem leA_r2: \forall n.
245 exp n (prim n) \le A n * A n.
247 elim (le_to_or_lt_eq ? ? (le_O_n n))
248 [rewrite < (exp_sigma_p (S n) n primeb).
250 rewrite < times_pi_p.
253 rewrite < exp_plus_times.
254 apply (trans_le ? (exp i (S(log i n))))
257 apply prime_to_lt_SO.
258 apply primeb_true_to_prime.
261 [apply prime_to_lt_O.
262 apply primeb_true_to_prime.
275 |rewrite < H. apply le_n
279 (* an equivalent formulation for psi *)
280 definition A': nat \to nat \def
281 \lambda n. pi_p (S n) primeb
282 (\lambda p.(pi_p (log p n) (\lambda i.true) (\lambda i.p))).
284 theorem eq_A_A': \forall n.A n = A' n.
285 intro.unfold A.unfold A'.
289 apply (trans_eq ? ? (exp x (sigma_p (log x n) (λi:nat.true) (λi:nat.(S O)))))
290 [apply eq_f.apply sym_eq.apply sigma_p_true
291 |apply sym_eq.apply exp_sigma_p
296 theorem eq_pi_p_primeb_divides_b: \forall n,m.
297 pi_p n (\lambda p.primeb p \land divides_b p m) (\lambda p.exp p (ord m p))
298 = pi_p n primeb (\lambda p.exp p (ord m p)).
302 |apply (bool_elim ? (primeb n1));intro
303 [rewrite > true_to_pi_p_Sn in ⊢ (? ? ? %)
304 [apply (bool_elim ? (divides_b n1 m));intro
305 [rewrite > true_to_pi_p_Sn
308 |apply true_to_true_to_andb_true;assumption
310 |rewrite > false_to_pi_p_Sn
311 [rewrite > not_divides_to_ord_O
312 [simplify in ⊢ (? ? ? (? % ?)).
314 rewrite < times_n_SO.
316 |apply primeb_true_to_prime.assumption
317 |apply divides_b_false_to_not_divides.
320 |rewrite > H1.rewrite > H2.reflexivity
325 |rewrite > false_to_pi_p_Sn
326 [rewrite > false_to_pi_p_Sn
330 |rewrite > H1.reflexivity
336 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
337 m = pi_p q (\lambda i.primeb i \land divides_b i m) (\lambda p.exp p (ord m p)).
340 apply (not_le_Sn_O ? H1)
341 |apply (bool_elim ? (primeb n∧divides_b n m));intro
342 [rewrite > true_to_pi_p_Sn
343 [rewrite > (exp_ord n m) in ⊢ (? ? % ?)
345 rewrite > (H (ord_rem m n))
348 apply (bool_elim ? (primeb x));intro
350 apply (bool_elim ? (divides_b x (ord_rem m n)));intro
352 apply divides_to_divides_b_true
353 [apply prime_to_lt_O.
354 apply primeb_true_to_prime.
356 |apply (trans_divides ? (ord_rem m n))
357 [apply divides_b_true_to_divides.
359 |apply divides_ord_rem
360 [apply (trans_lt ? x)
361 [apply prime_to_lt_SO.
362 apply primeb_true_to_prime.
371 apply not_divides_to_divides_b_false
372 [apply prime_to_lt_O.
373 apply primeb_true_to_prime.
375 |apply ord_O_to_not_divides
377 |apply primeb_true_to_prime.
379 |rewrite < (ord_ord_rem n)
380 [apply not_divides_to_ord_O
381 [apply primeb_true_to_prime.
383 |apply divides_b_false_to_not_divides.
387 |apply primeb_true_to_prime.
388 apply (andb_true_true ? ? H3)
389 |apply primeb_true_to_prime.
402 |apply primeb_true_to_prime.
403 apply (andb_true_true ? ? H3)
404 |apply primeb_true_to_prime.
405 apply (andb_true_true ? ? H5)
410 [apply prime_to_lt_SO.
411 apply primeb_true_to_prime.
412 apply (andb_true_true ? ? H3)
415 |apply not_eq_to_le_to_lt
416 [elim (exists_max_forall_false (λi:nat.primeb i∧divides_b i (ord_rem m n)) (ord_rem m n))
418 intro.rewrite > H7 in H6.simplify in H6.
419 apply (not_divides_ord_rem m n)
421 |apply prime_to_lt_SO.
422 apply primeb_true_to_prime.
423 apply (andb_true_true ? ? H3)
424 |apply divides_b_true_to_divides.
425 apply (andb_true_true_r ? ? H6)
427 |elim H4.rewrite > H6.
430 apply primeb_true_to_prime.
431 apply (andb_true_true ? ? H3)
433 |apply (trans_le ? (max m (λi:nat.primeb i∧divides_b i (ord_rem m n))))
437 |apply divides_ord_rem
438 [apply prime_to_lt_SO.
439 apply primeb_true_to_prime.
440 apply (andb_true_true ? ? H3)
444 |apply (trans_le ? (max m (λi:nat.primeb i∧divides_b i m)))
445 [apply le_max_f_max_g.
447 apply (bool_elim ? (primeb i));intro
449 apply divides_to_divides_b_true
450 [apply prime_to_lt_O.
451 apply primeb_true_to_prime.
453 |apply (trans_divides ? (ord_rem m n))
454 [apply divides_b_true_to_divides.
455 apply (andb_true_true_r ? ? H5)
456 |apply divides_ord_rem
457 [apply prime_to_lt_SO.
458 apply primeb_true_to_prime.
459 apply (andb_true_true ? ? H3)
473 |apply prime_to_lt_SO.
474 apply primeb_true_to_prime.
475 apply (andb_true_true ? ? H3)
480 |elim (le_to_or_lt_eq ? ? H1)
481 [rewrite > false_to_pi_p_Sn
484 |apply false_to_lt_max
485 [apply (lt_to_le_to_lt ? (max m (λi:nat.primeb i∧divides_b i m)))
487 apply lt_SO_max_prime.
500 rewrite < (pi_p_false (λp:nat.p\sup(ord (S O) p)) (S n) ) in ⊢ (? ? % ?).
503 apply (bool_elim ? (primeb x));intro
505 change with (divides_b x (S O) =false).
506 apply not_divides_to_divides_b_false
507 [apply prime_to_lt_O.
508 apply primeb_true_to_prime.
511 apply (le_to_not_lt x (S O))
513 [apply lt_O_S.assumption
516 |elim (primeb_true_to_prime ? H6).
529 (* factorization of n into primes *)
530 theorem pi_p_primeb_divides_b: \forall n. O < n \to
531 n = pi_p (S n) (\lambda i.primeb i \land divides_b i n) (\lambda p.exp p (ord n p)).
533 apply lt_max_to_pi_p_primeb
540 theorem pi_p_primeb: \forall n. O < n \to
541 n = pi_p (S n) primeb (\lambda p.exp p (ord n p)).
543 rewrite < eq_pi_p_primeb_divides_b.
544 apply pi_p_primeb_divides_b.
548 theorem le_ord_log: \forall n,p. O < n \to 1 < p \to
551 rewrite > (exp_ord p) in ⊢ (? ? (? ? %))
555 |apply lt_O_ord_rem;assumption
562 theorem sigma_p_divides_b:
563 \forall m,n,p. O < n \to prime p \to \lnot divides p n \to
564 m = sigma_p m (λi:nat.divides_b (p\sup (S i)) ((exp p m)*n)) (λx:nat.S O).
567 |simplify in ⊢ (? ? ? (? % ? ?)).
568 rewrite > true_to_sigma_p_Sn
569 [rewrite > sym_plus.rewrite < plus_n_SO.
571 rewrite > (H n1 p H1 H2 H3) in ⊢ (? ? % ?).
574 apply (bool_elim ? (divides_b (p\sup(S x)) (p\sup n*n1)));intro
576 apply divides_to_divides_b_true
580 |apply (witness ? ? ((exp p (n - x))*n1)).
581 rewrite < assoc_times.
582 rewrite < exp_plus_times.
584 [apply eq_f.simplify.
587 apply plus_minus_m_m.
588 apply lt_to_le.assumption
594 apply (divides_b_false_to_not_divides ? ? H5).
595 apply (witness ? ? ((exp p (n - S x))*n1)).
596 rewrite < assoc_times.
597 rewrite < exp_plus_times.
601 apply plus_minus_m_m.
608 |apply divides_to_divides_b_true
610 apply prime_to_lt_O.assumption
611 |apply (witness ? ? n1).reflexivity
617 theorem sigma_p_divides_b1:
618 \forall m,n,p,k. O < n \to prime p \to \lnot divides p n \to m \le k \to
619 m = sigma_p k (λi:nat.divides_b (p\sup (S i)) ((exp p m)*n)) (λx:nat.S O).
621 lapply (prime_to_lt_SO ? H1) as H4.
622 lapply (prime_to_lt_O ? H1) as H5.
623 rewrite > (false_to_eq_sigma_p m k)
624 [apply sigma_p_divides_b;assumption
627 apply not_divides_to_divides_b_false
628 [apply lt_O_exp.assumption
629 |intro.apply (le_to_not_lt ? ? H6).
631 rewrite < (ord_exp p)
632 [rewrite > (plus_n_O m).
633 rewrite < (not_divides_to_ord_O ? ? H1 H2).
634 rewrite < (ord_exp p ? H4) in ⊢ (? ? (? % ?)).
636 [apply divides_to_le_ord
637 [apply lt_O_exp.assumption
638 |rewrite > (times_n_O O).
640 [apply lt_O_exp.assumption
646 |apply lt_O_exp.assumption
656 theorem eq_ord_sigma_p:
657 \forall n,m,x. O < n \to prime x \to
658 exp x m \le n \to n < exp x (S m) \to
659 ord n x=sigma_p m (λi:nat.divides_b (x\sup (S i)) n) (λx:nat.1).
661 lapply (prime_to_lt_SO ? H1).
662 rewrite > (exp_ord x n) in ⊢ (? ? ? (? ? (λi:?.? ? %) ?))
663 [apply sigma_p_divides_b1
664 [apply lt_O_ord_rem;assumption
666 |apply not_divides_ord_rem;assumption
668 apply (le_to_lt_to_lt ? (log x n))
669 [apply le_ord_log;assumption
670 |apply (lt_exp_to_lt x)
672 |apply (le_to_lt_to_lt ? n ? ? H3).
683 theorem pi_p_primeb1: \forall n. O < n \to
684 n = pi_p (S n) primeb
685 (\lambda p.(pi_p (log p n)
686 (\lambda i.divides_b (exp p (S i)) n) (\lambda i.p))).
688 rewrite > (pi_p_primeb n H) in ⊢ (? ? % ?).
692 rewrite > exp_sigma_p.
696 |apply primeb_true_to_prime.
698 |apply le_exp_log.assumption
700 apply prime_to_lt_SO.
701 apply primeb_true_to_prime.
707 (* the factorial function *)
708 theorem eq_fact_pi_p:\forall n. fact n =
709 pi_p (S n) (\lambda i.leb (S O) i) (\lambda i.i).
712 |change with ((S n1)*n1! = pi_p (S (S n1)) (λi:nat.leb (S O) i) (λi:nat.i)).
713 rewrite > true_to_pi_p_Sn
714 [apply eq_f.assumption
720 theorem eq_sigma_p_div: \forall n,q.O < q \to
721 sigma_p (S n) (λm:nat.leb (S O) m∧divides_b q m) (λx:nat.S O)
724 apply (div_mod_spec_to_eq n q ? (n \mod q) ? (n \mod q))
725 [apply div_mod_spec_intro
726 [apply lt_mod_m_m.assumption
728 [simplify.elim q;reflexivity
729 |elim (or_div_mod1 n1 q)
731 rewrite > divides_to_mod_O
733 rewrite > true_to_sigma_p_Sn
734 [rewrite > H4 in ⊢ (? ? % ?).
739 apply (div_mod_spec_to_eq n1 q (div n1 q) (mod n1 q) ? (mod n1 q))
740 [apply div_mod_spec_div_mod.
742 |apply div_mod_spec_intro
743 [apply lt_mod_m_m.assumption
749 |apply true_to_true_to_andb_true
751 |apply divides_to_divides_b_true;assumption
758 rewrite > false_to_sigma_p_Sn
760 [rewrite < plus_n_Sm.
764 |elim (le_to_or_lt_eq (S (mod n1 q)) q)
768 apply (witness ? ? (S(div n1 q))).
769 rewrite < times_n_Sm.
771 rewrite < H2 in ⊢ (? ? ? (? ? %)).
778 |rewrite > not_divides_to_divides_b_false
779 [rewrite < andb_sym in ⊢ (? ? % ?).reflexivity
788 |apply div_mod_spec_div_mod.
793 (* still another characterization of the factorial *)
794 theorem fact_pi_p: \forall n. fact n =
796 (\lambda p.(pi_p (log p n)
797 (\lambda i.true) (\lambda i.(exp p (n /(exp p (S i))))))).
799 rewrite > eq_fact_pi_p.
801 (pi_p (S n) (λm:nat.leb (S O) m)
802 (λm.pi_p (S m) primeb
803 (\lambda p.(pi_p (log p m)
804 (\lambda i.divides_b (exp p (S i)) m) (\lambda i.p))))))
805 [apply eq_pi_p1;intros
808 apply leb_true_to_le.assumption
811 (pi_p (S n) (λm:nat.leb (S O) m)
813 .pi_p (S m) (\lambda p.primeb p\land leb p m)
814 (λp:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))))
817 |intros.apply eq_pi_p1
818 [intros.elim (primeb x1)
819 [simplify.apply sym_eq.
820 apply le_to_leb_true.
829 (pi_p (S n) (λm:nat.leb (S O) m)
831 .pi_p (S n) (λp:nat.primeb p∧leb p m)
832 (λp:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))))
837 apply false_to_eq_pi_p
839 |intros.rewrite > lt_to_leb_false
840 [elim primeb;reflexivity|assumption]
843 |(* make a general theorem *)
847 .pi_p (S n) (λm.leb p m)
848 (λm:nat.pi_p (log p m) (λi:nat.divides_b ((p)\sup(S i)) m) (λi:nat.p)))
852 apply (bool_elim ? (primeb y \land leb y x));intros
853 [rewrite > (le_to_leb_true (S O) x)
855 |apply (trans_le ? y)
856 [apply prime_to_lt_O.
857 apply primeb_true_to_prime.
858 apply (andb_true_true ? ? H2)
859 |apply leb_true_to_le.
860 apply (andb_true_true_r ? ? H2)
863 |elim (leb (S O) x);reflexivity
869 (pi_p (S n) (λm:nat.leb x m)
870 (λm:nat.pi_p (log x n) (λi:nat.divides_b (x\sup(S i)) m) (λi:nat.x))))
875 apply false_to_eq_pi_p
877 [apply prime_to_lt_SO.
878 apply primeb_true_to_prime.
884 apply not_divides_to_divides_b_false
887 apply primeb_true_to_prime.
890 apply (lt_to_not_le x1 (exp x (S i)))
891 [apply (lt_to_le_to_lt ? (exp x (S(log x x1))))
893 apply prime_to_lt_SO.
894 apply primeb_true_to_prime.
897 [apply prime_to_lt_O.
898 apply primeb_true_to_prime.
905 [apply (lt_to_le_to_lt ? x)
906 [apply prime_to_lt_O.
907 apply primeb_true_to_prime.
909 |apply leb_true_to_le.
920 (pi_p (log x n) (λi:nat.true)
921 (λi:nat.pi_p (S n) (λm:nat.leb x m \land divides_b (x\sup(S i)) m) (λm:nat.x))))
922 [apply (pi_p_pi_p1 (\lambda m,i.x)).
928 rewrite > exp_sigma_p.
931 (sigma_p (S n) (λm:nat.leb (S O) m∧divides_b (x\sup(S x1)) m) (λx:nat.S O)))
934 apply (bool_elim ? (divides_b (x\sup(S x1)) x2));intro
935 [apply (bool_elim ? (leb x x2));intro
936 [rewrite > le_to_leb_true
938 |apply (trans_le ? x)
939 [apply prime_to_lt_O.
940 apply primeb_true_to_prime.
942 |apply leb_true_to_le.
946 |rewrite > lt_to_leb_false
948 |apply not_le_to_lt.intro.
949 apply (leb_false_to_not_le ? ? H6).
950 apply (trans_le ? (exp x (S x1)))
951 [rewrite > times_n_SO in ⊢ (? % ?).
952 change with (exp x (S O) \le exp x (S x1)).
954 [apply prime_to_lt_O.
955 apply primeb_true_to_prime.
957 |apply le_S_S.apply le_O_n.
961 |apply divides_b_true_to_divides.
968 rewrite < andb_sym in ⊢ (? ? ? %).
973 |apply eq_sigma_p_div.
976 apply primeb_true_to_prime.
989 (* odd n is just mod n (S(S O))
993 | S m \Rightarrow (S O) - odd m
996 theorem le_odd_SO: \forall n. odd n \le S O.
999 |simplify.cases (odd n1)
1000 [simplify.apply le_n.
1006 theorem SSO_odd: \forall n. n = (n/(S(S O)))*(S(S O)) + odd n.
1008 [apply (lt_O_n_elim ? H).
1009 intro.simplify.reflexivity
1013 theorem fact_pi_p2: \forall n. fact (2*n) =
1014 pi_p (S (2*n)) primeb
1015 (\lambda p.(pi_p (log p (2*n))
1016 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))*(exp p (mod (2*n /(exp p (S i))) 2)))))).
1017 intros.rewrite > fact_pi_p.
1020 |intros.apply eq_pi_p
1023 rewrite < exp_plus_times.
1025 rewrite > sym_times in ⊢ (? ? ? (? % ?)).
1028 apply prime_to_lt_O.
1029 apply primeb_true_to_prime.
1035 theorem fact_pi_p3: \forall n. fact (2*n) =
1036 pi_p (S (2*n)) primeb
1037 (\lambda p.(pi_p (log p (2*n))
1038 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))*
1039 pi_p (S (2*n)) primeb
1040 (\lambda p.(pi_p (log p (2*n))
1041 (\lambda i.true) (\lambda i.(exp p (mod (2*n /(exp p (S i))) 2))))).
1043 rewrite < times_pi_p.
1044 rewrite > fact_pi_p2.
1045 apply eq_pi_p;intros
1051 theorem pi_p_primeb4: \forall n. 1 < n \to
1052 pi_p (S (2*n)) primeb
1053 (\lambda p.(pi_p (log p (2*n))
1054 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))
1057 (\lambda p.(pi_p (log p (2*n))
1058 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1060 apply or_false_eq_SO_to_eq_pi_p
1066 rewrite > log_i_SSOn
1067 [change with (i\sup((S(S O))*(n/i\sup(S O)))*(S O) = S O).
1068 rewrite < times_n_SO.
1071 |simplify.rewrite < times_n_SO.assumption
1075 |apply le_S_S_to_le.assumption
1080 theorem pi_p_primeb5: \forall n. 1 < n \to
1081 pi_p (S (2*n)) primeb
1082 (\lambda p.(pi_p (log p ((S(S O))*n))
1083 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i))))))))
1086 (\lambda p.(pi_p (log p n)
1087 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1089 rewrite > (pi_p_primeb4 ? H).
1090 apply eq_pi_p1;intros
1092 |apply or_false_eq_SO_to_eq_pi_p
1094 [apply prime_to_lt_SO.
1095 apply primeb_true_to_prime.
1102 [simplify.reflexivity
1103 |apply (lt_to_le_to_lt ? (exp x (S(log x n))))
1105 apply prime_to_lt_SO.
1106 apply primeb_true_to_prime.
1109 [apply prime_to_lt_O.
1110 apply primeb_true_to_prime.
1121 theorem exp_fact_SSO: \forall n.
1125 (\lambda p.(pi_p (log p n)
1126 (\lambda i.true) (\lambda i.(exp p (2*(n /(exp p (S i)))))))).
1128 rewrite > fact_pi_p.
1130 apply eq_pi_p;intros
1133 apply exp_times_pi_p
1140 (\lambda p.(pi_p (log p n)
1141 (\lambda i.true) (\lambda i.(exp p (mod (n /(exp p (S i))) (S(S O))))))).
1143 theorem B_SSSO: B 3 = 6.
1147 theorem B_SSSSO: B 4 = 6.
1151 theorem B_SSSSSO: B 5 = 30.
1155 theorem B_SSSSSSO: B 6 = 20.
1159 theorem B_SSSSSSSO: B 7 = 140.
1163 theorem B_SSSSSSSSO: B 8 = 70.
1167 theorem eq_fact_B:\forall n.S O < n \to
1168 fact (2*n) = exp (fact n) 2 * B(2*n).
1170 rewrite > fact_pi_p3.
1173 rewrite > pi_p_primeb5
1181 theorem le_B_A: \forall n. B n \le A n.
1185 apply le_pi_p.intros.
1186 apply le_pi_p.intros.
1187 rewrite > exp_n_SO in ⊢ (? ? %).
1189 [apply prime_to_lt_O.
1190 apply primeb_true_to_prime.
1192 |apply le_S_S_to_le.
1198 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).
1202 cut ((S(S O)) < (S ((S(S(S(S O))))*n)))
1203 [cut (O<log (S(S O)) ((S(S(S(S O))))*n))
1204 [rewrite > (pi_p_gi ? ? (S(S O)))
1205 [rewrite > (pi_p_gi ? ? (S(S O))) in ⊢ (? ? %)
1206 [rewrite < assoc_times.
1208 [rewrite > (pi_p_gi ? ? O)
1209 [rewrite > (pi_p_gi ? ? O) in ⊢ (? ? %)
1210 [rewrite < assoc_times.
1212 [rewrite < exp_n_SO.
1213 change in ⊢ (? (? ? (? ? (? (? (? % ?) ?) ?))) ?)
1214 with ((S(S O))*(S(S O))).
1215 rewrite > assoc_times.
1216 rewrite > sym_times in ⊢ (? (? ? (? ? (? (? % ?) ?))) ?).
1217 rewrite > lt_O_to_div_times
1218 [rewrite > divides_to_mod_O
1221 |apply (witness ? ? n).reflexivity
1225 |apply le_pi_p.intros.
1226 rewrite > exp_n_SO in ⊢ (? ? %).
1229 |apply le_S_S_to_le.
1240 |apply le_pi_p.intros.
1241 apply le_pi_p.intros.
1242 rewrite > exp_n_SO in ⊢ (? ? %).
1244 [apply prime_to_lt_O.
1245 apply primeb_true_to_prime.
1246 apply (andb_true_true ? ? H2)
1247 |apply le_S_S_to_le.
1259 [rewrite > (times_n_O (S(S(S(S O))))) in ⊢ (? % ?).
1264 |rewrite > times_n_SO in ⊢ (? % ?).
1266 [apply le_S.apply le_S.apply le_n
1272 rewrite > times_n_SO in ⊢ (? % ?).
1274 [apply le_S.apply le_n_Sn
1281 theorem le_fact_A:\forall n.S O < n \to
1282 fact (2*n) \le exp (fact n) 2 * A (2*n).
1291 theorem lt_SO_to_le_B_exp: \forall n.S O < n \to
1292 B (2*n) \le exp 2 (pred (2*n)).
1294 apply (le_times_to_le (exp (fact n) (S(S O))))
1297 |rewrite < eq_fact_B
1298 [rewrite < sym_times in ⊢ (? ? %).
1300 rewrite < assoc_times.
1307 theorem le_B_exp: \forall n.
1308 B (2*n) \le exp 2 (pred (2*n)).
1312 [simplify.apply le_n
1313 |apply lt_SO_to_le_B_exp.
1314 apply le_S_S.apply lt_O_S.
1319 theorem lt_SSSSO_to_le_B_exp: \forall n.4 < n \to
1320 B (2*n) \le exp 2 ((2*n)-2).
1322 apply (le_times_to_le (exp (fact n) (S(S O))))
1325 |rewrite < eq_fact_B
1326 [rewrite < sym_times in ⊢ (? ? %).
1328 rewrite < assoc_times.
1329 apply lt_SSSSO_to_fact.assumption
1330 |apply lt_to_le.apply lt_to_le.
1331 apply lt_to_le.assumption
1336 theorem lt_SO_to_le_exp_B: \forall n. 1 < n \to
1337 exp 2 (2*n) \le 2 * n * B (2*n).
1339 apply (le_times_to_le (exp (fact n) (S(S O))))
1342 |rewrite < assoc_times in ⊢ (? ? %).
1343 rewrite > sym_times in ⊢ (? ? (? % ?)).
1344 rewrite > assoc_times in ⊢ (? ? %).
1346 [rewrite < sym_times.
1348 apply lt_to_le.assumption
1354 theorem le_exp_B: \forall n. O < n \to
1355 exp 2 (2*n) \le 2 * n * B (2*n).
1359 |apply lt_SO_to_le_exp_B.
1360 apply le_S_S.assumption
1364 theorem eq_A_SSO_n: \forall n.O < n \to
1366 pi_p (S (2*n)) primeb
1367 (\lambda p.(pi_p (log p (2*n) )
1368 (\lambda i.true) (\lambda i.(exp p (bool_to_nat (leb (S n) (exp p (S i))))))))
1371 rewrite > eq_A_A'.rewrite > eq_A_A'.
1374 pi_p (S n) primeb (λp:nat.pi_p (log p n) (λi:nat.true) (λi:nat.p))
1375 = pi_p (S ((S(S O))*n)) primeb
1376 (λ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))))))))
1378 rewrite < times_pi_p.
1379 apply eq_pi_p1;intros
1381 |rewrite < times_pi_p.
1382 apply eq_pi_p;intros
1384 |apply (bool_elim ? (leb (S n) (exp x (S x1))));intro
1385 [simplify.rewrite < times_n_SO.apply times_n_SO
1386 |simplify.rewrite < plus_n_O.apply times_n_SO
1390 |apply (trans_eq ? ? (pi_p (S n) primeb
1391 (\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))))))))
1392 [apply eq_pi_p1;intros
1394 |apply eq_pi_p1;intros
1396 |rewrite > lt_to_leb_false
1397 [simplify.apply times_n_SO
1399 apply (trans_le ? (exp x (log x n)))
1401 [apply prime_to_lt_O.
1402 apply primeb_true_to_prime.
1412 |apply (trans_eq ? ?
1413 (pi_p (S ((S(S O))*n)) primeb
1414 (λp:nat.pi_p (log p n) (λi:nat.true)
1415 (λi:nat.(p)\sup(bool_to_nat (¬leb (S n) ((p)\sup(S i))))))))
1417 apply or_false_eq_SO_to_eq_pi_p
1422 rewrite > lt_to_log_O
1428 |apply eq_pi_p1;intros
1431 apply or_false_eq_SO_to_eq_pi_p
1433 [apply prime_to_lt_SO.
1434 apply primeb_true_to_prime.
1440 rewrite > le_to_leb_true
1441 [simplify.reflexivity
1442 |apply (lt_to_le_to_lt ? (exp x (S (log x n))))
1444 apply prime_to_lt_SO.
1445 apply primeb_true_to_prime.
1448 [apply prime_to_lt_O.
1449 apply primeb_true_to_prime.
1451 |apply le_S_S.assumption
1462 theorem le_A_BA1: \forall n. O < n \to
1463 A(2*n) \le B(2*n)*A n.
1465 rewrite > eq_A_SSO_n
1468 apply le_pi_p.intros.
1469 apply le_pi_p.intros.
1471 [apply prime_to_lt_O.
1472 apply primeb_true_to_prime.
1474 |apply (bool_elim ? (leb (S n) (exp i (S i1))));intro
1475 [simplify in ⊢ (? % ?).
1476 cut ((S(S O))*n/i\sup(S i1) = S O)
1477 [rewrite > Hcut.apply le_n
1478 |apply (div_mod_spec_to_eq
1479 ((S(S O))*n) (exp i (S i1))
1480 ? (mod ((S(S O))*n) (exp i (S i1)))
1481 ? (minus ((S(S O))*n) (exp i (S i1))) )
1482 [apply div_mod_spec_div_mod.
1484 apply prime_to_lt_O.
1485 apply primeb_true_to_prime.
1487 |cut (i\sup(S i1)≤(S(S O))*n)
1488 [apply div_mod_spec_intro
1489 [apply lt_plus_to_lt_minus
1491 |simplify in ⊢ (? % ?).
1494 [apply leb_true_to_le.assumption
1495 |apply leb_true_to_le.assumption
1498 |rewrite > sym_plus.
1499 rewrite > sym_times in ⊢ (? ? ? (? ? %)).
1500 rewrite < times_n_SO.
1501 apply plus_minus_m_m.
1504 |apply (trans_le ? (exp i (log i ((S(S O))*n))))
1506 [apply prime_to_lt_O.
1507 apply primeb_true_to_prime.
1512 rewrite > (times_n_O O) in ⊢ (? % ?).
1528 theorem le_A_BA: \forall n. A((S(S O))*n) \le B((S(S O))*n)*A n.
1531 |apply le_A_BA1.apply lt_O_S
1535 theorem le_A_exp: \forall n.
1536 A(2*n) \le (exp 2 (pred (2*n)))*A n.
1538 apply (trans_le ? (B(2*n)*A n))
1545 theorem lt_SSSSO_to_le_A_exp: \forall n. 4 < n \to
1546 A(2*n) \le exp 2 ((2*n)-2)*A n.
1548 apply (trans_le ? (B(2*n)*A n))
1551 apply lt_SSSSO_to_le_B_exp.assumption
1555 theorem times_SSO_pred: \forall n. 2*(pred n) \le pred (2*n).
1558 |simplify.apply le_plus_r.
1563 theorem le_S_times_SSO: \forall n. O < n \to S n \le 2*n.
1567 |rewrite > times_SSO.
1569 apply (trans_le ? (2*n1))
1576 theorem le_A_exp1: \forall n.
1577 A(exp 2 n) \le (exp 2 ((2*(exp 2 n)-(S(S n))))).
1579 [simplify.apply le_n
1580 |change in ⊢ (? % ?) with (A(2*(exp 2 n1))).
1581 apply (trans_le ? ((exp 2 (pred(2*(exp (S(S O)) n1))))*A (exp (S(S O)) n1)))
1583 |apply (trans_le ? ((2)\sup(pred (2*(2)\sup(n1)))*(2)\sup(2*(2)\sup(n1)-S (S n1))))
1586 |rewrite < exp_plus_times.
1589 |cut (S(S n1) \le 2*(exp 2 n1))
1590 [apply le_S_S_to_le.
1591 change in ⊢ (? % ?) with (S(pred (2*(2)\sup(n1)))+(2*(2)\sup(n1)-S (S n1))).
1593 [rewrite > eq_minus_S_pred in ⊢ (? ? %).
1595 [rewrite < eq_minus_plus_plus_minus
1596 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1600 |apply lt_to_lt_O_minus.
1601 apply (lt_to_le_to_lt ? (2*(S(S n1))))
1602 [rewrite > times_n_SO in ⊢ (? % ?).
1603 rewrite > sym_times.
1612 |unfold.rewrite > times_n_SO in ⊢ (? % ?).
1621 |apply (trans_le ? (2*(S(S n2))))
1622 [apply le_S_times_SSO.
1635 theorem monotonic_A: monotonic nat le A.
1639 |apply (trans_le ? (A n1))
1642 cut (pi_p (S n1) primeb (λp:nat.(p)\sup(log p n1))
1643 ≤pi_p (S n1) primeb (λp:nat.(p)\sup(log p (S n1))))
1644 [apply (bool_elim ? (primeb (S n1)));intro
1645 [rewrite > (true_to_pi_p_Sn ? ? ? H3).
1646 rewrite > times_n_SO in ⊢ (? % ?).
1647 rewrite > sym_times.
1649 [apply lt_O_exp.apply lt_O_S
1652 |rewrite > (false_to_pi_p_Sn ? ? ? H3).
1655 |apply le_pi_p.intros.
1657 [apply prime_to_lt_O.
1658 apply primeb_true_to_prime.
1661 [apply prime_to_lt_SO.
1662 apply primeb_true_to_prime.
1664 |apply le_S.apply le_n
1673 theorem le_A_exp2: \forall n. O < n \to
1674 A(n) \le (exp (S(S O)) ((S(S O)) * (S(S O)) * n)).
1676 apply (trans_le ? (A (exp (S(S O)) (S(log (S(S O)) n)))))
1681 |apply (trans_le ? ((exp (S(S O)) ((S(S O))*(exp (S(S O)) (S(log (S(S O)) n)))))))
1685 |rewrite > assoc_times.apply le_times_r.
1686 change with ((S(S O))*((S(S O))\sup(log (S(S O)) n))≤(S(S O))*n).
1697 theorem A_SO: A (S O) = S O.
1701 theorem A_SSO: A (S(S O)) = S (S O).
1705 theorem A_SSSO: A (S(S(S O))) = S(S(S(S(S(S O))))).
1709 theorem A_SSSSO: A (S(S(S(S O)))) = S(S(S(S(S(S(S(S(S(S(S(S O))))))))))).
1714 (* a better result *)
1715 theorem le_A_exp3: \forall n. S O < n \to
1716 A(n) \le exp (pred n) (2*(exp 2 (2 * n)).
1718 apply (nat_elim1 n).
1720 elim (or_eq_eq_S m).
1722 [elim (le_to_or_lt_eq (S O) a)
1723 [rewrite > H3 in ⊢ (? % ?).
1724 apply (trans_le ? ((exp (S(S O)) ((S(S O)*a)))*A a))
1726 |apply (trans_le ? (((S(S O)))\sup((S(S O))*a)*
1727 ((pred a)\sup((S(S O)))*((S(S O)))\sup((S(S O))*a))))
1731 rewrite > times_n_SO in ⊢ (? % ?).
1732 rewrite > sym_times.
1734 [apply lt_to_le.assumption
1739 |rewrite > sym_times.
1740 rewrite > assoc_times.
1741 rewrite < exp_plus_times.
1743 (pred a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1744 [rewrite > assoc_times.
1746 rewrite < exp_plus_times.
1752 apply le_S.apply le_S.
1756 rewrite > times_exp.
1757 apply monotonic_exp1.
1759 rewrite > sym_times.
1763 rewrite < plus_n_Sm.
1770 |rewrite < H4 in H3.
1774 apply le_S_S.apply le_S_S.apply le_O_n
1775 |apply not_lt_to_le.intro.
1776 apply (lt_to_not_le ? ? H1).
1778 apply (le_n_O_elim a)
1779 [apply le_S_S_to_le.assumption
1783 |elim (le_to_or_lt_eq O a (le_O_n ?))
1784 [apply (trans_le ? (A ((S(S O))*(S a))))
1787 rewrite > times_SSO.
1789 |apply (trans_le ? ((exp (S(S O)) ((S(S O)*(S a))))*A (S a)))
1791 |apply (trans_le ? (((S(S O)))\sup((S(S O))*S a)*
1792 (a\sup((S(S O)))*((S(S O)))\sup((S(S O))*(S a)))))
1798 rewrite > plus_n_SO.
1802 |apply le_S_S.assumption
1804 |rewrite > sym_times.
1805 rewrite > assoc_times.
1806 rewrite < exp_plus_times.
1808 (a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1809 [rewrite > assoc_times.
1811 rewrite < exp_plus_times.
1814 |rewrite > times_SSO.
1817 rewrite < plus_n_Sm.
1822 rewrite > times_exp.
1823 apply monotonic_exp1.
1825 rewrite > sym_times.
1831 |rewrite < H4 in H3.simplify in H3.
1833 apply (lt_to_not_le ? ? H1).
1841 theorem le_A_exp4: \forall n. S O < n \to
1842 A(n) \le (pred n)*exp 2 ((2 * n) -3).
1844 apply (nat_elim1 n).
1846 elim (or_eq_eq_S m).
1848 [elim (le_to_or_lt_eq (S O) a)
1849 [rewrite > H3 in ⊢ (? % ?).
1850 apply (trans_le ? (exp 2 (pred(2*a))*A a))
1852 |apply (trans_le ? (2\sup(pred(2*a))*((pred a)*2\sup((2*a)-3))))
1856 rewrite > times_n_SO in ⊢ (? % ?).
1857 rewrite > sym_times.
1859 [apply lt_to_le.assumption
1865 rewrite < assoc_times.
1866 rewrite > sym_times in ⊢ (? (? % ?) ?).
1867 rewrite > assoc_times.
1870 elim a[apply le_n|simplify.apply le_plus_n_r]
1871 |rewrite < exp_plus_times.
1874 |apply (trans_le ? (m+(m-3)))
1876 cases m[apply le_n|apply le_n_Sn]
1877 |simplify.rewrite < plus_n_O.
1878 rewrite > eq_minus_plus_plus_minus
1881 apply (trans_le ? (2*2))
1882 [simplify.apply (le_n_Sn 3)
1883 |apply le_times_r.assumption
1891 |rewrite > H3.rewrite < H4.simplify.
1892 apply le_S_S.apply lt_O_S
1893 |apply not_lt_to_le.intro.
1894 apply (lt_to_not_le ? ? H1).
1896 apply (le_n_O_elim a)
1897 [apply le_S_S_to_le.assumption
1901 |elim (le_to_or_lt_eq O a (le_O_n ?))
1902 [apply (trans_le ? (A ((S(S O))*(S a))))
1905 rewrite > times_SSO.
1907 |apply (trans_le ? ((exp 2 (pred(2*(S a))))*A (S a)))
1909 |apply (trans_le ? ((2\sup(pred (2*S a)))*(a*(exp 2 ((2*(S a))-3)))))
1914 apply le_S_times_SSO.
1916 |apply le_S_S.assumption
1919 change in ⊢ (? ? (? % ?)) with (2*a).
1920 rewrite > times_SSO.
1921 change in ⊢ (? (? (? ? %) ?) ?) with (S(2*a)).
1922 rewrite > minus_Sn_m
1923 [change in ⊢ (? (? ? (? ? %)) ?) with (2*(exp 2 (S(2*a)-3))).
1924 rewrite < assoc_times in ⊢ (? (? ? %) ?).
1925 rewrite < assoc_times.
1926 rewrite > sym_times in ⊢ (? (? % ?) ?).
1927 rewrite > sym_times in ⊢ (? (? (? % ?) ?) ?).
1928 rewrite > assoc_times.
1930 rewrite < exp_plus_times.
1933 |rewrite < eq_minus_plus_plus_minus
1934 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1937 apply O_lt_const_to_le_times_const.
1942 apply O_lt_const_to_le_times_const.
1948 |rewrite < H4 in H3.simplify in H3.
1950 apply (lt_to_not_le ? ? H1).
1957 theorem le_n_SSSSSSSSO_to_le_A_exp:
1958 \forall n. n \le 8 \to A(n) \le exp 2 ((2 * n) -3).
1966 [intro.apply leb_true_to_le.reflexivity
1968 [intro.apply leb_true_to_le.reflexivity
1970 [intro.apply leb_true_to_le.reflexivity
1972 [intro.apply leb_true_to_le.reflexivity
1974 [intro.apply leb_true_to_le.reflexivity
1976 [intro.apply leb_true_to_le.reflexivity
1977 |intro.apply False_ind.
1978 apply (lt_to_not_le ? ? H).
1979 apply leb_true_to_le.reflexivity
1991 theorem le_A_exp5: \forall n. A(n) \le exp 2 ((2 * n) -3).
1993 apply (nat_elim1 n).
1995 elim (decidable_le 9 m)
1996 [elim (or_eq_eq_S m).
1998 [rewrite > H3 in ⊢ (? % ?).
1999 apply (trans_le ? (exp 2 (pred(2*a))*A a))
2001 |apply (trans_le ? (2\sup(pred(2*a))*(2\sup((2*a)-3))))
2006 [apply (trans_lt ? 4)
2008 |apply (lt_times_to_lt 2)
2010 |rewrite < H3.assumption
2016 rewrite < exp_plus_times.
2019 |simplify.rewrite < plus_n_O.
2020 rewrite > eq_minus_plus_plus_minus
2023 |apply (trans_le ? 9)
2024 [apply leb_true_to_le. reflexivity
2031 |apply (trans_le ? (A (2*(S a))))
2034 rewrite > times_SSO.
2036 |apply (trans_le ? ((exp 2 ((2*(S a))-2))*A (S a)))
2037 [apply lt_SSSSO_to_le_A_exp.
2039 apply (le_times_to_le 2)
2041 |apply le_S_S_to_le.rewrite < H3.assumption
2043 |apply (trans_le ? ((2\sup((2*S a)-2))*(exp 2 ((2*(S a))-3))))
2049 [apply (lt_to_le_to_lt ? 4)
2051 |apply (le_times_to_le 2)
2053 |apply le_S_S_to_le.
2054 rewrite < H3.assumption
2059 |rewrite > times_SSO.
2061 rewrite < exp_plus_times.
2069 rewrite < minus_n_O.
2071 rewrite < plus_n_Sm.
2072 simplify.rewrite < minus_n_O.
2073 rewrite < plus_n_Sm.
2082 |apply le_n_SSSSSSSSO_to_le_A_exp.
2089 theorem le_exp_Al:\forall n. O < n \to exp 2 n \le A (2 * n).
2091 apply (trans_le ? ((exp 2 (2*n))/(2*n)))
2092 [apply le_times_to_le_div
2093 [rewrite > (times_n_O O) in ⊢ (? % ?).
2098 |simplify in ⊢ (? ? (? ? %)).
2100 rewrite > exp_plus_times.
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.