import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Log.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse import Mathlib.Analysis.SpecialFunctions.Sqrt import Mathlib.Analysis.Calculus.Deriv.Inverse import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Inv import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus import Mathlib.MeasureTheory.Integral.DominatedConvergence import Mathlib.Order.Filter.AtTopBot.Tendsto /-! # Analytic Foundations for F04 (When Separated Pieces Stay Positive Together) This module provides the elementary real analysis, calculus, improper-integral, and special-function results used throughout the F04 formalization: 1. `HasDerivAt Real.log x⁻¹ x` for `x ≠ 0`. 2. `arctan` via `Real.arcsin (x / √(1 + x^2))`, with its exact characterization `Real.tan (arctan x) = x`, range `(-π/2, π/2)`, and derivative `1 / (1 + x^2)`. 3. Integration by parts for `intervalIntegral` and improper-integral FTC on `Ioi a`. 4. Euler–Mascheroni constant `eulerGamma` as the genuine limit of `∑ k ∈ Finset.range (n + 1), (1 : ℝ) / (k + 1) - Real.log (n + 1)`, with convergence and explicit bounds, and `weilConstA = Real.log (8 * Real.pi) + eulerGamma + Real.pi / 2`. 5. The Weil weight `weilWeight t = exp (t/2) / sinh t`, exact antiderivative `B_func L = log ((1 + exp (-L/2)) / (1 - exp (-L/2))) + 2 * arctan (exp (-L/2))`, `m_func L = B_func L - weilConstA`, tail integral `∫ t in Ioi L, weilWeight t = B_func L`, exact kernel split `weilWeight t = 2 * exp (-t/2) + residualWeight t`, strict antitone property of `residualWeight`, the elementary bound `(1 + exp (-L/2)) / (1 - exp (-L/2)) ≥ 4 / L`, and `m_func L ≥ Real.log (4 / L) - weilConstA`. 6. The Connes–Consani normalization identity `Real.log (4 * Real.pi) + eulerGamma + ∫ t in Ioi 0, (exp (t/2) - 1) / sinh t = weilConstA`. -/ namespace F04Riemann open Real MeasureTheory Set Filter Topology /-! ### 1. Derivative of `Real.log`, `Real.sinh`, and `Real.cosh` -/ lemma hasDerivAt_log_pos {x : ℝ} (hx : 0 < x) : HasDerivAt Real.log x⁻¹ x := by have h1 : HasDerivAt Real.exp (Real.exp (Real.log x)) (Real.log x) := Real.hasDerivAt_exp _ rw [Real.exp_log hx] at h1 have hcont : ContinuousAt Real.log x := by rw [Metric.continuousAt_iff] intro ε hε have hlt : Real.exp (Real.log x - ε) < x := calc Real.exp (Real.log x - ε) < Real.exp (Real.log x) := Real.exp_lt_exp.mpr (by linarith) _ = x := Real.exp_log hx have hgt : x < Real.exp (Real.log x + ε) := calc x = Real.exp (Real.log x) := (Real.exp_log hx).symm _ < Real.exp (Real.log x + ε) := Real.exp_lt_exp.mpr (by linarith) refine ⟨min (x - Real.exp (Real.log x - ε)) (Real.exp (Real.log x + ε) - x), lt_min (by linarith) (by linarith), fun y hy => ?_⟩ rw [Real.dist_eq] at hy ⊢ have hy1 : Real.exp (Real.log x - ε) < y := by have := (abs_lt.mp hy).1 have hmin : min (x - Real.exp (Real.log x - ε)) (Real.exp (Real.log x + ε) - x) ≤ x - Real.exp (Real.log x - ε) := min_le_left _ _ linarith have hy2 : y < Real.exp (Real.log x + ε) := by have := (abs_lt.mp hy).2 have hmin : min (x - Real.exp (Real.log x - ε)) (Real.exp (Real.log x + ε) - x) ≤ Real.exp (Real.log x + ε) - x := min_le_right _ _ linarith have hypos : 0 < y := lt_trans (Real.exp_pos _) hy1 rw [abs_lt] constructor · have : Real.log x - ε < Real.log y := by rw [← Real.exp_lt_exp, Real.exp_log hypos]; exact hy1 linarith · have : Real.log y < Real.log x + ε := by rw [← Real.exp_lt_exp, Real.exp_log hypos]; exact hy2 linarith have hinv : ∀ᶠ y in 𝓝 x, Real.exp (Real.log y) = y := by filter_upwards [Ioi_mem_nhds hx] with y hy exact Real.exp_log hy exact h1.of_local_left_inverse hcont (ne_of_gt hx) hinv lemma hasDerivAt_log_of_ne_zero {x : ℝ} (hx : x ≠ 0) : HasDerivAt Real.log x⁻¹ x := by rcases lt_or_gt_of_ne hx with hneg | hpos · have hcomp : HasDerivAt (Real.log ∘ Neg.neg) ((-x)⁻¹ * (-1)) x := (hasDerivAt_log_pos (neg_pos.mpr hneg)).comp x (hasDerivAt_neg x) have heq : Real.log ∘ Neg.neg = Real.log := by ext y; exact Real.log_neg_eq_log y rw [heq] at hcomp have hval : (-x)⁻¹ * (-1 : ℝ) = x⁻¹ := by field_simp rwa [hval] at hcomp · exact hasDerivAt_log_pos hpos lemma continuousOn_log_Ioi : ContinuousOn Real.log (Ioi (0 : ℝ)) := fun _ hx => (hasDerivAt_log_pos hx).continuousAt.continuousWithinAt lemma hasDerivAt_exp_neg (x : ℝ) : HasDerivAt (fun t => Real.exp (-t)) (-Real.exp (-x)) x := by have h := (Real.hasDerivAt_exp (-x)).comp x (hasDerivAt_neg x) have hval : Real.exp (-x) * (-1) = -Real.exp (-x) := by ring rw [hval] at h exact h lemma hasDerivAt_sinh_real (x : ℝ) : HasDerivAt Real.sinh (Real.cosh x) x := by have h := ((Real.hasDerivAt_exp x).sub (hasDerivAt_exp_neg x)).div_const 2 have hval : (Real.exp x - -Real.exp (-x)) / 2 = Real.cosh x := by rw [Real.cosh_eq]; ring rw [hval] at h exact h.congr_of_eventuallyEq (Filter.Eventually.of_forall fun t => Real.sinh_eq t) lemma hasDerivAt_cosh_real (x : ℝ) : HasDerivAt Real.cosh (Real.sinh x) x := by have h := ((Real.hasDerivAt_exp x).add (hasDerivAt_exp_neg x)).div_const 2 have hval : (Real.exp x + -Real.exp (-x)) / 2 = Real.sinh x := by rw [Real.sinh_eq]; ring rw [hval] at h exact h.congr_of_eventuallyEq (Filter.Eventually.of_forall fun t => Real.cosh_eq t) /-! ### 2. `arctan` via `Real.arcsin` -/ /-- Exact arctangent defined via `Real.arcsin (x / √(1 + x^2))`. We prove `Real.tan (arctan x) = x`, `arctan x ∈ Ioo (-π/2) (π/2)`, and `HasDerivAt arctan (1 / (1 + x^2)) x`, uniquely characterizing it as standard arctangent. -/ noncomputable def arctan (x : ℝ) : ℝ := Real.arcsin (x / Real.sqrt (1 + x ^ 2)) lemma one_add_sq_pos (x : ℝ) : 0 < 1 + x ^ 2 := by positivity lemma sqrt_one_add_sq_pos (x : ℝ) : 0 < Real.sqrt (1 + x ^ 2) := Real.sqrt_pos.mpr (one_add_sq_pos x) lemma abs_div_sqrt_one_add_sq_lt_one (x : ℝ) : |x / Real.sqrt (1 + x ^ 2)| < 1 := by rw [abs_div, abs_of_pos (sqrt_one_add_sq_pos x), div_lt_one (sqrt_one_add_sq_pos x)] have h1 : |x| = Real.sqrt (x ^ 2) := (Real.sqrt_sq_eq_abs x).symm rw [h1] exact Real.sqrt_lt_sqrt (sq_nonneg x) (by linarith) lemma sin_arctan (x : ℝ) : Real.sin (arctan x) = x / Real.sqrt (1 + x ^ 2) := by unfold arctan have h := abs_lt.mp (abs_div_sqrt_one_add_sq_lt_one x) exact Real.sin_arcsin (le_of_lt h.1) (le_of_lt h.2) lemma cos_arctan (x : ℝ) : Real.cos (arctan x) = 1 / Real.sqrt (1 + x ^ 2) := by unfold arctan rw [Real.cos_arcsin] have hpos : 0 < 1 + x ^ 2 := one_add_sq_pos x have hsq : (x / Real.sqrt (1 + x ^ 2)) ^ 2 = x ^ 2 / (1 + x ^ 2) := by rw [div_pow, Real.sq_sqrt (le_of_lt hpos)] rw [hsq] have hsub : 1 - x ^ 2 / (1 + x ^ 2) = 1 / (1 + x ^ 2) := by field_simp ring rw [hsub, Real.sqrt_div zero_le_one, Real.sqrt_one] lemma tan_arctan (x : ℝ) : Real.tan (arctan x) = x := by rw [Real.tan_eq_sin_div_cos, sin_arctan, cos_arctan] have hpos : Real.sqrt (1 + x ^ 2) ≠ 0 := ne_of_gt (sqrt_one_add_sq_pos x) field_simp lemma arctan_mem_Ioo (x : ℝ) : arctan x ∈ Ioo (-(Real.pi / 2)) (Real.pi / 2) := by unfold arctan have h := abs_lt.mp (abs_div_sqrt_one_add_sq_lt_one x) constructor · have hlt : Real.arcsin (-1) < Real.arcsin (x / Real.sqrt (1 + x ^ 2)) := Real.arcsin_lt_arcsin (le_refl _) h.1 (le_of_lt h.2) rwa [Real.arcsin_neg_one] at hlt · exact Real.arcsin_lt_pi_div_two.mpr h.2 lemma arctan_zero : arctan 0 = 0 := by simp [arctan] lemma arctan_one : arctan 1 = Real.pi / 4 := by have htan : Real.tan (arctan 1) = Real.tan (Real.pi / 4) := by rw [tan_arctan, Real.tan_pi_div_four] have hmem1 := arctan_mem_Ioo 1 have hmem2 : Real.pi / 4 ∈ Ioo (-(Real.pi / 2)) (Real.pi / 2) := by constructor <;> linarith [Real.pi_pos] have hcos : ∀ t ∈ Ioo (-(Real.pi / 2)) (Real.pi / 2), 0 < Real.cos t := fun t ht => Real.cos_pos_of_mem_Ioo ht have hsin_eq : Real.sin (arctan 1 - Real.pi / 4) = 0 := by rw [Real.sin_sub] have hc1 := ne_of_gt (hcos _ hmem1) have hc2 := ne_of_gt (hcos _ hmem2) rw [Real.tan_eq_sin_div_cos, Real.tan_eq_sin_div_cos] at htan have hcross : Real.sin (arctan 1) * Real.cos (Real.pi / 4) = Real.sin (Real.pi / 4) * Real.cos (arctan 1) := by field_simp at htan; linarith linarith have hdiff_mem : arctan 1 - Real.pi / 4 ∈ Ioo (-Real.pi) Real.pi := by constructor <;> linarith [hmem1.1, hmem1.2, hmem2.1, hmem2.2] by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have : Real.sin (-(arctan 1 - Real.pi / 4)) > 0 := Real.sin_pos_of_pos_of_lt_pi (by linarith) (by linarith [hdiff_mem.1]) rw [Real.sin_neg, hsin_eq] at this linarith · have : Real.sin (arctan 1 - Real.pi / 4) > 0 := Real.sin_pos_of_pos_of_lt_pi (by linarith) hdiff_mem.2 linarith lemma arctan_pos {x : ℝ} (hx : 0 < x) : 0 < arctan x := by unfold arctan rw [Real.arcsin_pos] exact div_pos hx (sqrt_one_add_sq_pos x) lemma arctan_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ arctan x := by unfold arctan rw [Real.arcsin_nonneg] exact div_nonneg hx (le_of_lt (sqrt_one_add_sq_pos x)) lemma continuous_arctan : Continuous arctan := by unfold arctan refine Real.continuous_arcsin.comp ?_ refine continuous_id.div ?_ (fun x => ne_of_gt (sqrt_one_add_sq_pos x)) exact Real.continuous_sqrt.comp (continuous_const.add (continuous_pow 2)) lemma hasDerivAt_tan_of_cos_ne_zero {x : ℝ} (hcos : Real.cos x ≠ 0) : HasDerivAt Real.tan (1 / Real.cos x ^ 2) x := by have hsin := Real.hasDerivAt_sin x have hcosd := Real.hasDerivAt_cos x have hdiv := hsin.div hcosd hcos have hval : (Real.cos x * Real.cos x - Real.sin x * -Real.sin x) / Real.cos x ^ 2 = 1 / Real.cos x ^ 2 := by have hpyth := Real.sin_sq_add_cos_sq x field_simp nlinarith rw [hval] at hdiv exact hdiv.congr_of_eventuallyEq (Filter.Eventually.of_forall fun y => Real.tan_eq_sin_div_cos y) lemma hasDerivAt_arctan (x : ℝ) : HasDerivAt arctan (1 / (1 + x ^ 2)) x := by have hmem := arctan_mem_Ioo x have hcos_pos : 0 < Real.cos (arctan x) := Real.cos_pos_of_mem_Ioo hmem have htan_d : HasDerivAt Real.tan (1 / Real.cos (arctan x) ^ 2) (arctan x) := hasDerivAt_tan_of_cos_ne_zero (ne_of_gt hcos_pos) have hcos_sq : Real.cos (arctan x) ^ 2 = 1 / (1 + x ^ 2) := by rw [cos_arctan, div_pow, one_pow, Real.sq_sqrt (le_of_lt (one_add_sq_pos x))] have hderiv_val : 1 / Real.cos (arctan x) ^ 2 = 1 + x ^ 2 := by rw [hcos_sq]; field_simp rw [hderiv_val] at htan_d have hinv := htan_d.of_local_left_inverse continuous_arctan.continuousAt (ne_of_gt (one_add_sq_pos x)) (Filter.Eventually.of_forall tan_arctan) simpa [one_div] using hinv /-! ### 3. Integration by Parts and Improper Integral FTC -/ lemma intervalIntegral_mul_deriv_eq_deriv_mul_of_hasDerivAt {E : Type*} [NormedRing E] [NormedAlgebra ℝ E] [CompleteSpace E] {a b : ℝ} {u v u' v' : ℝ → E} (hu : ∀ x ∈ uIcc a b, HasDerivAt u (u' x) x) (hv : ∀ x ∈ uIcc a b, HasDerivAt v (v' x) x) (hu' : IntervalIntegrable u' volume a b) (hv' : IntervalIntegrable v' volume a b) : ∫ x in a..b, u x * v' x = u b * v b - u a * v a - ∫ x in a..b, u' x * v x := by have hcont_u : ContinuousOn u (uIcc a b) := fun x hx => (hu x hx).continuousAt.continuousWithinAt have hcont_v : ContinuousOn v (uIcc a b) := fun x hx => (hv x hx).continuousAt.continuousWithinAt have hint1 : IntervalIntegrable (fun x => u x * v' x) volume a b := hv'.continuousOn_mul hcont_u have hint2 : IntervalIntegrable (fun x => u' x * v x) volume a b := hu'.mul_continuousOn hcont_v have hprod : ∀ x ∈ uIcc a b, HasDerivAt (fun y => u y * v y) (u' x * v x + u x * v' x) x := fun x hx => (hu x hx).mul (hv x hx) have hftc := intervalIntegral.integral_eq_sub_of_hasDerivAt hprod (hint2.add hint1) rw [intervalIntegral.integral_add hint2 hint1] at hftc exact eq_sub_of_add_eq' hftc /-- Monotone convergence for set Lebesgue integrals along an increasing sequence of sets. -/ lemma tendsto_setLIntegral_of_monotone_seq {s : ℕ → Set ℝ} {f : ℝ → ENNReal} (hs_mono : Monotone s) : Tendsto (fun n => ∫⁻ x in s n, f x) atTop (𝓝 (∫⁻ x in ⋃ n, s n, f x)) := by rw [MeasureTheory.setLIntegral_iUnion_of_directed f hs_mono.directed_le] refine tendsto_atTop_iSup (fun m n hmn => ?_) exact MeasureTheory.lintegral_mono_set (hs_mono hmn) /-- Improper integral FTC on `(a, ∞)` for a nonnegative continuous function `f'` with antiderivative `f` tending to `c` at `∞`. -/ lemma integral_Ioi_of_hasDerivAt_of_nonneg {a c : ℝ} {f f' : ℝ → ℝ} (hderiv : ∀ x ∈ Ici a, HasDerivAt f (f' x) x) (hcont : ContinuousOn f' (Ici a)) (hnonneg : ∀ x ∈ Ioi a, 0 ≤ f' x) (htend : Tendsto f atTop (𝓝 c)) : IntegrableOn f' (Ioi a) volume ∧ ∫ x in Ioi a, f' x = c - f a := by have hmeas : AEStronglyMeasurable f' (volume.restrict (Ioi a)) := (hcont.mono Ioi_subset_Ici_self).aestronglyMeasurable measurableSet_Ioi have hIoc_eq : ∀ b ≥ a, ∫ x in Ioc a b, f' x = f b - f a := by intro b hba rw [← intervalIntegral.integral_of_le hba] refine intervalIntegral.integral_eq_sub_of_hasDerivAt (fun x hx => ?_) ?_ · rw [uIcc_of_le hba] at hx exact hderiv x hx.1 · exact (hcont.mono (by rw [uIcc_of_le hba]; exact fun x hx => hx.1)).intervalIntegrable have hbound : ∀ b ≥ a, ∫⁻ x in Ioc a b, ENNReal.ofReal (f' x) = ENNReal.ofReal (f b - f a) := by intro b hba have hint : IntegrableOn f' (Ioc a b) volume := (hcont.mono (fun x hx => hx.1)).integrableOn_Icc.mono_set Ioc_subset_Icc_self have hnn : ∀ x ∈ Ioc a b, 0 ≤ f' x := fun x hx => hnonneg x hx.1 rw [← ofReal_integral_eq_lintegral_ofReal hint ((ae_restrict_iff' measurableSet_Ioc).mpr (Filter.Eventually.of_forall hnn))] rw [hIoc_eq b hba] have hUnion : (⋃ n : ℕ, Ioc a (a + (n : ℝ))) = Ioi a := by ext x simp only [mem_iUnion, mem_Ioc, mem_Ioi] constructor · rintro ⟨_, h1, _⟩; exact h1 · intro hx obtain ⟨n, hn⟩ := exists_nat_gt (x - a) exact ⟨n, hx, by linarith⟩ have hmono : Monotone (fun n : ℕ => Ioc a (a + (n : ℝ))) := by intro m n hmn x hx exact ⟨hx.1, le_trans hx.2 (by linarith [show (m : ℝ) ≤ n from Nat.cast_le.mpr hmn])⟩ have hlim_lintegral : Tendsto (fun n : ℕ => ∫⁻ x in Ioc a (a + (n : ℝ)), ENNReal.ofReal (f' x)) atTop (𝓝 (∫⁻ x in Ioi a, ENNReal.ofReal (f' x))) := by rw [← hUnion] exact tendsto_setLIntegral_of_monotone_seq hmono have hlim_rhs : Tendsto (fun n : ℕ => ENNReal.ofReal (f (a + (n : ℝ)) - f a)) atTop (𝓝 (ENNReal.ofReal (c - f a))) := by have hshift : Tendsto (fun n : ℕ => a + (n : ℝ)) atTop atTop := tendsto_atTop_add_const_left atTop a tendsto_natCast_atTop_atTop exact ENNReal.continuous_ofReal.continuousAt.tendsto.comp ((htend.comp hshift).sub tendsto_const_nhds) have hlintegral_eq : ∫⁻ x in Ioi a, ENNReal.ofReal (f' x) = ENNReal.ofReal (c - f a) := by have hfun : (fun n : ℕ => ∫⁻ x in Ioc a (a + (n : ℝ)), ENNReal.ofReal (f' x)) = (fun n : ℕ => ENNReal.ofReal (f (a + (n : ℝ)) - f a)) := by ext n; exact hbound (a + n) (by linarith [Nat.cast_nonneg (α := ℝ) n]) rw [hfun] at hlim_lintegral exact tendsto_nhds_unique hlim_lintegral hlim_rhs have hfin : HasFiniteIntegral f' (volume.restrict (Ioi a)) := by rw [HasFiniteIntegral] have hae : (fun x => ‖f' x‖ₑ) =ᵐ[volume.restrict (Ioi a)] (fun x => ENNReal.ofReal (f' x)) := by filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx exact Real.enorm_eq_ofReal (hnonneg x hx) rw [lintegral_congr_ae hae, hlintegral_eq] exact ENNReal.ofReal_lt_top have hint : IntegrableOn f' (Ioi a) volume := ⟨hmeas, hfin⟩ refine ⟨hint, ?_⟩ have hnn_ae : 0 ≤ᵐ[volume.restrict (Ioi a)] f' := (ae_restrict_iff' measurableSet_Ioi).mpr (Filter.Eventually.of_forall hnonneg) have hofReal : ENNReal.ofReal (∫ x in Ioi a, f' x) = ENNReal.ofReal (c - f a) := by rw [ofReal_integral_eq_lintegral_ofReal hint hnn_ae, hlintegral_eq] have hnonneg_int : 0 ≤ ∫ x in Ioi a, f' x := integral_nonneg_of_ae hnn_ae have hnonneg_diff : 0 ≤ c - f a := by have hmono_f : ∀ n : ℕ, f a ≤ f (a + n) := by intro n have := hIoc_eq (a + n) (by linarith [Nat.cast_nonneg (α := ℝ) n]) have hnn_Ioc : 0 ≤ ∫ x in Ioc a (a + n), f' x := setIntegral_nonneg measurableSet_Ioc (fun x hx => hnonneg x hx.1) linarith have hshift : Tendsto (fun n : ℕ => a + (n : ℝ)) atTop atTop := tendsto_atTop_add_const_left atTop a tendsto_natCast_atTop_atTop have hle : f a ≤ c := ge_of_tendsto' (htend.comp hshift) hmono_f linarith exact (ENNReal.ofReal_eq_ofReal_iff hnonneg_int hnonneg_diff).mp hofReal /-! ### 4. Euler–Mascheroni Constant `γ_E` and Weil Constant `A` -/ /-- The `n`-th harmonic-minus-log sequence `u_n = ∑_{k=1}^{n+1} 1/k - log(n+1)`. -/ noncomputable def eulerSeq (n : ℕ) : ℝ := (∑ k ∈ Finset.range (n + 1), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log ((n : ℝ) + 1) /-- The lower sequence `l_n = ∑_{k=1}^{n+1} 1/k - log(n+2)`. -/ noncomputable def eulerLowerSeq (n : ℕ) : ℝ := (∑ k ∈ Finset.range (n + 1), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log ((n : ℝ) + 2) lemma one_div_le_log_succ_sub_log (m : ℝ) (hm : 0 < m) : 1 / (m + 1) ≤ Real.log (m + 1) - Real.log m := by have h1 : 0 < m / (m + 1) := div_pos hm (by linarith) have hlog : Real.log (m / (m + 1)) ≤ m / (m + 1) - 1 := Real.log_le_sub_one_of_pos h1 rw [Real.log_div (ne_of_gt hm) (by linarith)] at hlog have hring : m / (m + 1) - 1 = -(1 / (m + 1)) := by field_simp; ring linarith lemma log_succ_sub_log_le_one_div (m : ℝ) (hm : 0 < m) : Real.log (m + 1) - Real.log m ≤ 1 / m := by have h1 : 0 < (m + 1) / m := div_pos (by linarith) hm have hlog : Real.log ((m + 1) / m) ≤ (m + 1) / m - 1 := Real.log_le_sub_one_of_pos h1 rw [Real.log_div (by linarith) (ne_of_gt hm)] at hlog have hring : (m + 1) / m - 1 = 1 / m := by field_simp; ring linarith lemma eulerSeq_antitone : Antitone eulerSeq := by refine antitone_nat_of_succ_le (fun n => ?_) change (∑ k ∈ Finset.range (n + 2), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log (((n + 1 : ℕ) : ℝ) + 1) ≤ (∑ k ∈ Finset.range (n + 1), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log ((n : ℝ) + 1) rw [Finset.sum_range_succ (n := n + 1)] push_cast have hm : (0 : ℝ) < (n : ℝ) + 1 := by positivity have h := one_div_le_log_succ_sub_log ((n : ℝ) + 1) hm have h2 : (n : ℝ) + 1 + 1 = (n : ℝ) + 2 := by ring linarith lemma eulerLowerSeq_monotone : Monotone eulerLowerSeq := by refine monotone_nat_of_le_succ (fun n => ?_) change (∑ k ∈ Finset.range (n + 1), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log ((n : ℝ) + 2) ≤ (∑ k ∈ Finset.range (n + 2), (1 : ℝ) / ((k : ℝ) + 1)) - Real.log (((n + 1 : ℕ) : ℝ) + 2) rw [Finset.sum_range_succ (n := n + 1)] push_cast have hm : (0 : ℝ) < (n : ℝ) + 2 := by positivity have h := log_succ_sub_log_le_one_div ((n : ℝ) + 2) hm have heq1 : (n : ℝ) + 1 + 1 = (n : ℝ) + 2 := by ring have heq2 : (n : ℝ) + 1 + 2 = (n : ℝ) + 2 + 1 := by ring rw [heq1, heq2] linarith lemma eulerLowerSeq_le_eulerSeq (n : ℕ) : eulerLowerSeq n ≤ eulerSeq n := by unfold eulerLowerSeq eulerSeq have h : Real.log ((n : ℝ) + 1) ≤ Real.log ((n : ℝ) + 2) := Real.log_le_log (by positivity) (by linarith) linarith lemma eulerLowerSeq_nonneg (n : ℕ) : 0 ≤ eulerLowerSeq n := by have h0 : 0 ≤ eulerLowerSeq 0 := by unfold eulerLowerSeq simp only [Finset.range_one, Finset.sum_singleton, Nat.cast_zero, zero_add, div_one] have hlog : Real.log 2 ≤ 1 := by have := Real.log_le_sub_one_of_pos (show (0 : ℝ) < 2 by norm_num) linarith linarith exact le_trans h0 (eulerLowerSeq_monotone (Nat.zero_le n)) lemma eulerSeq_bddBelow : BddBelow (Set.range eulerSeq) := by refine ⟨0, ?_⟩ rintro _ ⟨n, rfl⟩ exact le_trans (eulerLowerSeq_nonneg n) (eulerLowerSeq_le_eulerSeq n) /-- Euler–Mascheroni constant `γ_E = lim_{N→∞} (∑_{k=1}^N 1/k - log N)`. -/ noncomputable def eulerGamma : ℝ := ⨅ n : ℕ, eulerSeq n lemma tendsto_eulerSeq : Tendsto eulerSeq atTop (𝓝 eulerGamma) := tendsto_atTop_ciInf eulerSeq_antitone eulerSeq_bddBelow lemma eulerGamma_le_eulerSeq (n : ℕ) : eulerGamma ≤ eulerSeq n := ciInf_le eulerSeq_bddBelow n lemma eulerLowerSeq_le_eulerGamma (n : ℕ) : eulerLowerSeq n ≤ eulerGamma := by refine le_ciInf (fun m => ?_) have h1 : eulerLowerSeq n ≤ eulerLowerSeq (max n m) := eulerLowerSeq_monotone (le_max_left n m) have h2 : eulerLowerSeq (max n m) ≤ eulerSeq (max n m) := eulerLowerSeq_le_eulerSeq (max n m) have h3 : eulerSeq (max n m) ≤ eulerSeq m := eulerSeq_antitone (le_max_right n m) linarith lemma eulerGamma_nonneg : 0 ≤ eulerGamma := le_trans (eulerLowerSeq_nonneg 0) (eulerLowerSeq_le_eulerGamma 0) /-- The fixed constant `A = log(8π) + γ_E + π/2` from Section 2 of F04. -/ noncomputable def weilConstA : ℝ := Real.log (8 * Real.pi) + eulerGamma + Real.pi / 2 /-! ### 5. Weil Weight `w(t)`, Antiderivative `B(L)`, Margin `m(L)`, and Split `w_0(t)` -/ /-- The continuous weight `w(t) = e^{t/2} / sinh(t)`. -/ noncomputable def weilWeight (t : ℝ) : ℝ := Real.exp (t / 2) / Real.sinh t /-- Residual weight `w_0(t) = 2 e^{-5t/2} / (1 - e^{-2t})` after removing `2 e^{-t/2}`. -/ noncomputable def residualWeight (t : ℝ) : ℝ := 2 * Real.exp (-(5 * t / 2)) / (1 - Real.exp (-(2 * t))) /-- Exact tail integral `B(L) = log ((1 + e^{-L/2}) / (1 - e^{-L/2})) + 2 arctan (e^{-L/2})`. -/ noncomputable def B_func (L : ℝ) : ℝ := Real.log ((1 + Real.exp (-(L / 2))) / (1 - Real.exp (-(L / 2)))) + 2 * arctan (Real.exp (-(L / 2))) /-- Single-interval lower bound coefficient `m(L) = B(L) - A`. -/ noncomputable def m_func (L : ℝ) : ℝ := B_func L - weilConstA lemma exp_neg_half_pos (t : ℝ) : 0 < Real.exp (-(t / 2)) := Real.exp_pos _ lemma exp_neg_half_lt_one {t : ℝ} (ht : 0 < t) : Real.exp (-(t / 2)) < 1 := by rw [Real.exp_lt_one_iff]; linarith lemma one_sub_exp_neg_two_pos {t : ℝ} (ht : 0 < t) : 0 < 1 - Real.exp (-(2 * t)) := by have : Real.exp (-(2 * t)) < 1 := by rw [Real.exp_lt_one_iff]; linarith linarith lemma sinh_pos_of_pos {t : ℝ} (ht : 0 < t) : 0 < Real.sinh t := by rw [Real.sinh_eq] have h : Real.exp (-t) < Real.exp t := Real.exp_lt_exp.mpr (by linarith) linarith lemma weilWeight_pos {t : ℝ} (ht : 0 < t) : 0 < weilWeight t := div_pos (Real.exp_pos _) (sinh_pos_of_pos ht) lemma weilWeight_eq_q {t : ℝ} (ht : 0 < t) : weilWeight t = 2 * Real.exp (-(t / 2)) / (1 - Real.exp (-(2 * t))) := by unfold weilWeight rw [Real.sinh_eq] have h1 : Real.exp t - Real.exp (-t) = Real.exp t * (1 - Real.exp (-(2 * t))) := by rw [mul_sub, mul_one, ← Real.exp_add] congr 1; ring have h2 : Real.exp (t / 2) = Real.exp t * Real.exp (-(t / 2)) := by rw [← Real.exp_add]; congr 1; ring have hexp_ne : Real.exp t ≠ 0 := ne_of_gt (Real.exp_pos t) have hden_ne : 1 - Real.exp (-(2 * t)) ≠ 0 := ne_of_gt (one_sub_exp_neg_two_pos ht) rw [h1, h2] field_simp /-- Exact weight decomposition `w(t) = 2 e^{-t/2} + w_0(t)` from Section 4 of F04. -/ lemma weilWeight_split {t : ℝ} (ht : 0 < t) : weilWeight t = 2 * Real.exp (-(t / 2)) + residualWeight t := by rw [weilWeight_eq_q ht] unfold residualWeight have hden : 1 - Real.exp (-(2 * t)) ≠ 0 := ne_of_gt (one_sub_exp_neg_two_pos ht) have hexp : Real.exp (-(t / 2)) * Real.exp (-(2 * t)) = Real.exp (-(5 * t / 2)) := by rw [← Real.exp_add]; congr 1; ring rw [eq_comm, add_div' _ _ _ hden] congr 1 linarith [hexp] lemma residualWeight_pos {t : ℝ} (ht : 0 < t) : 0 < residualWeight t := div_pos (mul_pos zero_lt_two (Real.exp_pos _)) (one_sub_exp_neg_two_pos ht) lemma residualWeight_antiOn : StrictAntiOn residualWeight (Ioi 0) := by intro t₁ ht₁ t₂ ht₂ hlt unfold residualWeight have hnum : 2 * Real.exp (-(5 * t₂ / 2)) < 2 * Real.exp (-(5 * t₁ / 2)) := by apply mul_lt_mul_of_pos_left _ zero_lt_two exact Real.exp_lt_exp.mpr (by linarith) have hden1 : 0 < 1 - Real.exp (-(2 * t₁)) := one_sub_exp_neg_two_pos ht₁ have hden2 : 1 - Real.exp (-(2 * t₁)) < 1 - Real.exp (-(2 * t₂)) := by have : Real.exp (-(2 * t₂)) < Real.exp (-(2 * t₁)) := Real.exp_lt_exp.mpr (by linarith) linarith calc 2 * Real.exp (-(5 * t₂ / 2)) / (1 - Real.exp (-(2 * t₂))) < 2 * Real.exp (-(5 * t₁ / 2)) / (1 - Real.exp (-(2 * t₂))) := div_lt_div_of_pos_right hnum (lt_trans hden1 hden2) _ < 2 * Real.exp (-(5 * t₁ / 2)) / (1 - Real.exp (-(2 * t₁))) := div_lt_div_of_pos_left (mul_pos zero_lt_two (Real.exp_pos _)) hden1 hden2 lemma continuousOn_weilWeight : ContinuousOn weilWeight (Ioi 0) := by refine ContinuousOn.div ?_ ?_ (fun t ht => ne_of_gt (sinh_pos_of_pos ht)) · exact (Real.continuous_exp.comp (continuous_id.div_const 2)).continuousOn · exact Real.continuous_sinh.continuousOn lemma continuousOn_residualWeight : ContinuousOn residualWeight (Ioi 0) := by refine ContinuousOn.div ?_ ?_ (fun t ht => ne_of_gt (one_sub_exp_neg_two_pos ht)) · exact (continuous_const.mul (Real.continuous_exp.comp ((continuous_const.mul continuous_id).div_const 2 |>.neg))).continuousOn · exact (continuous_const.sub (Real.continuous_exp.comp ((continuous_const.mul continuous_id).neg))).continuousOn lemma hasDerivAt_exp_neg_half (x : ℝ) : HasDerivAt (fun t => Real.exp (-(t / 2))) (-(Real.exp (-(x / 2)) / 2)) x := by have hlin : HasDerivAt (fun t : ℝ => -(t / 2)) (-(1 / 2 : ℝ)) x := by have h1 := ((hasDerivAt_id' x).div_const 2).neg exact h1.congr_of_eventuallyEq (Filter.Eventually.of_forall fun _ => rfl) have hcomp := HasDerivAt.comp x (Real.hasDerivAt_exp (-(x / 2))) hlin have hval : Real.exp (-(x / 2)) * -(1 / 2) = -(Real.exp (-(x / 2)) / 2) := by ring rw [hval] at hcomp exact hcomp /-- Exact derivative `B'(L) = -w(L)` for every `L > 0` (Section 3 of F04). -/ lemma hasDerivAt_B_func {L : ℝ} (hL : 0 < L) : HasDerivAt B_func (-weilWeight L) L := by set q := Real.exp (-(L / 2)) with hq_def have hq_pos : 0 < q := Real.exp_pos _ have hq_lt : q < 1 := exp_neg_half_lt_one hL have h1pq : 0 < 1 + q := by linarith have h1mq : 0 < 1 - q := by linarith have hq_deriv : HasDerivAt (fun x => Real.exp (-(x / 2))) (-(q / 2)) L := hasDerivAt_exp_neg_half L have hlog1 := HasDerivAt.comp L (hasDerivAt_log_pos h1pq) (hq_deriv.const_add 1) have hlog2 := HasDerivAt.comp L (hasDerivAt_log_pos h1mq) (hq_deriv.const_sub 1) have hatan := (HasDerivAt.comp L (hasDerivAt_arctan q) hq_deriv).const_mul 2 have hcomb := (hlog1.sub hlog2).add hatan have heq : B_func =ᶠ[𝓝 L] (fun x => Real.log (1 + Real.exp (-(x / 2))) - Real.log (1 - Real.exp (-(x / 2))) + 2 * arctan (Real.exp (-(x / 2)))) := by filter_upwards [Ioi_mem_nhds hL] with x hx unfold B_func have hpx : 0 < 1 + Real.exp (-(x / 2)) := by linarith [Real.exp_pos (-(x / 2))] have hmx : 0 < 1 - Real.exp (-(x / 2)) := by linarith [exp_neg_half_lt_one hx] rw [Real.log_div (ne_of_gt hpx) (ne_of_gt hmx)] have hB := hcomb.congr_of_eventuallyEq heq have hval : ((1 + q)⁻¹ * -(q / 2) - (1 - q)⁻¹ * -(-(q / 2)) + 2 * (1 / (1 + q ^ 2) * -(q / 2))) = -weilWeight L := by rw [weilWeight_eq_q hL] have hq4 : q ^ 4 = Real.exp (-(2 * L)) := by rw [hq_def, ← Real.exp_nat_mul]; congr 1; push_cast; ring have hden : 1 - q ^ 4 ≠ 0 := by rw [hq4]; exact ne_of_gt (one_sub_exp_neg_two_pos hL) have h1pq_ne : 1 + q ≠ 0 := ne_of_gt h1pq have h1mq_ne : 1 - q ≠ 0 := ne_of_gt h1mq have h1pq2_ne : 1 + q ^ 2 ≠ 0 := by positivity rw [← hq_def, ← hq4] field_simp ring rwa [hval] at hB /-- `B(L) → 0` as `L → ∞` (Section 3 of F04). -/ lemma tendsto_B_func_atTop : Tendsto B_func atTop (𝓝 0) := by have hq : Tendsto (fun L : ℝ => Real.exp (-(L / 2))) atTop (𝓝 0) := by have hneg : Tendsto (fun L : ℝ => -(L / 2)) atTop atBot := tendsto_neg_atTop_atBot.comp (tendsto_id.atTop_div_const zero_lt_two) exact Real.tendsto_exp_atBot.comp hneg have hratio : Tendsto (fun L : ℝ => (1 + Real.exp (-(L / 2))) / (1 - Real.exp (-(L / 2)))) atTop (𝓝 ((1 + 0) / (1 - 0))) := (tendsto_const_nhds.add hq).div (tendsto_const_nhds.sub hq) (by norm_num) simp only [add_zero, sub_zero, div_one] at hratio have hlog : Tendsto (fun L : ℝ => Real.log ((1 + Real.exp (-(L / 2))) / (1 - Real.exp (-(L / 2))))) atTop (𝓝 (Real.log 1)) := (hasDerivAt_log_pos zero_lt_one).continuousAt.tendsto.comp hratio rw [Real.log_one] at hlog have hatan : Tendsto (fun L : ℝ => 2 * arctan (Real.exp (-(L / 2)))) atTop (𝓝 (2 * arctan 0)) := (continuous_const.mul continuous_arctan).continuousAt.tendsto.comp hq rw [arctan_zero, mul_zero] at hatan have hsum := hlog.add hatan rw [add_zero] at hsum exact hsum /-- Exact tail integral `∫_{L}^{∞} w(t) dt = B(L)` for every `L > 0` (Section 3 of F04). -/ theorem integral_Ioi_weilWeight {L : ℝ} (hL : 0 < L) : IntegrableOn weilWeight (Ioi L) volume ∧ ∫ t in Ioi L, weilWeight t = B_func L := by have hderiv : ∀ x ∈ Ici L, HasDerivAt (fun t => -B_func t) (weilWeight x) x := by intro x hx have hxpos : 0 < x := lt_of_lt_of_le hL hx have h := (hasDerivAt_B_func hxpos).neg rw [neg_neg] at h exact h have hcont : ContinuousOn weilWeight (Ici L) := continuousOn_weilWeight.mono (fun x hx => lt_of_lt_of_le hL hx) have hnn : ∀ x ∈ Ioi L, 0 ≤ weilWeight x := fun x hx => le_of_lt (weilWeight_pos (lt_trans hL hx)) have htend : Tendsto (fun t => -B_func t) atTop (𝓝 0) := by have := tendsto_B_func_atTop.neg rwa [neg_zero] at this obtain ⟨hint, heq⟩ := integral_Ioi_of_hasDerivAt_of_nonneg hderiv hcont hnn htend refine ⟨hint, ?_⟩ linarith /-- Elementary inequality `(1 + e^{-L/2}) / (1 - e^{-L/2}) ≥ 4 / L` for `L > 0` (Section 6 of F04). -/ lemma ratio_ge_four_div {L : ℝ} (hL : 0 < L) : 4 / L ≤ (1 + Real.exp (-(L / 2))) / (1 - Real.exp (-(L / 2))) := by set x := L / 4 with hx_def have hx : 0 < x := by positivity let g : ℝ → ℝ := fun t => t * Real.cosh t - Real.sinh t have hg_deriv : ∀ t, HasDerivAt g (t * Real.sinh t) t := by intro t have h1 := (hasDerivAt_id' t).mul (hasDerivAt_cosh_real t) have h2 := hasDerivAt_sinh_real t have hsub := h1.sub h2 have hval : 1 * Real.cosh t + t * Real.sinh t - Real.cosh t = t * Real.sinh t := by ring rw [hval] at hsub exact hsub have hg_nonneg : 0 ≤ g x := by have hcont : Continuous (fun t : ℝ => t * Real.sinh t) := continuous_id.mul Real.continuous_sinh have hftc : ∫ t in (0 : ℝ)..x, t * Real.sinh t = g x - g 0 := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun t _ => hg_deriv t) (hcont.intervalIntegrable 0 x) have h0 : g 0 = 0 := by simp [g] have hint_nn : 0 ≤ ∫ t in (0 : ℝ)..x, t * Real.sinh t := by refine intervalIntegral.integral_nonneg (le_of_lt hx) (fun t ht => ?_) rcases eq_or_lt_of_le ht.1 with rfl | htpos · simp · exact mul_nonneg (le_of_lt htpos) (le_of_lt (sinh_pos_of_pos htpos)) linarith have hsinh_le : Real.sinh x ≤ x * Real.cosh x := by linarith [hg_nonneg] have hden : 0 < 1 - Real.exp (-(L / 2)) := by linarith [exp_neg_half_lt_one hL] rw [div_le_div_iff₀ hL hden] rw [Real.sinh_eq, Real.cosh_eq] at hsinh_le have hexp_mul : Real.exp x * Real.exp (-(L / 2)) = Real.exp (-x) := by rw [← Real.exp_add, hx_def]; congr 1; ring have hexp_pos : 0 < Real.exp x := Real.exp_pos x have hscaled : Real.exp x * (1 - Real.exp (-(L / 2))) = Real.exp x - Real.exp (-x) := by rw [mul_sub, mul_one, hexp_mul] have hscaled2 : Real.exp x * (1 + Real.exp (-(L / 2))) = Real.exp x + Real.exp (-x) := by rw [mul_add, mul_one, hexp_mul] have hL4 : L = 4 * x := by rw [hx_def]; ring have htarget : Real.exp x * (4 * (1 - Real.exp (-(L / 2)))) ≤ Real.exp x * ((1 + Real.exp (-(L / 2))) * L) := by calc Real.exp x * (4 * (1 - Real.exp (-(L / 2)))) = 4 * (Real.exp x * (1 - Real.exp (-(L / 2)))) := by ring _ = 4 * (Real.exp x - Real.exp (-x)) := by rw [hscaled] _ ≤ 4 * x * (Real.exp x + Real.exp (-x)) := by linarith _ = 4 * x * (Real.exp x * (1 + Real.exp (-(L / 2)))) := by rw [← hscaled2] _ = Real.exp x * ((1 + Real.exp (-(L / 2))) * L) := by rw [hL4]; ring exact le_of_mul_le_mul_left htarget hexp_pos /-- Lower bound `B(L) ≥ log(4 / L)` for all `L > 0`. -/ lemma log_four_div_le_B_func {L : ℝ} (hL : 0 < L) : Real.log (4 / L) ≤ B_func L := by unfold B_func have hlog : Real.log (4 / L) ≤ Real.log ((1 + Real.exp (-(L / 2))) / (1 - Real.exp (-(L / 2)))) := Real.log_le_log (by positivity) (ratio_ge_four_div hL) have hatan : 0 ≤ 2 * arctan (Real.exp (-(L / 2))) := mul_nonneg zero_le_two (arctan_nonneg (le_of_lt (Real.exp_pos _))) linarith /-- Lower bound `m(L) ≥ log(4 / L) - A` for all `L > 0` (Section 6 of F04). -/ theorem m_func_ge_log_four_div_sub_A {L : ℝ} (hL : 0 < L) : Real.log (4 / L) - weilConstA ≤ m_func L := by unfold m_func linarith [log_four_div_le_B_func hL] /-! ### 6. Connes–Consani Normalization Identity -/ /-- Exact antiderivative for `(e^{t/2} - 1) / sinh t` on `(0, ∞)`. -/ noncomputable def normAntideriv (t : ℝ) : ℝ := -(2 * Real.log (1 + Real.exp (-(t / 2))) + 2 * arctan (Real.exp (-(t / 2))) - Real.log (1 + Real.exp (-t))) lemma hasDerivAt_normAntideriv_pos {t : ℝ} (ht : 0 < t) : HasDerivAt normAntideriv ((Real.exp (t / 2) - 1) / Real.sinh t) t := by set q := Real.exp (-(t / 2)) with hq_def have hq_pos : 0 < q := Real.exp_pos _ have hq2 : Real.exp (-t) = q ^ 2 := by rw [hq_def, sq, ← Real.exp_add]; congr 1; ring have h1pq : 0 < 1 + q := by linarith have h1pq2 : 0 < 1 + Real.exp (-t) := by positivity have hq_deriv : HasDerivAt (fun x => Real.exp (-(x / 2))) (-(q / 2)) t := hasDerivAt_exp_neg_half t have hq2_deriv : HasDerivAt (fun x => Real.exp (-x)) (-q ^ 2) t := by have h := hasDerivAt_exp_neg t rwa [hq2] at h have hd1 := (HasDerivAt.comp t (hasDerivAt_log_pos h1pq) (hq_deriv.const_add 1)).const_mul 2 have hd2 := (HasDerivAt.comp t (hasDerivAt_arctan q) hq_deriv).const_mul 2 have hd3 := HasDerivAt.comp t (hasDerivAt_log_pos h1pq2) (hq2_deriv.const_add 1) have htot := ((hd1.add hd2).sub hd3).neg have hval : -(2 * ((1 + q)⁻¹ * -(q / 2)) + 2 * (1 / (1 + q ^ 2) * -(q / 2)) - (1 + Real.exp (-t))⁻¹ * -q ^ 2) = (Real.exp (t / 2) - 1) / Real.sinh t := by rw [Real.sinh_eq] have hexp_t : Real.exp t = (q ^ 2)⁻¹ := by rw [← hq2, Real.exp_neg, inv_inv] have hexp_half : Real.exp (t / 2) = q⁻¹ := by rw [hq_def, Real.exp_neg, inv_inv] rw [hexp_half, hexp_t, hq2] have hq_ne : q ≠ 0 := ne_of_gt hq_pos have h1pq_ne : 1 + q ≠ 0 := ne_of_gt h1pq have h1pq2_ne : 1 + q ^ 2 ≠ 0 := by positivity have h1mq4_ne : 1 - q ^ 4 ≠ 0 := by have hlt : q < 1 := exp_neg_half_lt_one ht have hsq_lt : q ^ 2 < 1 := by nlinarith have hq4_lt : q ^ 4 < 1 := by nlinarith [sq_nonneg q] linarith have hsinh_ne : (q ^ 2)⁻¹ - q ^ 2 ≠ 0 := by have hlt : q < 1 := exp_neg_half_lt_one ht have hsq_lt : q ^ 2 < 1 := by nlinarith have hinv_gt : 1 < (q ^ 2)⁻¹ := (one_lt_inv₀ (sq_pos_of_pos hq_pos)).mpr hsq_lt linarith field_simp ring rw [hval] at htot exact htot /-- Connes–Consani normalization identity from `PROOF-REVIEW.md`: `log(4π) + γ_E + ∫_{0}^{∞} (e^{t/2} - 1) / sinh(t) dt = A = log(8π) + γ_E + π/2`. -/ theorem connes_consani_normalization : IntegrableOn (fun t => (Real.exp (t / 2) - 1) / Real.sinh t) (Ioi 0) volume ∧ Real.log (4 * Real.pi) + eulerGamma + ∫ t in Ioi (0 : ℝ), (Real.exp (t / 2) - 1) / Real.sinh t = weilConstA := by have hpos_int : ∀ ε > 0, IntegrableOn (fun t => (Real.exp (t / 2) - 1) / Real.sinh t) (Ioi ε) volume ∧ ∫ t in Ioi ε, (Real.exp (t / 2) - 1) / Real.sinh t = -normAntideriv ε := by intro ε hε have hderiv : ∀ x ∈ Ici ε, HasDerivAt normAntideriv ((Real.exp (x / 2) - 1) / Real.sinh x) x := fun x hx => hasDerivAt_normAntideriv_pos (lt_of_lt_of_le hε hx) have hcont : ContinuousOn (fun x => (Real.exp (x / 2) - 1) / Real.sinh x) (Ici ε) := by refine ContinuousOn.div ?_ Real.continuous_sinh.continuousOn (fun x hx => ne_of_gt (sinh_pos_of_pos (lt_of_lt_of_le hε hx))) exact ((Real.continuous_exp.comp (continuous_id.div_const 2)).sub continuous_const).continuousOn have hnn : ∀ x ∈ Ioi ε, 0 ≤ (Real.exp (x / 2) - 1) / Real.sinh x := by intro x hx have hx0 : 0 < x := lt_trans hε hx exact div_nonneg (by linarith [Real.one_le_exp (show 0 ≤ x / 2 by linarith)]) (le_of_lt (sinh_pos_of_pos hx0)) have htend : Tendsto normAntideriv atTop (𝓝 0) := by have hq : Tendsto (fun t : ℝ => Real.exp (-(t / 2))) atTop (𝓝 0) := Real.tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp (tendsto_id.atTop_div_const zero_lt_two)) have hq2 : Tendsto (fun t : ℝ => Real.exp (-t)) atTop (𝓝 0) := Real.tendsto_exp_atBot.comp tendsto_neg_atTop_atBot have h1_arg : Tendsto (fun t : ℝ => (1 : ℝ) + Real.exp (-(t / 2))) atTop (𝓝 1) := by simpa using (tendsto_const_nhds (x := (1 : ℝ))).add hq have h1 : Tendsto (fun t => 2 * Real.log (1 + Real.exp (-(t / 2)))) atTop (𝓝 0) := by have := ((hasDerivAt_log_pos zero_lt_one).continuousAt.tendsto.comp h1_arg).const_mul 2 simpa using this have h2 : Tendsto (fun t => 2 * arctan (Real.exp (-(t / 2)))) atTop (𝓝 0) := by have := (continuous_arctan.continuousAt.tendsto.comp hq).const_mul 2 simpa [arctan_zero] using this have h3_arg : Tendsto (fun t : ℝ => (1 : ℝ) + Real.exp (-t)) atTop (𝓝 1) := by simpa using (tendsto_const_nhds (x := (1 : ℝ))).add hq2 have h3 : Tendsto (fun t => Real.log (1 + Real.exp (-t))) atTop (𝓝 0) := by have h := (hasDerivAt_log_pos zero_lt_one).continuousAt.tendsto.comp h3_arg rw [Real.log_one] at h exact h have hcomb := ((h1.add h2).sub h3).neg have h0val : -((0 : ℝ) + 0 - 0) = 0 := by ring rw [h0val] at hcomb exact hcomb obtain ⟨hi, heq⟩ := integral_Ioi_of_hasDerivAt_of_nonneg hderiv hcont hnn htend exact ⟨hi, by linarith⟩ let g : ℝ → ℝ := fun t => (Real.exp (t / 2) - 1) / Real.sinh t have hg_nn : ∀ t ∈ Ioi (0 : ℝ), 0 ≤ g t := by intro t ht rw [mem_Ioi] at ht exact div_nonneg (by linarith [Real.one_le_exp (show 0 ≤ t / 2 by linarith)]) (le_of_lt (sinh_pos_of_pos ht)) have hg_cont : ContinuousOn g (Ioi 0) := by refine ContinuousOn.div ?_ Real.continuous_sinh.continuousOn (fun t ht => ne_of_gt (sinh_pos_of_pos ht)) exact ((Real.continuous_exp.comp (continuous_id.div_const 2)).sub continuous_const).continuousOn have hUnion : (⋃ n : ℕ, Ioi (1 / ((n : ℝ) + 1))) = Ioi (0 : ℝ) := by ext x simp only [mem_iUnion, mem_Ioi] constructor · rintro ⟨n, hn⟩; exact lt_trans (by positivity) hn · intro hx obtain ⟨n, hn⟩ := exists_nat_gt (1 / x) refine ⟨n, ?_⟩ rw [div_lt_iff₀ (by positivity)] have h1 : 1 < x * (n : ℝ) := by have := (div_lt_iff₀ hx).mp hn linarith nlinarith have hmono : Monotone (fun n : ℕ => Ioi (1 / ((n : ℝ) + 1))) := by intro m n hmn x hx have hle : (1 : ℝ) / ((n : ℝ) + 1) ≤ 1 / ((m : ℝ) + 1) := one_div_le_one_div_of_le (by positivity) (by linarith [show (m : ℝ) ≤ n from Nat.cast_le.mpr hmn]) exact lt_of_le_of_lt hle hx have hlim_lintegral : Tendsto (fun n : ℕ => ∫⁻ t in Ioi (1 / ((n : ℝ) + 1)), ENNReal.ofReal (g t)) atTop (𝓝 (∫⁻ t in Ioi (0 : ℝ), ENNReal.ofReal (g t))) := by rw [← hUnion] exact tendsto_setLIntegral_of_monotone_seq hmono have hval_n : ∀ n : ℕ, ∫⁻ t in Ioi (1 / ((n : ℝ) + 1)), ENNReal.ofReal (g t) = ENNReal.ofReal (-normAntideriv (1 / ((n : ℝ) + 1))) := by intro n have hpos_n : (0 : ℝ) < 1 / ((n : ℝ) + 1) := by positivity obtain ⟨hi, heq⟩ := hpos_int (1 / ((n : ℝ) + 1)) hpos_n rw [← ofReal_integral_eq_lintegral_ofReal hi ((ae_restrict_iff' measurableSet_Ioi).mpr (Filter.Eventually.of_forall (fun t ht => hg_nn t (lt_trans hpos_n ht)))), heq] have hcont_norm : Continuous normAntideriv := by unfold normAntideriv refine Continuous.neg (Continuous.sub (Continuous.add ?_ ?_) ?_) · exact continuous_const.mul (continuousOn_log_Ioi.comp_continuous (continuous_const.add (Real.continuous_exp.comp (continuous_id.div_const 2).neg)) (fun x => by show (0 : ℝ) < 1 + Real.exp (-(x / 2)); linarith [Real.exp_pos (-(x / 2))])) · exact continuous_const.mul (continuous_arctan.comp (Real.continuous_exp.comp (continuous_id.div_const 2).neg)) · exact continuousOn_log_Ioi.comp_continuous (continuous_const.add (Real.continuous_exp.comp continuous_neg)) (fun x => by show (0 : ℝ) < 1 + Real.exp (-x); linarith [Real.exp_pos (-x)]) have hlim_0 : Tendsto (fun n : ℕ => (1 : ℝ) / ((n : ℝ) + 1)) atTop (𝓝 0) := tendsto_one_div_add_atTop_nhds_zero_nat have hnorm0 : -normAntideriv 0 = Real.log 2 + Real.pi / 2 := by unfold normAntideriv simp only [neg_zero, zero_div, Real.exp_zero, arctan_one] ring have hlim_rhs : Tendsto (fun n : ℕ => ENNReal.ofReal (-normAntideriv (1 / ((n : ℝ) + 1)))) atTop (𝓝 (ENNReal.ofReal (Real.log 2 + Real.pi / 2))) := by rw [← hnorm0] exact ENNReal.continuous_ofReal.continuousAt.tendsto.comp (hcont_norm.neg.continuousAt.tendsto.comp hlim_0) have hlintegral : ∫⁻ t in Ioi (0 : ℝ), ENNReal.ofReal (g t) = ENNReal.ofReal (Real.log 2 + Real.pi / 2) := by simp_rw [hval_n] at hlim_lintegral exact tendsto_nhds_unique hlim_lintegral hlim_rhs have hint : IntegrableOn g (Ioi 0) volume := by refine ⟨hg_cont.aestronglyMeasurable measurableSet_Ioi, ?_⟩ rw [HasFiniteIntegral] have hae : (fun x => ‖g x‖ₑ) =ᵐ[volume.restrict (Ioi 0)] (fun x => ENNReal.ofReal (g x)) := by filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx exact Real.enorm_eq_ofReal (hg_nn x hx) rw [lintegral_congr_ae hae, hlintegral] exact ENNReal.ofReal_lt_top refine ⟨hint, ?_⟩ have hint_eq : ∫ t in Ioi (0 : ℝ), g t = Real.log 2 + Real.pi / 2 := by have hnn_ae : 0 ≤ᵐ[volume.restrict (Ioi 0)] g := (ae_restrict_iff' measurableSet_Ioi).mpr (Filter.Eventually.of_forall hg_nn) have hof := ofReal_integral_eq_lintegral_ofReal hint hnn_ae rw [hlintegral] at hof have hnn1 : 0 ≤ ∫ t in Ioi (0 : ℝ), g t := integral_nonneg_of_ae hnn_ae have hnn2 : 0 ≤ Real.log 2 + Real.pi / 2 := by have : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) linarith [Real.pi_pos] exact (ENNReal.ofReal_eq_ofReal_iff hnn1 hnn2).mp hof rw [hint_eq] unfold weilConstA have hlog8 : Real.log (8 * Real.pi) = Real.log (4 * Real.pi) + Real.log 2 := by have : (8 : ℝ) * Real.pi = (4 * Real.pi) * 2 := by ring rw [this, Real.log_mul (by positivity) (by norm_num)] linarith end F04Riemann