import Mathlib.NumberTheory.LSeries.HurwitzZetaEven/-! An explicit weight-one theta candidate for the global continuation.The Mellin transform is entire and symmetric; agreement with the cubic Eulerproduct is a separate arithmetic identity. -/noncomputable sectionopen Real HurwitzZeta Asymptotics Filter Set MeasureTheory Topologynamespace CubicPrimeRacenamespace Theta/-- θ(d²x), with θ(x) = ∑_{n∈ℤ} exp(−πn²x). -/def theta (d x : ℝ) := evenKernel 0 (d^2*x)private theorem inversion {d x : ℝ} (hd : 0 < d) (hx : 0 < x) :theta d (1/x) = (Real.sqrt x / d) * theta d⁻¹ x := byunfold thetarw [evenKernel_functional_equation 0 (d^2*(1/x)), ← evenKernel_eq_cosKernel_of_zero,← Real.sqrt_eq_rpow, Real.sqrt_mul (sq_nonneg d), Real.sqrt_sq hd.le,one_div x, Real.sqrt_inv]congr 1 <;> field_simpprivate theorem continuous_theta {d : ℝ} (hd : 0 < d) : ContinuousOn (theta d) (Ioi 0) :=(continuousOn_evenKernel 0).comp (by fun_prop) (fun x hx => mul_pos (sq_pos_of_pos hd) hx)private theorem rapid_theta {d : ℝ} (hd : 0 < d) (r : ℝ) :(fun x => theta d x - 1) =O[atTop] (fun x : ℝ => x^r) := byobtain ⟨c,hc,h⟩ := isBigO_atTop_evenKernel_sub 0simp only [if_true] at hhave hlim : Tendsto (fun x : ℝ => d^2*x) atTop atTop :=tendsto_id.const_mul_atTop (sq_pos_of_pos hd)have h' := h.comp_tendsto hlimhave he := (isLittleO_exp_neg_mul_rpow_atTop (mul_pos hc (sq_pos_of_pos hd)) r).isBigOapply h'.transconvert he using 1funext x; change Real.exp (-c * (d^2*x)) = _congr 1; ringprivate def prodTheta (d e x : ℝ) := theta d x * theta e xprivate def block (d e x : ℝ) :=prodTheta d e x + (d*e)⁻¹ * prodTheta d⁻¹ e⁻¹ xprivate def blockLimit (d e : ℝ) := 1+(d*e)⁻¹private def centered (d e x : ℝ) := block d e x - blockLimit d eprivate theorem block_inv {d e x : ℝ} (hd : 0 < d) (he : 0 < e) (hx : 0 < x) :block d e (1/x) = x * block d e x := byunfold block prodThetarw [inversion hd hx, inversion he hx, inversion (inv_pos.mpr hd) hx, inversion (inv_pos.mpr he) hx]simp only [inv_inv]have hsq := Real.sq_sqrt hx.lefield_simplinear_combination (norm := ring_nf)(d*e*theta d x*theta e x + theta d⁻¹ x*theta e⁻¹ x)*hsqprivate theorem rapid_prod {d e : ℝ} (hd : 0 < d) (he : 0 < e) (r : ℝ) :(fun x => prodTheta d e x - 1) =O[atTop] (fun x : ℝ => x^r) := byhave h := (rapid_theta hd r).mul (rapid_theta he 0)simp only [Real.rpow_zero, mul_one] at hconvert (h.add (rapid_theta hd r)).add (rapid_theta he r) using 1funext x; dsimp [prodTheta]; ringprivate theorem rapid_centered {d e : ℝ} (hd : 0 < d) (he : 0 < e) (r : ℝ) :(fun x => centered d e x) =O[atTop] (fun x : ℝ => x^r) := byhave h := (rapid_prod hd he r).add((rapid_prod (inv_pos.mpr hd) (inv_pos.mpr he) r).const_mul_left ((d*e)⁻¹))convert h using 1funext x; dsimp [centered, block, blockLimit]; ringprivate theorem continuous_centered {d e : ℝ} (hd : 0 < d) (he : 0 < e) :ContinuousOn (centered d e) (Ioi 0) := byunfold centered block prodThetaexact (((continuous_theta hd).mul (continuous_theta he)).add(continuousOn_const.mul ((continuous_theta (inv_pos.mpr hd)).mul (continuous_theta (inv_pos.mpr he))))).sub continuousOn_constprivate def combination (f : ℝ → ℝ → ℝ) (d : ℝ) :=(f d (2*d⁻¹) + f (2*d) d⁻¹ - 2*f (2*d) (2*d⁻¹) - (1/4)*f d d⁻¹)/2/-- d² = 1/√27 gives the determinant-27 scaling of the discriminant −108binary forms. The factor 1/2 normalizes the first Fourier coefficient. -/def scale : ℝ := (Real.sqrt (Real.sqrt 27))⁻¹def kernel (x : ℝ) := combination (fun d e => centered d e x) scaleprivate theorem hscale : 0 < scale := by unfold scale; positivityprivate theorem constant_cancels {d : ℝ} (hd : d ≠ 0) : combination blockLimit d = 0 := bydsimp [combination, blockLimit]field_simp; ringprivate theorem kernel_uncentered (x : ℝ) : kernel x = combination (fun d e => block d e x) scale := byhave h := constant_cancels hscale.ne'dsimp only [kernel, combination, centered] at *linariththeorem kernel_inversion {x : ℝ} (hx : 0 < x) : kernel (1/x) = x * kernel x := byrw [kernel_uncentered, kernel_uncentered]dsimp only [combination]have hd := hscalerw [block_inv hd (by positivity) hx, block_inv (by positivity) (inv_pos.mpr hd) hx,block_inv (by positivity) (by positivity) hx, block_inv hd (inv_pos.mpr hd) hx]ringprivate theorem kernel_rapid (r : ℝ) :kernel =O[atTop] (fun x : ℝ => x^r) := byhave hd := hscalehave h1 := rapid_centered hd (show 0 < 2*scale⁻¹ by positivity) rhave h2 := rapid_centered (show 0 < 2*scale by positivity) (inv_pos.mpr hd) rhave h3 := rapid_centered (show 0 < 2*scale by positivity) (show 0 < 2*scale⁻¹ by positivity) rhave h4 := rapid_centered hd (inv_pos.mpr hd) rconvert (((h1.add h2).sub (h3.const_mul_left 2)).sub (h4.const_mul_left (1/4))).const_mul_left (1/2) using 1funext x; dsimp [kernel, combination]; ringprivate theorem kernel_continuous : ContinuousOn kernel (Ioi 0) := byhave hd := hscalehave h1 := continuous_centered hd (show 0 < 2*scale⁻¹ by positivity)have h2 := continuous_centered (show 0 < 2*scale by positivity) (inv_pos.mpr hd)have h3 := continuous_centered (show 0 < 2*scale by positivity) (show 0 < 2*scale⁻¹ by positivity)have h4 := continuous_centered hd (inv_pos.mpr hd)exact ((((h1.add h2).sub (continuousOn_const.mul h3)).sub (continuousOn_const.mul h4))).div_const 2private def fePair : StrongFEPair ℂ wheref := fun x => (kernel x : ℂ)g := fun x => (kernel x : ℂ)k := 1ε := 1f₀ := 0g₀ := 0hk := zero_lt_onehε := one_ne_zerohf₀ := rflhg₀ := rflhf_int := (Complex.continuous_ofReal.comp_continuousOn kernel_continuous).locallyIntegrableOn measurableSet_Ioihg_int := (Complex.continuous_ofReal.comp_continuousOn kernel_continuous).locallyIntegrableOn measurableSet_Ioih_feq := fun x hx => by rw [kernel_inversion hx]; simphf_top := fun r => by simpa using (Complex.isBigO_ofReal_left.mpr (kernel_rapid r))hg_top := fun r => by simpa using (Complex.isBigO_ofReal_left.mpr (kernel_rapid r))/-- The Mellin transform of the explicit theta kernel. -/def completion : ℂ → ℂ := fePair.Λtheorem completion_eq_mellin : completion = mellin (fun x => (kernel x : ℂ)) := rfltheorem entire_completion : Differentiable ℂ completion := fePair.differentiable_Λtheorem reflection (s : ℂ) : completion (1-s) = completion s := bysimpa [completion, StrongFEPair.Λ, StrongFEPair.symm, WeakFEPair.symm, fePair] using fePair.functional_equation send Thetaend CubicPrimeRace#print axioms CubicPrimeRace.Theta.kernel_inversion#print axioms CubicPrimeRace.Theta.entire_completion#print axioms CubicPrimeRace.Theta.reflection