Pratik Patil

GaussianRadius.lean

1module23public import Mathlib.Probability.Distributions.Gaussian.Real4public import Mathlib.Probability.Independence.Basic5import Mathlib.Analysis.SpecialFunctions.PolarCoord6import Mathlib.MeasureTheory.Function.JacobianOneDim78/-! The squared radius of two independent standard real Gaussians,9divided by two, has unit exponential density. -/10@[expose] public section11noncomputable section12open MeasureTheory MeasureTheory.Measure ProbabilityTheory Real Set13namespace SubentropyCertificates.Representations1415private def energy (p : ℝ × ℝ) : ℝ := (p.1^2 + p.2^2) / 21617private theorem radial_substitution (f : ℝ → ℝ) :18    (∫ r in Ioi (0 : ℝ), r * f (r^2 / 2)) = ∫ t in Ioi (0 : ℝ), f t := by19  let u (r : ℝ) := r^2 / 220  have himage : u '' Ioi 0 = Ioi 0 := by21    ext t22    constructor23    · rintro ⟨r, hr, rfl⟩24      change 0 < r^2 / 225      exact div_pos (sq_pos_of_pos hr) zero_lt_two26    · intro ht27      refine ⟨√(2*t), sqrt_pos.mpr (mul_pos zero_lt_two ht), ?_⟩28      change (√(2*t))^2 / 2 = t29      rw [sq_sqrt (mul_nonneg zero_le_two ht.le)]30      ring31  have hd (r : ℝ) (_ : r ∈ Ioi (0 : ℝ)) : HasDerivWithinAt u r (Ioi 0) r := by32    have h := ((hasDerivAt_pow 2 r).div_const 2).hasDerivWithinAt (s := Ioi 0)33    convert h using 134    simp35  have hinj : InjOn u (Ioi 0) := by36    intro x hx y hy hxy37    change x^2 / 2 = y^2 / 2 at hxy38    exact (sq_eq_sq₀ hx.le hy.le).mp (by linarith)39  have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi hd hinj f40  rw [himage] at h41  rw [h]42  exact setIntegral_congr_fun measurableSet_Ioi fun r hr => by43    rw [abs_of_pos hr, smul_eq_mul]4445private theorem plane_radial_integral (f : ℝ → ℝ) :46    (∫ p : ℝ × ℝ, f (energy p)) = (2 * π) * ∫ t in Ioi (0 : ℝ), f t := by47  have henergy (p : ℝ × ℝ) : energy (polarCoord.symm p) = p.1^2 / 2 := by48    simp only [energy, polarCoord_symm_apply, mul_pow]49    rw [← mul_add, cos_sq_add_sin_sq, mul_one]50  rw [← integral_comp_polarCoord_symm, polarCoord_target]51  simp_rw [henergy, smul_eq_mul]52  have hprod := setIntegral_prod_mul (μ := volume) (ν := volume)53    (s := Ioi (0 : ℝ)) (t := Ioo (-π) π) (fun r => r * f (r^2 / 2)) (fun _ => (1 : ℝ))54  simp only [mul_one, ← volume_eq_prod] at hprod55  rw [hprod, radial_substitution]56  simp only [integral_const, measureReal_restrict_apply MeasurableSet.univ, univ_inter,57    volume_real_Ioo_of_le (a := -π) (b := π) (by linarith [pi_pos]), smul_eq_mul]58  ring5960theorem gaussian_pair_integral (f : ℝ → ℝ) :61    (∫ p : ℝ × ℝ, f ((p.1^2 + p.2^2) / 2) ∂(gaussianReal 0 1).prod (gaussianReal 0 1)) =62      ∫ t in Ioi (0 : ℝ), exp (-t) * f t := by63  let d := gaussianPDF 0 164  have hm : Measurable (fun p : ℝ × ℝ => d p.1 * d p.2) :=65    ((measurable_gaussianPDF 0 1).comp measurable_fst).mul66      ((measurable_gaussianPDF 0 1).comp measurable_snd)67  have htop (p : ℝ × ℝ) : d p.1 * d p.2 < ⊤ :=68    ENNReal.mul_lt_top gaussianPDF_lt_top gaussianPDF_lt_top69  have hd (x y : ℝ) :70      gaussianPDFReal 0 1 x * gaussianPDFReal 0 1 y =71      (2 * π)⁻¹ * exp (-energy (x,y)) := by72    simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero, energy]73    rw [mul_mul_mul_comm, ← mul_inv, ← sq, sq_sqrt (by positivity), ← exp_add]74    congr 275    ring76  rw [gaussianReal_of_var_ne_zero 0 one_ne_zero,77    prod_withDensity (measurable_gaussianPDF _ _) (measurable_gaussianPDF _ _),78    ← volume_eq_prod, integral_withDensity_eq_integral_toReal_smul hm (.of_forall htop)]79  simp only [d, ENNReal.toReal_mul, toReal_gaussianPDF, smul_eq_mul, hd, mul_assoc]80  rw [integral_const_mul]81  change (2 * π)⁻¹ * (∫ p : ℝ × ℝ, exp (-energy p) * f (energy p)) = _82  rw [plane_radial_integral (fun t => exp (-t) * f t)]83  field_simp8485theorem gaussian_coordinate_integral {D : Type*} [Fintype D] (i : D) (f : ℝ → ℝ)86    (hf : Measurable f) :87    (∫ z : (D × Fin 2) → ℝ, f (((z (i,0))^2 + (z (i,1))^2) / 2)88      ∂Measure.pi (fun _ => gaussianReal 0 1)) = ∫ t in Ioi (0 : ℝ), exp (-t) * f t := by89  let μ := fun _ : D × Fin 2 => gaussianReal 0 190  let pair (z : (D × Fin 2) → ℝ) := (z (i,0), z (i,1))91  have hind := iIndepFun_pi (μ := μ) (X := fun _ => id) (fun _ => aemeasurable_id)92  have hne : (i, (0 : Fin 2)) ≠ (i, 1) := by simp93  have hmap : (Measure.pi μ).map pair = (gaussianReal 0 1).prod (gaussianReal 0 1) := by94    have h := (hind.indepFun hne).map_prod_eq_prod_map_map95      (measurable_pi_apply (i,0)).aemeasurable (measurable_pi_apply (i,1)).aemeasurable96    exact h.trans (congrArg₂ Measure.prod (measurePreserving_eval μ (i,0)).map_eq97      (measurePreserving_eval μ (i,1)).map_eq)98  rw [← gaussian_pair_integral f, ← hmap, integral_map]99  · exact ((measurable_pi_apply (i,0)).prodMk (measurable_pi_apply (i,1))).aemeasurable100  · exact (hf.comp (show Measurable energy by unfold energy; fun_prop)).aestronglyMeasurable101102end SubentropyCertificates.Representations

Axioms used

Choose a statement to see which axioms its proof uses.