module public import ConditionalGoldbach.Proofs.ResidualKernelBound public import ConditionalGoldbach.Proofs.SpectralTraceBounds public import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals /-! Truncation in both spectral height variables before compression to the Hardy space. -/ @[expose] public section set_option autoImplicit false noncomputable section open MeasureTheory Filter Set Complex open scoped Topology BigOperators ComplexConjugate namespace ConditionalGoldbach namespace ResidualAverage abbrev BoundarySquareIntegrable (a b : ℝ) (K : ℂ → ℂ → ℂ) : Prop := ∀ x ∈ ({a,b} : Finset ℝ), ∀ y ∈ ({a,b} : Finset ℝ), MemLp (fun p : ℝ × ℝ => K (line x p.1) (line y p.2)) 2 volume /-- Restrict both spectral heights to the square of radius `H`. -/ def windowKernel (H : ℝ) (K : ℂ → ℂ → ℂ) (s z : ℂ) : ℂ := if |s.im| ≤ H ∧ |z.im| ≤ H then K s z else 0 lemma windowKernel_mem {a b : ℝ} {K : ℂ → ℂ → ℂ} (hK : BoundarySquareIntegrable a b K) (H : ℝ) : BoundarySquareIntegrable a b (windowKernel H K) := by intro x hx y hy let S : Set (ℝ × ℝ) := {p | |p.1| ≤ H ∧ |p.2| ≤ H} have hm : MeasurableSet S := (isClosed_le continuous_fst.abs continuous_const).measurableSet.inter (isClosed_le continuous_snd.abs continuous_const).measurableSet have h := (hK x hx y hy).indicator hm.nullMeasurableSet refine MemLp.ae_eq ?_ h filter_upwards [] with p have hx' : (line x p.1).im = p.1 := by simp [line] have hy' : (line y p.2).im = p.2 := by simp [line] by_cases hp : |p.1| ≤ H ∧ |p.2| ≤ H · rw [Set.indicator_of_mem (show p ∈ S from hp)] simp only [windowKernel, hx', hy', ite_eq_left hp] · rw [Set.indicator_of_notMem (show p ∉ S from hp)] simp only [windowKernel, hx', hy', ite_eq_right hp] /-- Compress the masked boundary operator. The masked kernel only needs to be square integrable. -/ def windowOperator {a b : ℝ} (hab : a < b) (K : ℂ → ℂ → ℂ) (hK : BoundarySquareIntegrable a b K) (H : ℝ) : HardySpace a b →L[ℂ] HardySpace a b := hardyBoundaryCompression hab (boundaryKernelOperator a b (windowKernel H K) (windowKernel_mem hK H)) private lemma l2KernelOperator_sub_apply {K J : ℝ × ℝ → ℂ} (hK : MemLp K 2 (volume.prod volume)) (hJ : MemLp J 2 (volume.prod volume)) (f : BoundaryL2) : l2KernelOperator (hK.sub hJ) f = l2KernelOperator hK f - l2KernelOperator hJ f := by apply ext_inner_left ℂ intro g rw [inner_sub_right, l2KernelOperator_pairing (hK.sub hJ), l2KernelOperator_pairing hK, l2KernelOperator_pairing hJ, ← integral_sub (l2Kernel_pairing_integrable hK g f) (l2Kernel_pairing_integrable hJ g f)] apply integral_congr_ae filter_upwards [] with p simp only [Pi.sub_apply] ring private lemma boundaryKernelOperator_sub {a b : ℝ} {K J : ℂ → ℂ → ℂ} (hK : BoundarySquareIntegrable a b K) (hJ : BoundarySquareIntegrable a b J) : boundaryKernelOperator a b (fun s z => K s z - J s z) (fun x hx y hy => (hK x hx y hy).sub (hJ x hx y hy)) = boundaryKernelOperator a b K hK - boundaryKernelOperator a b J hJ := by apply ContinuousLinearMap.ext intro f have row (x : ℝ) (hx : x ∈ ({a,b} : Finset ℝ)) : l2KernelOperator ((hK x hx a (by simp)).sub (hJ x hx a (by simp))) f.fst + l2KernelOperator ((hK x hx b (by simp)).sub (hJ x hx b (by simp))) f.snd = (l2KernelOperator (hK x hx a (by simp)) f.fst + l2KernelOperator (hK x hx b (by simp)) f.snd) - (l2KernelOperator (hJ x hx a (by simp)) f.fst + l2KernelOperator (hJ x hx b (by simp)) f.snd) := by rw [l2KernelOperator_sub_apply (hK x hx a (by simp)) (hJ x hx a (by simp)) f.fst, l2KernelOperator_sub_apply (hK x hx b (by simp)) (hJ x hx b (by simp)) f.snd] abel apply WithLp.ofLp_injective 2 exact Prod.ext (row a (by simp)) (row b (by simp)) private lemma compression_energy_bound {a b : ℝ} (hab : a < b) (K : ℂ → ℂ → ℂ) (hK : BoundarySquareIntegrable a b K) : ‖hardyBoundaryCompression hab (boundaryKernelOperator a b K hK)‖ ^ 2 ≤ BoundaryKernelSquareIntegral a b K := by obtain ⟨hHS, he⟩ := boundaryKernelOperator_hilbertSchmidt a b hab.ne K hK (Classical.choice boundaryL2_exists_nat_hilbertBasis) rw [← he] exact (sq_le_sq₀ (norm_nonneg _) (hsNorm_nonneg _)).2 ((hardyBoundaryCompression_norm_le hab _).trans hHS.norm_le_hsNorm) /-- The energy of the retained kernel bounds the square of the window operator norm. -/ theorem windowOperator_energy_bound {a b : ℝ} (hab : a < b) (K : ℂ → ℂ → ℂ) (hK : BoundarySquareIntegrable a b K) (H : ℝ) : ‖windowOperator hab K hK H‖ ^ 2 ≤ BoundaryKernelSquareIntegral a b (windowKernel H K) := compression_energy_bound hab _ (windowKernel_mem hK H) /-- All four boundary pairs contribute to the omitted energy. Within each pair the omitted region includes each of the two one-sided tails. -/ theorem window_error_le_tail_energy {a b : ℝ} (hab : a < b) (K : ℂ → ℂ → ℂ) (hK : BoundarySquareIntegrable a b K) (H : ℝ) : ‖hardyBoundaryCompression hab (boundaryKernelOperator a b K hK) - windowOperator hab K hK H‖ ^ 2 ≤ BoundaryKernelSquareIntegral a b (fun s z => K s z - windowKernel H K s z) := by let hW := windowKernel_mem hK H have he := boundaryKernelOperator_sub hK hW have hc (B W : BoundaryL2Pair →L[ℂ] BoundaryL2Pair) : hardyBoundaryCompression hab B - hardyBoundaryCompression hab W = hardyBoundaryCompression hab (B-W) := by apply ContinuousLinearMap.ext intro f exact (map_sub (hardyTraceIsometry hab).toContinuousLinearMap.adjoint _ _).symm unfold windowOperator rw [hc, ← he] exact compression_energy_bound hab _ _ private def decay (t : ℝ) : ℝ := (1 + |t|) ^ (-(3/2 : ℝ)) private def tailDecay (H t : ℝ) : ℝ := if H < |t| then decay t else 0 private lemma tailDecay_integrable (H : ℝ) : Integrable (tailDecay H) := by have hs : MeasurableSet {t : ℝ | H < |t|} := (isOpen_lt continuous_const continuous_abs).measurableSet exact hardy_decay_integrable.indicator hs private lemma integral_tailDecay {H : ℝ} (hH : 0 < H) : (∫ t, tailDecay H t) ≤ 4 * H ^ (-(1/2 : ℝ)) := by let f := fun x : ℝ => (1+x)^(-(3/2 : ℝ)) have he : (∫ t, tailDecay H t) = 2 * ∫ t in Ioi H, f t := by change (∫ t : ℝ, (Ioi H).indicator f |t|) = _ rw [integral_comp_abs, setIntegral_indicator measurableSet_Ioi, inter_eq_right.mpr (Ioi_subset_Ioi hH.le)] have hfi : IntegrableOn f (Ioi H) := by rw [show f = (fun t : ℝ => (t+1)^(-(3/2 : ℝ))) by funext t; dsimp only [f]; rw [add_comm 1 t]] exact integrableOn_add_rpow_Ioi_of_lt (by norm_num : (-(3/2 : ℝ)) < -1) (by linarith : -(1 : ℝ) < H) have hi : (∫ t in Ioi H, f t) ≤ ∫ t in Ioi H, t ^ (-(3/2 : ℝ)) := by apply setIntegral_mono_on hfi (integrableOn_Ioi_rpow_of_lt (by norm_num) hH) measurableSet_Ioi intro t ht exact Real.rpow_le_rpow_of_nonpos (hH.trans ht) (by linarith : t ≤ 1+t) (by norm_num) rw [he] apply (mul_le_mul_of_nonneg_left hi (by norm_num : (0 : ℝ) ≤ 2)).trans rw [integral_Ioi_rpow_of_lt (by norm_num) hH, show -(3/2 : ℝ) + 1 = -(1/2 : ℝ) by norm_num] ring_nf exact le_rfl private lemma window_tail_integral_bound {a b H A : ℝ} (hab : a < b) (hH : 0 < H) (hA : 0 ≤ A) (K : ℂ → ℂ → ℂ) (hK : BoundarySquareIntegrable a b K) (h : ∀ x ∈ Icc a b, ∀ y ∈ Icc a b, ∀ t u : ℝ, ‖K (line x t) (line y u)‖^2 ≤ A * decay t * decay u) : BoundaryKernelSquareIntegral a b (fun s z => K s z - windowKernel H K s z) ≤ 32 * A * (∫ t, decay t) * H ^ (-(1/2 : ℝ)) := by let F (p : ℝ × ℝ) := A * (tailDecay H p.1 * decay p.2 + decay p.1 * tailDecay H p.2) have hd : Integrable decay := hardy_decay_integrable have ht := tailDecay_integrable H have hF : Integrable F volume := by simpa only [F, Pi.add_apply, Measure.volume_eq_prod] using ((ht.mul_prod hd).add (hd.mul_prod ht)).const_mul A have hFi : (∫ p : ℝ × ℝ, F p) ≤ 8 * A * (∫ t, decay t) * H ^ (-(1/2 : ℝ)) := by dsimp only [F] rw [Measure.volume_eq_prod, integral_const_mul, integral_add (ht.mul_prod hd) (hd.mul_prod ht), integral_prod_mul, integral_prod_mul] have hdpos : 0 ≤ ∫ t, decay t := integral_nonneg (fun t => by unfold decay; positivity) have hmul := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (integral_tailDecay hH) hdpos) hA linarith only [hmul] have hmem {x : ℝ} (hx : x ∈ ({a,b} : Finset ℝ)) : x ∈ Icc a b := by simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl <;> exact ⟨by linarith, by linarith⟩ let W := windowKernel H K have hW := windowKernel_mem hK H have hi (x : ℝ) (hx : x ∈ ({a,b} : Finset ℝ)) (y : ℝ) (hy : y ∈ ({a,b} : Finset ℝ)) : (∫ t : ℝ, ∫ u : ℝ, ‖K (line x t) (line y u) - W (line x t) (line y u)‖ ^ 2) ≤ 8 * A * (∫ t, decay t) * H ^ (-(1/2 : ℝ)) := by have hdiff := ((hK x hx y hy).sub (hW x hx y hy)).norm.integrable_sq calc _ = ∫ p : ℝ × ℝ, ‖K (line x p.1) (line y p.2) - W (line x p.1) (line y p.2)‖ ^ 2 := by simpa only [Pi.sub_apply, W, Measure.volume_eq_prod] using (integral_prod _ hdiff).symm _ ≤ ∫ p : ℝ × ℝ, F p := by apply integral_mono hdiff hF rintro ⟨t,u⟩ have hb := h x (hmem hx) y (hmem hy) t u have hpos : 0 ≤ A * decay t * decay u := (sq_nonneg _).trans hb have hx' : (line x t).im = t := by simp [line] have hy' : (line y u).im = u := by simp [line] by_cases hv : |t| ≤ H <;> by_cases hu : |u| ≤ H <;> simp [F, windowKernel, tailDecay, hx', hy', ← not_le, hv, hu] <;> nlinarith only [hb, hpos] _ ≤ _ := hFi unfold BoundaryKernelSquareIntegral calc _ ≤ ∑ x ∈ ({a,b} : Finset ℝ), ∑ y ∈ ({a,b} : Finset ℝ), 8 * A * (∫ t, decay t) * H ^ (-(1/2 : ℝ)) := Finset.sum_le_sum fun x hx => Finset.sum_le_sum fun y hy => hi x hx y hy _ = _ := by simp only [Finset.sum_pair hab.ne]; ring theorem residual_blocks (N : ℕ) [NeZero N] (hlarge : Real.exp 10 < (N : ℝ)) (hGRH : GRH N) : BoundarySquareIntegrable (alpha N) beta (weightedKernel N) := (residualOperator_spec_at _ N (alpha_pos_at N (large_parameters hlarge).1 1 zero_lt_one) (large_parameters hlarge).1 hGRH (large_parameters hlarge).2.2).1 /-- The actual full residual on its standard strip with the two boundary heights truncated. -/ def windowResidualOperator (N : ℕ) [NeZero N] (hlarge : Real.exp 10 < (N : ℝ)) (hGRH : GRH N) (H : ℝ) := windowOperator (large_parameters hlarge).2.2 (weightedKernel N) (residual_blocks N hlarge hGRH) H private lemma residual_eq_compression (N : ℕ) [NeZero N] (hlarge : Real.exp 10 < (N : ℝ)) (hGRH : GRH N) : residualOperator (large_parameters hlarge).2.2 N = hardyBoundaryCompression (large_parameters hlarge).2.2 (boundaryKernelOperator _ beta (weightedKernel N) (residual_blocks N hlarge hGRH)) := by obtain ⟨hN, _, hab⟩ := large_parameters hlarge have ha := alpha_pos_at N hN 1 zero_lt_one obtain ⟨L,Z,hL,hZ,hlog,hζ⟩ := arithmeticKernel_growth_inputs_at _ N ha hN hGRH hab have hcol := (weightedKernel_inputs_of_growth_at _ N ha hN hGRH hab L Z hL hZ hlog hζ).2 exact kernelOperator_eq_boundaryCompression hab N _ (weightedKernel_hermitian N) _ hcol /-- A uniform squared operator-norm error for every positive spectral height. The omitted region includes points where only one height exceeds the cutoff. -/ theorem windowResidual_error_height : ∃ C : ℝ, 0 ≤ C ∧ ∀ N : ℕ, ∀ (_ : NeZero N), Even N → ∀ hlarge : Real.exp 10 < (N : ℝ), ∀ hGRH : GRH N, ∀ H : ℝ, 0 < H → ‖residualOperator (large_parameters hlarge).2.2 N - windowResidualOperator N hlarge hGRH H‖ ^ 2 ≤ C * Real.log N ^ 16 * H ^ (-(1 / 2 : ℝ)) := by obtain ⟨A, hA, hbound⟩ := weightedKernel_standard_height_bound have hd : 0 ≤ ∫ t, decay t := integral_nonneg (fun _ => by unfold decay; positivity) refine ⟨32*A*(∫ t, decay t), by positivity, ?_⟩ intro N _ he hlarge hGRH H hH obtain ⟨_, hL, hab⟩ := large_parameters hlarge rw [residual_eq_compression N hlarge hGRH] apply (window_error_le_tail_energy hab _ (residual_blocks N hlarge hGRH) H).trans calc _ ≤ 32 * (A * Real.log N ^ 16) * (∫ t, decay t) * H ^ (-(1 / 2 : ℝ)) := window_tail_integral_bound hab hH (mul_nonneg hA.le (pow_nonneg hL.le 16)) (weightedKernel N) (residual_blocks N hlarge hGRH) (hbound N inferInstance he hlarge hGRH) _ = _ := by ring /-- At height `log(N)^36` the squared error is at most `C / log(N)^2`. -/ theorem windowResidual_error_log : ∃ C : ℝ, 0 ≤ C ∧ ∀ N : ℕ, ∀ (_ : NeZero N), Even N → ∀ hlarge : Real.exp 10 < (N : ℝ), ∀ hGRH : GRH N, ‖residualOperator (large_parameters hlarge).2.2 N - windowResidualOperator N hlarge hGRH (Real.log N ^ 36)‖ ^ 2 ≤ C / Real.log N ^ 2 := by obtain ⟨C, hC, herr⟩ := windowResidual_error_height refine ⟨C, hC, ?_⟩ intro N _ he hlarge hGRH let L := Real.log (N : ℝ) have hL : 0 < L := (large_parameters hlarge).2.1 have hp : (L^36) ^ (-(1/2 : ℝ)) = (L^18)⁻¹ := by rw [← Real.rpow_natCast_mul hL.le, show ((36 : ℕ) : ℝ) * -(1/2 : ℝ) = -((18 : ℕ) : ℝ) by norm_num, Real.rpow_neg hL.le, Real.rpow_natCast] calc _ ≤ C * L ^ 16 * (L ^ 36) ^ (-(1 / 2 : ℝ)) := herr N inferInstance he hlarge hGRH (L ^ 36) (pow_pos hL _) _ = C / L ^ 2 := by rw [hp, ← div_eq_mul_inv] exact (div_eq_div_iff (pow_ne_zero 18 hL.ne') (pow_ne_zero 2 hL.ne')).2 (by ring) end ResidualAverage end ConditionalGoldbach