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 include "nat/binomial.ma".
16 include "nat/pi_p.ma".
18 (* This is chebishev teta function *)
20 definition teta: nat \to nat \def
21 \lambda n. pi_p (S n) primeb (\lambda p.p).
23 theorem lt_O_teta: \forall n. O < teta n.
26 |unfold teta.apply (bool_elim ? (primeb (S n1)));intro
27 [rewrite > true_to_pi_p_Sn
28 [rewrite > (times_n_O O).
35 |rewrite > false_to_pi_p_Sn;assumption
40 definition M \def \lambda m.bc (S(2*m)) m.
42 theorem lt_M: \forall m. O < m \to M m < exp 2 (2*m).
44 apply (lt_times_to_lt 2)
46 |change in ⊢ (? ? %) with (exp 2 (S(2*m))).
47 change in ⊢ (? ? (? % ?)) with (1+1).
48 rewrite > exp_plus_sigma_p.
49 apply (le_to_lt_to_lt ? (sigma_p (S (S (2*m))) (λk:nat.orb (eqb k m) (eqb k (S m)))
50 (λk:nat.bc (S (2*m)) k*(1)\sup(S (2*m)-k)*(1)\sup(k))))
51 [rewrite > (sigma_p_gi ? ? m)
52 [rewrite > (sigma_p_gi ? ? (S m))
53 [rewrite > (false_to_eq_sigma_p O (S(S(2*m))))
54 [simplify in ⊢ (? ? (? ? (? ? %))).
55 simplify in ⊢ (? % ?).
56 rewrite < exp_SO_n.rewrite < exp_SO_n.
57 rewrite < exp_SO_n.rewrite < exp_SO_n.
58 rewrite < times_n_SO.rewrite < times_n_SO.
59 rewrite < times_n_SO.rewrite < times_n_SO.
62 |apply le_plus_l.unfold M.
63 change in \vdash (? ? %) with (fact (S(2*m))/(fact (S m)*(fact ((2*m)-m)))).
64 simplify in \vdash (? ? (? ? (? ? (? (? % ?))))).
65 rewrite < plus_n_O.rewrite < minus_plus_m_m.
66 rewrite < sym_times in \vdash (? ? (? ? %)).
67 change in \vdash (? % ?) with (fact (S(2*m))/(fact m*(fact (S(2*m)-m)))).
68 simplify in \vdash (? (? ? (? ? (? (? (? %) ?)))) ?).
69 rewrite < plus_n_O.change in \vdash (? (? ? (? ? (? (? % ?)))) ?) with (S m + m).
70 rewrite < minus_plus_m_m.
75 elim (eqb i m);elim (eqb i (S m));reflexivity
77 |apply le_S_S.apply le_S_S.
80 |rewrite > (eq_to_eqb_true ? ? (refl_eq ? (S m))).
81 rewrite > (not_eq_to_eqb_false (S m) m)
83 |intro.apply (not_eq_n_Sn m).
84 apply sym_eq.assumption
87 |apply le_S.apply le_S_S.
90 |rewrite > (eq_to_eqb_true ? ? (refl_eq ? (S m))).
93 |rewrite > (bool_to_nat_to_eq_sigma_p (S(S(2*m))) ? (\lambda k.true) ?
94 (\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))))
97 [intros.elim (eqb i m\lor eqb i (S m))
98 [rewrite > sym_times.rewrite < times_n_SO.apply le_n
101 |apply (ex_intro ? ? O).
103 [split[apply lt_O_S|reflexivity]
104 |rewrite > (not_eq_to_eqb_false ? ? (not_eq_O_S m)).
105 rewrite > (not_eq_to_eqb_false ? ? (lt_to_not_eq ? ? H)).
106 simplify in \vdash (? % ?).
107 rewrite < exp_SO_n.rewrite < exp_SO_n.
108 rewrite > bc_n_O.simplify.
112 |intros.rewrite > sym_times in \vdash (? ? ? %).
113 rewrite < times_n_SO.
120 theorem divides_fact_to_divides: \forall p,n. prime p \to divides p n! \to
121 \exists m.O < m \land m \le n \land divides p m.
123 [apply False_ind.elim H.
124 apply (lt_to_not_le ? ? H2).
125 apply divides_to_le[apply le_n|assumption]
126 |rewrite > factS in H2.
127 elim (divides_times_to_divides ? ? ? H H2)
128 [apply (ex_intro ? ? (S n1)).split
135 |elim (H1 H3).elim H4.elim H5.
136 apply (ex_intro ? ? a).split
139 |apply le_S.assumption
147 theorem divides_fact_to_le: \forall p,n. prime p \to divides p n! \to
150 elim (divides_fact_to_divides p n H H1).
153 [apply divides_to_le;assumption
158 theorem prime_to_divides_M: \forall m,p. prime p \to S m < p \to p \le S(2*m) \to
161 elim (bc2 (S(2*m)) m)
162 [unfold bc.rewrite > H3.
164 rewrite > lt_O_to_div_times
165 [elim (divides_times_to_divides p (m!*(S (2*m)-m)!) n1)
167 elim (divides_times_to_divides p (m!) (S (2*m)-m)!)
168 [apply (lt_to_not_le ? ? (lt_to_le ? ? H1)).
169 apply divides_fact_to_le;assumption
170 |apply (lt_to_not_le ? ? H1).
171 apply divides_fact_to_le
173 |cut (S m = S(2*m)-m)
174 [rewrite > Hcut.assumption
175 |simplify in ⊢ (? ? ? (? (? %) ?)).
177 change in ⊢ (? ? ? (? % ?)) with (S m + m).
188 [apply prime_to_lt_O.assumption
192 |rewrite > (times_n_O O).
193 apply lt_times;apply lt_O_fact
195 |simplify in ⊢ (? ? (? %)).
197 change in ⊢ (? ? %) with (S m + m).
202 theorem divides_pi_p_M1: \forall m.\forall i. i \le (S(S(2*m))) \to
203 divides (pi_p i (\lambda p.leb (S(S m)) p \land primeb p)(\lambda p.p)) (M m).
206 [simplify.apply (witness ? ? (M m)).rewrite > sym_times.apply times_n_SO
207 |apply (bool_elim ? (leb (S (S m)) n \land primeb n));intro
208 [rewrite > true_to_pi_p_Sn
209 [apply divides_to_divides_times
210 [apply primeb_true_to_prime.
211 apply (andb_true_true_r ? ? H2).
212 |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))
214 [apply primeb_true_to_prime.
215 apply (andb_true_true_r ? ? H2)
220 [simplify.intro.elim H3.apply (lt_to_not_le ? ? H6).
225 |apply (bool_elim ? (leb (S (S m)) n1∧primeb n1));intro
226 [rewrite > true_to_pi_p_Sn
227 [intro.elim (divides_times_to_divides ? ? ? H3 H7)
228 [apply (le_to_not_lt ? ? H5).
231 [apply prime_to_lt_O.
232 apply primeb_true_to_prime.
233 apply (andb_true_true_r ? ? H6)
237 [apply lt_to_le.assumption
243 |rewrite > false_to_pi_p_Sn
245 apply lt_to_le.assumption
251 |apply prime_to_divides_M
252 [apply primeb_true_to_prime.
253 apply (andb_true_true_r ? ? H2)
254 |apply leb_true_to_le.
255 apply (andb_true_true ? ? H2)
256 |apply le_S_S_to_le.assumption
264 |rewrite > false_to_pi_p_Sn
274 theorem divides_pi_p_M:\forall m.
275 divides (pi_p (S(S(2*m))) (\lambda p.leb (S(S m)) p \land primeb p)(\lambda p.p)) (M m).
277 apply divides_pi_p_M1.
281 theorem teta_pi_p_teta: \forall m. teta (S (2*m))
282 =pi_p (S (S (2*m))) (λp:nat.leb (S (S m)) p∧primeb p) (λp:nat.p)*teta (S m).
284 rewrite > (eq_pi_p1 ? (\lambda p.leb p (S m) \land primeb p) ? (\lambda p.p) (S(S m)))
285 [rewrite < (false_to_eq_pi_p (S(S m)) (S(S(2*m))))
286 [generalize in match (S(S(2*m))).intro.
288 [simplify.reflexivity
289 |apply (bool_elim ? (primeb n1));intro
290 [rewrite > true_to_pi_p_Sn
291 [apply (bool_elim ? (leb n1 (S m))); intro
292 [rewrite > false_to_pi_p_Sn
293 [rewrite > true_to_pi_p_Sn
294 [rewrite < assoc_times.
295 rewrite > sym_times in ⊢ (? ? ? (? % ?)).
296 rewrite > assoc_times.
299 |apply true_to_true_to_andb_true;assumption
301 |rewrite > lt_to_leb_false
304 apply leb_true_to_le.
308 |rewrite > true_to_pi_p_Sn
309 [rewrite > false_to_pi_p_Sn
310 [rewrite > assoc_times.
313 |rewrite > H2.reflexivity
316 rewrite > le_to_leb_true
319 apply leb_false_to_not_le.
326 |rewrite > false_to_pi_p_Sn
327 [rewrite > false_to_pi_p_Sn
328 [rewrite > false_to_pi_p_Sn
342 |apply le_S_S.apply le_S_S.
346 rewrite > lt_to_leb_false
352 rewrite > le_to_leb_true
361 theorem div_teta_teta: \forall m.
362 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).
363 intros.apply (div_mod_spec_to_eq ? ? ? ? ? O (div_mod_spec_div_mod ? ? ? ))
365 |apply div_mod_spec_intro
373 theorem le_teta_M_teta: \forall m.
374 teta (S(2*m)) \le (M m)*teta (S m).
376 rewrite > teta_pi_p_teta.
379 [unfold M.apply lt_O_bc.apply lt_to_le.
380 apply le_S_S.apply le_times_n.
382 |apply divides_pi_p_M
386 theorem lt_O_to_le_teta_exp_teta: \forall m. O < m\to
387 teta (S(2*m)) < exp 2 (2*m)*teta (S m).
389 apply (le_to_lt_to_lt ? (M m*teta (S m)))
390 [apply le_teta_M_teta
399 theorem teta_pred: \forall n. S O < n \to teta (2*n) = teta (pred (2*n)).
401 rewrite > false_to_pi_p_Sn
404 |rewrite > (times_n_O 2) in ⊢ (? % ?).
406 apply lt_to_le.assumption
408 |apply not_prime_to_primeb_false.
411 apply (lt_to_not_eq ? ? H).
412 apply (injective_times_r 1).
413 rewrite < times_n_SO.
415 [apply (witness ? ? n).reflexivity
421 theorem le_teta: \forall m.teta m \le exp 2 (2*m).
422 intro.apply (nat_elim1 m).intros.
423 elim (or_eq_eq_S m1).
426 generalize in match H2.
430 [apply leb_true_to_le.reflexivity
432 [rewrite > times_SSO.
433 change in ⊢ (? (? %) ?) with (S (2*S n1)).
434 apply (trans_le ? (exp 2 (2*(S n1))*teta (S (S n1))))
436 apply lt_O_to_le_teta_exp_teta.
438 |rewrite < times_SSO.
439 change in ⊢ (? ? (? ? %)) with ((2*S (S n1))+((2*S (S n1)) + O)).
441 rewrite > exp_plus_times.
456 |apply le_S_S.apply lt_O_S
461 generalize in match H2.
463 [apply leb_true_to_le.reflexivity
464 |apply (trans_le ? (exp 2 (2*(S n))*teta (S (S n))))
466 apply lt_O_to_le_teta_exp_teta.
468 |change in ⊢ (? ? (? ? %)) with (S (2*S n) + (S (2*S n) +O)).
473 rewrite > exp_plus_times.
489 alias id "sqrt" = "cic:/matita/nat/sqrt/sqrt.con".
490 alias id "not" = "cic:/matita/logic/connectives/Not.con".
491 theorem absurd_bound: \forall n. exp 2 7 \le n \to
492 (\forall p. n < p \to p < 2*n \to not (prime p)) \to
493 bc (2*n) n < exp (2*n) (div (sqrt (2*n)) 2 - 1)*exp 4 (div (2*n) 3).
496 [cut (sqrt (2*n) < div (2*n) 3)