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

tactic: lift ε to ℝ≥0 using εpos.le
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ
εpos : 0 < ε
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: rw [NNReal.coe_pos, ← ENNReal.coe_pos] at εpos
state_before: case intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: have If : (∫⁻ x, f x ∂μ) < ∞ := hasFiniteIntegral_iff_ofNNReal.1 fint.hasFiniteIntegral
state_before: case intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: rcases exists_upperSemicontinuous_le_lintegral_le f If.ne εpos.ne' with ⟨g, gf, gcont, gint⟩
state_before: case intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: have Ig : (∫⁻ x, g x ∂μ) < ∞ := by
  refine' lt_of_le_of_lt (lintegral_mono fun x => _) If
  simpa using gf x
state_before: case intro.intro.intro.intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: refine' ⟨g, gf, gcont, _, _⟩
state_before: case intro.intro.intro.intro
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ∃ g,
    (∀ (x : α), g x ≤ f x) ∧
      UpperSemicontinuous g ∧ (Integrable fun x => ↑(g x)) ∧ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: refine' lt_of_le_of_lt (lintegral_mono fun x => _) If
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
⊢ (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤

tactic: simpa using gf x
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
x : α
⊢ ↑(g x) ≤ ↑(f x)

tactic: refine'
  Integrable.mono fint gcont.measurable.coe_nnreal_real.aemeasurable.aestronglyMeasurable _
state_before: case intro.intro.intro.intro.refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ Integrable fun x => ↑(g x)

tactic: exact Filter.eventually_of_forall fun x => by simp [gf x]
state_before: case intro.intro.intro.intro.refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ∀ᵐ (a : α) ∂μ, ‖↑(g a)‖ ≤ ‖↑(f a)‖

tactic: simp [gf x]
state_before: α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
x : α
⊢ ‖↑(g x)‖ ≤ ‖↑(f x)‖

tactic: rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae]
state_before: case intro.intro.intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ (∫ (x : α), ↑(f x) ∂μ) - ↑ε ≤ ∫ (x : α), ↑(g x) ∂μ

tactic: rw [sub_le_iff_le_add]
state_before: case intro.intro.intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(f a) ∂μ) - ↑ε ≤ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(g a) ∂μ)

tactic: convert ENNReal.toReal_mono _ gint
state_before: case intro.intro.intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(f a) ∂μ) ≤ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(g a) ∂μ) + ↑ε

tactic: simp
state_before: case h.e'_3.h.e'_1.h.e'_4.h
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
x✝ : α
⊢ ENNReal.ofReal ↑(f x✝) = ↑(f x✝)

tactic: rw [ENNReal.toReal_add Ig.ne ENNReal.coe_ne_top]
state_before: case h.e'_4
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(g a) ∂μ) + ↑ε = ENNReal.toReal ((∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε)

tactic: simp
state_before: case h.e'_4
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal ↑(g a) ∂μ) + ↑ε =
    ENNReal.toReal (∫⁻ (x : α), ↑(g x) ∂μ) + ENNReal.toReal ↑ε

tactic: simpa using Ig.ne
state_before: case intro.intro.intro.intro.refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε ≠ ⊤

tactic: apply Filter.eventually_of_forall
state_before: case intro.intro.intro.intro.refine'_2.hf
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ 0 ≤ᶠ[ae μ] fun x => ↑(g x)

tactic: simp
state_before: case intro.intro.intro.intro.refine'_2.hf.hp
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ∀ (x : α), OfNat.ofNat 0 x ≤ (fun x => ↑(g x)) x

tactic: exact gcont.measurable.coe_nnreal_real.aemeasurable.aestronglyMeasurable
state_before: case intro.intro.intro.intro.refine'_2.hfm
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ AEStronglyMeasurable (fun x => ↑(g x)) μ

tactic: apply Filter.eventually_of_forall
state_before: case intro.intro.intro.intro.refine'_2.hf
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ 0 ≤ᶠ[ae μ] fun x => ↑(f x)

tactic: simp
state_before: case intro.intro.intro.intro.refine'_2.hf.hp
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ ∀ (x : α), OfNat.ofNat 0 x ≤ (fun x => ↑(f x)) x

tactic: exact fint.aestronglyMeasurable
state_before: case intro.intro.intro.intro.refine'_2.hfm
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : MeasurableSpace α
inst✝¹ : BorelSpace α
μ : Measure α
inst✝ : WeaklyRegular μ
f : α → ℝ≥0
fint : Integrable fun x => ↑(f x)
ε : ℝ≥0
εpos : 0 < ↑ε
If : (∫⁻ (x : α), ↑(f x) ∂μ) < ⊤
g : α → ℝ≥0
gf : ∀ (x : α), g x ≤ f x
gcont : UpperSemicontinuous g
gint : (∫⁻ (x : α), ↑(f x) ∂μ) ≤ (∫⁻ (x : α), ↑(g x) ∂μ) + ↑ε
Ig : (∫⁻ (x : α), ↑(g x) ∂μ) < ⊤
⊢ AEStronglyMeasurable (fun x => ↑(f x)) μ