l3lab/ntp-mathlib huggingface dataset:
/-- The Pdf of the exponential Distribution integrates to 1-/
@[simp]
lemma lintegral_exponentialPdf_eq_one (r : ℝ) (hr : 0 < r) : ∫⁻ x, exponentialPdf r x = 1 := by
  rw [lintegral_eq_lintegral_Ici_add_Iio (exponentialPdf r) 0, ← ENNReal.toReal_eq_one_iff]
  have leftSide : ∫⁻ x in Iio 0, exponentialPdf r x = 0 := by
    rw [set_lintegral_congr_fun measurableSet_Iio
      (ae_of_all _ (fun x (hx : x < 0) ↦ exponentialPdf_of_neg hx)), lintegral_zero]
  have rightSide :
      ∫⁻ x in Ici 0, exponentialPdf r x = ∫⁻ x in Ici 0, ENNReal.ofReal (r * rexp (-(r * x))) :=
    set_lintegral_congr_fun isClosed_Ici.measurableSet
      (ae_of_all _ (fun x (hx : 0 ≤ x) ↦ exponentialPdf_of_nonneg hx))
  simp only [leftSide, add_zero]
  rw [rightSide, ENNReal.toReal_eq_one_iff, ← ENNReal.toReal_eq_one_iff]
  rw [← integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (fun _ ↦ by positivity))]
  · have integrOn : IntegrableOn (fun x ↦ rexp (-(r * x))) (Ioi 0) := by
      simp only [← neg_mul, exp_neg_integrableOn_Ioi 0 hr]
    

Proof state:
r : ℝ
hr : 0 < r
leftSide : ∫⁻ (x : ℝ) in Iio 0, exponentialPdf r x = 0
rightSide : ∫⁻ (x : ℝ) in Ici 0, exponentialPdf r x = ∫⁻ (x : ℝ) in Ici 0, ENNReal.ofReal (r * rexp (-(r * x)))
integrOn : IntegrableOn (fun x => rexp (-(r * x))) (Ioi 0)
⊢ ∫ (a : ℝ) in Ici 0, r * rexp (-(r * a)) = 1

Next tactic:
rw [integral_mul_left, integral_Ici_eq_integral_Ioi,
        integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (fun _ _ ↦ hasDerivAt_exp_neg hr) integrOn]
/-- The Pdf of the exponential Distribution integrates to 1-/
@[simp]
lemma lintegral_exponentialPdf_eq_one (r : ℝ) (hr : 0 < r) : ∫⁻ x, exponentialPdf r x = 1 := by
  rw [lintegral_eq_lintegral_Ici_add_Iio (exponentialPdf r) 0, ← ENNReal.toReal_eq_one_iff]
  have leftSide : ∫⁻ x in Iio 0, exponentialPdf r x = 0 := by
    rw [set_lintegral_congr_fun measurableSet_Iio
      (ae_of_all _ (fun x (hx : x < 0) ↦ exponentialPdf_of_neg hx)), lintegral_zero]
  have rightSide :
      ∫⁻ x in Ici 0, exponentialPdf r x = ∫⁻ x in Ici 0, ENNReal.ofReal (r * rexp (-(r * x))) :=
    set_lintegral_congr_fun isClosed_Ici.measurableSet
      (ae_of_all _ (fun x (hx : 0 ≤ x) ↦ exponentialPdf_of_nonneg hx))
  simp only [leftSide, add_zero]
  rw [rightSide, ENNReal.toReal_eq_one_iff, ← ENNReal.toReal_eq_one_iff]
  rw [← integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (fun _ ↦ by positivity))]
  · have integrOn : IntegrableOn (fun x ↦ rexp (-(r * x))) (Ioi 0) := by
      simp only [← neg_mul, exp_neg_integrableOn_Ioi 0 hr]
    rw [integral_mul_left, integral_Ici_eq_integral_Ioi,
        integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (fun _ _ ↦ hasDerivAt_exp_neg hr) integrOn]
    · 

Proof state:
r : ℝ
hr : 0 < r
leftSide : ∫⁻ (x : ℝ) in Iio 0, exponentialPdf r x = 0
rightSide : ∫⁻ (x : ℝ) in Ici 0, exponentialPdf r x = ∫⁻ (x : ℝ) in Ici 0, ENNReal.ofReal (r * rexp (-(r * x)))
integrOn : IntegrableOn (fun x => rexp (-(r * x))) (Ioi 0)
⊢ r * (0 - -1 / r * rexp (-(r * 0))) = 1

Next tactic:
field_simp
/-- The Pdf of the exponential Distribution integrates to 1-/
@[simp]
lemma lintegral_exponentialPdf_eq_one (r : ℝ) (hr : 0 < r) : ∫⁻ x, exponentialPdf r x = 1 := by
  rw [lintegral_eq_lintegral_Ici_add_Iio (exponentialPdf r) 0, ← ENNReal.toReal_eq_one_iff]
  have leftSide : ∫⁻ x in Iio 0, exponentialPdf r x = 0 := by
    rw [set_lintegral_congr_fun measurableSet_Iio
      (ae_of_all _ (fun x (hx : x < 0) ↦ exponentialPdf_of_neg hx)), lintegral_zero]
  have rightSide :
      ∫⁻ x in Ici 0, exponentialPdf r x = ∫⁻ x in Ici 0, ENNReal.ofReal (r * rexp (-(r * x))) :=
    set_lintegral_congr_fun isClosed_Ici.measurableSet
      (ae_of_all _ (fun x (hx : 0 ≤ x) ↦ exponentialPdf_of_nonneg hx))
  simp only [leftSide, add_zero]
  rw [rightSide, ENNReal.toReal_eq_one_iff, ← ENNReal.toReal_eq_one_iff]
  rw [← integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (fun _ ↦ by positivity))]
  · have integrOn : IntegrableOn (fun x ↦ rexp (-(r * x))) (Ioi 0) := by
      simp only [← neg_mul, exp_neg_integrableOn_Ioi 0 hr]
    rw [integral_mul_left, integral_Ici_eq_integral_Ioi,
        integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (fun _ _ ↦ hasDerivAt_exp_neg hr) integrOn]
    · field_simp
    · 

Proof state:
r : ℝ
hr : 0 < r
leftSide : ∫⁻ (x : ℝ) in Iio 0, exponentialPdf r x = 0
rightSide : ∫⁻ (x : ℝ) in Ici 0, exponentialPdf r x = ∫⁻ (x : ℝ) in Ici 0, ENNReal.ofReal (r * rexp (-(r * x)))
integrOn : IntegrableOn (fun x => rexp (-(r * x))) (Ioi 0)
⊢ Tendsto (fun a => -1 / r * rexp (-(r * a))) atTop (𝓝 0)

Next tactic:
rw [← mul_zero (-1/r)]
/-- The Pdf of the exponential Distribution integrates to 1-/
@[simp]
lemma lintegral_exponentialPdf_eq_one (r : ℝ) (hr : 0 < r) : ∫⁻ x, exponentialPdf r x = 1 := by
  rw [lintegral_eq_lintegral_Ici_add_Iio (exponentialPdf r) 0, ← ENNReal.toReal_eq_one_iff]
  have leftSide : ∫⁻ x in Iio 0, exponentialPdf r x = 0 := by
    rw [set_lintegral_congr_fun measurableSet_Iio
      (ae_of_all _ (fun x (hx : x < 0) ↦ exponentialPdf_of_neg hx)), lintegral_zero]
  have rightSide :
      ∫⁻ x in Ici 0, exponentialPdf r x = ∫⁻ x in Ici 0, ENNReal.ofReal (r * rexp (-(r * x))) :=
    set_lintegral_congr_fun isClosed_Ici.measurableSet
      (ae_of_all _ (fun x (hx : 0 ≤ x) ↦ exponentialPdf_of_nonneg hx))
  simp only [leftSide, add_zero]
  rw [rightSide, ENNReal.toReal_eq_one_iff, ← ENNReal.toReal_eq_one_iff]
  rw [← integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (fun _ ↦ by positivity))]
  · have integrOn : IntegrableOn (fun x ↦ rexp (-(r * x))) (Ioi 0) := by
      simp only [← neg_mul, exp_neg_integrableOn_Ioi 0 hr]
    rw [integral_mul_left, integral_Ici_eq_integral_Ioi,
        integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (fun _ _ ↦ hasDerivAt_exp_neg hr) integrOn]
    · field_simp
    · rw [← mul_zero (-1/r)]
      

Proof state:
r : ℝ
hr : 0 < r
leftSide : ∫⁻ (x : ℝ) in Iio 0, exponentialPdf r x = 0
rightSide : ∫⁻ (x : ℝ) in Ici 0, exponentialPdf r x = ∫⁻ (x : ℝ) in Ici 0, ENNReal.ofReal (r * rexp (-(r * x)))
integrOn : IntegrableOn (fun x => rexp (-(r * x))) (Ioi 0)
⊢ Tendsto (fun a => -1 / r * rexp (-(r * a))) atTop (𝓝 (-1 / r * 0))

Next tactic:
exact tendsto_const_nhds.mul (tendsto_exp_neg_atTop_nhds_0.comp
        ((tendsto_const_mul_atTop_of_pos hr).2 tendsto_id))
/-- The Pdf of the exponential Distribution integrates to 1-/
@[simp]
lemma lintegral_exponentialPdf_eq_one (r : ℝ) (hr : 0 < r) : ∫⁻ x, exponentialPdf r x = 1 := by
  rw [lintegral_eq_lintegral_Ici_add_Iio (exponentialPdf r) 0, ← ENNReal.toReal_eq_one_iff]
  have leftSide : ∫⁻ x in Iio 0, exponentialPdf r x = 0 := by
    rw [set_lintegral_congr_fun measurableSet_Iio
      (ae_of_all _ (fun x (hx : x < 0) ↦ exponentialPdf_of_neg hx)), lintegral_zero]
  have rightSide :
      ∫⁻ x in Ici 0, exponentialPdf r x = ∫⁻ x in Ici 0, ENNReal.ofReal (r * rexp (-(r * x))) :=
    set_lintegral_congr_fun isClosed_Ici.measurableSet
      (ae_of_all _ (fun x (hx : 0 ≤ x) ↦ exponentialPdf_of_nonneg hx))
  simp only [leftSide, add_zero]
  rw [rightSide, ENNReal.toReal_eq_one_iff, ← ENNReal.toReal_eq_one_iff]
  rw [← integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (fun _ ↦ by positivity))]
  · have integrOn : IntegrableOn (fun x ↦ rexp (-(r * x))) (Ioi 0) := by
      simp only [← neg_mul, exp_neg_integrableOn_Ioi 0 hr]
    rw [integral_mul_left, integral_Ici_eq_integral_Ioi,
        integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (fun _ _ ↦ hasDerivAt_exp_neg hr) integrOn]
    · field_simp
    · rw [← mul_zero (-1/r)]
      exact tendsto_const_nhds.mul (tendsto_exp_neg_atTop_nhds_0.comp
        ((tendsto_const_mul_atTop_of_pos hr).2 tendsto_id))
  · 

Proof state:
r : ℝ
hr : 0 < r
leftSide : ∫⁻ (x : ℝ) in Iio 0, exponentialPdf r x = 0
rightSide : ∫⁻ (x : ℝ) in Ici 0, exponentialPdf r x = ∫⁻ (x : ℝ) in Ici 0, ENNReal.ofReal (r * rexp (-(r * x)))
⊢ AEStronglyMeasurable (fun x => r * rexp (-(r * x))) (Measure.restrict ℙ (Ici 0))

Next tactic:
exact ((measurable_id'.const_mul r).neg.exp.const_mul r).stronglyMeasurable.aestronglyMeasurable
instance instIsProbabilityMeasureExponential (r : ℝ) [Fact (0 < r)] :
    IsProbabilityMeasure (expMeasure r) where
  measure_univ := by 

Proof state:
r : ℝ
inst✝ : Fact (0 < r)
⊢ ↑↑(expMeasure r) univ = 1

Next tactic:
simp [expMeasure, lintegral_exponentialPdf_eq_one r Fact.out]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ↑(exponentialCdfReal r) x = ∫ (x : ℝ) in Iic x, exponentialPdfReal r x

Next tactic:
rw [exponentialCdfReal,cdf_eq_toReal]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ENNReal.toReal (↑↑(expMeasure r) (Iic x)) = ∫ (x : ℝ) in Iic x, exponentialPdfReal r x

Next tactic:
simp only [expMeasure, measurableSet_Iic, withDensity_apply]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  simp only [expMeasure, measurableSet_Iic, withDensity_apply]
  

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ENNReal.toReal (∫⁻ (a : ℝ) in Iic x, exponentialPdf r a ∂ℙ) = ∫ (x : ℝ) in Iic x, exponentialPdfReal r x

Next tactic:
rw [integral_eq_lintegral_of_nonneg_ae]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  simp only [expMeasure, measurableSet_Iic, withDensity_apply]
  rw [integral_eq_lintegral_of_nonneg_ae]; 

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ENNReal.toReal (∫⁻ (a : ℝ) in Iic x, exponentialPdf r a ∂ℙ) =
    ENNReal.toReal (∫⁻ (a : ℝ) in Iic x, ENNReal.ofReal (exponentialPdfReal r a))
case hf
r x : ℝ
inst✝ : Fact (0 < r)
⊢ 0 ≤ᵐ[Measure.restrict ℙ (Iic x)] fun x => exponentialPdfReal r x
case hfm
r x : ℝ
inst✝ : Fact (0 < r)
⊢ AEStronglyMeasurable (fun x => exponentialPdfReal r x) (Measure.restrict ℙ (Iic x))

Next tactic:
exact rfl
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  simp only [expMeasure, measurableSet_Iic, withDensity_apply]
  rw [integral_eq_lintegral_of_nonneg_ae]; exact rfl
  · 

Proof state:
case hf
r x : ℝ
inst✝ : Fact (0 < r)
⊢ 0 ≤ᵐ[Measure.restrict ℙ (Iic x)] fun x => exponentialPdfReal r x

Next tactic:
exact ae_of_all _ fun a ↦ by simp [Pi.zero_apply, exponentialPdfReal_nonneg Fact.out a]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  simp only [expMeasure, measurableSet_Iic, withDensity_apply]
  rw [integral_eq_lintegral_of_nonneg_ae]; exact rfl
  · exact ae_of_all _ fun a ↦ by 

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
a : ℝ
⊢ OfNat.ofNat 0 a ≤ (fun x => exponentialPdfReal r x) a

Next tactic:
simp [Pi.zero_apply, exponentialPdfReal_nonneg Fact.out a]
lemma exponentialCdfReal_eq_integral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ∫ x in Iic x, exponentialPdfReal r x := by
  rw [exponentialCdfReal,cdf_eq_toReal]
  simp only [expMeasure, measurableSet_Iic, withDensity_apply]
  rw [integral_eq_lintegral_of_nonneg_ae]; exact rfl
  · exact ae_of_all _ fun a ↦ by simp [Pi.zero_apply, exponentialPdfReal_nonneg Fact.out a]
  · 

Proof state:
case hfm
r x : ℝ
inst✝ : Fact (0 < r)
⊢ AEStronglyMeasurable (fun x => exponentialPdfReal r x) (Measure.restrict ℙ (Iic x))

Next tactic:
exact (Measurable.aestronglyMeasurable (measurable_exponentialPdfReal r)).restrict
lemma exponentialCdfReal_eq_lintegral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ENNReal.toReal (∫⁻ x in Iic x, exponentialPdf r x) := by
  

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ↑(exponentialCdfReal r) x = ENNReal.toReal (∫⁻ (x : ℝ) in Iic x, exponentialPdf r x)

Next tactic:
simp only [exponentialPdf, exponentialCdfReal, cdf_eq_toReal]
lemma exponentialCdfReal_eq_lintegral (r x : ℝ) [Fact (0 < r)] :
    exponentialCdfReal r x = ENNReal.toReal (∫⁻ x in Iic x, exponentialPdf r x) := by
  simp only [exponentialPdf, exponentialCdfReal, cdf_eq_toReal]
  

Proof state:
r x : ℝ
inst✝ : Fact (0 < r)
⊢ ENNReal.toReal (↑↑(expMeasure r) (Iic x)) =
    ENNReal.toReal (∫⁻ (x : ℝ) in Iic x, ENNReal.ofReal (exponentialPdfReal r x))

Next tactic:
simp only [expMeasure, measurableSet_Iic, withDensity_apply, exponentialPdf]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  

Proof state:
r x : ℝ
hr : 0 < r
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPdf r y = ENNReal.ofReal (if 0 ≤ x then 1 - rexp (-(r * x)) else 0)

Next tactic:
split_ifs with h
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  

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

Next tactic:
case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPdf r y = ENNReal.ofReal 0

Next tactic:
case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPdf r y = ENNReal.ofReal 0

Next tactic:
simp only [exponentialPdf_eq]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, ENNReal.ofReal (if 0 ≤ y then r * rexp (-(r * y)) else 0) = ENNReal.ofReal 0

Next tactic:
rw [set_lintegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
    

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
⊢ ∀ᵐ (x_1 : ℝ), x_1 ∈ Iic x → ENNReal.ofReal (if 0 ≤ x_1 then r * rexp (-(r * x_1)) else 0) = 0

Next tactic:
exact ae_of_all _ fun a (_ : a ≤ _) ↦ by rw [if_neg (by linarith), ENNReal.ofReal_eq_zero]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
    exact ae_of_all _ fun a (_ : a ≤ _) ↦ by 

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
a : ℝ
x✝ : a ≤ x
⊢ ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = 0

Next tactic:
rw [if_neg (by linarith), ENNReal.ofReal_eq_zero]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Iic, lintegral_zero, ENNReal.ofReal_zero]
    exact ae_of_all _ fun a (_ : a ≤ _) ↦ by rw [if_neg (by 

Proof state:
r x : ℝ
hr : 0 < r
h : ¬0 ≤ x
a : ℝ
x✝ : a ≤ x
⊢ ¬0 ≤ a

Next tactic:
linarith
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  

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

Next tactic:
case pos =>
    rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Icc (ae_of_all _
        (by intro a ⟨(hle : _ ≤ a), _⟩; rw [if_pos hle]))]
    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 _)))]
    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]
    rw [integral_Icc_eq_integral_Ioc, ← uIoc_of_le h, this]
    rw [intervalIntegral.integral_eq_sub_of_hasDeriv_right_of_le h
      (f := fun a ↦ -1 * rexp (-(r * a))) _ _]
    rw [ENNReal.toReal_ofReal_eq_iff.2 (by norm_num; positivity)]
    · norm_num; ring
    · simp only [intervalIntegrable_iff, uIoc_of_le h]
      exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
    · have : Continuous (fun a ↦ rexp (-(r * a))) := by
        simp only [← neg_mul]; exact (continuous_mul_left (-r)).exp
      exact Continuous.continuousOn (Continuous.comp' (continuous_mul_left (-1)) this)
    · simp only [neg_mul, one_mul]
      exact fun _ _ ↦ HasDerivAt.hasDerivWithinAt hasDerivAt_neg_exp_mul_exp
    · apply Integrable.aestronglyMeasurable (Integrable.const_mul _ _)
      rw [← integrableOn_def, integrableOn_Icc_iff_integrableOn_Ioc]
      exact exp_neg_integrableOn_Ioc hr
    · refine ne_of_lt (IntegrableOn.set_lintegral_lt_top ?_)
      rw [integrableOn_Icc_iff_integrableOn_Ioc]
      exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  

Proof state:
r x : ℝ
hr : 0 < r
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPdf r y = ENNReal.ofReal (1 - rexp (-(r * x)))

Next tactic:
case pos =>
    rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Icc (ae_of_all _
        (by intro a ⟨(hle : _ ≤ a), _⟩; rw [if_pos hle]))]
    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 _)))]
    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]
    rw [integral_Icc_eq_integral_Ioc, ← uIoc_of_le h, this]
    rw [intervalIntegral.integral_eq_sub_of_hasDeriv_right_of_le h
      (f := fun a ↦ -1 * rexp (-(r * a))) _ _]
    rw [ENNReal.toReal_ofReal_eq_iff.2 (by norm_num; positivity)]
    · norm_num; ring
    · simp only [intervalIntegrable_iff, uIoc_of_le h]
      exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
    · have : Continuous (fun a ↦ rexp (-(r * a))) := by
        simp only [← neg_mul]; exact (continuous_mul_left (-r)).exp
      exact Continuous.continuousOn (Continuous.comp' (continuous_mul_left (-1)) this)
    · simp only [neg_mul, one_mul]
      exact fun _ _ ↦ HasDerivAt.hasDerivWithinAt hasDerivAt_neg_exp_mul_exp
    · apply Integrable.aestronglyMeasurable (Integrable.const_mul _ _)
      rw [← integrableOn_def, integrableOn_Icc_iff_integrableOn_Ioc]
      exact exp_neg_integrableOn_Ioc hr
    · refine ne_of_lt (IntegrableOn.set_lintegral_lt_top ?_)
      rw [integrableOn_Icc_iff_integrableOn_Ioc]
      exact Integrable.const_mul (exp_neg_integrableOn_Ioc hr) _
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  case pos =>
    

Proof state:
r x : ℝ
hr : 0 < r
h : 0 ≤ x
⊢ ∫⁻ (y : ℝ) in Iic x, exponentialPdf r y = ENNReal.ofReal (1 - rexp (-(r * x)))

Next tactic:
rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  case pos =>
    rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
    

Proof state:
r x : ℝ
hr : 0 < r
h : 0 ≤ x
⊢ ∫⁻ (x : ℝ) in Icc 0 x, exponentialPdf r x = ENNReal.ofReal (1 - rexp (-(r * x)))

Next tactic:
simp only [exponentialPdf_eq]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  case pos =>
    rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
    simp only [exponentialPdf_eq]
    

Proof state:
r x : ℝ
hr : 0 < r
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)))

Next tactic:
rw [set_lintegral_congr_fun measurableSet_Icc (ae_of_all _
        (by intro a ⟨(hle : _ ≤ a), _⟩; rw [if_pos hle]))]
lemma lintegral_exponentialPdf_eq_antiDeriv (r x : ℝ) (hr : 0 < r) :
    ∫⁻ y in Iic x, exponentialPdf r y
    = ENNReal.ofReal (if 0 ≤ x then 1 - exp (-(r * x)) else 0) := by
  split_ifs with h
  case neg =>
    simp only [exponentialPdf_eq]
    rw [set_lintegral_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]
  case pos =>
    rw [lintegral_Iic_eq_lintegral_Iio_add_Icc _ h, lintegral_exponentialPdf_of_nonpos (le_refl 0),
      zero_add]
    simp only [exponentialPdf_eq]
    rw [set_lintegral_congr_fun measurableSet_Icc (ae_of_all _
        (by 

Proof state:
r x : ℝ
hr : 0 < r
h : 0 ≤ x
⊢ ∀ a ∈ Icc 0 x, ENNReal.ofReal (if 0 ≤ a then r * rexp (-(r * a)) else 0) = ?m.55101 a

Next tactic:
intro a ⟨(hle : _ ≤ a), _⟩