import OAI.NumberTheory.TwoPointCorrelations.HalaszSmoothBounds namespace OAI /-! A fixed-power change of the prime cutoff changes the squared pretentious distance by an absolute constant. -/ namespace TwoPointCorrelations open Finset Complex open scoped ComplexConjugate lemma halasz_prime_cutoff_subset {n N : ℕ} (hn : n ≤ N) : primesUpTo n ⊆ primesUpTo N := by intro p hp obtain ⟨hp, hprime⟩ := mem_filter.mp hp exact mem_filter.mpr ⟨mem_range.mpr (by have := mem_range.mp hp; omega), hprime⟩ theorem halasz_distance_cutoff_loss : ∃ K : ℝ, 0 ≤ K ∧ ∀ (f : ℕ → ℂ), OneBounded f → ∀ (n N : ℕ), 2 ≤ n → n ≤ N → N ≤ n ^ 3 → ∀ t : ℝ, squaredDistance f (mrtArchimedeanTwist t) N ≤ squaredDistance f (mrtArchimedeanTwist t) n + K := by obtain ⟨C, hC⟩ := primeReciprocalInput let K := 2 * (Real.log 3 + 2 * |C|) have hK : 0 ≤ K := by dsimp [K]; positivity refine ⟨K, hK, ?_⟩ intro f hf n N hn hnN hNcube t have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) have hln : 0 < Real.log (n : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < n)) have hlN : 0 < Real.log (N : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < N)) have hlNn : Real.log (N : ℝ) ≤ 3 * Real.log (n : ℝ) := by have h := Real.log_le_log hN0 (show (N : ℝ) ≤ (n : ℝ) ^ 3 by exact_mod_cast hNcube) simpa only [Real.log_pow, Nat.cast_ofNat] using h have hll : Real.log (Real.log (N : ℝ)) - Real.log (Real.log (n : ℝ)) ≤ Real.log 3 := by have h := Real.log_le_log hlN hlNn rw [Real.log_mul (by norm_num) hln.ne'] at h linarith have hmN := hC (N : ℝ) (by exact_mod_cast (show 2 ≤ N by omega)) have hmn := hC (n : ℝ) (by exact_mod_cast hn) rw [mrt_sievePrimesUpTo_nat] at hmN hmn have hmass : (∑ p ∈ primesUpTo N, (1 : ℝ) / p) - (∑ p ∈ primesUpTo n, (1 : ℝ) / p) ≤ Real.log 3 + 2 * |C| := by have ha := (abs_le.mp hmN).2 have hb := (abs_le.mp hmn).1 linarith [le_abs_self C] let P := primesUpTo N \ primesUpTo n have hsub := halasz_prime_cutoff_subset hnN have hterm (p : ℕ) (hp : p ∈ P) : (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ) ≤ 2 * (1 / (p : ℝ)) := by have hprime : p.Prime := (mem_filter.mp (mem_sdiff.mp hp).1).2 have hnrm : ‖f p * conj (mrtArchimedeanTwist t p)‖ ≤ 1 := by simpa only [norm_mul, norm_conj, mrtArchimedeanTwist_norm, mul_one] using hf p hprime.pos have hre := (neg_le_abs _).trans ((Complex.abs_re_le_norm _).trans hnrm) have hnum : 1 - (f p * conj (mrtArchimedeanTwist t p)).re ≤ 2 := by linarith simpa only [mul_one_div] using div_le_div_of_nonneg_right hnum (Nat.cast_nonneg p) have hs := sum_le_sum (fun p hp => hterm p hp) rw [← mul_sum] at hs have heDist := sum_sdiff hsub (f := fun p : ℕ => (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ)) have heMass := sum_sdiff hsub (f := fun p : ℕ => (1 : ℝ) / p) change (∑ p ∈ P, (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ)) + squaredDistance f (mrtArchimedeanTwist t) n = squaredDistance f (mrtArchimedeanTwist t) N at heDist change (∑ p ∈ P, (1 : ℝ) / p) + (∑ p ∈ primesUpTo n, (1 : ℝ) / p) = (∑ p ∈ primesUpTo N, (1 : ℝ) / p) at heMass dsimp [K] linarith end TwoPointCorrelations end OAI