Skip to main content
AlexKontorovich/PrimeNumberTheoremAnd
Source indexedtheorem · leanprover/lean4:v4.32.0

chebyshev_asymptotic_pnt

PrimeNumberTheoremAnd.Consequences · PrimeNumberTheoremAnd/Consequences.lean:2436 to 2512

Source documentation

\section{Consequences of the PNT in arithmetic progressions}

Exact Lean statement

@[blueprint
  "chebyshev-asymptotic-pnt"
  (title := "Prime number theorem in AP")
  (statement := /--
  If $a\ (q)$ is a primitive residue class, then one has
  $$ \sum_{p \leq x: p = a\ (q)} \log p = \frac{x}{\phi(q)} + o(x).$$
  -/)
  (proof := /--
  This is a routine modification of the proof of Theorem \ref{chebyshev-asymptotic}.
  -/)
  (proofUses := ["chebyshev-asymptotic"])
  (latexEnv := "theorem")]
theorem chebyshev_asymptotic_pnt
    {q : ℕ} {a : ℕ} (hq : q ≥ 1) (ha : a.Coprime q) (ha' : a < q) :
    (fun x ↦ ∑ p ∈ filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then log p else 0) ~[atTop]
      fun x ↦ x / q.totient

Complete declaration

Lean source

Canonical source
Full Lean sourceLean 4
@[blueprint  "chebyshev-asymptotic-pnt"  (title := "Prime number theorem in AP")  (statement := /--  If $a\ (q)$ is a primitive residue class, then one has  $$ \sum_{p \leq x: p = a\ (q)} \log p = \frac{x}{\phi(q)} + o(x).$$  -/)  (proof := /--  This is a routine modification of the proof of Theorem \ref{chebyshev-asymptotic}.  -/)  (proofUses := ["chebyshev-asymptotic"])  (latexEnv := "theorem")]theorem chebyshev_asymptotic_pnt    {q : } {a : } (hq : q  1) (ha : a.Coprime q) (ha' : a < q) :    (fun x  ∑ p  filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then log p else 0) ~[atTop]      fun x  x / q.totient := by  let ψ_aq :    := fun x  ∑ n  Icc 1 ⌊x⌋₊, if n % q = a then Λ n else 0  have htot_pos : (0 : ) < q.totient := cast_pos.mpr (totient_pos.mpr hq)  have hψ_equiv : ψ_aq ~[atTop] fun x  x / q.totient := by    have hW := WeakPNT_AP hq ha ha'    simp only [cumsum,  Iio_eq_range] at hW    have hψ_eq x : ψ_aq x = ∑ n  Iio (⌊x⌋₊ + 1), if n % q = a then Λ n else 0 := by      simp only [ψ_aq, show Icc 1 ⌊x⌋₊ = (Iio (⌊x⌋₊ + 1)).filter (1  ·) by        ext n; simp [mem_Icc, mem_filter]; tauto, sum_filter]      refine sum_congr rfl fun n _  ?_      by_cases hn : 1  n <;> simp only [hn, ↓reduceIte]      push Not at hn; interval_cases n; simp    refine (isEquivalent_iff_tendsto_one ?_).mpr ?_    · filter_upwards [eventually_ge_atTop 1] with x hx; exact div_ne_zero (by linarith) htot_pos.ne'    have hlim1 : Tendsto (fun x :   (∑ n  Iio (⌊x⌋₊ + 1), if n % q = a then Λ n else 0) /        (⌊x⌋₊ + 1 : )) atTop (nhds (1 / q.totient)) := by      have heq : (fun x :   (∑ n  Iio (⌊x⌋₊ + 1), if n % q = a then Λ n else 0) /          (⌊x⌋₊ + 1 : )) = (fun N  (∑ n  Iio N, if n % q = a then Λ n else 0) / N) ∘          (fun x :   ⌊x⌋₊ + 1) := by ext x; simp [Function.comp_apply]      exact heq ▸ hW.comp ((tendsto_add_atTop_nat 1).comp tendsto_nat_floor_atTop)    have hgoal_eq : (ψ_aq / fun x  x / (q.totient : )) =        fun x  ψ_aq x / x * q.totient := by ext x; simp only [Pi.div_apply, div_div_eq_mul_div]; ring    rw [hgoal_eq, show (1 : ) = 1 / q.totient * 1 * q.totient by field_simp]    refine Tendsto.mul ?_ tendsto_const_nhds    have heq' : (fun x  ψ_aq x / x) =ᶠ[atTop]        fun x  (∑ n  Iio (⌊x⌋₊ + 1), if n % q = a then Λ n else 0) / (⌊x⌋₊ + 1 : ) * ((⌊x⌋₊ + 1 : ) / x) := by      filter_upwards [eventually_gt_atTop 0] with x hx      simp only [hψ_eq]; field_simp    exact Tendsto.congr' heq'.symm (hlim1.mul tendsto_floor_add_one_div_self)  refine hψ_equiv.add_isLittleO'' (IsBigO.trans_isLittleO (g := fun x  2 * x.sqrt * x.log) ?_ ?_)  · rw [isBigO_iff']; refine 1, one_pos, eventually_atTop.mpr 2, fun x hx  ?_⟩⟩    simp only [Pi.sub_apply, norm_eq_abs, one_mul]    have hdiff_nonneg : 0  ψ_aq x - ∑ p  filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then log p else 0 := by      simp only [ψ_aq, sub_nonneg]      calc (∑ p  filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then log p else (0 : ))           ∑ p  filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then Λ p else (0 : ) :=            sum_le_sum fun p hp  by split_ifs <;> simp [vonMangoldt_apply_prime (mem_filter.mp hp).2]        _  ∑ n  Icc 1 ⌊x⌋₊, if n % q = a then Λ n else (0 : ) :=            sum_le_sum_of_subset_of_nonneg              (fun p hp  by simp only [mem_filter, mem_Iic, mem_Icc] at hp ; exact hp.2.one_lt.le, hp.1)              (fun n _ _  by split_ifs <;> [exact vonMangoldt_nonneg; rfl])    have hdiff_le : ψ_aq x - (∑ p  filter Nat.Prime (Iic ⌊x⌋₊), if p % q = a then log p else (0 : ))  ψ x - θ x := by      simp only [ψ_aq, Chebyshev.psi_eq_sum_Icc, Chebyshev.theta_eq_sum_Icc]      conv_rhs => rw [Icc_zero_eq_insert, sum_insert (by simp : (0 : )  Icc 1 ⌊x⌋₊),        show Λ 0 = 0 by simp only [ArithmeticFunction.map_zero], zero_add,        show filter Nat.Prime (insert 0 (Icc 1 ⌊x⌋₊)) = filter Nat.Prime (Icc 1 ⌊x⌋₊) by          simp [filter_insert, Nat.not_prime_zero]]      rw [filter_prime_Iic_eq_Icc,  sum_filter_add_sum_filter_not (Icc 1 ⌊x⌋₊) Nat.Prime,        show (∑ p  filter Nat.Prime (Icc 1 ⌊x⌋₊), if p % q = a then log p else (0 : )) =          ∑ p  filter Nat.Prime (Icc 1 ⌊x⌋₊), if p % q = a then Λ p else (0 : ) from          sum_congr rfl fun p hp  by simp only [mem_filter] at hp; split_ifs <;> simp [vonMangoldt_apply_prime hp.2],         sum_filter_add_sum_filter_not (Icc 1 ⌊x⌋₊) Nat.Prime,        show (∑ p  filter Nat.Prime (Icc 1 ⌊x⌋₊), Λ p) = ∑ p  filter Nat.Prime (Icc 1 ⌊x⌋₊), log p from          sum_congr rfl fun p hp  vonMangoldt_apply_prime (mem_filter.mp hp).2]      have h1 : (∑ n  (Icc 1 ⌊x⌋₊).filter (¬Nat.Prime ·), if n % q = a then Λ n else (0 : ))           ∑ n  (Icc 1 ⌊x⌋₊).filter (¬Nat.Prime ·), Λ n :=        sum_le_sum fun n _  by split_ifs <;> [exact le_refl _; exact vonMangoldt_nonneg]      linarith    rw [abs_of_nonneg hdiff_nonneg, abs_of_nonneg (by bound)]    exact hdiff_le.trans ((le_abs_self _).trans (Chebyshev.abs_psi_sub_theta_le_sqrt_mul_log (by linarith)))  · simpa only [mul_assoc] using      (isLittleO_sqrt_mul_log.const_mul_left 2).trans_isTheta (isTheta_self_div_const htot_pos.ne')