import Mathlib.MeasureTheory.Group.Integral import OAI.NumberTheory.Jacobsthal.Estimates.InvariantFiniteness namespace OAI namespace Erdos970 section open Set MeasureTheory namespace Erdos970Dependency.DeficitIntegralValues open NumberTheoryLean.LinearSieveFunctions NumberTheoryLean.BuchstabBridge open NumberTheoryLean.NormalizedDeficits NumberTheoryLean.DeficitFutureIntegrals theorem shift_indicator (f : ℝ → ℝ) (a d : ℝ) : (fun s ↦ (Ioi a).indicator f (s - d)) = (Ioi (a + d)).indicator (fun s ↦ f (s - d)) := by funext s by_cases hs : a + d < s · rw [indicator_of_mem (show s ∈ Ioi (a + d) from hs), indicator_of_mem (show s - d ∈ Ioi a by change a < s - d; linarith)] · rw [indicator_of_notMem (show s ∉ Ioi (a + d) from hs), indicator_of_notMem (show s - d ∉ Ioi a by change ¬a < s - d; linarith)] theorem integrableOn_shift_Ioi {f : ℝ → ℝ} {a : ℝ} (hf : IntegrableOn f (Ioi a)) (d : ℝ) : IntegrableOn (fun s ↦ f (s - d)) (Ioi (a + d)) := by have h := ((integrable_indicator_iff measurableSet_Ioi).mpr hf).comp_sub_right d rw [shift_indicator] at h exact (integrable_indicator_iff measurableSet_Ioi).mp h theorem integral_shift_Ioi (f : ℝ → ℝ) (a d : ℝ) : (∫ s in Ioi (a + d), f (s - d)) = ∫ s in Ioi a, f s := by have h := integral_sub_right_eq_self (μ := (volume : Measure ℝ)) ((Ioi a).indicator f) d rw [shift_indicator, integral_indicator measurableSet_Ioi, integral_indicator measurableSet_Ioi] at h exact h theorem upper_integral_one : IntegrableOn upperDeficit (Ioi (1 : ℝ)) ∧ (∫ s in Ioi (1 : ℝ), upperDeficit s) = 2 := by have h := lower_future_integral (s := 2) (by norm_num) norm_num only [show (2 : ℝ) - 1 = 1 by norm_num] at h refine ⟨h.1, ?_⟩ rw [← h.2] norm_num [lowerDeficit, f_initial sieveA (s := 2) (by norm_num)] theorem lower_integral_zero : IntegrableOn lowerDeficit (Ioi (0 : ℝ)) ∧ (∫ s in Ioi (0 : ℝ), lowerDeficit s) = sieveA - 1 := by have h := upper_future_integral (s := 1) (by norm_num) norm_num only [show (1 : ℝ) - 1 = 0 by norm_num, one_mul] at h refine ⟨h.1, ?_⟩ rw [← h.2] norm_num [upperDeficit, F_initial sieveA (s := 1) (by norm_num) (by norm_num)] theorem lower_integral_two : IntegrableOn lowerDeficit (Ioi (2 : ℝ)) ∧ (∫ s in Ioi (2 : ℝ), lowerDeficit s) = sieveA - 3 := by have h := upper_future_integral (s := 3) (by norm_num) norm_num only [show (3 : ℝ) - 1 = 2 by norm_num] at h refine ⟨h.1, ?_⟩ rw [← h.2] simp only [upperDeficit, F_initial sieveA (s := 3) (by norm_num) (by norm_num)] ring theorem even_majorant_integral : IntegrableOn (fun s ↦ lowerDeficit s + upperDeficit (s - 1)) (Ici (2 : ℝ)) ∧ (∫ s in Ici (2 : ℝ), lowerDeficit s + upperDeficit (s - 1)) = sieveA - 1 := by have ha := lower_integral_two.1 have hc : IntegrableOn (fun s ↦ upperDeficit (s - 1)) (Ioi (2 : ℝ)) := by simpa only [show (1 : ℝ) + 1 = 2 by norm_num] using integrableOn_shift_Ioi upper_integral_one.1 1 refine ⟨Iff.mpr integrableOn_Ici_iff_integrableOn_Ioi (ha.add hc), ?_⟩ rw [integral_Ici_eq_integral_Ioi, integral_add ha hc, lower_integral_two.2] have h := integral_shift_Ioi upperDeficit 1 1 norm_num only [show (1 : ℝ) + 1 = 2 by norm_num] at h rw [h, upper_integral_one.2] ring theorem odd_majorant_integral : IntegrableOn (fun s ↦ upperDeficit s + lowerDeficit (s - 1)) (Ici (1 : ℝ)) ∧ (∫ s in Ici (1 : ℝ), upperDeficit s + lowerDeficit (s - 1)) = sieveA + 1 := by have hc := upper_integral_one.1 have ha : IntegrableOn (fun s ↦ lowerDeficit (s - 1)) (Ioi (1 : ℝ)) := by simpa only [zero_add] using integrableOn_shift_Ioi lower_integral_zero.1 1 refine ⟨Iff.mpr integrableOn_Ici_iff_integrableOn_Ioi (hc.add ha), ?_⟩ rw [integral_Ici_eq_integral_Ioi, integral_add hc ha, upper_integral_one.2] have h := integral_shift_Ioi lowerDeficit 0 1 rw [zero_add] at h rw [h, lower_integral_zero.2] ring end Erdos970Dependency.DeficitIntegralValues end end Erdos970 end OAI