import OAI.NumberTheory.PrimeGaps.RieszDecay namespace OAI namespace LargePrimeGaps open Complex Real Set MeasureTheory Filter Topology open Complex Filter Topology open Complex Filter Topology MeasureTheory open scoped FourierTransform open Complex Real Set MeasureTheory Filter Topology open Complex Real Set MeasureTheory Filter Topology open Complex Real Set MeasureTheory Filter Topology open scoped FourierTransform open Complex Real Set MeasureTheory Filter Topology open Complex Real Set MeasureTheory Filter Topology open Complex Real Set MeasureTheory Filter Topology lemma primeCharacterError_log_bound (A B : ℝ) (hA : 0 simp rw [heq] have hu := prefix_unsmoothing hx0.le hh0 (show 0≤2*L by positivity) (primeCoefficients χ) (characterMain χ) hcoeff change _≤(E (x+h)+E x)/h+(h+1)*(2*L)+‖characterMain χ‖*h/2 at hu have hδ : ‖characterMain χ‖*h/2≤h := by have := mul_le_mul_of_nonneg_right (characterMain_norm_le χ) hh0.le linarith have htail : (h+1)*(2*L)≤4*h*L := by nlinarith have herr : (E (x+h)+E x)/h ≤ 15*D*x*L^(-A)+3*x*L^(-A) := by calc _ ≤ (5*D*Q*x^2*L^(-a)+3*x)/h := by apply div_le_div_of_nonneg_right _ hh0.le linarith _ ≤ (5*D*(3*L^B)*x^2*L^(-a)+3*x)/h := by gcongr _ = (15*D*L^B*x^2*L^(-a)+3*x)/h := by ring _ = 15*D*x*L^(-A)+3*L^K := by dsimp [h] rw [div_eq_mul_inv,inv_div] have hr : L^B*L^(-a)*L^K=L^(-A) := by rw [←Real.rpow_add hL0,←Real.rpow_add hL0] congr 1 dsimp [a,K] ring field_simp linear_combination 15*D*x*hr _ ≤ _ := by have ht : L^K≤x*L^(-A) := by calc _ = L^(2*A+2)*L^(-A) := by rw [←Real.rpow_add hL0]; congr 1; dsimp [K]; ring _ ≤ _ := mul_le_mul_of_nonneg_right hpower (by positivity) nlinarith [ht] have hsmall : h≤x*L^(-A) := by dsimp [h] rw [div_eq_mul_inv,←Real.rpow_neg hL0.le] exact mul_le_mul_of_nonneg_left (Real.rpow_le_rpow_of_exponent_le hL (show -K≤-A by dsimp [K]; linarith)) hx0.le have htail' : 4*h*L≤4*x*L^(-A) := by calc _ = 4*x*L^(1-K) := by dsimp [h] rw [div_eq_mul_inv,Real.rpow_sub hL0,Real.rpow_one] ring _ ≤ _ := mul_le_mul_of_nonneg_left (Real.rpow_le_rpow_of_exponent_le hL (show 1-K≤-A by dsimp [K]; linarith)) (by positivity) calc _ ≤ (E (x+h)+E x)/h+(h+1)*(2*L)+‖characterMain χ‖*h/2 := hu _ ≤ (15*D*x*L^(-A)+3*x*L^(-A))+4*x*L^(-A)+x*L^(-A) := add_le_add (add_le_add herr (htail.trans htail')) (hδ.trans hsmall) _ = _ := by ring theorem siegelWalfisz : SiegelWalfisz := by intro A B hA hB obtain ⟨M,hM,hb⟩ := primeCharacterError_log_bound A B hA hB have hevent : ∀ᶠ x : ℝ in atTop, 2≤x ∧ 1≤Real.log x ∧ (Real.log x)^(2*A+2)≤x := by filter_upwards [eventually_ge_atTop (2:ℝ),eventually_ge_atTop (Real.exp 1), eventually_log_rpow_le_rpow (2*A+2) (by norm_num : (0:ℝ)<1)] with x hx hex hp refine ⟨hx,?_,by simpa only [Real.rpow_one] using hp⟩ rw [←Real.log_exp (1:ℝ)] exact Real.log_le_log (Real.exp_pos _) hex obtain ⟨x₀,hx₀⟩ := eventually_atTop.mp hevent refine ⟨M,hM,max x₀ 2,by have := le_max_right x₀ (2:ℝ); linarith,?_⟩ intro x hx d hd hdlog χ hχ let : NeZero d := ⟨ne_of_gt hd⟩ obtain ⟨hx2,hlog,hpower⟩ := hx₀ x ((le_max_left _ _).trans hx) exact hb d χ hχ x hx2 hlog hpower hdlog theorem bombieriVinogradov : BombieriVinogradov := bombieriVinogradov_of_siegelWalfisz siegelWalfisz theorem main : ∀ C : ℝ, 0 < C → ∃ c : ℝ, 0 < c ∧ ∃ N₀ : ℕ, ∀ N : ℕ, N₀ ≤ N → c * (N : ℝ) ≤ ((largeGapIndices C N).card : ℝ) := index_density_of_bombieriVinogradov bombieriVinogradov end LargePrimeGaps end OAI