l3lab/ntp-mathlib huggingface dataset:
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · 

Proof state:
case refine_2
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ : SimpleFunc E E
⊢ ∀ ⦃f g : SimpleFunc E E⦄,
    Disjoint (Function.support ↑f) (Function.support ↑g) →
      (fun ψ =>
            ∀ᵐ (ω : Ω),
              Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a)))
          f →
        (fun ψ =>
              ∀ᵐ (ω : Ω),
                Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a)))
            g →
          (fun ψ =>
              ∀ᵐ (ω : Ω),
                Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a)))
            (f + g)

Next tactic:
rintro φ ψ - hφ hψ
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    

Proof state:
case refine_2
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ ∀ᵐ (ω : Ω),
    Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑(φ + ψ) (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑(φ + ψ) ∘ X 0) a))

Next tactic:
filter_upwards [hφ, hψ] with ω hωφ hωψ
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    

Proof state:
case h
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑(φ + ψ) (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑(φ + ψ) ∘ X 0) a))

Next tactic:
convert hωφ.add hωψ using 1
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    convert hωφ.add hωψ using 1
    · 

Proof state:
case h.e'_3
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑(φ + ψ) (X i ω)) = fun x =>
    (↑x)⁻¹ • ∑ i in Finset.range x, ↑φ (X i ω) + (↑x)⁻¹ • ∑ i in Finset.range x, ↑ψ (X i ω)

Next tactic:
simp [sum_add_distrib]
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    convert hωφ.add hωψ using 1
    · simp [sum_add_distrib]
    · 

Proof state:
case h.e'_5
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ 𝓝 (∫ (a : Ω), (↑(φ + ψ) ∘ X 0) a) = 𝓝 ((∫ (a : Ω), (↑φ ∘ X 0) a) + ∫ (a : Ω), (↑ψ ∘ X 0) a)

Next tactic:
congr 1
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    convert hωφ.add hωψ using 1
    · simp [sum_add_distrib]
    · congr 1
      

Proof state:
case h.e'_5.e_a
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ ∫ (a : Ω), (↑(φ + ψ) ∘ X 0) a = (∫ (a : Ω), (↑φ ∘ X 0) a) + ∫ (a : Ω), (↑ψ ∘ X 0) a

Next tactic:
rw [← integral_add]
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    convert hωφ.add hωψ using 1
    · simp [sum_add_distrib]
    · congr 1
      rw [← integral_add]
      · 

Proof state:
case h.e'_5.e_a
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ ∫ (a : Ω), (↑(φ + ψ) ∘ X 0) a = ∫ (a : Ω), (↑φ ∘ X 0) a + (↑ψ ∘ X 0) a

Next tactic:
rfl
/-- Preliminary lemma for the strong law of large numbers for vector-valued random variables:
the composition of the random variables with a simple function satisfies the strong law of large
numbers. -/
lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0))
    (hindep : Pairwise (fun i j ↦ IndepFun (X i) (X j))) (hident : ∀ i, IdentDistrib (X i) (X 0))
    (φ : SimpleFunc E E) : ∀ᵐ ω,
      Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, φ (X i ω))) atTop (𝓝 𝔼[φ ∘ (X 0)]) := by
  -- this follows from the one-dimensional version when `φ` takes a single value, and is then
  -- extended to the general case by linearity.
  classical
  refine SimpleFunc.induction (P := fun ψ ↦ ∀ᵐ ω,
    Tendsto (fun n : ℕ ↦ (n : ℝ) ⁻¹ • (∑ i in range n, ψ (X i ω))) atTop (𝓝 𝔼[ψ ∘ (X 0)])) ?_ ?_ φ
  · intro c s hs
    simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
      SimpleFunc.coe_zero, piecewise_eq_indicator, Function.comp_apply]
    let F : E → ℝ := indicator s 1
    have F_meas : Measurable F := (measurable_indicator_const_iff 1).2 hs
    let Y : ℕ → Ω → ℝ := fun n ↦ F ∘ (X n)
    have : ∀ᵐ (ω : Ω), Tendsto (fun (n : ℕ) ↦ (n : ℝ)⁻¹ • ∑ i in Finset.range n, Y i ω)
        atTop (𝓝 𝔼[Y 0]) := by
      simp only [Pi.const_one, smul_eq_mul, ← div_eq_inv_mul]
      apply strong_law_ae_real
      · exact SimpleFunc.integrable_of_isFiniteMeasure
          ((SimpleFunc.piecewise s hs (SimpleFunc.const _ (1 : ℝ))
            (SimpleFunc.const _ (0 : ℝ))).comp (X 0) h')
      · exact fun i j hij ↦ IndepFun.comp (hindep hij) F_meas F_meas
      · exact fun i ↦ (hident i).comp F_meas
    filter_upwards [this] with ω hω
    have I : indicator s (Function.const E c) = (fun x ↦ (indicator s (1 : E → ℝ) x) • c) := by
      ext
      rw [← indicator_smul_const_apply]
      congr! 1
      ext
      simp
    simp only [I, integral_smul_const]
    convert Tendsto.smul_const hω c using 1
    simp [← sum_smul, smul_smul]
  · rintro φ ψ - hφ hψ
    filter_upwards [hφ, hψ] with ω hωφ hωψ
    convert hωφ.add hωψ using 1
    · simp [sum_add_distrib]
    · congr 1
      rw [← integral_add]
      · rfl
      · 

Proof state:
case h.e'_5.e_a.hf
Ω : Type u_1
inst✝⁶ : MeasureSpace Ω
inst✝⁵ : IsProbabilityMeasure ℙ
E : Type u_2
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace ℝ E
inst✝² : CompleteSpace E
inst✝¹ : MeasurableSpace E
inst✝ : BorelSpace E
X : ℕ → Ω → E
h' : Measurable (X 0)
hindep : Pairwise fun i j => IndepFun (X i) (X j)
hident : ∀ (i : ℕ), IdentDistrib (X i) (X 0)
φ✝ φ ψ : SimpleFunc E E
hφ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hψ : ∀ᵐ (ω : Ω), Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
ω : Ω
hωφ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑φ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑φ ∘ X 0) a))
hωψ : Tendsto (fun n => (↑n)⁻¹ • ∑ i in Finset.range n, ↑ψ (X i ω)) atTop (𝓝 (∫ (a : Ω), (↑ψ ∘ X 0) a))
⊢ Integrable fun a => (↑φ ∘ X 0) a

Next tactic:
exact (φ.comp (X 0) h').integrable_of_isFiniteMeasure