module public import ConditionalGoldbach.Proofs.CutoffSmooth public import Mathlib.Analysis.SpecialFunctions.Sqrt public import Mathlib.Analysis.SpecialFunctions.Log.Deriv public section set_option autoImplicit false noncomputable section open scoped BigOperators Topology ContDiff open Filter Set MeasureTheory namespace ConditionalGoldbach lemma cutoffPolynomial_of_nonpos {t : ℝ} (ht : t≤0) : cutoffPolynomial t=0 := by simp [cutoffPolynomial,ht] lemma cutoffPolynomial_of_one_le {t : ℝ} (ht : 1≤t) : cutoffPolynomial t=1 := by simp [cutoffPolynomial,ht,show ¬t≤0 by linarith] lemma wideCutoff_contDiff : ContDiff ℝ 6 wideCutoff := by unfold wideCutoff exact (cutoffPolynomial_contDiff.comp (by fun_prop)).mul (cutoffPolynomial_contDiff.comp (by fun_prop)) lemma wideCutoff_reflection (x : ℝ) : wideCutoff x=wideCutoff (experimentN-x) := by unfold wideCutoff rw [show (experimentN:ℝ)-(experimentN-x)-16=x-16 by ring] exact mul_comm _ _ lemma wideCutoff_plateau (x : ℝ) (hx : x∈Icc (1000:ℝ) (experimentN-1000)) : wideCutoff x=1 := by norm_num [experimentN] at hx unfold wideCutoff rw [cutoffPolynomial_of_one_le (by norm_num; linarith [hx.1]), cutoffPolynomial_of_one_le (by norm_num [experimentN]; linarith [hx.2])] norm_num lemma wideCutoff_zero_left (x : ℝ) (hx : x≤16) : wideCutoff x=0 := by unfold wideCutoff rw [cutoffPolynomial_of_nonpos (by apply div_nonpos_of_nonpos_of_nonneg (by linarith); norm_num)] simp lemma wideCutoff_zero_right (x : ℝ) (hx : (experimentN:ℝ)-16≤x) : wideCutoff x=0 := by rw [wideCutoff_reflection] exact wideCutoff_zero_left _ (by linarith) lemma wideCompanion_formula (u : ℝ) : wideCompanion u = Real.sqrt (1-u)*wideCutoff (experimentN*u)/ Real.sqrt (Real.log (experimentN*u)*Real.log (experimentN*(1-u))) := by unfold wideCompanion split_ifs with hu · rfl · have hc : wideCutoff (experimentN*u)=0 := by simp only [mem_Ioo,not_and_or,not_lt] at hu rcases hu with hu|hu · apply wideCutoff_zero_left norm_num [experimentN] at hu ⊢ linarith · apply wideCutoff_zero_right norm_num [experimentN] at hu ⊢ linarith change (0:ℝ)=Real.sqrt (1-u)*wideCutoff ((experimentN:ℝ)*u)/Real.sqrt (Real.log ((experimentN:ℝ)*u)*Real.log ((experimentN:ℝ)*(1-u))) rw [hc,mul_zero,zero_div] lemma wideCompanion_support : Function.support wideCompanion ⊆ Ioo (16/experimentN:ℝ) (1-16/experimentN:ℝ) := by intro u hu by_contra hn apply hu unfold wideCompanion exact ite_eq_right hn lemma wideWeight_support : Function.support wideWeight ⊆ Ioo (16/experimentN:ℝ) (1-16/experimentN:ℝ) := by intro u hu apply wideCompanion_support intro he exact hu (by simp [wideWeight,he]) lemma wideWeight_hasCompactSupport : HasCompactSupport wideWeight := HasCompactSupport.of_support_subset_isCompact isCompact_Icc (wideWeight_support.trans Ioo_subset_Icc_self) lemma wideCompanion_hasCompactSupport : HasCompactSupport wideCompanion := HasCompactSupport.of_support_subset_isCompact isCompact_Icc (wideCompanion_support.trans Ioo_subset_Icc_self) lemma wideCompanion_contDiff : ContDiff ℝ 6 wideCompanion := by rw [contDiff_iff_contDiffAt] intro u by_cases hu : u∈Icc (16/experimentN:ℝ) (1-16/experimentN:ℝ) · have hNu : 1<(experimentN:ℝ)*u := by norm_num [experimentN] at hu ⊢; linarith [hu.1] have hNv : 1<(experimentN:ℝ)*(1-u) := by norm_num [experimentN] at hu ⊢; linarith [hu.2] have hu1 : 0<1-u := by norm_num [experimentN] at hu ⊢; linarith [hu.2] have he : wideCompanion = fun v => Real.sqrt (1-v)*wideCutoff (experimentN*v)/ Real.sqrt (Real.log (experimentN*v)*Real.log (experimentN*(1-v))) := funext wideCompanion_formula rw [he] apply ContDiffAt.div · exact ((contDiffAt_const.sub contDiffAt_id).sqrt hu1.ne').mul (wideCutoff_contDiff.contDiffAt.comp u (by fun_prop)) · apply ContDiffAt.sqrt · exact ((contDiffAt_const.mul contDiffAt_id).log (ne_of_gt (by linarith : 0<(experimentN:ℝ)*u))).mul ((contDiffAt_const.mul (contDiffAt_const.sub contDiffAt_id)).log (ne_of_gt (by linarith : 0<(experimentN:ℝ)*(1-u)))) · exact (mul_pos (Real.log_pos hNu) (Real.log_pos hNv)).ne' · exact (Real.sqrt_pos.mpr (mul_pos (Real.log_pos hNu) (Real.log_pos hNv))).ne' · have he : wideCompanion =ᶠ[𝓝 u] fun _ => (0:ℝ) := by filter_upwards [isClosed_Icc.isOpen_compl.mem_nhds hu] with v hv by_contra hs exact hv (Ioo_subset_Icc_self (wideCompanion_support hs)) exact contDiffAt_const.congr_of_eventuallyEq he lemma wideWeight_contDiff : ContDiff ℝ 6 wideWeight := by rw [contDiff_iff_contDiffAt] intro u by_cases hu : 0 (0:ℝ) := by filter_upwards [Iio_mem_nhds hupper] with v hv by_contra hs have hh := (wideWeight_support hs).1 change v < 16/experimentN at hv linarith exact contDiffAt_const.congr_of_eventuallyEq he lemma wideWeight_product (u : ℝ) (hu : u∈Ioo (16/experimentN:ℝ) (1-16/experimentN:ℝ)) : wideWeight u*wideWeight (1-u)=wideCutoff (experimentN*u)^2/ (Real.log (experimentN*u)*Real.log (experimentN*(1-u))) := by have hu0 : 0 wideWeight u*wideWeight (1-u)) volume 0 1 := (wideWeight_contDiff.continuous.mul (wideWeight_contDiff.continuous.comp (continuous_const.sub continuous_id))).intervalIntegrable _ _ lemma wideModelIntegrand_intervalIntegrable : IntervalIntegrable (fun x : ℝ => wideCutoff x^2/ (Real.log x*Real.log ((experimentN:ℝ)-x))) volume 16 ((experimentN:ℝ)/2) := by apply ContinuousOn.intervalIntegrable intro x hx rw [uIcc_of_le (by norm_num [experimentN] : (16:ℝ)≤(experimentN:ℝ)/2)] at hx have hx0 : 0 wideWeight u * wideWeight (1 - u)) volume 0 1 ∧ IntervalIntegrable (fun x : ℝ => wideCutoff x ^ 2 / (Real.log x * Real.log ((experimentN : ℝ) - x))) volume 16 ((experimentN : ℝ) / 2) := by refine ⟨wideWeight_contDiff,wideWeight_hasCompactSupport,?_,wideWeight_product_integrable, wideModelIntegrand_intervalIntegrable⟩ intro u hu have hs := wideWeight_support hu norm_num [experimentN] at hs constructor <;> linarith [hs.1,hs.2] end ConditionalGoldbach