-- Mathlib/Probability/Distributions/Gaussian.lean
/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/
lemma lintegral_gaussianPDFReal_eq_one (μ : ℝ) {v : ℝ≥0} (h : v ≠ 0) :
    ∫⁻ x, ENNReal.ofReal (gaussianPDFReal μ v x) = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ √((2 * π * ↑v)⁻¹ * (π / ((↑v)⁻¹ * 2⁻¹))) = 1

Tactic:
field_simp

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ √π * (√↑v * √2) = √2 * √π * √↑v

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Tactic:
have hfm : AEStronglyMeasurable (gaussianPDFReal μ v) volume :=
  (stronglyMeasurable_gaussianPDFReal μ v).aestronglyMeasurable

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (a : ℝ), rexp (-(a - μ) ^ 2 / (2 * ↑v)) = 1

Tactic:
rw [integral_sub_right_eq_self (μ := volume) (fun a ↦ rexp (-a ^ 2 / ((2 : ℝ) * v))) μ]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-x ^ 2 / (2 * ↑v)) = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
⊢ ∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x) = 1

Tactic:
rw [← ENNReal.toReal_eq_one_iff]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Proof state:
case hx
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ 0 ≤ (2 * π * ↑v)⁻¹

Tactic:
positivity

Result:
no goals

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ ∫ (a : ℝ), gaussianPDFReal μ v a = 1

Tactic:
simp only [gaussianPDFReal, zero_lt_two, mul_nonneg_iff_of_pos_right, one_div,
  Nat.cast_ofNat, integral_mul_left]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (a : ℝ), rexp (-(a - μ) ^ 2 / (2 * ↑v)) = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ √π * (√↑v * √2) = √2 * √π * √↑v

Tactic:
ring

Result:
no goals

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-x ^ 2 / (2 * ↑v)) = 1

Tactic:
simp only [zero_lt_two, mul_nonneg_iff_of_pos_right, div_eq_inv_mul, mul_inv_rev,
  mul_neg]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-((↑v)⁻¹ * 2⁻¹ * x ^ 2)) = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Tactic:
have hf : 0 ≤ₐₛ gaussianPDFReal μ v := ae_of_all _ (gaussianPDFReal_nonneg μ v)

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (∫⁻ (x : ℝ), ENNReal.ofReal (gaussianPDFReal μ v x)).toReal = 1

Tactic:
rw [← integral_eq_lintegral_of_nonneg_ae hf hfm]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ ∫ (a : ℝ), gaussianPDFReal μ v a = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-((↑v)⁻¹ * 2⁻¹ * x ^ 2)) = 1

Tactic:
simp_rw [← neg_mul]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-(↑v)⁻¹ * 2⁻¹ * x ^ 2) = 1

Proof state:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ (√(2 * π * ↑v))⁻¹ * ∫ (x : ℝ), rexp (-(↑v)⁻¹ * 2⁻¹ * x ^ 2) = 1

Tactic:
rw [neg_mul, integral_gaussian, ← Real.sqrt_inv, ← Real.sqrt_mul]

Result:
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ √((2 * π * ↑v)⁻¹ * (π / ((↑v)⁻¹ * 2⁻¹))) = 1

case hx
μ : ℝ
v : ℝ≥0
h : v ≠ 0
hfm : AEStronglyMeasurable (gaussianPDFReal μ v) ℙ
hf : 0 ≤ᶠ[ae ℙ] gaussianPDFReal μ v
⊢ 0 ≤ (2 * π * ↑v)⁻¹