module public import ConditionalGoldbach.Proofs.CharacterShortPolynomial public import ConditionalGoldbach.Proofs.CharacterSeries public import ConditionalGoldbach.Proofs.DensitySeries public import ConditionalGoldbach.Proofs.PerronDiagonalWeights public import ConditionalGoldbach.Proofs.VariableStripOperators /-! Exact short-sum cancellation in the arithmetic kernel on the Hardy strip. -/ @[expose] public section set_option autoImplicit false noncomputable section open scoped BigOperators ComplexConjugate namespace ConditionalGoldbach /-- The Perron polynomial for the shifted logarithmic derivative at cutoff `N / 2`. -/ def perronShortSum {N : ℕ} (χ : Character N) (s : ℂ) : ℂ := smoothedDirichletPolynomial χ (perronCutoff N) (1 / 2 + s) /-- The signed error used in the Perron truncation of the logarithmic derivative. -/ def perronRemainder {N : ℕ} [NeZero N] (χ : Character N) (s : ℂ) : ℂ := -logDerivative χ s - perronShortSum χ s /-- A summand of the full coprime diagonal Dirichlet series. -/ def coprimeDiagonalTerm (N : ℕ) (w : ℂ) (n : ℕ) : ℂ := if 0 < n ∧ Nat.Coprime n N then (mangoldt n : ℂ) ^ 2 / (n : ℂ) ^ (1 + w) else 0 /-- The diagonal left over after removing the square of the Perron cutoff weight. -/ def perronDiagonalTail (N : ℕ) (w : ℂ) : ℂ := ∑' n, coprimeDiagonalTerm N w n * (1 - (smoothedPerronWeight (perronCutoff N) n : ℂ) ^ 2) /-- The positive diagonal tail obeys the same row-sum bound as the full diagonal. -/ theorem perronDiagonalTail_overlap_sum_le (N n M : ℕ) (hn : 1 ≤ n) (a : ℝ) (ha : 0 < a) : (∑ j ∈ Finset.range M, (1 - smoothedPerronWeight (perronCutoff N) (j + 1) ^ 2) * (diagonalCoefficient N j * (j + 1 : ℕ) ^ (-2 * a) * min ((j + 1 : ℕ) / (n : ℝ)) ((n : ℝ) / (j + 1 : ℕ)))) ≤ 2 * (Real.log 4 + 4) / a := by apply le_trans _ (diagonalCoefficient_overlap_sum_le N n M hn a ha) apply Finset.sum_le_sum intro j _ apply mul_le_of_le_one_left · exact mul_nonneg (mul_nonneg (diagonalCoefficient_nonneg N j) (Real.rpow_nonneg (by positivity) _)) (le_min (by positivity) (by positivity)) · linarith [sq_nonneg (smoothedPerronWeight (perronCutoff N) (j + 1))] private lemma smoothedPolynomialCoeff_pair (N : ℕ) (X : ℝ) (s z : ℂ) (n : ℕ) : (if Nat.Coprime n N then smoothedPolynomialCoeff X (1 / 2 + s) n * conj (smoothedPolynomialCoeff X (1 / 2 + z) n) else 0) = coprimeDiagonalTerm N (s + conj z) n * (smoothedPerronWeight X n : ℂ) ^ 2 := by by_cases hn : 0 < n · by_cases hc : Nat.Coprime n N · have hn' : (n : ℂ) ≠ 0 := by exact_mod_cast hn.ne' simp only [coprimeDiagonalTerm, hn, hc, and_self, ite_true, smoothedPolynomialCoeff, map_mul, Complex.conj_ofReal, conj_natCast_cpow, map_neg, map_add, map_div₀, map_one, map_ofNat] rw [div_eq_mul_inv ((mangoldt n : ℂ) ^ 2) _, ← Complex.cpow_neg] have he : -(1 + (s + conj z)) = -(1 / 2 + s) + -(1 / 2 + conj z) := by ring rw [he, Complex.cpow_add _ _ hn'] ring · simp [coprimeDiagonalTerm, hc] · have hz : n = 0 := by omega subst n simp [smoothedPolynomialCoeff, coprimeDiagonalTerm, mangoldt] /-- The short Gram kernel plus its explicit diagonal tail equals the full diagonal. Only the diagonal series needs a convergence hypothesis. -/ theorem perronShortSum_pairing_add_tail (N : ℕ) [NeZero N] (hN : Even N) (hN4 : 4 ≤ N) (s z : ℂ) (hw : 0 < (s + conj z).re) : (2 / (N.totient : ℂ)) * (∑ χ ∈ oddCharacters N, perronShortSum χ s * conj (perronShortSum χ z)) + perronDiagonalTail N (s + conj z) = diagonalSeries N (s + conj z) := by let w := s + conj z let X := perronCutoff N let f := coprimeDiagonalTerm N w let g := fun n => f n * (smoothedPerronWeight X n : ℂ) ^ 2 have hf : Summable f := by apply Summable.of_norm simpa only [f, coprimeDiagonalTerm, apply_ite norm, norm_zero] using diagonalSeries_summable N hw have hg0 (n : ℕ) (hn : n ∉ Finset.range (⌊X⌋₊ + 1)) : g n = 0 := by have hfloor : ⌊X⌋₊ < n := by simp only [Finset.mem_range] at hn; omega have hNreal : (4 : ℝ) ≤ N := by exact_mod_cast hN4 have hX : 1 < X := by dsimp [X, perronCutoff]; linarith simp [g, smoothedPerronWeight_eq_zero_of_le hX n (Nat.lt_of_floor_lt hfloor).le] have hg : Summable g := summable_of_ne_finset_zero hg0 have hp : (2 / (N.totient : ℂ)) * (∑ χ ∈ oddCharacters N, perronShortSum χ s * conj (perronShortSum χ z)) = ∑' n, g n := by unfold perronShortSum perronCutoff rw [smoothed_polynomial_odd_pairing N hN hN4, tsum_eq_sum hg0] exact Finset.sum_congr rfl (fun n _ => smoothedPolynomialCoeff_pair N X s z n) have ht : perronDiagonalTail N w = ∑' n, (f n - g n) := by apply tsum_congr intro n dsimp only [g, f, X] ring change _ + perronDiagonalTail N w = ∑' n, f n rw [hp, ht, hf.tsum_sub hg] ring /-- The two mixed Perron terms and the pure error Gram term, before Hardy weighting. -/ def perronErrorKernel (N : ℕ) [NeZero N] (s z : ℂ) : ℂ := (2 / (N.totient : ℂ)) * ∑ χ ∈ oddCharacters N, (perronShortSum χ s * conj (perronRemainder χ z) + perronRemainder χ s * conj (perronShortSum χ z) + perronRemainder χ s * conj (perronRemainder χ z)) /-- On the strip subtracting the full diagonal leaves the three error products minus the explicit diagonal tail. -/ theorem characterKernel_sub_diagonal_perron (N : ℕ) [NeZero N] (hN : Even N) (hN4 : 4 ≤ N) (s z : ℂ) (hw : 0 < (s + conj z).re) : characterKernel N s (conj z) - diagonalSeries N (s + conj z) = perronErrorKernel N s z - perronDiagonalTail N (s + conj z) := by rw [← perronShortSum_pairing_add_tail N hN hN4 s z hw] simp only [characterKernel, perronErrorKernel, Complex.conj_conj] rw [← sub_sub, ← mul_sub, ← Finset.sum_sub_distrib] apply congrArg (fun k : ℂ => 2 / (N.totient : ℂ) * k - perronDiagonalTail N (s + conj z)) apply Finset.sum_congr rfl intro χ _ simp only [perronRemainder, map_sub, map_neg] ring /-- Matrix coefficients of the actual residual operator between evaluation vectors, with both mixed terms, the diagonal tail and the model retained. -/ theorem residualOperator_pairing_perron (N : ℕ) [NeZero N] (hN : Even N) (hN4 : 4 ≤ N) (hGRH : GRH N) {a : ℝ} (ha0 : 0 < a) (ha : a < beta) (s z : ℂ) (hs : s ∈ strip a beta) (hz : z ∈ strip a beta) : paperInner (residualOperator ha N (evaluationVector z)) (evaluationVector s) = (perronErrorKernel N s z - perronDiagonalTail N (s + conj z) - continuedModel N s (conj z)) / ((1 + s) * (1 + conj z)) := by have hw : 0 < (s + conj z).re := by rw [Complex.add_re, Complex.conj_re] linarith [hs.1, hz.1] rw [← residualOperator_pairing_at a N ha0 hN4 hGRH ha s z hs hz, weightedKernel, residual, characterKernel_sub_diagonal_perron N hN hN4 s z hw] end ConditionalGoldbach