l3lab/ntp-mathlib huggingface dataset:
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hfi' : ∫⁻ (x : α) in S, ↑‖f x‖₊ ∂μ < ⊤
hSm : MeasurableSet S
⊢ Tendsto (fun i => ∫ (a : α) in s i, f a ∂μ) atTop (𝓝 (∫ (a : α) in S, f a ∂μ))

Next tactic:
have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hfi' : ∫⁻ (x : α) in S, ↑‖f x‖₊ ∂μ < ⊤
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
⊢ Tendsto (fun i => ∫ (a : α) in s i, f a ∂μ) atTop (𝓝 (∫ (a : α) in S, f a ∂μ))

Next tactic:
rw [← withDensity_apply _ hSm] at hfi'
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hfi' : ↑↑(Measure.withDensity μ fun x => ↑‖f x‖₊) S < ⊤
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
⊢ Tendsto (fun i => ∫ (a : α) in s i, f a ∂μ) atTop (𝓝 (∫ (a : α) in S, f a ∂μ))

Next tactic:
set ν := μ.withDensity fun x => ‖f x‖₊ with hν
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
⊢ Tendsto (fun i => ∫ (a : α) in s i, f a ∂μ) atTop (𝓝 (∫ (a : α) in S, f a ∂μ))

Next tactic:
refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ
ε0 : 0 < ε
⊢ ∀ᶠ (x : ι) in atTop, ∫ (a : α) in s x, f a ∂μ ∈ Metric.closedBall (∫ (a : α) in S, f a ∂μ) ε

Next tactic:
lift ε to ℝ≥0 using ε0.le
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
⊢ ∀ᶠ (x : ι) in atTop, ∫ (a : α) in s x, f a ∂μ ∈ Metric.closedBall (∫ (a : α) in S, f a ∂μ) ↑ε

Next tactic:
have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ∀ᶠ (x : ι) in atTop, ∫ (a : α) in s x, f a ∂μ ∈ Metric.closedBall (∫ (a : α) in S, f a ∂μ) ↑ε

Next tactic:
refine' this.mono fun i hi => _
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
  refine' this.mono fun i hi => _
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
i : ι
hi : ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ∫ (a : α) in s i, f a ∂μ ∈ Metric.closedBall (∫ (a : α) in S, f a ∂μ) ↑ε

Next tactic:
rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ←
    ENNReal.coe_le_coe]
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
  refine' this.mono fun i hi => _
  rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ←
    ENNReal.coe_le_coe]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
i : ι
hi : ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ↑‖∫ (x : α) in S \ s i, f x ∂μ‖₊ ≤ ↑ε

Next tactic:
refine' (ennnorm_integral_le_lintegral_ennnorm _).trans _
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
  refine' this.mono fun i hi => _
  rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ←
    ENNReal.coe_le_coe]
  refine' (ennnorm_integral_le_lintegral_ennnorm _).trans _
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
i : ι
hi : ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ∫⁻ (a : α) in S \ s i, ↑‖f a‖₊ ∂μ ≤ ↑ε

Next tactic:
rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _)]
theorem tendsto_set_integral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι]
    {s : ι → Set α} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
    (hfi : IntegrableOn f (⋃ n, s n) μ) :
    Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋃ n, s n, f a ∂μ)) := by
  have hfi' : (∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ) < ∞ := hfi.2
  set S := ⋃ i, s i
  have hSm : MeasurableSet S := MeasurableSet.iUnion hsm
  have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s)
  rw [← withDensity_apply _ hSm] at hfi'
  set ν := μ.withDensity fun x => ‖f x‖₊ with hν
  refine' Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => _
  lift ε to ℝ≥0 using ε0.le
  have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
    tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
  refine' this.mono fun i hi => _
  rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ←
    ENNReal.coe_le_coe]
  refine' (ennnorm_integral_le_lintegral_ennnorm _).trans _
  rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _)]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
i : ι
hi : ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ↑↑ν S - ↑↑ν (s i) ≤ ↑ε
case intro
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace α
inst✝³ : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν✝ : Measure α
l l' : Filter α
inst✝² : NormedSpace ℝ E
ι : Type u_5
inst✝¹ : Countable ι
inst✝ : SemilatticeSup ι
s : ι → Set α
hsm : ∀ (i : ι), MeasurableSet (s i)
h_mono : Monotone s
S : Set α := ⋃ i, s i
hfi : IntegrableOn f S
hSm : MeasurableSet S
hsub : ∀ {i : ι}, s i ⊆ S
ν : Measure α := Measure.withDensity μ fun x => ↑‖f x‖₊
hfi' : ↑↑ν S < ⊤
hν : ν = Measure.withDensity μ fun x => ↑‖f x‖₊
ε : ℝ≥0
ε0 : 0 < ↑ε
this : ∀ᶠ (i : ι) in atTop, ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
i : ι
hi : ↑↑ν (s i) ∈ Icc (↑↑ν S - ↑ε) (↑↑ν S + ↑ε)
⊢ ↑↑ν (s i) ≠ ⊤

Next tactic:
exacts [tsub_le_iff_tsub_le.mp hi.1,
    (hi.2.trans_lt <| ENNReal.add_lt_top.2 ⟨hfi', ENNReal.coe_lt_top⟩).ne]
theorem hasSum_integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set α}
    (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s))
    (hfi : IntegrableOn f (⋃ i, s i) μ) :
    HasSum (fun n => ∫ a in s n, f a ∂μ) (∫ a in ⋃ n, s n, f a ∂μ) := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝³ : MeasurableSpace α
inst✝² : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝¹ : NormedSpace ℝ E
ι : Type u_5
inst✝ : Countable ι
s : ι → Set α
hm : ∀ (i : ι), NullMeasurableSet (s i)
hd : Pairwise (AEDisjoint μ on s)
hfi : IntegrableOn f (⋃ i, s i)
⊢ HasSum (fun n => ∫ (a : α) in s n, f a ∂μ) (∫ (a : α) in ⋃ n, s n, f a ∂μ)

Next tactic:
simp only [IntegrableOn, Measure.restrict_iUnion_ae hd hm] at hfi ⊢
theorem hasSum_integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set α}
    (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s))
    (hfi : IntegrableOn f (⋃ i, s i) μ) :
    HasSum (fun n => ∫ a in s n, f a ∂μ) (∫ a in ⋃ n, s n, f a ∂μ) := by
  simp only [IntegrableOn, Measure.restrict_iUnion_ae hd hm] at hfi ⊢
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝³ : MeasurableSpace α
inst✝² : NormedAddCommGroup E
f g : α → E
s✝ t : Set α
μ ν : Measure α
l l' : Filter α
inst✝¹ : NormedSpace ℝ E
ι : Type u_5
inst✝ : Countable ι
s : ι → Set α
hm : ∀ (i : ι), NullMeasurableSet (s i)
hd : Pairwise (AEDisjoint μ on s)
hfi : Integrable f
⊢ HasSum (fun n => ∫ (a : α) in s n, f a ∂μ) (∫ (a : α), f a ∂Measure.sum fun i => Measure.restrict μ (s i))

Next tactic:
exact hasSum_integral_measure hfi
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
⊢ ∫ (x : α) in t, f x ∂μ = 0

Next tactic:
by_cases hf : AEStronglyMeasurable f (μ.restrict t)
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); 

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ∫ (x : α) in t, f x ∂μ = 0
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : ¬AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ∫ (x : α) in t, f x ∂μ = 0

Next tactic:
swap
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : ¬AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ∫ (x : α) in t, f x ∂μ = 0

Next tactic:
rw [integral_undef]
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · rw [integral_undef]
    

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : ¬AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ¬Integrable fun x => f x

Next tactic:
contrapose! hf
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · rw [integral_undef]
    contrapose! hf
    

Proof state:
case neg
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : Integrable fun x => f x
⊢ AEStronglyMeasurable f (Measure.restrict μ t)

Next tactic:
exact hf.1
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · rw [integral_undef]
    contrapose! hf
    exact hf.1
  

Proof state:
case pos
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ∫ (x : α) in t, f x ∂μ = 0

Next tactic:
have : ∫ x in t, hf.mk f x ∂μ = 0 := by
    refine' integral_eq_zero_of_ae _
    rw [EventuallyEq,
      ae_restrict_iff (hf.stronglyMeasurable_mk.measurableSet_eq_fun stronglyMeasurable_zero)]
    filter_upwards [ae_imp_of_ae_restrict hf.ae_eq_mk, ht_eq] with x hx h'x h''x
    rw [← hx h''x]
    exact h'x h''x
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · rw [integral_undef]
    contrapose! hf
    exact hf.1
  have : ∫ x in t, hf.mk f x ∂μ = 0 := by
    

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : AEStronglyMeasurable f (Measure.restrict μ t)
⊢ ∫ (x : α) in t, AEStronglyMeasurable.mk f hf x ∂μ = 0

Next tactic:
refine' integral_eq_zero_of_ae _
theorem set_integral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
    ∫ x in t, f x ∂μ = 0 := by
  by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
  · rw [integral_undef]
    contrapose! hf
    exact hf.1
  have : ∫ x in t, hf.mk f x ∂μ = 0 := by
    refine' integral_eq_zero_of_ae _
    

Proof state:
α : Type u_1
β : Type u_2
E : Type u_3
F : Type u_4
inst✝² : MeasurableSpace α
inst✝¹ : NormedAddCommGroup E
f g : α → E
s t : Set α
μ ν : Measure α
l l' : Filter α
inst✝ : NormedSpace ℝ E
ht_eq : ∀ᵐ (x : α) ∂μ, x ∈ t → f x = 0
hf : AEStronglyMeasurable f (Measure.restrict μ t)
⊢ (fun x => AEStronglyMeasurable.mk f hf x) =ᵐ[Measure.restrict μ t] 0

Next tactic:
rw [EventuallyEq,
      ae_restrict_iff (hf.stronglyMeasurable_mk.measurableSet_eq_fun stronglyMeasurable_zero)]