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.(S O)).
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 (* si dovrebbe poter migliorare *)
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 S O < 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.S O).
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) (λi:nat.leb (S O) i)
801 (λn.pi_p (S n) primeb
802 (\lambda p.(pi_p (log p n)
803 (\lambda i.divides_b (exp p (S i)) n) (\lambda i.p))))))
804 [apply eq_pi_p1;intros
807 apply leb_true_to_le.assumption
810 (pi_p (S n) (λi:nat.leb (S O) i)
812 .pi_p (S n) (\lambda p.primeb p\land leb p n)
813 (λp:nat.pi_p (log p n) (λi:nat.divides_b ((p)\sup(S i)) n) (λ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) (λi:nat.leb (S O) i)
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 ((S(S O))*n) =
1013 pi_p (S ((S(S O))*n)) primeb
1014 (\lambda p.(pi_p (log p ((S(S O))*n))
1015 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(n /(exp p (S i))))*(exp p (mod ((S(S O))*n /(exp p (S i))) (S(S O)))))))).
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 ((S(S O))*n) =
1035 pi_p (S ((S(S O))*n)) primeb
1036 (\lambda p.(pi_p (log p ((S(S O))*n))
1037 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(n /(exp p (S i))))))))*
1038 pi_p (S ((S(S O))*n)) primeb
1039 (\lambda p.(pi_p (log p ((S(S O))*n))
1040 (\lambda i.true) (\lambda i.(exp p (mod ((S(S O))*n /(exp p (S i))) (S(S O))))))).
1042 rewrite < times_pi_p.
1043 rewrite > fact_pi_p2.
1044 apply eq_pi_p;intros
1050 theorem pi_p_primeb4: \forall n. S O < n \to
1051 pi_p (S ((S(S O))*n)) primeb
1052 (\lambda p.(pi_p (log p ((S(S O))*n))
1053 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(n /(exp p (S i))))))))
1056 (\lambda p.(pi_p (log p (S(S O)*n))
1057 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(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. S O < n \to
1080 pi_p (S ((S(S O))*n)) primeb
1081 (\lambda p.(pi_p (log p ((S(S O))*n))
1082 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(n /(exp p (S i))))))))
1085 (\lambda p.(pi_p (log p n)
1086 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(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.
1121 exp (fact n) (S(S O))
1124 (\lambda p.(pi_p (log p n)
1125 (\lambda i.true) (\lambda i.(exp p ((S(S O))*(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 ((S(S O))*n) = exp (fact n) (S(S O)) * B((S(S O))*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
1279 theorem le_fact_A:\forall n.S O < n \to
1280 fact (2*n) \le exp (fact n) 2 * A (2*n).
1289 theorem lt_SO_to_le_B_exp: \forall n.S O < n \to
1290 B (2*n) \le exp 2 (pred (2*n)).
1292 apply (le_times_to_le (exp (fact n) (S(S O))))
1295 |rewrite < eq_fact_B
1296 [rewrite < sym_times in ⊢ (? ? %).
1298 rewrite < assoc_times.
1305 theorem le_B_exp: \forall n.
1306 B (2*n) \le exp 2 (pred (2*n)).
1310 [simplify.apply le_n
1311 |apply lt_SO_to_le_B_exp.
1312 apply le_S_S.apply lt_O_S.
1317 theorem lt_SSSSO_to_le_B_exp: \forall n.4 < n \to
1318 B (2*n) \le exp 2 ((2*n)-2).
1320 apply (le_times_to_le (exp (fact n) (S(S O))))
1323 |rewrite < eq_fact_B
1324 [rewrite < sym_times in ⊢ (? ? %).
1326 rewrite < assoc_times.
1327 apply lt_SSSSO_to_fact.assumption
1328 |apply lt_to_le.apply lt_to_le.
1329 apply lt_to_le.assumption
1334 theorem lt_SO_to_le_exp_B: \forall n. S O < n \to
1335 exp (S(S O)) ((S(S O))*n) \le (S(S O)) * n * B ((S(S O))*n).
1337 apply (le_times_to_le (exp (fact n) (S(S O))))
1340 |rewrite < assoc_times in ⊢ (? ? %).
1341 rewrite > sym_times in ⊢ (? ? (? % ?)).
1342 rewrite > assoc_times in ⊢ (? ? %).
1344 [rewrite < sym_times.
1346 apply lt_to_le.assumption
1352 theorem le_exp_B: \forall n. O < n \to
1353 exp (S(S O)) ((S(S O))*n) \le (S(S O)) * n * B ((S(S O))*n).
1357 |apply lt_SO_to_le_exp_B.
1358 apply le_S_S.assumption
1362 theorem eq_A_SSO_n: \forall n.O < n \to
1364 pi_p (S ((S(S O))*n)) primeb
1365 (\lambda p.(pi_p (log p ((S(S O))*n) )
1366 (\lambda i.true) (\lambda i.(exp p (bool_to_nat (leb (S n) (exp p (S i))))))))
1369 rewrite > eq_A_A'.rewrite > eq_A_A'.
1372 pi_p (S n) primeb (λp:nat.pi_p (log p n) (λi:nat.true) (λi:nat.p))
1373 = pi_p (S ((S(S O))*n)) primeb
1374 (λ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))))))))
1376 rewrite < times_pi_p.
1377 apply eq_pi_p1;intros
1379 |rewrite < times_pi_p.
1380 apply eq_pi_p;intros
1382 |apply (bool_elim ? (leb (S n) (exp x (S x1))));intro
1383 [simplify.rewrite < times_n_SO.apply times_n_SO
1384 |simplify.rewrite < plus_n_O.apply times_n_SO
1388 |apply (trans_eq ? ? (pi_p (S n) primeb
1389 (\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))))))))
1390 [apply eq_pi_p1;intros
1392 |apply eq_pi_p1;intros
1394 |rewrite > lt_to_leb_false
1395 [simplify.apply times_n_SO
1397 apply (trans_le ? (exp x (log x n)))
1399 [apply prime_to_lt_O.
1400 apply primeb_true_to_prime.
1410 |apply (trans_eq ? ?
1411 (pi_p (S ((S(S O))*n)) primeb
1412 (λp:nat.pi_p (log p n) (λi:nat.true)
1413 (λi:nat.(p)\sup(bool_to_nat (¬leb (S n) ((p)\sup(S i))))))))
1415 apply or_false_eq_SO_to_eq_pi_p
1420 rewrite > lt_to_log_O
1426 |apply eq_pi_p1;intros
1429 apply or_false_eq_SO_to_eq_pi_p
1431 [apply prime_to_lt_SO.
1432 apply primeb_true_to_prime.
1438 rewrite > le_to_leb_true
1439 [simplify.reflexivity
1440 |apply (lt_to_le_to_lt ? (exp x (S (log x n))))
1442 apply prime_to_lt_SO.
1443 apply primeb_true_to_prime.
1446 [apply prime_to_lt_O.
1447 apply primeb_true_to_prime.
1449 |apply le_S_S.assumption
1460 theorem le_A_BA1: \forall n. O < n \to
1461 A((S(S O))*n) \le B((S(S O))*n)*A n.
1463 rewrite > eq_A_SSO_n
1466 apply le_pi_p.intros.
1467 apply le_pi_p.intros.
1469 [apply prime_to_lt_O.
1470 apply primeb_true_to_prime.
1472 |apply (bool_elim ? (leb (S n) (exp i (S i1))));intro
1473 [simplify in ⊢ (? % ?).
1474 cut ((S(S O))*n/i\sup(S i1) = S O)
1475 [rewrite > Hcut.apply le_n
1476 |apply (div_mod_spec_to_eq
1477 ((S(S O))*n) (exp i (S i1))
1478 ? (mod ((S(S O))*n) (exp i (S i1)))
1479 ? (minus ((S(S O))*n) (exp i (S i1))) )
1480 [apply div_mod_spec_div_mod.
1482 apply prime_to_lt_O.
1483 apply primeb_true_to_prime.
1485 |cut (i\sup(S i1)≤(S(S O))*n)
1486 [apply div_mod_spec_intro
1487 [apply lt_plus_to_lt_minus
1489 |simplify in ⊢ (? % ?).
1492 [apply leb_true_to_le.assumption
1493 |apply leb_true_to_le.assumption
1496 |rewrite > sym_plus.
1497 rewrite > sym_times in ⊢ (? ? ? (? ? %)).
1498 rewrite < times_n_SO.
1499 apply plus_minus_m_m.
1502 |apply (trans_le ? (exp i (log i ((S(S O))*n))))
1504 [apply prime_to_lt_O.
1505 apply primeb_true_to_prime.
1510 rewrite > (times_n_O O) in ⊢ (? % ?).
1526 theorem le_A_BA: \forall n. A((S(S O))*n) \le B((S(S O))*n)*A n.
1529 |apply le_A_BA1.apply lt_O_S
1533 theorem le_A_exp: \forall n.
1534 A(2*n) \le (exp 2 (pred (2*n)))*A n.
1536 apply (trans_le ? (B(2*n)*A n))
1543 theorem lt_SSSSO_to_le_A_exp: \forall n. 4 < n \to
1544 A(2*n) \le exp 2 ((2*n)-2)*A n.
1546 apply (trans_le ? (B(2*n)*A n))
1549 apply lt_SSSSO_to_le_B_exp.assumption
1553 theorem times_SSO_pred: \forall n. 2*(pred n) \le pred (2*n).
1556 |simplify.apply le_plus_r.
1561 theorem le_S_times_SSO: \forall n. O < n \to S n \le 2*n.
1565 |rewrite > times_SSO.
1567 apply (trans_le ? (2*n1))
1574 theorem le_A_exp1: \forall n.
1575 A(exp 2 n) \le (exp 2 ((2*(exp 2 n)-(S(S n))))).
1577 [simplify.apply le_n
1578 |change in ⊢ (? % ?) with (A(2*(exp 2 n1))).
1579 apply (trans_le ? ((exp 2 (pred(2*(exp (S(S O)) n1))))*A (exp (S(S O)) n1)))
1581 |apply (trans_le ? ((2)\sup(pred (2*(2)\sup(n1)))*(2)\sup(2*(2)\sup(n1)-S (S n1))))
1584 |rewrite < exp_plus_times.
1587 |cut (S(S n1) \le 2*(exp 2 n1))
1588 [apply le_S_S_to_le.
1589 change in ⊢ (? % ?) with (S(pred (2*(2)\sup(n1)))+(2*(2)\sup(n1)-S (S n1))).
1591 [rewrite > eq_minus_S_pred in ⊢ (? ? %).
1593 [rewrite < eq_minus_plus_plus_minus
1594 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1598 |apply lt_to_lt_O_minus.
1599 apply (lt_to_le_to_lt ? (2*(S(S n1))))
1600 [rewrite > times_n_SO in ⊢ (? % ?).
1601 rewrite > sym_times.
1610 |unfold.rewrite > times_n_SO in ⊢ (? % ?).
1619 |apply (trans_le ? (2*(S(S n2))))
1620 [apply le_S_times_SSO.
1633 theorem monotonic_A: monotonic nat le A.
1637 |apply (trans_le ? (A n1))
1640 cut (pi_p (S n1) primeb (λp:nat.(p)\sup(log p n1))
1641 ≤pi_p (S n1) primeb (λp:nat.(p)\sup(log p (S n1))))
1642 [apply (bool_elim ? (primeb (S n1)));intro
1643 [rewrite > (true_to_pi_p_Sn ? ? ? H3).
1644 rewrite > times_n_SO in ⊢ (? % ?).
1645 rewrite > sym_times.
1647 [apply lt_O_exp.apply lt_O_S
1650 |rewrite > (false_to_pi_p_Sn ? ? ? H3).
1653 |apply le_pi_p.intros.
1655 [apply prime_to_lt_O.
1656 apply primeb_true_to_prime.
1659 [apply prime_to_lt_SO.
1660 apply primeb_true_to_prime.
1662 |apply le_S.apply le_n
1671 theorem le_A_exp2: \forall n. O < n \to
1672 A(n) \le (exp (S(S O)) ((S(S O)) * (S(S O)) * n)).
1674 apply (trans_le ? (A (exp (S(S O)) (S(log (S(S O)) n)))))
1679 |apply (trans_le ? ((exp (S(S O)) ((S(S O))*(exp (S(S O)) (S(log (S(S O)) n)))))))
1683 |rewrite > assoc_times.apply le_times_r.
1684 change with ((S(S O))*((S(S O))\sup(log (S(S O)) n))≤(S(S O))*n).
1695 theorem A_SO: A (S O) = S O.
1699 theorem A_SSO: A (S(S O)) = S (S O).
1703 theorem A_SSSO: A (S(S(S O))) = S(S(S(S(S(S O))))).
1707 theorem A_SSSSO: A (S(S(S(S O)))) = S(S(S(S(S(S(S(S(S(S(S(S O))))))))))).
1712 (* a better result *)
1713 theorem le_A_exp3: \forall n. S O < n \to
1714 A(n) \le exp (pred n) (2*(exp 2 (2 * n)).
1716 apply (nat_elim1 n).
1718 elim (or_eq_eq_S m).
1720 [elim (le_to_or_lt_eq (S O) a)
1721 [rewrite > H3 in ⊢ (? % ?).
1722 apply (trans_le ? ((exp (S(S O)) ((S(S O)*a)))*A a))
1724 |apply (trans_le ? (((S(S O)))\sup((S(S O))*a)*
1725 ((pred a)\sup((S(S O)))*((S(S O)))\sup((S(S O))*a))))
1729 rewrite > times_n_SO in ⊢ (? % ?).
1730 rewrite > sym_times.
1732 [apply lt_to_le.assumption
1737 |rewrite > sym_times.
1738 rewrite > assoc_times.
1739 rewrite < exp_plus_times.
1741 (pred a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1742 [rewrite > assoc_times.
1744 rewrite < exp_plus_times.
1750 apply le_S.apply le_S.
1754 rewrite > times_exp.
1755 apply monotonic_exp1.
1757 rewrite > sym_times.
1761 rewrite < plus_n_Sm.
1768 |rewrite < H4 in H3.
1772 apply le_S_S.apply le_S_S.apply le_O_n
1773 |apply not_lt_to_le.intro.
1774 apply (lt_to_not_le ? ? H1).
1776 apply (le_n_O_elim a)
1777 [apply le_S_S_to_le.assumption
1781 |elim (le_to_or_lt_eq O a (le_O_n ?))
1782 [apply (trans_le ? (A ((S(S O))*(S a))))
1785 rewrite > times_SSO.
1787 |apply (trans_le ? ((exp (S(S O)) ((S(S O)*(S a))))*A (S a)))
1789 |apply (trans_le ? (((S(S O)))\sup((S(S O))*S a)*
1790 (a\sup((S(S O)))*((S(S O)))\sup((S(S O))*(S a)))))
1796 rewrite > plus_n_SO.
1800 |apply le_S_S.assumption
1802 |rewrite > sym_times.
1803 rewrite > assoc_times.
1804 rewrite < exp_plus_times.
1806 (a\sup((S(S O)))*(S(S O))\sup(S(S O))*(S(S O))\sup((S(S O))*m)))
1807 [rewrite > assoc_times.
1809 rewrite < exp_plus_times.
1812 |rewrite > times_SSO.
1815 rewrite < plus_n_Sm.
1820 rewrite > times_exp.
1821 apply monotonic_exp1.
1823 rewrite > sym_times.
1829 |rewrite < H4 in H3.simplify in H3.
1831 apply (lt_to_not_le ? ? H1).
1839 theorem le_A_exp4: \forall n. S O < n \to
1840 A(n) \le (pred n)*exp 2 ((2 * n) -3).
1842 apply (nat_elim1 n).
1844 elim (or_eq_eq_S m).
1846 [elim (le_to_or_lt_eq (S O) a)
1847 [rewrite > H3 in ⊢ (? % ?).
1848 apply (trans_le ? (exp 2 (pred(2*a))*A a))
1850 |apply (trans_le ? (2\sup(pred(2*a))*((pred a)*2\sup((2*a)-3))))
1854 rewrite > times_n_SO in ⊢ (? % ?).
1855 rewrite > sym_times.
1857 [apply lt_to_le.assumption
1863 rewrite < assoc_times.
1864 rewrite > sym_times in ⊢ (? (? % ?) ?).
1865 rewrite > assoc_times.
1868 elim a[apply le_n|simplify.apply le_plus_n_r]
1869 |rewrite < exp_plus_times.
1872 |apply (trans_le ? (m+(m-3)))
1874 cases m[apply le_n|apply le_n_Sn]
1875 |simplify.rewrite < plus_n_O.
1876 rewrite > eq_minus_plus_plus_minus
1879 apply (trans_le ? (2*2))
1880 [simplify.apply (le_n_Sn 3)
1881 |apply le_times_r.assumption
1889 |rewrite > H3.rewrite < H4.simplify.
1890 apply le_S_S.apply lt_O_S
1891 |apply not_lt_to_le.intro.
1892 apply (lt_to_not_le ? ? H1).
1894 apply (le_n_O_elim a)
1895 [apply le_S_S_to_le.assumption
1899 |elim (le_to_or_lt_eq O a (le_O_n ?))
1900 [apply (trans_le ? (A ((S(S O))*(S a))))
1903 rewrite > times_SSO.
1905 |apply (trans_le ? ((exp 2 (pred(2*(S a))))*A (S a)))
1907 |apply (trans_le ? ((2\sup(pred (2*S a)))*(a*(exp 2 ((2*(S a))-3)))))
1912 apply le_S_times_SSO.
1914 |apply le_S_S.assumption
1917 change in ⊢ (? ? (? % ?)) with (2*a).
1918 rewrite > times_SSO.
1919 change in ⊢ (? (? (? ? %) ?) ?) with (S(2*a)).
1920 rewrite > minus_Sn_m
1921 [change in ⊢ (? (? ? (? ? %)) ?) with (2*(exp 2 (S(2*a)-3))).
1922 rewrite < assoc_times in ⊢ (? (? ? %) ?).
1923 rewrite < assoc_times.
1924 rewrite > sym_times in ⊢ (? (? % ?) ?).
1925 rewrite > sym_times in ⊢ (? (? (? % ?) ?) ?).
1926 rewrite > assoc_times.
1928 rewrite < exp_plus_times.
1931 |rewrite < eq_minus_plus_plus_minus
1932 [rewrite > plus_n_O in ⊢ (? (? (? ? %) ?) ?).
1935 apply O_lt_const_to_le_times_const.
1940 apply O_lt_const_to_le_times_const.
1946 |rewrite < H4 in H3.simplify in H3.
1948 apply (lt_to_not_le ? ? H1).
1955 theorem le_n_SSSSSSSSO_to_le_A_exp:
1956 \forall n. n \le 8 \to A(n) \le exp 2 ((2 * n) -3).
1964 [intro.apply leb_true_to_le.reflexivity
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
1975 |intro.apply False_ind.
1976 apply (lt_to_not_le ? ? H).
1977 apply leb_true_to_le.reflexivity
1989 theorem le_A_exp5: \forall n. A(n) \le exp 2 ((2 * n) -3).
1991 apply (nat_elim1 n).
1993 elim (decidable_le 9 m)
1994 [elim (or_eq_eq_S m).
1996 [rewrite > H3 in ⊢ (? % ?).
1997 apply (trans_le ? (exp 2 (pred(2*a))*A a))
1999 |apply (trans_le ? (2\sup(pred(2*a))*(2\sup((2*a)-3))))
2004 [apply (trans_lt ? 4)
2006 |apply (lt_times_to_lt 2)
2008 |rewrite < H3.assumption
2014 rewrite < exp_plus_times.
2017 |simplify.rewrite < plus_n_O.
2018 rewrite > eq_minus_plus_plus_minus
2021 |apply (trans_le ? 9)
2022 [apply leb_true_to_le. reflexivity
2029 |apply (trans_le ? (A (2*(S a))))
2032 rewrite > times_SSO.
2034 |apply (trans_le ? ((exp 2 ((2*(S a))-2))*A (S a)))
2035 [apply lt_SSSSO_to_le_A_exp.
2037 apply (le_times_to_le 2)
2039 |apply le_S_S_to_le.rewrite < H3.assumption
2041 |apply (trans_le ? ((2\sup((2*S a)-2))*(exp 2 ((2*(S a))-3))))
2047 [apply (lt_to_le_to_lt ? 4)
2049 |apply (le_times_to_le 2)
2051 |apply le_S_S_to_le.
2052 rewrite < H3.assumption
2057 |rewrite > times_SSO.
2059 rewrite < exp_plus_times.
2067 rewrite < minus_n_O.
2069 rewrite < plus_n_Sm.
2070 simplify.rewrite < minus_n_O.
2071 rewrite < plus_n_Sm.
2080 |apply le_n_SSSSSSSSO_to_le_A_exp.
2087 theorem eq_sigma_pi_SO_n: \forall n.
2088 sigma_p n (\lambda i.true) (\lambda i.S O) = n.
2091 |rewrite > true_to_sigma_p_Sn
2092 [rewrite > H.reflexivity
2098 theorem leA_prim: \forall n.
2099 exp n (prim n) \le A n * pi_p (S n) primeb (λp:nat.p).
2102 rewrite < (exp_sigma_p (S n) n primeb).
2104 rewrite < times_pi_p.
2107 rewrite > sym_times.
2108 change in ⊢ (? ? %) with (exp i (S (log i n))).
2111 apply prime_to_lt_SO.
2112 apply primeb_true_to_prime.
2117 theorem le_prim_log : \forall n,b.S O < b \to
2118 log b (A n) \leq prim n * (S (log b n)).
2119 intros;apply (trans_le ? ? ? ? (log_exp1 ? ? ? ?))
2127 (* the inequalities *)
2128 theorem le_exp_priml: \forall n. O < n \to
2129 exp (S(S O)) ((S(S O))*n) \le exp ((S(S O))*n) (S(prim ((S(S O))*n))).
2131 apply (trans_le ? ((((S(S O))*n*(B ((S(S O))*n))))))
2132 [apply le_exp_B.assumption
2133 |change in ⊢ (? ? %) with ((((S(S O))*n))*(((S(S O))*n))\sup (prim ((S(S O))*n))).
2135 apply (trans_le ? (A ((S(S O))*n)))
2142 theorem le_exp_prim4l: \forall n. O < n \to
2143 exp 2 (S(4*n)) \le exp (4*n) (S(prim (4*n))).
2145 apply (trans_le ? (2*(4*n*(B (4*n)))))
2146 [change in ⊢ (? % ?) with (2*(exp 2 (4*n))).
2151 apply lt_to_le.unfold.
2152 rewrite > times_n_SO in ⊢ (? % ?).
2153 apply le_times_r.assumption
2154 |rewrite < assoc_times.
2157 |change in ⊢ (? ? %) with ((4*n)*(4*n)\sup (prim (4*n))).
2158 rewrite < assoc_times.
2159 rewrite > sym_times in ⊢ (? (? % ?) ?).
2160 rewrite > assoc_times.
2162 apply (trans_le ? (A (4*n)))
2163 [apply le_B_A4.assumption
2169 theorem le_priml: \forall n. O < n \to
2170 2*n \le (S (log 2 (2*n)))*S(prim (2*n)).
2172 rewrite < (eq_log_exp (S(S O))) in ⊢ (? % ?)
2173 [apply (trans_le ? ((log (S(S O)) (exp ((S(S O))*n) (S(prim ((S(S O))*n)))))))
2176 |apply le_exp_priml.assumption
2178 |rewrite > sym_times in ⊢ (? ? %).
2186 theorem le_exp_primr: \forall n.
2187 exp n (prim n) \le exp 2 (2*(2*n-3)).
2189 apply (trans_le ? (exp (A n) 2))
2190 [change in ⊢ (? ? %) with ((A n)*((A n)*(S O))).
2191 rewrite < times_n_SO.
2193 |rewrite > sym_times.
2194 rewrite < exp_exp_times.
2195 apply monotonic_exp1.
2201 theorem le_primr: \forall n. 1 < n \to prim n \le 2*(2*n-3)/log 2 n.
2203 apply le_times_to_le_div
2205 [apply lt_to_le.assumption
2208 |apply (trans_le ? (log 2 (exp n (prim n))))
2209 [rewrite > sym_times.
2212 |apply lt_to_le.assumption
2214 |rewrite < (eq_log_exp 2) in ⊢ (? ? %)
2225 theorem le_priml1: \forall n. O < n \to
2226 2*n/((log 2 n)+2) - 1 \le prim (2*n).
2228 apply le_plus_to_minus.
2229 apply le_times_to_le_div2
2230 [rewrite > sym_plus.
2231 simplify.apply lt_O_S
2232 |rewrite > sym_times in ⊢ (? ? %).
2233 rewrite < plus_n_Sm.
2234 rewrite < plus_n_Sm in ⊢ (? ? (? ? %)).
2238 [simplify in ⊢ (? ? (? (? (? ? (? % ?))) ?)).
2248 theorem prim_SSSSSSO: \forall n.30\le n \to O < prim (8*n) - prim n.
2250 apply lt_to_lt_O_minus.
2251 change in ⊢ (? ? (? (? % ?))) with (2*4).
2252 rewrite > assoc_times.
2253 apply (le_to_lt_to_lt ? (2*(2*n-3)/log 2 n))
2254 [apply le_primr.apply (trans_lt ? ? ? ? H).
2255 apply leb_true_to_le.reflexivity
2256 |apply (lt_to_le_to_lt ? (2*(4*n)/((log 2 (4*n))+2) - 1))
2259 normalize in ⊢ (%);simplify.