Skip to content

Commit 15b0938

Browse files
committed
finished proofs
1 parent 983edc4 commit 15b0938

File tree

2 files changed

+119
-20
lines changed

2 files changed

+119
-20
lines changed

Asympt.v

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Require Import Utf8 Arith.
44
Import List List.ListNotations.
55
Require Import Reals.
66

7-
Require Import Psatz Misc Primes Totient Primisc Prod Harmonic.
7+
Require Import Psatz Misc Primes Totient Primisc Prod Harmonic Log.
88
Require Import Interval.Tactic.
99
Require Import Logic.FunctionalExtensionality.
1010

@@ -236,16 +236,69 @@ Proof.
236236
apply Nat.log2_le_pow2. lia.
237237
remember (S n) as m.
238238
rewrite <- prime_divisor_pow_prod by lia.
239-
simpl. apply prod_le_const.
240-
Admitted.
239+
rewrite <- prod_const_f with (f := (fun _ => 2%nat)) by (intros; easy).
240+
apply prod_le. intros.
241+
specialize (in_prime_divisors_power_ge_1 _ _ H) as G.
242+
apply prime_divisors_decomp in H.
243+
specialize (in_prime_decomp_ge_2 _ _ H) as T.
244+
split. lia.
245+
assert (a ^ 1 <= a ^ (pow_in_n m a))%nat by (apply Nat.pow_le_mono_r; lia).
246+
simpl in H0. rewrite Nat.mul_1_r in H0. lia.
247+
Qed.
241248

242249
Inductive entrywise_le : list nat → list nat → Prop :=
243250
| entrywise_le_nil : entrywise_le [] []
244251
| entrywise_le_cons x1 l1 x2 l2 (Hlex : x1 ≤ x2) (Hlel : entrywise_le l1 l2): entrywise_le (x1 :: l1) (x2 :: l2).
245252

253+
Print prime_divisors.
254+
255+
Lemma entrywise_le_extend :
256+
forall a1 a2 l1 l2, (a1 <= a2)%nat -> entrywise_le l1 l2 -> entrywise_le (l1 ++ [a1]) (l2 ++ [a2]).
257+
Proof.
258+
intros. induction H0. simpl. constructor. easy. constructor.
259+
do 2 rewrite <- app_comm_cons. constructor; easy.
260+
Qed.
261+
262+
Lemma seq_extend :
263+
forall n x, seq x (S n) = seq x n ++ [(x + n)%nat].
264+
Proof.
265+
induction n; intros. simpl. rewrite Nat.add_0_r. easy.
266+
replace (seq x (S (S n))) with (x :: seq (S x) (S n)) by easy.
267+
rewrite IHn. simpl. replace (x + S n)%nat with (S (x + n))%nat by lia.
268+
easy.
269+
Qed.
270+
271+
Lemma filter_seq_extend :
272+
forall n f, (filter f (seq 1 (S n))) = if (f (S n)) then (filter f (seq 1 n) ++ [S n]) else filter f (seq 1 n).
273+
Proof.
274+
intros. rewrite seq_extend. rewrite filter_app. simpl.
275+
destruct (f (S n)). easy. apply app_nil_r.
276+
Qed.
277+
278+
Lemma filter_length :
279+
forall {A} f (l : list A), (length (filter f l) <= length l)%nat.
280+
Proof.
281+
intros. induction l. simpl. lia.
282+
simpl. destruct (f a). simpl. lia. lia.
283+
Qed.
284+
285+
Lemma filter_seq_le :
286+
forall n f, entrywise_le (seq 1 (length (filter f (seq 1 n)))) (filter f (seq 1 n)).
287+
Proof.
288+
induction n; intros. simpl. constructor.
289+
rewrite filter_seq_extend. destruct (f (S n)).
290+
rewrite app_length. simpl.
291+
replace (length (filter f (seq 1 n)) + 1)%nat with (S (length (filter f (seq 1 n)))) by lia.
292+
rewrite seq_extend. apply entrywise_le_extend.
293+
specialize (filter_length f (seq 1 n)) as G. rewrite seq_length in G. lia.
294+
easy. easy.
295+
Qed.
296+
246297
Lemma seq_entrywise_le_prime_divisors :
247-
∀ n, entrywise_le (seq 1 (length (prime_divisors n))) (prime_divisors n).
248-
Admitted.
298+
∀ n, entrywise_le (seq 1 (length (prime_divisors n))) (prime_divisors n).
299+
Proof.
300+
intros. apply filter_seq_le.
301+
Qed.
249302

250303
Lemma Rprod_increasing_f :
251304
∀ (l1 l2 : list nat) (f : nat → R),
@@ -322,16 +375,28 @@ Proof.
322375
Qed.
323376

324377
Lemma final_log_bound :
325-
∀ n, 4 ≤ n →
326-
Nat.log2 (Nat.log2 n) + 1 <= - / 2 * ln (0.001 / Nat.log2 n).
327-
Admitted.
378+
∀ n, 2 ≤ n →
379+
Nat.log2 (Nat.log2 n) + 1 <= - / 2 * ln (exp (-2) / Nat.log2 n ^ 4).
380+
Proof.
381+
intros.
382+
assert (0 < Nat.log2 n)%nat by (apply Nat.log2_pos; lia).
383+
rewrite Rcomplements.ln_div.
384+
rewrite ln_exp.
385+
rewrite Rcomplements.ln_pow.
386+
replace (INR 4) with 4 by (simpl; lra).
387+
replace (- / 2 * (-2 - 4 * ln (Nat.log2 n))) with (1 + 2 * ln (Nat.log2 n)) by field.
388+
specialize (log_bound _ H0) as G. lra.
389+
replace 0 with (INR 0) by easy. apply lt_INR; easy.
390+
apply exp_pos.
391+
replace 0 with (INR 0) by easy. rewrite <- pow_INR. apply lt_INR. simpl. nia.
392+
Qed.
328393

329394
Theorem φ_lower_bound :
330-
∃ (N0 : nat) (c : R),
331-
(∀ n, N0 ≤ n → φ n / n >= c / Nat.log2 n) ∧ c > 0.
395+
∃ (c : R),
396+
(∀ n, 2 ≤ n → φ n / n >= c / ((Nat.log2 n) ^ 4)) ∧ c > 0.
332397
Proof.
333-
exists 4%nat. exists 0.001. split.
334-
intros.
398+
exists (exp (-2)). split.
399+
intros.
335400
rewrite <- (prime_divisor_pow_prod n) at 2.
336401
rewrite φ_prime_divisors_power.
337402
repeat rewrite prod_INR_Rprod.
@@ -362,15 +427,15 @@ Proof.
362427
replace (/ i + - / j) with (/ i - / j) by reflexivity.
363428
apply Rge_le. apply Rge_minus. apply Rle_ge. apply Raux.Rinv_le; auto.
364429
{
365-
replace 0 with (INR 0%nat) by auto.
430+
replace 0 with (INR 0%nat) by auto.
366431
apply lt_INR. destruct H0. apply le_seq in H0. lia.
367432
eapply lt_le_trans with 2%nat. lia. apply prime_ge_2.
368433
eapply in_prime_decomp_is_prime. apply prime_divisors_decomp.
369434
apply H0.
370435
}
371436
rewrite map_ext_in with _ _ _ (λ x : nat, (-2) * / x) _ by auto.
372437
rewrite Rsum_distr_f.
373-
replace (ln (?[c] / Nat.log2 n)) with (-2 * (-/2 * ln (0.001 / Nat.log2 n))). (* 0.001 can be any constant *)
438+
replace (ln (exp (-2) / (Nat.log2 n ^ 4))) with (-2 * (-/2 * ln (exp (-2) / (Nat.log2 n ^ 4)))).
374439
apply Rmult_le_ge_compat_neg_l. lra. eapply Rle_trans.
375440
simpl. rewrite map_ext_in with _ _ _ (λ x : nat, 1 / x) _.
376441
apply harmonic_upper_bound.
@@ -386,12 +451,18 @@ Proof.
386451
(* side conditions *)
387452
- assert (0 < Nat.log2 n).
388453
{ replace 0 with (INR 0%nat) by auto. apply lt_INR.
454+
apply Nat.log2_pos. lia.
455+
(*
389456
eapply Nat.lt_trans. constructor.
390457
eapply Nat.lt_le_trans. auto.
391458
replace 2%nat with (Nat.log2 4) by auto.
392-
apply Nat.log2_le_mono. auto. }
393-
unfold Rdiv at 1. apply Rmult_lt_0_compat.
394-
lra. apply Rinv_0_lt_compat. auto.
459+
apply Nat.log2_le_mono. auto.
460+
*)
461+
}
462+
unfold Rdiv at 1. apply Rmult_lt_0_compat.
463+
apply exp_pos. apply Rinv_0_lt_compat.
464+
replace 0 with (INR 0) in * by easy. apply INR_lt in H0.
465+
rewrite <- pow_INR. apply lt_INR. simpl. nia.
395466
- unfold not. intros. apply map_eq_nil in H0.
396467
apply prime_divisors_nil_iff in H0. lia.
397468
- intros. apply map_in_exists in H0 as (y & Hy0 & Hy1).
@@ -432,7 +503,7 @@ Proof.
432503
now apply pow_nonzero.
433504
- lia.
434505
- lia.
435-
- lra.
506+
- specialize (exp_pos (-2)). lra.
436507
Qed.
437508

438-
Local Close Scope R_scope.
509+
Local Close Scope R_scope.

Prod.v

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Proof.
3636
simpl. rewrite IHl. symmetry. rewrite IHl. lia.
3737
Qed.
3838

39+
Lemma prod_empty :
40+
prod [] = 1.
41+
Proof. easy. Qed.
42+
3943
Lemma prod_extend :
4044
forall l a, prod (a :: l) = a * prod l.
4145
Proof.
@@ -96,6 +100,31 @@ Proof.
96100
intros. apply Hocc. right. easy.
97101
Qed.
98102

103+
Lemma prod_le :
104+
forall {A} (l : list A) f1 f2,
105+
(forall a, a ∈ l -> 0 < f1 a <= f2 a) ->
106+
prod (map f1 l) <= prod (map f2 l).
107+
Proof.
108+
intro A. induction l; intros. simpl. lia.
109+
simpl. do 2 rewrite prod_extend.
110+
assert (∀ a0 : A, a0 ∈ l → 0 < f1 a0 ≤ f2 a0) by (intros; apply H; constructor; easy).
111+
specialize (IHl _ _ H0).
112+
assert (0 < f1 a <= f2 a) by (apply H; constructor; easy).
113+
nia.
114+
Qed.
115+
116+
Lemma prod_const_f :
117+
forall {A} (l : list A) f c,
118+
(forall a, a ∈ l -> f a = c) ->
119+
prod (map f l) = c^(length l).
120+
Proof.
121+
intro A. induction l; intros. simpl. apply prod_empty.
122+
simpl. rewrite prod_extend. rewrite IHl with (c := c).
123+
rewrite H. easy.
124+
constructor; easy.
125+
intros. apply H. constructor; easy.
126+
Qed.
127+
99128
Local Transparent prod.
100129

101130
Theorem prime_divisor_pow_prod :
@@ -209,4 +238,3 @@ Proof.
209238
intros. apply prime_divisors_decomp in H0.
210239
apply in_prime_decomp_is_prime with n. assumption.
211240
Qed.
212-

0 commit comments

Comments
 (0)