Download data/lean/OAI/Computability/FourierTransform/PrimeSelection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.45 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/FourierTransform/PrimeSelection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/FourierTransform/PrimeSelection.lean
-
curl -L -o PrimeSelection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/FourierTransform/PrimeSelection.lean
3.45 kB
| import OAI.Computability.FourierTransform.ChineseRemainder | |
| namespace OAI | |
| /- Prime supply and bounded parameters -/ | |
| namespace PowerSaving.Selection | |
| open Finset Real | |
| noncomputable section | |
| def stackN (n : β) := Nat.log 2 (2*n)+1 | |
| lemma stack_pos (n : β) : 0< stackN n := Nat.succ_pos _ | |
| lemma stack_above (n : β) : | |
| 2*n < 2^stackN n := | |
| Nat.lt_pow_succ_log_self Nat.one_lt_two _ | |
| lemma stack_pow (n : β) (hn : 0<n) : | |
| 2^stackN n β€ 4*n := by | |
| have hh : 2^(Nat.log 2 (2*n)) β€ 2*n := Nat.pow_log_le_self _ (by omega) | |
| rw [stackN,pow_succ]; omega | |
| lemma stack_le (n : β) (hn : 0<n) : | |
| stackN n β€ 4*n := Nat.lt_two_pow_self.le.trans (stack_pow n hn) | |
| def silo (k : β) := (16*(k+4))^2 | |
| lemma silo_big (k : β) : 2 < silo k := by | |
| have hh : 2 < 16*(k+4) := by omega | |
| unfold silo; nlinarith [hh] | |
| lemma harvest (k : β) : | |
| k+2 β€ Nat.primeCounting (silo k) := by | |
| let q := silo k | |
| let t : β := k+4 | |
| let s : β := 16*t | |
| have hq : (q:β)=s^2 := by dsimp [q,silo,s,t]; push_cast; ring | |
| have ht : 4β€t := by simp [t] | |
| have hs : 64β€ s := by unfold s; linarith | |
| have he : 0< s := by linarith | |
| have hh : 1 < (q:β) := by rw [hq]; nlinarith | |
| have HL : log (q:β) β€ 2*s := by | |
| rw [hq, Real.log_pow] | |
| norm_num | |
| have := Real.log_le_sub_one_of_pos he | |
| linarith | |
| have hk : log (2:β) β₯ 2/3 := by | |
| have hh := Real.le_log_one_add_of_nonneg (show (0:β)β€1 by norm_num) | |
| norm_num at hh β’ | |
| exact hh | |
| have hu : log ((q:β)+1) β€ 1+2*s := by | |
| have h1 : (q:β)+1 β€ 2*q := by linarith | |
| have hy := Real.log_le_log (by linarith : 0<(q:β)+1) h1 | |
| rw [Real.log_mul (by norm_num) (by linarith)] at hy | |
| have h2 := Real.log_le_sub_one_of_pos (show (0:β)<2 by norm_num) | |
| linarith | |
| have h3 := Chebyshev.pi_ge q | |
| have HG : (k:β)+2 β€ Nat.primeCounting q := by | |
| refine le_trans ?_ h3 | |
| rw [le_div_iffβ (Real.log_pos hh)] | |
| calc | |
| _ β€ t * (2*s) := by | |
| have hg : (k:β)+2 β€ t := by unfold t; linarith | |
| gcongr | |
| _ β€ s^2*(2/3)-(1+2*s) := by | |
| have g : s=16*t := rfl | |
| nlinarith | |
| _ β€ _ := by rw [hq] at hu β’; gcongr | |
| exact_mod_cast HG | |
| -- odd primes up to and excluding limit | |
| def Bar (i : β) := Nat.Prime i β§ i>2 | |
| instance (i) : Decidable (Bar i) := inferInstanceAs (Decidable (_ β§ _)) | |
| def bars (p : β) : β := β i β range p, if Bar i then 1 else 0 | |
| lemma bars_step (i : β) : bars (i+1)=bars i+(if Bar i then 1 else 0) := sum_range_succ .. | |
| lemma bars_zero : bars 0=0 := by simp [bars] | |
| lemma bars_count (p : β) (hp : 2 β€ p) : | |
| bars (p+1)+1 = Nat.primeCounting p := by | |
| let Q := range (p+1) | |
| have h (i : β) : (if Bar i then 1 else 0)+(if i=2 then 1 else 0)= | |
| (if i.Prime then 1 else 0) := by | |
| by_cases g : i.Prime | |
| Β· have ht := g.two_le; simp only [Bar,g,true_and,ite_true]; split_ifs <;> omega | |
| Β· have hh : iβ 2 := by intro H; rw [H] at g; exact g Nat.prime_two | |
| simp [g,hh,Bar] | |
| have hh1 : β i β Q, (if i=2 then 1 else 0)=1 := by | |
| have hg : 2<p+1 := by omega | |
| simp [Q,hg] | |
| conv_lhs => rhs; rw [β hh1] | |
| rw [bars] | |
| dsimp only [Q] | |
| rw [β sum_add_distrib] | |
| simp_rw [h] | |
| rw [β Nat.primesLE_card_eq_primeCounting] | |
| -- filter | |
| rw [β sum_filter] | |
| simp [Nat.primesLE,Nat.primesBelow] | |
| lemma bar_bounds (k : β) : | |
| k < bars (silo k+1) := by | |
| have H := bars_count _ (silo_big k).le | |
| have G := harvest k | |
| omega | |
| end | |
| end PowerSaving.Selection | |
| end OAI | |