module public import ConditionalGoldbach.Proofs.ResidualAverage public import ConditionalGoldbach.Proofs.ResidualWindow public import ConditionalGoldbach.Proofs.SingularLower /-! Transfer of density-one convergence and of dyadic mean estimates from a growing window. -/ @[expose] public section set_option autoImplicit false noncomputable section open MeasureTheory Filter open scoped Topology BigOperators namespace ConditionalGoldbach.ResidualAverage /-- The family hypothesis is only needed at large even moduli. -/ abbrev FamilyGRH := ∀ N : ℕ, Even N → Real.exp 10 < (N : ℝ) → GRH N /-- The normalized norm after truncation to the square of height `log(N)^36`. -/ def windowRatio (hF : FamilyGRH) (N : ℕ) : ℝ := if h : Real.exp 10 < (N : ℝ) ∧ Even N then letI : NeZero N := ⟨by have := (large_parameters h.1).1; omega⟩ ‖windowResidualOperator N h.1 (hF N h.2 h.1) (Real.log N ^ 36)‖ / singularSeries N else 0 /-- Four squared integrals of the centered kernel on the window, divided by the squared singular series. The subtraction in the residual is performed before squaring. -/ def windowEnergyRatio (N : ℕ) : ℝ := if h : Real.exp 10 < (N : ℝ) ∧ Even N then letI : NeZero N := ⟨by have := (large_parameters h.1).1; omega⟩ BoundaryKernelSquareIntegral (alpha N) beta (windowKernel (Real.log N ^ 36) (weightedKernel N)) / singularSeries N ^ 2 else 0 private lemma windowRatio_nonneg (hF : FamilyGRH) (N : ℕ) : 0 ≤ windowRatio hF N := by unfold windowRatio split_ifs · exact div_nonneg (norm_nonneg _) (singularSeries_pos N).le · exact le_rfl private lemma windowRatio_sq_le_energy (hF : FamilyGRH) (N : ℕ) : windowRatio hF N ^ 2 ≤ windowEnergyRatio N := by unfold windowRatio windowEnergyRatio split_ifs with h · rw [div_pow] apply div_le_div_of_nonneg_right _ (sq_nonneg _) apply windowOperator_energy_bound · norm_num private lemma ratio_difference (hF : FamilyGRH) : ∃ B : ℝ, ∀ N : ℕ, Even N → Real.exp 10 < (N : ℝ) → |residualRatio N - windowRatio hF N| ≤ B / Real.log N := by obtain ⟨C,hC,herr⟩ := windowResidual_error_log refine ⟨Real.sqrt C, ?_⟩ intro N he hl obtain ⟨hN, hL, hab⟩ := large_parameters hl have : NeZero N := ⟨by omega⟩ let T := residualOperator hab N let W := windowResidualOperator N hl (hF N he hl) (Real.log N ^ 36) have hb : ‖T - W‖ ≤ Real.sqrt C / Real.log N := by apply (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp rw [div_pow, Real.sq_sqrt hC] exact herr N inferInstance he hl (hF N he hl) simp only [residualRatio, windowRatio, dite_eq_left hl, dite_eq_left (And.intro hl he)] calc |‖T‖ / singularSeries N - ‖W‖ / singularSeries N| = |‖T‖ - ‖W‖| / singularSeries N := by rw [← sub_div, abs_div, abs_of_pos (singularSeries_pos N)] _ ≤ ‖T-W‖ / singularSeries N := div_le_div_of_nonneg_right (abs_norm_sub_norm_le _ _) (singularSeries_pos N).le _ ≤ ‖T-W‖ := div_le_self (norm_nonneg _) (singularSeries_gt_one N).le _ ≤ _ := hb private lemma transfer_density {p q : ℕ → ℝ} (hclose : ∀ ε : ℝ, 0 < ε → ∃ n : ℕ, ∀ N ≥ n, Even N → |p N - q N| < ε) (hq : DensityOneLimit q) : DensityOneLimit p := by obtain ⟨E, hE, hd, hsmall⟩ := hq refine ⟨E, hE, hd, ?_⟩ intro ε hε obtain ⟨n, hn⟩ := hclose (ε/2) (half_pos hε) obtain ⟨m, hm⟩ := hsmall (ε/2) (half_pos hε) refine ⟨max n m, ?_⟩ intro N hNE hN have h₁ := hn N ((le_max_left ..).trans hN) (hE N hNE).2 have h₂ := hm N hNE ((le_max_right ..).trans hN) linarith [le_abs_self (p N - q N)] /-- The full norm decays on a density-one set exactly when the clipped square mean of the growing-window norms vanishes. -/ theorem residual_iff_window_clippedMean (hF : FamilyGRH) : DensityOneLimit residualRatio ↔ Tendsto (prefixMean fun j => min 1 (windowRatio hF (evenAt j) ^ 2)) atTop (𝓝 0) := by rw [clippedMean_iff (windowRatio_nonneg hF)] obtain ⟨B, hb⟩ := ratio_difference hF have ht : Tendsto (fun N : ℕ => B / Real.log N) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop) have hclose (ε : ℝ) (hε : 0 < ε) : ∃ n : ℕ, ∀ N ≥ n, Even N → |residualRatio N - windowRatio hF N| < ε := by apply eventually_atTop.mp filter_upwards [ht.eventually_lt_const hε, (tendsto_natCast_atTop_atTop (R := ℝ)).eventually_gt_atTop (Real.exp 10)] with N hN hl exact fun he => (hb N he hl).trans_lt hN refine ⟨transfer_density ?_, transfer_density hclose⟩ intro ε hε obtain ⟨n, hn⟩ := hclose ε hε exact ⟨n, fun N hN he => by rw [abs_sub_comm]; exact hn N hN he⟩ /-- Clipped means over all dyadic blocks characterize the full density-one conclusion. -/ theorem residual_iff_window_clippedBlockMean (hF : FamilyGRH) : DensityOneLimit residualRatio ↔ Tendsto (blockMean fun j => min 1 (windowRatio hF (evenAt j) ^ 2)) atTop (𝓝 0) := (residual_iff_window_clippedMean hF).trans (prefixMean_iff_blockMean fun _ => le_min zero_le_one (sq_nonneg _)) /-- A dyadic normalized mean square bound on the growing window suffices for the full norm. -/ theorem residual_of_window_blockMeanSquare (hF : FamilyGRH) (h : Tendsto (blockMean fun j => windowRatio hF (evenAt j) ^ 2) atTop (𝓝 0)) : DensityOneLimit residualRatio := by apply (residual_iff_window_clippedMean hF).mpr apply squeeze_zero _ _ (prefixMean_of_blockMean (fun _ => sq_nonneg _) h) · intro M exact div_nonneg (Finset.sum_nonneg fun _ _ => le_min zero_le_one (sq_nonneg _)) (Nat.cast_nonneg _) · intro M exact div_le_div_of_nonneg_right (Finset.sum_le_sum fun _ _ => min_le_right _ _) (Nat.cast_nonneg _) /-- Averaging the four window energies with the full signed kernel is a sufficient arithmetic input. No interchange of an operator supremum and the average is needed. -/ theorem residual_of_windowEnergy_blockMean (hF : FamilyGRH) (h : Tendsto (blockMean fun j => windowEnergyRatio (evenAt j)) atTop (𝓝 0)) : DensityOneLimit residualRatio := by apply residual_of_window_blockMeanSquare hF apply squeeze_zero _ _ h · intro X exact div_nonneg (Finset.sum_nonneg fun _ _ => sq_nonneg _) (Nat.cast_nonneg _) · intro X exact div_le_div_of_nonneg_right (Finset.sum_le_sum fun _ _ => windowRatio_sq_le_energy hF _) (Nat.cast_nonneg _) end ConditionalGoldbach.ResidualAverage