Theorem: ProbabilityTheory.lintegral_exponentialPDF_eq_antiDeriv
File: Mathlib/Probability/Distributions/Exponential.lean

tactic: split_ifs with h
state_before: r : ℝ
hr : 0 < r
x : ℝ
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal (if 0 ≤ x then 1 - rexp (-(r * x)) else 0)
state_after: case pos
r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal (1 - rexp (-(r * x)))

case neg
r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal 0

tactic: case neg =>
  simp only [exponentialPDF_eq]
  rw [setLIntegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
  exact ae_of_all _ fun a (_ : a ≤ _) ↦ by rw [if_neg (by linarith), ENNReal.ofReal_eq_zero]
state_before: case pos
r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal (1 - rexp (-(r * x)))

case neg
r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal 0
state_after: case pos
r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal (1 - rexp (-(r * x)))

tactic: simp only [exponentialPDF_eq]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal 0
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, ENNReal.ofReal (if 0 ≤ y then r * rexp (-(r * y)) else 0) = ENNReal.ofReal 0

tactic: rw [setLIntegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, ENNReal.ofReal (if 0 ≤ y then r * rexp (-(r * y)) else 0) = ENNReal.ofReal 0
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∀ᵐ (x_1 : ℝ), x_1 ∈ Iic x → ENNReal.ofReal (if 0 ≤ x_1 then r * rexp (-(r * x_1)) else 0) = 0

tactic: exact ae_of_all _ fun a (_ : a ≤ _) ↦ by rw [if_neg (by linarith), ENNReal.ofReal_eq_zero]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
⊢ ∀ᵐ (x_1 : ℝ), x_1 ∈ Iic x → ENNReal.ofReal (if 0 ≤ x_1 then r * rexp (-(r * x_1)) else 0) = 0
state_after: no goals

tactic: rw [if_neg (by linarith), ENNReal.ofReal_eq_zero]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
a : ℝ
x✝ : a ≤ x
⊢ ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = 0
state_after: no goals

tactic: linarith
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : ¬0 ≤ x
a : ℝ
x✝ : a ≤ x
⊢ ¬0 ≤ a
state_after: no goals

tactic: rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPDF_of_nonpos (le_refl 0),
  zero_add]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPDF r y = ENNReal.ofReal (1 - rexp (-(r * x)))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, exponentialPDF r x = ENNReal.ofReal (1 - rexp (-(r * x)))

tactic: simp only [exponentialPDF_eq]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, exponentialPDF r x = ENNReal.ofReal (1 - rexp (-(r * x)))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (if 0 ≤ x then r * rexp (-(r * x)) else 0) =
    ENNReal.ofReal (1 - rexp (-(r * x)))

tactic: rw [setLIntegral_congr_fun measurableSet_Icc (ae_of_all _
    (by intro a ⟨(hle : _ ≤ a), _⟩; rw [if_pos hle]))]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (if 0 ≤ x then r * rexp (-(r * x)) else 0) =
    ENNReal.ofReal (1 - rexp (-(r * x)))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (r * rexp (-(r * x))) = ENNReal.ofReal (1 - rexp (-(r * x)))

tactic: rw [← ENNReal.toReal_eq_toReal _ ENNReal.ofReal_ne_top, ← integral_eq_lintegral_of_nonneg_ae
    (eventually_of_forall fun _ ↦ le_of_lt (mul_pos hr (exp_pos _)))]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (r * rexp (-(r * x))) = ENNReal.ofReal (1 - rexp (-(r * x)))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫ (a : ℝ) in Icc 0 x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal

r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ AEStronglyMeasurable (fun x => r * rexp (-(r * x))) (ℙ.restrict (Icc 0 x))

r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (r * rexp (-(r * x))) ≠ ⊤

tactic: intro a ⟨(hle : _ ≤ a), _⟩
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∀ a ∈ Icc 0 x, ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = ?m.13634 a
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
a : ℝ
hle : 0 ≤ a
right✝ : a ≤ x
⊢ ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = ?m.13634 a

tactic: rw [if_pos hle]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
a : ℝ
hle : 0 ≤ a
right✝ : a ≤ x
⊢ ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = ?m.13634 a
state_after: no goals

tactic: have : ∫ a in uIoc 0 x, r * rexp (-(r * a)) = ∫ a in (0)..x, r * rexp (-(r * a)) := by
  rw [intervalIntegral.intervalIntegral_eq_integral_uIoc, smul_eq_mul, if_pos h, one_mul]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫ (a : ℝ) in Icc 0 x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∫ (a : ℝ) in Icc 0 x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal

tactic: rw [integral_Icc_eq_integral_Ioc, ← uIoc_of_le h, this]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∫ (a : ℝ) in Icc 0 x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal

tactic: rw [intervalIntegral.integral_eq_sub_of_hasDeriv_right_of_le h
  (f := fun a ↦ -1 * rexp (-(r * a))) _ _]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -1 * rexp (-(r * x)) - -1 * rexp (-(r * 0)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal

r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ IntervalIntegrable (fun a => r * rexp (-(r * a))) ℙ 0 x

r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ContinuousOn (fun a => -1 * rexp (-(r * a))) (Icc 0 x)

r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∀ x_1 ∈ Ioo 0 x, HasDerivWithinAt (fun a => -1 * rexp (-(r * a))) (r * rexp (-(r * x_1))) (Ioi x_1) x_1

tactic: rw [intervalIntegral.intervalIntegral_eq_integral_uIoc, smul_eq_mul, if_pos h, one_mul]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
state_after: no goals

tactic: rw [ENNReal.toReal_ofReal_eq_iff.2 (by norm_num; positivity)]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -1 * rexp (-(r * x)) - -1 * rexp (-(r * 0)) = (ENNReal.ofReal (1 - rexp (-(r * x)))).toReal
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -1 * rexp (-(r * x)) - -1 * rexp (-(r * 0)) = 1 - rexp (-(r * x))

tactic: norm_num
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -1 * rexp (-(r * x)) - -1 * rexp (-(r * 0)) = 1 - rexp (-(r * x))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -rexp (-(r * x)) + 1 = 1 - rexp (-(r * x))

tactic: ring
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ -rexp (-(r * x)) + 1 = 1 - rexp (-(r * x))
state_after: no goals

tactic: norm_num
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ 0 ≤ 1 - rexp (-(r * x))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ 0 ≤ r * x

tactic: positivity
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ 0 ≤ r * x
state_after: no goals

tactic: simp only [intervalIntegrable_iff, uIoc_of_le h]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ IntervalIntegrable (fun a => r * rexp (-(r * a))) ℙ 0 x
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ IntegrableOn (fun a => r * rexp (-(r * a))) (Ioc 0 x) ℙ

tactic: exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ IntegrableOn (fun a => r * rexp (-(r * a))) (Ioc 0 x) ℙ
state_after: no goals

tactic: have : Continuous (fun a ↦ rexp (-(r * a))) := by
  simp only [← neg_mul]; exact (continuous_mul_left (-r)).rexp
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ContinuousOn (fun a => -1 * rexp (-(r * a))) (Icc 0 x)
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this✝ : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
this : Continuous fun a => rexp (-(r * a))
⊢ ContinuousOn (fun a => -1 * rexp (-(r * a))) (Icc 0 x)

tactic: exact Continuous.continuousOn (Continuous.comp' (continuous_mul_left (-1)) this)
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this✝ : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
this : Continuous fun a => rexp (-(r * a))
⊢ ContinuousOn (fun a => -1 * rexp (-(r * a))) (Icc 0 x)
state_after: no goals

tactic: simp only [← neg_mul]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ Continuous fun a => rexp (-(r * a))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ Continuous fun a => rexp (-r * a)

tactic: exact (continuous_mul_left (-r)).rexp
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ Continuous fun a => rexp (-r * a)
state_after: no goals

tactic: simp only [neg_mul, one_mul]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∀ x_1 ∈ Ioo 0 x, HasDerivWithinAt (fun a => -1 * rexp (-(r * a))) (r * rexp (-(r * x_1))) (Ioi x_1) x_1
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∀ x_1 ∈ Ioo 0 x, HasDerivWithinAt (fun a => -rexp (-(r * a))) (r * rexp (-(r * x_1))) (Ioi x_1) x_1

tactic: exact fun _ _ ↦ HasDerivAt.hasDerivWithinAt hasDerivAt_neg_exp_mul_exp
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
this : ∫ (a : ℝ) in Ι 0 x, r * rexp (-(r * a)) = ∫ (a : ℝ) in 0 ..x, r * rexp (-(r * a))
⊢ ∀ x_1 ∈ Ioo 0 x, HasDerivWithinAt (fun a => -rexp (-(r * a))) (r * rexp (-(r * x_1))) (Ioi x_1) x_1
state_after: no goals

tactic: apply Integrable.aestronglyMeasurable (Integrable.const_mul _ _)
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ AEStronglyMeasurable (fun x => r * rexp (-(r * x))) (ℙ.restrict (Icc 0 x))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ Integrable (fun x => rexp (-(r * x))) (ℙ.restrict (Icc 0 x))

tactic: rw [← IntegrableOn, integrableOn_Icc_iff_integrableOn_Ioc]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ Integrable (fun x => rexp (-(r * x))) (ℙ.restrict (Icc 0 x))
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => rexp (-(r * x))) (Ioc 0 x) ℙ

tactic: exact exp_neg_integrableOn_Ioc hr
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => rexp (-(r * x))) (Ioc 0 x) ℙ
state_after: no goals

tactic: refine ne_of_lt (IntegrableOn.setLIntegral_lt_top ?_)
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, ENNReal.ofReal (r * rexp (-(r * x))) ≠ ⊤
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => r * rexp (-(r * x))) (Icc 0 x) ℙ

tactic: rw [integrableOn_Icc_iff_integrableOn_Ioc]
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => r * rexp (-(r * x))) (Icc 0 x) ℙ
state_after: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => r * rexp (-(r * x))) (Ioc 0 x) ℙ

tactic: exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
state_before: r : ℝ
hr : 0 < r
x : ℝ
h : 0 ≤ x
⊢ IntegrableOn (fun x => r * rexp (-(r * x))) (Ioc 0 x) ℙ
state_after: no goals