import PrimeRaceLogDerivative import PrimeRaceTheta import Mathlib.NumberTheory.LSeries.MellinEqDirichlet /-! Differentiate the normalized centered product without assuming the zero-sum identity. Index reflection pairs with multiplicity and keep central entries separate. -/ noncomputable section open Filter Topology Complex namespace CubicPrimeRace /-- The coefficient of (s−2)(s+1) in the product factor for r and 1−r. -/ def pairCoeff (r : ℂ) : ℂ := ((2-r)*(1+r))⁻¹ def pairProduct {ι : Type*} (a : ι → ℂ) (s : ℂ) : ℂ := ∏' i, (1+(s-2)*(s+1)*a i) theorem normalized_pair (r s : ℂ) (h₁ : 2-r ≠ 0) (h₂ : 1+r ≠ 0) : (s-r)*(s-(1-r))/((2-r)*(1+r)) = 1+(s-2)*(s+1)*pairCoeff r := by unfold pairCoeff field_simp ring private theorem scale_diff (s : ℂ) : HasDerivAt (fun z : ℂ => (z-2)*(z+1)) ((s+1)+(s-2)) s := by simpa using (((hasDerivAt_id s).sub_const 2).mul ((hasDerivAt_id s).add_const 1)) private theorem pairProduct_two {ι : Type*} (a : ι → ℂ) : pairProduct a 2 = 1 := by simp [pairProduct] private theorem pairProduct_deriv {ι : Type*} (a : ι → ℂ) (ha : Summable fun i => ‖a i‖) : HasDerivAt (pairProduct a) (3 * ∑' i, a i) 2 := by let K := Metric.closedBall (2:ℂ) 1 let U := Metric.ball (2:ℂ) 1 have hx : (2:ℂ) ∈ U := Metric.mem_ball_self (by norm_num) let P := fun (t : Finset ι) (s : ℂ) => ∏ i ∈ t, (1+(s-2)*(s+1)*a i) have hbound (i : ι) (s : ℂ) (hs : s ∈ K) : ‖(s-2)*(s+1)*a i‖ ≤ 4 * ‖a i‖ := by have h : ‖s-2‖ ≤ 1 := by simpa only [K, Metric.mem_closedBall, dist_eq_norm] using hs have h' : ‖s+1‖ ≤ 4 := by calc _ = ‖(s-2)+3‖ := by congr 1; ring _ ≤ ‖s-2‖+‖(3:ℂ)‖ := norm_add_le _ _ _ ≤ 4 := by rw [Complex.norm_ofNat]; linarith simp only [norm_mul] exact mul_le_mul_of_nonneg_right ((mul_le_mul h h' (norm_nonneg _) (by norm_num)).trans_eq (by norm_num)) (norm_nonneg _) have hu := (ha.mul_left 4).hasProdUniformlyOn_one_add (isCompact_closedBall (2:ℂ) 1) (Filter.Eventually.of_forall hbound) (fun i => by fun_prop) have hc : TendstoLocallyUniformlyOn P (pairProduct a) atTop U := by have hv := (hasProdUniformlyOn_iff_tendstoUniformlyOn.mp hu) K (Set.mem_singleton _) exact (hv.mono Metric.ball_subset_closedBall).tendstoLocallyUniformlyOn have hD : ∀ᶠ t in (atTop : Filter (Finset ι)), DifferentiableOn ℂ (P t) U := .of_forall (fun t => by dsimp [P]; fun_prop) have hd := hc.differentiableOn hD Metric.isOpen_ball have hlim := Complex.logDeriv_tendsto Metric.isOpen_ball ⟨2,hx⟩ hc hD (by rw [pairProduct_two]; exact one_ne_zero) have hfd (t : Finset ι) : logDeriv (P t) 2 = ∑ i ∈ t, 3 * a i := by rw [show P t = fun s : ℂ => ∏ i ∈ t, (1+(s-2)*(s+1)*a i) from rfl, logDeriv_prod t (fun i (s:ℂ) => 1+(s-2)*(s+1)*a i) 2 (by simp) (fun _ _ => by fun_prop)] apply Finset.sum_congr rfl intro i _ have dd := ((scale_diff 2).mul_const (a i)).const_add 1 rw [logDeriv_apply, dd.deriv]; norm_num change Tendsto (fun t => logDeriv (P t) 2) atTop (𝓝 (logDeriv (pairProduct a) 2)) at hlim simp_rw [hfd] at hlim have ht := (ha.of_norm.hasSum.mul_left 3) have hval := tendsto_nhds_unique hlim ht rw [logDeriv_apply, pairProduct_two, div_one] at hval exact hval ▸ (hd.differentiableAt (Metric.isOpen_ball.mem_nhds hx)).hasDerivAt /-- This normalized product has value one at 2. The power records every central zero. Each remaining factor accounts for a reflected pair. -/ def centeredProduct {ι : Type*} (m : ℕ) (r : ι → ℂ) (s : ℂ) : ℂ := ((2*s-1)/3)^m * pairProduct (fun i => pairCoeff (r i)) s private theorem centered_deriv {ι : Type*} (m : ℕ) (r : ι → ℂ) (ha : Summable fun i => ‖pairCoeff (r i)‖) : HasDerivAt (centeredProduct m r) ((m:ℂ)*(2/3) + 3 * ∑' i, pairCoeff (r i)) 2 := by have hc := ((((hasDerivAt_id (2:ℂ)).const_mul 2).sub_const 1).div_const 3).pow m have hp := pairProduct_deriv _ ha have h := hc.mul hp change HasDerivAt (centeredProduct m r) _ 2 at h convert h using 1 rw [pairProduct_two] norm_num theorem paired_identity_of_product {ι : Type*} (m : ℕ) (r : ι → ℂ) (ha : Summable fun i => ‖pairCoeff (r i)‖) (hproduct : (fun s => completedEuler s / completedEuler 2) =ᶠ[𝓝 (2:ℂ)] centeredProduct m r) : ((m:ℂ)*(2/3) + 3 * ∑' i, pairCoeff (r i)) = ((Real.log cubicConductorScale + 1 - Real.eulerMascheroniConstant + ∑' n, eulerTermAtTwo n : ℝ):ℂ) := by have d := (centered_deriv m r ha).congr_of_eventuallyEq hproduct have he := d.deriv rw [deriv_div_const] at he exact he.symm.trans logDeriv_completedEuler_two private theorem centered_two {ι : Type*} (m : ℕ) (r : ι → ℂ) : centeredProduct m r 2 = 1 := by simp only [centeredProduct, pairProduct_two, mul_one] norm_num private theorem reflected_product {ι : Type*} (m : ℕ) (r : ι → ℂ) (z : ℂ) : centeredProduct m r (1-z) = (-1:ℂ)^m * centeredProduct m r z := by simp only [centeredProduct, pairProduct, show (1-z-2)*(1-z+1) = (z-2)*(z+1) by ring, show (2*(1-z)-1)/3 = (-1)*((2*z-1)/3) by ring, mul_pow, mul_assoc] /-- In a genus-one factorization into reflected pairs, the affine exponential has zero slope by the functional equation. This works with central zeros. -/ theorem remove_affine_factor {ι : Type*} (m : ℕ) (r : ι → ℂ) (ha : Summable fun i => ‖pairCoeff (r i)‖) (G : ℂ → ℂ) (A B : ℂ) (hA : A ≠ 0) (hfe : ∀ z, G (1-z) = G z) (hf : ∀ z, G z = A * Complex.exp (B*(z-2)) * centeredProduct m r z) : B = 0 := by let k : ℂ := (-1)^m have hnear := (centered_deriv m r ha).continuousAt.eventually_ne (by rw [centered_two]; exact one_ne_zero : centeredProduct m r 2 ≠ 0) have he : (fun z : ℂ => k * Complex.exp (B*((1-z)-2))) =ᶠ[𝓝 (2:ℂ)] (fun z : ℂ => Complex.exp (B*(z-2))) := by filter_upwards [hnear] with z hz have eq := hfe z rw [hf (1-z), hf z, reflected_product] at eq apply mul_left_cancel₀ hA apply mul_right_cancel₀ hz dsimp [k]; linear_combination eq have atTwo := he.eq_of_nhds change k * Complex.exp (B*((1-2)-2)) = Complex.exp (B*(2-2)) at atTwo have hleft := (((((hasDerivAt_id (2:ℂ)).const_sub 1).sub_const 2).const_mul B).cexp).const_mul k have hright := (((hasDerivAt_id (2:ℂ)).sub_const 2).const_mul B).cexp have e := hleft.unique (hright.congr_of_eventuallyEq he) simp only [sub_self, mul_zero, Complex.exp_zero] at atTwo simp only [id_eq, mul_one, mul_neg, sub_self, mul_zero, Complex.exp_zero, one_mul] at e linear_combination (norm := ring_nf) -(e + B*atTwo)/2 /-- All zero entries separately, as needed in the original budget theorem. -/ def zeroEntries {ι : Type*} (m : ℕ) (r : ι → ℂ) : Fin m ⊕ (ι ⊕ ι) → ℂ := Sum.elim (fun _ => 1/2) (Sum.elim r (fun i => 1-r i)) private theorem weight_nonneg (r : ℂ) (hr : r.re ≤ 1) : 0 ≤ ((2-r)⁻¹).re := by rw [zero_weight_eq] exact div_nonneg (by linarith) (by positivity) set_option maxHeartbeats 600000 in private theorem separate_entries {ι : Type*} (m : ℕ) (r : ι → ℂ) (hs : ∀ i, 0 ≤ (r i).re ∧ (r i).re ≤ 1) (ha : Summable fun i => ‖pairCoeff (r i)‖) : HasSum (fun j => ((2-zeroEntries m r j)⁻¹).re) (((m:ℂ)*(2/3) + 3 * ∑' i, pairCoeff (r i)).re) := by let w := fun z : ℂ => ((2-z)⁻¹).re have hpos (i : ι) : 0 ≤ w (r i) := weight_nonneg _ (hs i).2 have hpos' (i : ι) : 0 ≤ w (1-r i) := by apply weight_nonneg rw [Complex.sub_re, Complex.one_re]; linarith [(hs i).1] have heq (i : ι) : w (r i) + w (1-r i) = (3*pairCoeff (r i)).re := by have h₁ : 2-r i ≠ 0 := by intro h; have hh := congrArg Complex.re h norm_num [Complex.sub_re] at hh; linarith [(hs i).2] have h₂ : 1+r i ≠ 0 := by intro h; have hh := congrArg Complex.re h simp only [Complex.add_re, Complex.one_re, Complex.zero_re] at hh; linarith [(hs i).1] change _ + _ = _ unfold w rw [← Complex.add_re] congr 1 rw [show 2-(1-r i) = 1+r i by ring] unfold pairCoeff; field_simp; ring have hboth := Complex.hasSum_re (ha.of_norm.hasSum.mul_left 3) simp_rw [← heq] at hboth have h₁ : Summable fun i => w (r i) := hboth.summable.of_nonneg_of_le hpos (fun i => le_add_of_nonneg_right (hpos' i)) have h₂ : Summable fun i => w (1-r i) := hboth.summable.of_nonneg_of_le hpos' (fun i => le_add_of_nonneg_left (hpos i)) have htotal := (h₁.hasSum.add h₂.hasSum).unique hboth have hpair : HasSum (fun i : ι ⊕ ι => w (Sum.elim r (fun i => 1-r i) i)) ((3*∑' i, pairCoeff (r i)).re) := by rw [← htotal] exact HasSum.sum (f := fun i : ι ⊕ ι => w (Sum.elim r (fun j => 1-r j) i)) h₁.hasSum h₂.hasSum rw [Complex.add_re] apply HasSum.sum (f := fun j => w (zeroEntries m r j)) _ hpair change HasSum (fun _ : Fin m => w (1/2)) _ convert hasSum_fintype (fun _ : Fin m => w (1/2)) using 1 have hcentral : w (1/2) = (2/3:ℝ) := by have hh : ((2-(1/2:ℂ))⁻¹ : ℂ) = ((2/3:ℝ):ℂ) := by push_cast; norm_num exact congrArg Complex.re hh rw [hcentral] simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] have hh : ((2/3:ℝ):ℂ) = 2/3 := by push_cast; rfl rw [← hh, ← Complex.ofReal_natCast, ← Complex.ofReal_mul, Complex.ofReal_re] /-- Sufficient global inputs for the full zero-sum identity. Neither a logarithmic derivative formula nor an estimate on that derivative is an input. The cubic continuation and its zero factorization still have to be constructed. -/ theorem zero_sum_of_continuation_factorization {ι : Type*} (m : ℕ) (r : ι → ℂ) (hs : ∀ i, 0 ≤ (r i).re ∧ (r i).re ≤ 1) (ha : Summable fun i => ‖pairCoeff (r i)‖) (G : ℂ → ℂ) (A B : ℂ) (germ : G =ᶠ[𝓝 (2:ℂ)] completedEuler) (hfe : ∀ z, G (1-z) = G z) (hf : ∀ z, G z = A * Complex.exp (B*(z-2)) * centeredProduct m r z) : HasSum (fun j => ((2-zeroEntries m r j)⁻¹).re) (Real.log cubicConductorScale + 1 - Real.eulerMascheroniConstant + ∑' n, eulerTermAtTwo n) := by have hA : A = completedEuler 2 := by have he := germ.eq_of_nhds rw [hf 2, centered_two] at he simpa using he have hA' : A ≠ 0 := hA.trans_ne completed_two_ne have hb := remove_affine_factor m r ha G A B hA' hfe hf have hp : (fun z => completedEuler z / completedEuler 2) =ᶠ[𝓝 (2:ℂ)] centeredProduct m r := by filter_upwards [germ] with z hz rw [← hz, hf z, hb, zero_mul, Complex.exp_zero, mul_one, ← hA, mul_div_cancel_left₀ _ hA'] have he := congrArg Complex.re (paired_identity_of_product m r ha hp) rw [Complex.ofReal_re] at he exact he ▸ separate_entries m r hs ha /-- Entire continuation of the Euler germ, if supplied, is unique. -/ theorem unique_entire_continuation {G H : ℂ → ℂ} (hG : Differentiable ℂ G) (hH : Differentiable ℂ H) (gG : G =ᶠ[𝓝 (2:ℂ)] completedEuler) (gH : H =ᶠ[𝓝 (2:ℂ)] completedEuler) : G = H := (hG.differentiableOn.analyticOnNhd isOpen_univ).eq_of_eventuallyEq (hH.differentiableOn.analyticOnNhd isOpen_univ) (gG.trans gH.symm) /-- Mellin identification at any point where the two coefficient expansions agree. Index n stands for the positive Fourier index n+1. -/ theorem theta_equals_euler_of_coefficients {s : ℂ} (hs : 0 < s.re) (a : ℕ → ℂ) (heat : ∀ t : ℝ, 0 < t → HasSum (fun n : ℕ => a n * Real.exp (-(((n:ℝ)+1)/cubicConductorScale)*t)) (Theta.kernel t : ℂ)) (absolute : Summable fun n : ℕ => ‖a n‖ / (((n:ℝ)+1)/cubicConductorScale)^s.re) (dirichlet : HasSum (fun n : ℕ => a n / (((n:ℝ)+1 : ℝ):ℂ)^s) (cubicEuler s)) : Theta.completion s = completedEuler s := by have hQ : 0 < cubicConductorScale := by unfold cubicConductorScale; positivity have h := hasSum_mellin (a := a) (p := fun n : ℕ => ((n:ℝ)+1)/cubicConductorScale) (fun _ => Or.inr (by positivity)) hs heat absolute rw [Theta.completion_eq_mellin] let C : ℂ := Complex.exp ((Real.log cubicConductorScale:ℂ)*s) * Complex.Gamma s apply h.unique change HasSum _ (C * cubicEuler s) convert dirichlet.mul_left C using 1 funext n have hn : 0 < (n:ℝ)+1 := by positivity have he (v : ℝ) (hv : 0 < v) : (v:ℂ)^s = Complex.exp ((Real.log v : ℂ)*s) := by rw [Complex.cpow_def_of_ne_zero (Complex.ofReal_ne_zero.mpr hv.ne'), Complex.ofReal_log hv.le] rw [he _ (div_pos hn hQ), he _ hn, Real.log_div hn.ne' hQ.ne', Complex.ofReal_sub, sub_mul, Complex.exp_sub] dsimp [C]; field_simp /-- Specialization to the explicit theta completion. Its functional equation is proved in PrimeRaceTheta, so it is not a hypothesis here. -/ theorem theta_zero_sum {ι : Type*} (m : ℕ) (r : ι → ℂ) (hs : ∀ i, 0 ≤ (r i).re ∧ (r i).re ≤ 1) (ha : Summable fun i => ‖pairCoeff (r i)‖) (A B : ℂ) (germ : Theta.completion =ᶠ[𝓝 (2:ℂ)] completedEuler) (hf : ∀ z, Theta.completion z = A * Complex.exp (B*(z-2)) * centeredProduct m r z) : HasSum (fun j => ((2-zeroEntries m r j)⁻¹).re) (Real.log cubicConductorScale + 1 - Real.eulerMascheroniConstant + ∑' n, eulerTermAtTwo n) := zero_sum_of_continuation_factorization m r hs ha _ A B germ Theta.reflection hf end CubicPrimeRace #print axioms CubicPrimeRace.normalized_pair #print axioms CubicPrimeRace.paired_identity_of_product #print axioms CubicPrimeRace.remove_affine_factor #print axioms CubicPrimeRace.zero_sum_of_continuation_factorization #print axioms CubicPrimeRace.unique_entire_continuation #print axioms CubicPrimeRace.theta_zero_sum #print axioms CubicPrimeRace.theta_equals_euler_of_coefficients