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 (**************************************************************************)
15 set "baseuri" "cic:/matita/nat/chebyshev_teta".
17 include "nat/binomial.ma".
18 include "nat/pi_p.ma".
20 (* This is chebishev teta function *)
22 definition teta: nat \to nat \def
23 \lambda n. pi_p (S n) primeb (\lambda p.p).
25 theorem lt_O_teta: \forall n. O < teta n.
28 |unfold teta.apply (bool_elim ? (primeb (S n1)));intro
29 [rewrite > true_to_pi_p_Sn
30 [rewrite > (times_n_O O).
37 |rewrite > false_to_pi_p_Sn;assumption
42 definition M \def \lambda m.bc (S(2*m)) m.
44 theorem lt_M: \forall m. O < m \to M m < exp 2 (2*m).
46 apply (lt_times_to_lt 2)
48 |change in ⊢ (? ? %) with (exp 2 (S(2*m))).
49 change in ⊢ (? ? (? % ?)) with (1+1).
50 rewrite > exp_plus_sigma_p.
51 apply (le_to_lt_to_lt ? (sigma_p (S (S (2*m))) (λk:nat.orb (eqb k m) (eqb k (S m)))
52 (λk:nat.bc (S (2*m)) k*(1)\sup(S (2*m)-k)*(1)\sup(k))))
53 [rewrite > (sigma_p_gi ? ? m)
54 [rewrite > (sigma_p_gi ? ? (S m))
55 [rewrite > (false_to_eq_sigma_p O (S(S(2*m))))
56 [simplify in ⊢ (? ? (? ? (? ? %))).
57 simplify in ⊢ (? % ?).
58 rewrite < exp_SO_n.rewrite < exp_SO_n.
59 rewrite < exp_SO_n.rewrite < exp_SO_n.
60 rewrite < times_n_SO.rewrite < times_n_SO.
61 rewrite < times_n_SO.rewrite < times_n_SO.
64 |apply le_plus_l.unfold M.
65 change in \vdash (? ? %) with (fact (S(2*m))/(fact (S m)*(fact ((2*m)-m)))).
66 simplify in \vdash (? ? (? ? (? ? (? (? % ?))))).
67 rewrite < plus_n_O.rewrite < minus_plus_m_m.
68 rewrite < sym_times in \vdash (? ? (? ? %)).
69 change in \vdash (? % ?) with (fact (S(2*m))/(fact m*(fact (S(2*m)-m)))).
70 simplify in \vdash (? (? ? (? ? (? (? (? %) ?)))) ?).
71 rewrite < plus_n_O.change in \vdash (? (? ? (? ? (? (? % ?)))) ?) with (S m + m).
72 rewrite < minus_plus_m_m.
77 elim (eqb i m);elim (eqb i (S m));reflexivity
79 |apply le_S_S.apply le_S_S.
82 |rewrite > (eq_to_eqb_true ? ? (refl_eq ? (S m))).
83 rewrite > (not_eq_to_eqb_false (S m) m)
85 |intro.apply (not_eq_n_Sn m).
86 apply sym_eq.assumption
89 |apply le_S.apply le_S_S.
92 |rewrite > (eq_to_eqb_true ? ? (refl_eq ? (S m))).
95 |rewrite > (bool_to_nat_to_eq_sigma_p (S(S(2*m))) ? (\lambda k.true) ?
96 (\lambda k.bool_to_nat (eqb k m\lor eqb k (S m))*(bc (S (2*m)) k*(1)\sup(S (2*m)-k)*(1)\sup(k))))
99 [intros.elim (eqb i m\lor eqb i (S m))
100 [rewrite > sym_times.rewrite < times_n_SO.apply le_n
103 |apply (ex_intro ? ? O).
105 [split[apply lt_O_S|reflexivity]
106 |rewrite > (not_eq_to_eqb_false ? ? (not_eq_O_S m)).
107 rewrite > (not_eq_to_eqb_false ? ? (lt_to_not_eq ? ? H)).
108 simplify in \vdash (? % ?).
109 rewrite < exp_SO_n.rewrite < exp_SO_n.
110 rewrite > bc_n_O.simplify.
114 |intros.rewrite > sym_times in \vdash (? ? ? %).
115 rewrite < times_n_SO.
122 theorem divides_fact_to_divides: \forall p,n. prime p \to divides p n! \to
123 \exists m.O < m \land m \le n \land divides p m.
125 [apply False_ind.elim H.
126 apply (lt_to_not_le ? ? H2).
127 apply divides_to_le[apply le_n|assumption]
128 |rewrite > factS in H2.
129 elim (divides_times_to_divides ? ? ? H H2)
130 [apply (ex_intro ? ? (S n1)).split
137 |elim (H1 H3).elim H4.elim H5.
138 apply (ex_intro ? ? a).split
141 |apply le_S.assumption
149 theorem divides_fact_to_le: \forall p,n. prime p \to divides p n! \to
152 elim (divides_fact_to_divides p n H H1).
155 [apply divides_to_le;assumption
160 theorem prime_to_divides_M: \forall m,p. prime p \to S m < p \to p \le S(2*m) \to
163 elim (bc2 (S(2*m)) m)
164 [unfold bc.rewrite > H3.
166 rewrite > lt_O_to_div_times
167 [elim (divides_times_to_divides p (m!*(S (2*m)-m)!) n2)
169 elim (divides_times_to_divides p (m!) (S (2*m)-m)!)
170 [apply (lt_to_not_le ? ? (lt_to_le ? ? H1)).
171 apply divides_fact_to_le;assumption
172 |apply (lt_to_not_le ? ? H1).
173 apply divides_fact_to_le
175 |cut (S m = S(2*m)-m)
176 [rewrite > Hcut.assumption
177 |simplify in ⊢ (? ? ? (? (? %) ?)).
179 change in ⊢ (? ? ? (? % ?)) with (S m + m).
190 [apply prime_to_lt_O.assumption
194 |rewrite > (times_n_O O).
195 apply lt_times;apply lt_O_fact
197 |simplify in ⊢ (? ? (? %)).
199 change in ⊢ (? ? %) with (S m + m).
204 theorem divides_pi_p_M1: \forall m.\forall i. i \le (S(S(2*m))) \to
205 divides (pi_p i (\lambda p.leb (S(S m)) p \land primeb p)(\lambda p.p)) (M m).
208 [simplify.apply (witness ? ? (M m)).rewrite > sym_times.apply times_n_SO
209 |apply (bool_elim ? (leb (S (S m)) n \land primeb n));intro
210 [rewrite > true_to_pi_p_Sn
211 [apply divides_to_divides_times
212 [apply primeb_true_to_prime.
213 apply (andb_true_true_r ? ? H2).
214 |cut (\forall p.prime p \to n \le p \to ¬p∣pi_p n (λp:nat.leb (S (S m)) p∧primeb p) (λp:nat.p))
216 [apply primeb_true_to_prime.
217 apply (andb_true_true_r ? ? H2)
222 [simplify.intro.elim H3.apply (lt_to_not_le ? ? H6).
227 |apply (bool_elim ? (leb (S (S m)) n1∧primeb n1));intro
228 [rewrite > true_to_pi_p_Sn
229 [intro.elim (divides_times_to_divides ? ? ? H3 H7)
230 [apply (le_to_not_lt ? ? H5).
233 [apply prime_to_lt_O.
234 apply primeb_true_to_prime.
235 apply (andb_true_true_r ? ? H6)
239 [apply lt_to_le.assumption
245 |rewrite > false_to_pi_p_Sn
247 apply lt_to_le.assumption
253 |apply prime_to_divides_M
254 [apply primeb_true_to_prime.
255 apply (andb_true_true_r ? ? H2)
256 |apply leb_true_to_le.
257 apply (andb_true_true ? ? H2)
258 |apply le_S_S_to_le.assumption
266 |rewrite > false_to_pi_p_Sn
276 theorem divides_pi_p_M:\forall m.
277 divides (pi_p (S(S(2*m))) (\lambda p.leb (S(S m)) p \land primeb p)(\lambda p.p)) (M m).
279 apply divides_pi_p_M1.
283 theorem teta_pi_p_teta: \forall m. teta (S (2*m))
284 =pi_p (S (S (2*m))) (λp:nat.leb (S (S m)) p∧primeb p) (λp:nat.p)*teta (S m).
286 rewrite > (eq_pi_p1 ? (\lambda p.leb p (S m) \land primeb p) ? (\lambda p.p) (S(S m)))
287 [rewrite < (false_to_eq_pi_p (S(S m)) (S(S(2*m))))
288 [generalize in match (S(S(2*m))).intro.
290 [simplify.reflexivity
291 |apply (bool_elim ? (primeb n1));intro
292 [rewrite > true_to_pi_p_Sn
293 [apply (bool_elim ? (leb n1 (S m))); intro
294 [rewrite > false_to_pi_p_Sn
295 [rewrite > true_to_pi_p_Sn
296 [rewrite < assoc_times.
297 rewrite > sym_times in ⊢ (? ? ? (? % ?)).
298 rewrite > assoc_times.
301 |apply true_to_true_to_andb_true;assumption
303 |rewrite > lt_to_leb_false
306 apply leb_true_to_le.
310 |rewrite > true_to_pi_p_Sn
311 [rewrite > false_to_pi_p_Sn
312 [rewrite > assoc_times.
315 |rewrite > H2.reflexivity
318 rewrite > le_to_leb_true
321 apply leb_false_to_not_le.
328 |rewrite > false_to_pi_p_Sn
329 [rewrite > false_to_pi_p_Sn
330 [rewrite > false_to_pi_p_Sn
344 |apply le_S_S.apply le_S_S.
348 rewrite > lt_to_leb_false
354 rewrite > le_to_leb_true
363 theorem div_teta_teta: \forall m.
364 teta (S(2*m))/teta (S m) = pi_p (S(S(2*m))) (\lambda p.leb (S(S m)) p \land primeb p)(\lambda p.p).
365 intros.apply (div_mod_spec_to_eq ? ? ? ? ? O (div_mod_spec_div_mod ? ? ? ))
367 |apply div_mod_spec_intro
375 theorem le_teta_M_teta: \forall m.
376 teta (S(2*m)) \le (M m)*teta (S m).
378 rewrite > teta_pi_p_teta.
381 [unfold M.apply lt_O_bc.apply lt_to_le.
382 apply le_S_S.apply le_times_n.
384 |apply divides_pi_p_M
388 theorem lt_O_to_le_teta_exp_teta: \forall m. O < m\to
389 teta (S(2*m)) < exp 2 (2*m)*teta (S m).
391 apply (le_to_lt_to_lt ? (M m*teta (S m)))
392 [apply le_teta_M_teta
401 theorem teta_pred: \forall n. S O < n \to teta (2*n) = teta (pred (2*n)).
403 rewrite > false_to_pi_p_Sn
406 |rewrite > (times_n_O 2) in ⊢ (? % ?).
408 apply lt_to_le.assumption
410 |apply not_prime_to_primeb_false.
413 apply (lt_to_not_eq ? ? H).
414 apply (injective_times_r 1).
415 rewrite < times_n_SO.
417 [apply (witness ? ? n).reflexivity
423 theorem le_teta: \forall m.teta m \le exp 2 (2*m).
424 intro.apply (nat_elim1 m).intros.
425 elim (or_eq_eq_S m1).
428 generalize in match H2.
432 [apply leb_true_to_le.reflexivity
434 [rewrite > times_SSO.
435 change in ⊢ (? (? %) ?) with (S (2*S n1)).
436 apply (trans_le ? (exp 2 (2*(S n1))*teta (S (S n1))))
438 apply lt_O_to_le_teta_exp_teta.
440 |rewrite < times_SSO.
441 change in ⊢ (? ? (? ? %)) with ((2*S (S n1))+((2*S (S n1)) + O)).
443 rewrite > exp_plus_times.
458 |apply le_S_S.apply lt_O_S
463 generalize in match H2.
465 [apply leb_true_to_le.reflexivity
466 |apply (trans_le ? (exp 2 (2*(S n))*teta (S (S n))))
468 apply lt_O_to_le_teta_exp_teta.
470 |change in ⊢ (? ? (? ? %)) with (S (2*S n) + (S (2*S n) +O)).
475 rewrite > exp_plus_times.
491 alias id "sqrt" = "cic:/matita/nat/sqrt/sqrt.con".
492 alias id "not" = "cic:/matita/logic/connectives/Not.con".
493 theorem absurd_bound: \forall n. exp 2 7 \le n \to
494 (\forall p. n < p \to p < 2*n \to not (prime p)) \to
495 bc (2*n) n < exp (2*n) (div (sqrt (2*n)) 2 - 1)*exp 4 (div (2*n) 3).
498 [cut (sqrt (2*n) < div (2*n) 3)