Theorem: MeasureTheory.exists_le_lowerSemicontinuous_lintegral_ge
File: Mathlib/MeasureTheory/Integral/VitaliCaratheodory.lean

tactic: rcases ENNReal.exists_pos_sum_of_countable' εpos ℕ with ⟨δ, δpos, hδ⟩
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
⊢ ∃ g, (∀ (x : α), f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ (x : α), g x ∂μ) ≤ (∫⁻ (x : α), f x ∂μ) + ε

tactic: have :
  ∀ n,
    ∃ g : α → ℝ≥0,
      (∀ x, SimpleFunc.eapproxDiff f n x ≤ g x) ∧
        LowerSemicontinuous g ∧
          (∫⁻ x, g x ∂μ) ≤ (∫⁻ x, SimpleFunc.eapproxDiff f n x ∂μ) + δ n :=
  fun n =>
  SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge μ (SimpleFunc.eapproxDiff f n)
    (δpos n).ne'
state_before: case intro.intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
⊢ ∃ g, (∀ (x : α), f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ (x : α), g x ∂μ) ≤ (∫⁻ (x : α), f x ∂μ) + ε

tactic: choose g f_le_g gcont hg using this
state_before: case intro.intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
this :
  ∀ (n : ℕ),
    ∃ g,
      (∀ (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g x) ∧
        LowerSemicontinuous g ∧ (∫⁻ (x : α), ↑(g x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ ∃ g, (∀ (x : α), f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ (x : α), g x ∂μ) ≤ (∫⁻ (x : α), f x ∂μ) + ε

tactic: refine' ⟨fun x => ∑' n, g n x, fun x => _, _, _⟩
state_before: case intro.intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ ∃ g, (∀ (x : α), f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ (x : α), g x ∂μ) ≤ (∫⁻ (x : α), f x ∂μ) + ε

tactic: rw [← SimpleFunc.tsum_eapproxDiff f hf]
state_before: case intro.intro.refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
x : α
⊢ f x ≤ (fun x => ∑' (n : ℕ), ↑(g n x)) x

tactic: exact ENNReal.tsum_le_tsum fun n => ENNReal.coe_le_coe.2 (f_le_g n x)
state_before: case intro.intro.refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
x : α
⊢ (∑' (n : ℕ), ↑(↑(SimpleFunc.eapproxDiff f n) x)) ≤ (fun x => ∑' (n : ℕ), ↑(g n x)) x

tactic: refine' lowerSemicontinuous_tsum fun n => _
state_before: case intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ LowerSemicontinuous fun x => ∑' (n : ℕ), ↑(g n x)

tactic: exact
  ENNReal.continuous_coe.comp_lowerSemicontinuous (gcont n) fun x y hxy =>
    ENNReal.coe_le_coe.2 hxy
state_before: case intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
n : ℕ
⊢ LowerSemicontinuous fun x => ↑(g n x)

tactic: rw [lintegral_tsum fun n => (gcont n).measurable.coe_nnreal_ennreal.aemeasurable]
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ (∫⁻ (x : α), ∑' (n : ℕ), ↑(g n x) ∂μ) = ∑' (n : ℕ), ∫⁻ (x : α), ↑(g n x) ∂μ

tactic: refine' add_le_add _ hδ.le
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ ((∑' (n : ℕ), ∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + ∑' (n : ℕ), δ n) ≤ (∫⁻ (x : α), f x ∂μ) + ε

tactic: rw [← lintegral_tsum]
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ (∑' (n : ℕ), ∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) ≤ ∫⁻ (x : α), f x ∂μ

tactic: simp_rw [SimpleFunc.tsum_eapproxDiff f hf, le_refl]
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ (∫⁻ (a : α), ∑' (i : ℕ), ↑(↑(SimpleFunc.eapproxDiff f i) a) ∂μ) ≤ ∫⁻ (x : α), f x ∂μ

tactic: intro n
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
⊢ ∀ (i : ℕ), AEMeasurable fun x => ↑(↑(SimpleFunc.eapproxDiff f i) x)

tactic: exact (SimpleFunc.measurable _).coe_nnreal_ennreal.aemeasurable
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0∞
hf : Measurable f
ε : ℝ≥0∞
εpos : ε ≠ 0
δ : ℕ → ℝ≥0∞
δpos : ∀ (i : ℕ), 0 < δ i
hδ : (∑' (i : ℕ), δ i) < ε
g : ℕ → α → ℝ≥0
f_le_g : ∀ (n : ℕ) (x : α), ↑(SimpleFunc.eapproxDiff f n) x ≤ g n x
gcont : ∀ (n : ℕ), LowerSemicontinuous (g n)
hg : ∀ (n : ℕ), (∫⁻ (x : α), ↑(g n x) ∂μ) ≤ (∫⁻ (x : α), ↑(↑(SimpleFunc.eapproxDiff f n) x) ∂μ) + δ n
n : ℕ
⊢ AEMeasurable fun x => ↑(↑(SimpleFunc.eapproxDiff f n) x)