import OAI.NumberTheory.DirichletL.Continuation import Mathlib.Analysis.MellinInversion namespace OAI noncomputable section open MeasureTheory Set Filter Asymptotics open scoped Topology FourierTransform namespace SevenEighths.Continuation theorem integrable_logProfile {f : ℝ → ℂ} {σ : ℝ} (hf : MellinConvergent f (σ : ℂ)) : Integrable (fun u : ℝ => Real.exp (-σ * u) • f (Real.exp (-u))) := by have hder : ∀ x ∈ (univ : Set ℝ), HasDerivWithinAt (Real.exp ∘ Neg.neg) (-Real.exp (-x)) univ x := fun x _ => mul_neg_one (Real.exp (-x)) ▸ ((Real.hasDerivAt_exp (-x)).comp x (hasDerivAt_neg x)).hasDerivWithinAt have himage : Real.exp ∘ Neg.neg '' (univ : Set ℝ) = Ioi 0 := by rw [Set.image_comp, Set.image_univ_of_surjective neg_surjective, Set.image_univ, Real.range_exp] have hinj : univ.InjOn (Real.exp ∘ Neg.neg) := Real.exp_injective.injOn.comp neg_injective.injOn (univ.mapsTo_univ _) rw [MellinConvergent, ← himage, integrableOn_image_iff_integrableOn_abs_deriv_smul MeasurableSet.univ hder hinj] at hf have heq (u : ℝ) : |-(Real.exp (-u))| • ((Real.exp (-u) : ℂ) ^ ((σ : ℂ) - 1) • f (Real.exp (-u))) = Real.exp (-σ * u) • f (Real.exp (-u)) := by rw [abs_neg, abs_of_pos (Real.exp_pos _)] change (Real.exp (-u) : ℂ) * ((Real.exp (-u) : ℂ) ^ ((σ : ℂ) - 1) * f (Real.exp (-u))) = (Real.exp (-σ * u) : ℂ) * f (Real.exp (-u)) rw [← mul_assoc] congr 1 rw [show (σ : ℂ) - 1 = ((σ - 1 : ℝ) : ℂ) by push_cast; rfl, ← Complex.ofReal_cpow (Real.exp_pos (-u)).le] norm_cast rw [Real.rpow_def_of_pos (Real.exp_pos (-u)), Real.log_exp, ← Real.exp_add] congr 1 ring simpa only [Function.comp_apply, integrableOn_univ, heq] using hf theorem mellin_mellinInv_eq (σ : ℝ) (F : ℂ → ℂ) (f : ℝ → ℂ) (hf : MellinConvergent f (σ : ℂ)) (hF : Integrable (fun y : ℝ => F ((σ : ℂ) + 2 * Real.pi * y * Complex.I))) (hcont : Continuous (fun y : ℝ => F ((σ : ℂ) + 2 * Real.pi * y * Complex.I))) (hrep : ∀ x : ℝ, 0 < x → f x = mellinInv σ F x) (y : ℝ) : mellin f ((σ : ℂ) + 2 * Real.pi * y * Complex.I) = F ((σ : ℂ) + 2 * Real.pi * y * Complex.I) := by let A : ℝ → ℂ := fun y => F ((σ : ℂ) + 2 * Real.pi * y * Complex.I) let g : ℝ → ℂ := fun u => Real.exp (-σ * u) • f (Real.exp (-u)) have hg : Integrable g := integrable_logProfile hf have hginv : g = 𝓕⁻ A := by funext u dsimp [g] rw [hrep _ (Real.exp_pos _), mellinInv_eq_fourierInv _ _ (Real.exp_pos _)] simp only [Real.log_exp, neg_neg] change (Real.exp (-σ * u) : ℂ) * ((Real.exp (-u) : ℂ) ^ (-(σ : ℂ)) * 𝓕⁻ A u) = 𝓕⁻ A u rw [← mul_assoc, ← Complex.ofReal_neg, ← Complex.ofReal_cpow (Real.exp_pos (-u)).le] have hc : Real.exp (-σ * u) * Real.exp (-u) ^ (-σ) = 1 := by rw [Real.rpow_def_of_pos (Real.exp_pos (-u)), Real.log_exp, ← Real.exp_add] rw [show -σ * u + -u * -σ = 0 by ring, Real.exp_zero] rw [← Complex.ofReal_mul, hc, Complex.ofReal_one, one_mul] have hfourier : Integrable (𝓕 A) := by have hn := hg.comp_neg rw [hginv] at hn simpa only [Real.fourierInv_eq_fourier_neg, neg_neg] using hn rw [mellin_eq_fourier] have hre : ((σ : ℂ) + 2 * Real.pi * y * Complex.I).re = σ := by simp have him : ((σ : ℂ) + 2 * Real.pi * y * Complex.I).im / (2 * Real.pi) = y := by simp rw [hre, him] change 𝓕 g y = A y rw [hginv] exact hF.fourier_fourierInv_eq hfourier hcont.continuousAt def normalizedSignal (f : ℝ → ℂ) (c : ℝ) (x : ℝ) : ℂ := (x : ℂ) ^ (-(c : ℂ)) • f x theorem mellin_normalizedSignal (f : ℝ → ℂ) (c : ℝ) (s : ℂ) : mellin (normalizedSignal f c) (-s) = signalMellin f c s := by unfold normalizedSignal signalMellin rw [mellin_cpow_smul] congr 1 ring theorem signalMellin_eq_on_line (f : ℝ → ℂ) (A : ℂ → ℂ) (c d : ℝ) (hf : MellinConvergent f (-((d : ℂ) + (c : ℂ)))) (hA : Integrable (fun y : ℝ => A ((d : ℂ) - 2 * Real.pi * y * Complex.I))) (hcont : Continuous (fun y : ℝ => A ((d : ℂ) - 2 * Real.pi * y * Complex.I))) (hrep : ∀ x : ℝ, 0 < x → normalizedSignal f c x = mellinInv (-d) (fun s => A (-s)) x) (y : ℝ) : signalMellin f c ((d : ℂ) - 2 * Real.pi * y * Complex.I) = A ((d : ℂ) - 2 * Real.pi * y * Complex.I) := by have hf' : MellinConvergent (normalizedSignal f c) ((-d : ℝ) : ℂ) := by unfold normalizedSignal apply MellinConvergent.cpow_smul.mpr convert hf using 1; push_cast; ring have harg (y : ℝ) : -(((-d : ℝ) : ℂ) + 2 * Real.pi * y * Complex.I) = (d : ℂ) - 2 * Real.pi * y * Complex.I := by push_cast; ring have hA' : Integrable (fun y : ℝ => A (-(((-d : ℝ) : ℂ) + 2 * Real.pi * y * Complex.I))) := by simpa only [harg] using hA have hcont' : Continuous (fun y : ℝ => A (-(((-d : ℝ) : ℂ) + 2 * Real.pi * y * Complex.I))) := by simpa only [harg] using hcont have hid := mellin_mellinInv_eq (-d) (fun s => A (-s)) (normalizedSignal f c) hf' hA' hcont' hrep y rw [harg] at hid rw [← mellin_normalizedSignal] convert hid using 1; congr 1; push_cast; ring end SevenEighths.Continuation end end OAI