module public import Mathlib.Analysis.Normed.Module.MultipliableUniformlyOn public import ConditionalGoldbach.Proofs.DensityResidue @[expose] public section set_option autoImplicit false noncomputable section open scoped BigOperators ComplexConjugate Topology open MeasureTheory Filter Set Complex namespace ConditionalGoldbach attribute [local instance] Classical.propDecidable def baselineEulerTerm (N p : ℕ) (w : ℂ) : ℂ := 2*densityEulerTerm N p (1+w)-densityEulerTerm N p (1+2*w) lemma baselineEulerTerm_eq (N p : ℕ) (w : ℂ) : 1+baselineEulerTerm N p w = if p.Prime ∧ 2

‖baselineEulerTerm N p w‖) := by have hs := ((LSeriesSummable_one_iff.mpr (by norm_num : (1:ℝ)<(3/2:ℂ).re)).norm).mul_left 9 exact hs.of_nonneg_of_le (fun _ => norm_nonneg _) (fun p => baselineEulerTerm_bound N p w hw) lemma baselineEulerProduct_differentiableOn (N : ℕ) : DifferentiableOn ℂ (fun w => ∏' p, (1+baselineEulerTerm N p w)) {w : ℂ | -(1/4:ℝ) 9*‖LSeries.term 1 (3/2:ℂ) p‖) := ((LSeriesSummable_one_iff.mpr (by norm_num : (1:ℝ)<(3/2:ℂ).re)).norm).mul_left 9 have hu : TendstoLocallyUniformlyOn (fun k w => ∏ p ∈ Finset.range k, (1+baselineEulerTerm N p w)) (fun w => ∏' p, (1+baselineEulerTerm N p w)) atTop {w : ℂ | -(1/4:ℝ) baselineEulerTerm_bound N p w (hKU hw))) (fun p => (baselineEulerTerm_differentiable N p).continuous.continuousOn) exact hh.tendstoUniformlyOn_finsetRange apply hu.differentiableOn _ ho filter_upwards with k apply Differentiable.differentiableOn apply Differentiable.fun_finsetProd intro p hp exact (differentiable_const (1:ℂ)).add (baselineEulerTerm_differentiable N p) lemma baselineProductR_differentiableOn (N : ℕ) : DifferentiableOn ℂ (baselineProductR N) {w : ℂ | -(1/4:ℝ) (∏ p ∈ N.primeFactors, (1-(p:ℂ)^(-1-w)))*(∏' p, (1+baselineEulerTerm N p w)) := by funext w unfold baselineProductR congr 1 exact (tprod_congr (fun p => baselineEulerTerm_eq N p w)).symm rw [he] apply DifferentiableOn.mul _ (baselineEulerProduct_differentiableOn N) apply Differentiable.differentiableOn apply Differentiable.fun_finsetProd intro p hp have hp0 : (p:ℂ) ≠ 0 := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).ne_zero intro w exact (differentiableAt_const (c := (1:ℂ))).sub ((by fun_prop : DifferentiableAt ℂ (fun w : ℂ => -1-w) w).const_cpow (Or.inl hp0)) lemma baselineProductR_zero (N : ℕ) (hN : Even N) (hpos : 0 if p.Prime ∧ 2 < p ∧ ¬p ∣ N then 1 + (2 * (p : ℂ) ^ (-w) - (p : ℂ) ^ (-2 * w)) / ((p : ℂ) * ((p : ℂ) - 2)) else 1) ∧ DifferentiableAt ℂ (baselineProductR N) w) ∧ (singularSeries N : ℂ) * baselineProductR N 0 = 1 := by refine ⟨⟨1/4,by norm_num,?_⟩,baselineProductR_zero N hN (by omega)⟩ intro w hw have hw' : -(1/4:ℝ) (baselineEulerTerm_eq N p w).symm) · exact (baselineProductR_differentiableOn N).differentiableAt ((isOpen_lt continuous_const Complex.continuous_re).mem_nhds hw') end ConditionalGoldbach