l3lab/ntp-mathlib huggingface dataset:
theorem IndepFun.integrable_exp_mul_add {X Y : Ω → ℝ} (h_indep : IndepFun X Y μ)
    (h_int_X : Integrable (fun ω => exp (t * X ω)) μ)
    (h_int_Y : Integrable (fun ω => exp (t * Y ω)) μ) :
    Integrable (fun ω => exp (t * (X + Y) ω)) μ := by
  simp_rw [Pi.add_apply, mul_add, exp_add]
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
X Y : Ω → ℝ
h_indep : IndepFun X Y
h_int_X : Integrable fun ω => rexp (t * X ω)
h_int_Y : Integrable fun ω => rexp (t * Y ω)
⊢ Integrable fun ω => rexp (t * X ω) * rexp (t * Y ω)

Next tactic:
exact (h_indep.exp_mul t t).integrable_mul h_int_X h_int_Y
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)

Next tactic:
classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
    specialize h_rec this
    rw [sum_insert hi_notin_s]
    refine' IndepFun.integrable_exp_mul_add _ (h_int i (mem_insert_self _ _)) h_rec
    exact (h_indep.indepFun_finset_sum_of_not_mem h_meas hi_notin_s).symm
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)

Next tactic:
induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · 

Proof state:
case empty
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
h_int : ∀ i ∈ ∅, Integrable fun ω => rexp (t * X i ω)
⊢ Integrable fun ω => rexp (t * Finset.sum ∅ (fun i => X i) ω)

Next tactic:
simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    

Proof state:
case empty
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
h_int : ∀ i ∈ ∅, Integrable fun ω => rexp (t * X i ω)
⊢ Integrable fun ω => 1

Next tactic:
exact integrable_const _
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · 

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_rec : (∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)) → Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)
h_int : ∀ i_1 ∈ insert i s, Integrable fun ω => rexp (t * X i_1 ω)
⊢ Integrable fun ω => rexp (t * Finset.sum (insert i s) (fun i => X i) ω)

Next tactic:
have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
    

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_rec : (∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)) → Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)
h_int : ∀ i_1 ∈ insert i s, Integrable fun ω => rexp (t * X i_1 ω)
this : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ Integrable fun ω => rexp (t * Finset.sum (insert i s) (fun i => X i) ω)

Next tactic:
specialize h_rec this
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
    specialize h_rec this
    

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_int : ∀ i_1 ∈ insert i s, Integrable fun ω => rexp (t * X i_1 ω)
this : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
h_rec : Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)
⊢ Integrable fun ω => rexp (t * Finset.sum (insert i s) (fun i => X i) ω)

Next tactic:
rw [sum_insert hi_notin_s]
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
    specialize h_rec this
    rw [sum_insert hi_notin_s]
    

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_int : ∀ i_1 ∈ insert i s, Integrable fun ω => rexp (t * X i_1 ω)
this : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
h_rec : Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)
⊢ Integrable fun ω => rexp (t * (X i + ∑ x in s, X x) ω)

Next tactic:
refine' IndepFun.integrable_exp_mul_add _ (h_int i (mem_insert_self _ _)) h_rec
theorem iIndepFun.integrable_exp_mul_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    Integrable (fun ω => exp (t * (∑ i in s, X i) ω)) μ := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [Pi.zero_apply, sum_apply, sum_empty, mul_zero, exp_zero]
    exact integrable_const _
  · have : ∀ i : ι, i ∈ s → Integrable (fun ω : Ω => exp (t * X i ω)) μ := fun i hi =>
      h_int i (mem_insert_of_mem hi)
    specialize h_rec this
    rw [sum_insert hi_notin_s]
    refine' IndepFun.integrable_exp_mul_add _ (h_int i (mem_insert_self _ _)) h_rec
    

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_int : ∀ i_1 ∈ insert i s, Integrable fun ω => rexp (t * X i_1 ω)
this : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
h_rec : Integrable fun ω => rexp (t * Finset.sum s (fun i => X i) ω)
⊢ IndepFun (X i) (∑ x in s, X x)

Next tactic:
exact (h_indep.indepFun_finset_sum_of_not_mem h_meas hi_notin_s).symm
theorem iIndepFun.mgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    (s : Finset ι) : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t := by
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
⊢ mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t

Next tactic:
classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [sum_empty, mgf_zero_fun, measure_univ, ENNReal.one_toReal, prod_empty]
  · have h_int' : ∀ i : ι, AEStronglyMeasurable (fun ω : Ω => exp (t * X i ω)) μ := fun i =>
      ((h_meas i).const_mul t).exp.aestronglyMeasurable
    rw [sum_insert hi_notin_s,
      IndepFun.mgf_add (h_indep.indepFun_finset_sum_of_not_mem h_meas hi_notin_s).symm (h_int' i)
        (aestronglyMeasurable_exp_mul_sum fun i _ => h_int' i),
      h_rec, prod_insert hi_notin_s]
theorem iIndepFun.mgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    (s : Finset ι) : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t := by
  classical
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
⊢ mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t

Next tactic:
induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
theorem iIndepFun.mgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    (s : Finset ι) : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · 

Proof state:
case empty
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
⊢ mgf (∑ i in ∅, X i) μ t = ∏ i in ∅, mgf (X i) μ t

Next tactic:
simp only [sum_empty, mgf_zero_fun, measure_univ, ENNReal.one_toReal, prod_empty]
theorem iIndepFun.mgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    (s : Finset ι) : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [sum_empty, mgf_zero_fun, measure_univ, ENNReal.one_toReal, prod_empty]
  · 

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_rec : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t
⊢ mgf (∑ i in insert i s, X i) μ t = ∏ i in insert i s, mgf (X i) μ t

Next tactic:
have h_int' : ∀ i : ι, AEStronglyMeasurable (fun ω : Ω => exp (t * X i ω)) μ := fun i =>
      ((h_meas i).const_mul t).exp.aestronglyMeasurable
theorem iIndepFun.mgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    (s : Finset ι) : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t := by
  classical
  induction' s using Finset.induction_on with i s hi_notin_s h_rec h_int
  · simp only [sum_empty, mgf_zero_fun, measure_univ, ENNReal.one_toReal, prod_empty]
  · have h_int' : ∀ i : ι, AEStronglyMeasurable (fun ω : Ω => exp (t * X i ω)) μ := fun i =>
      ((h_meas i).const_mul t).exp.aestronglyMeasurable
    

Proof state:
case insert
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
i : ι
s : Finset ι
hi_notin_s : i ∉ s
h_rec : mgf (∑ i in s, X i) μ t = ∏ i in s, mgf (X i) μ t
h_int' : ∀ (i : ι), AEStronglyMeasurable (fun ω => rexp (t * X i ω)) μ
⊢ mgf (∑ i in insert i s, X i) μ t = ∏ i in insert i s, mgf (X i) μ t

Next tactic:
rw [sum_insert hi_notin_s,
      IndepFun.mgf_add (h_indep.indepFun_finset_sum_of_not_mem h_meas hi_notin_s).symm (h_int' i)
        (aestronglyMeasurable_exp_mul_sum fun i _ => h_int' i),
      h_rec, prod_insert hi_notin_s]
theorem iIndepFun.cgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    cgf (∑ i in s, X i) μ t = ∑ i in s, cgf (X i) μ t := by
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ cgf (∑ i in s, X i) μ t = ∑ i in s, cgf (X i) μ t

Next tactic:
simp_rw [cgf]
theorem iIndepFun.cgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    cgf (∑ i in s, X i) μ t = ∑ i in s, cgf (X i) μ t := by
  simp_rw [cgf]
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ log (mgf (∑ i in s, X i) μ t) = ∑ x in s, log (mgf (X x) μ t)

Next tactic:
rw [← log_prod _ _ fun j hj => ?_]
theorem iIndepFun.cgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    cgf (∑ i in s, X i) μ t = ∑ i in s, cgf (X i) μ t := by
  simp_rw [cgf]
  rw [← log_prod _ _ fun j hj => ?_]
  · 

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
⊢ log (mgf (∑ i in s, X i) μ t) = log (∏ i in s, mgf (X i) μ t)

Next tactic:
rw [h_indep.mgf_sum h_meas]
theorem iIndepFun.cgf_sum [IsProbabilityMeasure μ] {X : ι → Ω → ℝ}
    (h_indep : iIndepFun (fun i => inferInstance) X μ) (h_meas : ∀ i, Measurable (X i))
    {s : Finset ι} (h_int : ∀ i ∈ s, Integrable (fun ω => exp (t * X i ω)) μ) :
    cgf (∑ i in s, X i) μ t = ∑ i in s, cgf (X i) μ t := by
  simp_rw [cgf]
  rw [← log_prod _ _ fun j hj => ?_]
  · rw [h_indep.mgf_sum h_meas]
  · 

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X✝ : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsProbabilityMeasure μ
X : ι → Ω → ℝ
h_indep : iIndepFun (fun i => inferInstance) X
h_meas : ∀ (i : ι), Measurable (X i)
s : Finset ι
h_int : ∀ i ∈ s, Integrable fun ω => rexp (t * X i ω)
j : ι
hj : j ∈ s
⊢ mgf (X j) μ t ≠ 0

Next tactic:
exact (mgf_pos (h_int j hj)).ne'
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) ≤ rexp (-t * ε) * mgf X μ t

Next tactic:
rcases ht.eq_or_lt with ht_zero_eq | ht_pos
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · 

Proof state:
case inl
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_zero_eq : 0 = t
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) ≤ rexp (-t * ε) * mgf X μ t

Next tactic:
rw [ht_zero_eq.symm]
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · rw [ht_zero_eq.symm]
    

Proof state:
case inl
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_zero_eq : 0 = t
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) ≤ rexp (-0 * ε) * mgf X μ 0

Next tactic:
simp only [neg_zero, zero_mul, exp_zero, mgf_zero', one_mul]
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · rw [ht_zero_eq.symm]
    simp only [neg_zero, zero_mul, exp_zero, mgf_zero', one_mul]
    

Proof state:
case inl
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_zero_eq : 0 = t
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) ≤ ENNReal.toReal (↑↑μ Set.univ)

Next tactic:
rw [ENNReal.toReal_le_toReal (measure_ne_top μ _) (measure_ne_top μ _)]
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · rw [ht_zero_eq.symm]
    simp only [neg_zero, zero_mul, exp_zero, mgf_zero', one_mul]
    rw [ENNReal.toReal_le_toReal (measure_ne_top μ _) (measure_ne_top μ _)]
    

Proof state:
case inl
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_zero_eq : 0 = t
⊢ ↑↑μ {ω | ε ≤ X ω} ≤ ↑↑μ Set.univ

Next tactic:
exact measure_mono (Set.subset_univ _)
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · rw [ht_zero_eq.symm]
    simp only [neg_zero, zero_mul, exp_zero, mgf_zero', one_mul]
    rw [ENNReal.toReal_le_toReal (measure_ne_top μ _) (measure_ne_top μ _)]
    exact measure_mono (Set.subset_univ _)
  

Proof state:
case inr
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_pos : 0 < t
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) ≤ rexp (-t * ε) * mgf X μ t

Next tactic:
calc
    (μ {ω | ε ≤ X ω}).toReal = (μ {ω | exp (t * ε) ≤ exp (t * X ω)}).toReal := by
      congr with ω
      simp only [Set.mem_setOf_eq, exp_le_exp, gt_iff_lt]
      exact ⟨fun h => mul_le_mul_of_nonneg_left h ht_pos.le,
        fun h => le_of_mul_le_mul_left h ht_pos⟩
    _ ≤ (exp (t * ε))⁻¹ * μ[fun ω => exp (t * X ω)] := by
      have : exp (t * ε) * (μ {ω | exp (t * ε) ≤ exp (t * X ω)}).toReal ≤
          μ[fun ω => exp (t * X ω)] :=
        mul_meas_ge_le_integral_of_nonneg (ae_of_all _ fun x => (exp_pos _).le) h_int _
      rwa [mul_comm (exp (t * ε))⁻¹, ← div_eq_mul_inv, le_div_iff' (exp_pos _)]
    _ = exp (-t * ε) * mgf X μ t := by rw [neg_mul, exp_neg]; rfl
/-- **Chernoff bound** on the upper tail of a real random variable. -/
theorem measure_ge_le_exp_mul_mgf [IsFiniteMeasure μ] (ε : ℝ) (ht : 0 ≤ t)
    (h_int : Integrable (fun ω => exp (t * X ω)) μ) :
    (μ {ω | ε ≤ X ω}).toReal ≤ exp (-t * ε) * mgf X μ t := by
  rcases ht.eq_or_lt with ht_zero_eq | ht_pos
  · rw [ht_zero_eq.symm]
    simp only [neg_zero, zero_mul, exp_zero, mgf_zero', one_mul]
    rw [ENNReal.toReal_le_toReal (measure_ne_top μ _) (measure_ne_top μ _)]
    exact measure_mono (Set.subset_univ _)
  calc
    (μ {ω | ε ≤ X ω}).toReal = (μ {ω | exp (t * ε) ≤ exp (t * X ω)}).toReal := by
      

Proof state:
Ω : Type u_1
ι : Type u_2
m : MeasurableSpace Ω
X : Ω → ℝ
p : ℕ
μ : Measure Ω
t : ℝ
inst✝ : IsFiniteMeasure μ
ε : ℝ
ht : 0 ≤ t
h_int : Integrable fun ω => rexp (t * X ω)
ht_pos : 0 < t
⊢ ENNReal.toReal (↑↑μ {ω | ε ≤ X ω}) = ENNReal.toReal (↑↑μ {ω | rexp (t * ε) ≤ rexp (t * X ω)})

Next tactic:
congr with ω