-- Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean
theorem _root_.MeasureTheory.MemLp.exists_simpleFunc_eLpNorm_sub_lt {E : Type*}
    [NormedAddCommGroup E] {f : β → E} {μ : Measure β} (hf : MemLp f p μ) (hp_ne_top : p ≠ ∞)
    {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : β →ₛ E, eLpNorm (f - ⇑g) p μ < ε ∧ MemLp g p μ

Proof state:
case intro.intro.hfg
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ f - ⇑g =ᶠ[ae μ] f' - ⇑g

Tactic:
filter_upwards [hf.1.ae_eq_mk] with x hx

Result:
case h
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
x : β
hx : f x = AEStronglyMeasurable.mk f ⋯ x
⊢ (f - ⇑g) x = (f' - ⇑g) x

Proof state:
case intro.intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ ∃ g, eLpNorm (f - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Tactic:
refine ⟨g, ?_, g_mem⟩

Result:
case intro.intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ eLpNorm (f - ⇑g) p μ < ε

Proof state:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
⊢ ∃ g, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Tactic:
have hf' : MemLp f' p μ := hf.ae_eq hf.1.ae_eq_mk

Result:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
hf' : MemLp f' p μ
⊢ ∃ g, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Proof state:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
⊢ ∃ g, eLpNorm (f - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Tactic:
borelize E

Result:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
⊢ ∃ g, eLpNorm (f - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Proof state:
case intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
hf' : MemLp f' p μ
f'meas : Measurable f'
this : SeparableSpace ↑(Set.range f' ∪ {0})
n : ℕ
hn : eLpNorm (f' - ⇑(approxOn f' f'meas (Set.range f' ∪ {0}) 0 ⋯ n)) p μ < ε
⊢ ∃ g, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Tactic:
exact ⟨_, hn, memLp_approxOn_range f'meas hf' _⟩

Result:
no goals

Proof state:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
this : eLpNorm (f - ⇑g) p μ = eLpNorm (f' - ⇑g) p μ
⊢ eLpNorm (f - ⇑g) p μ < ε

Tactic:
rwa [this]

Result:
no goals

Proof state:
case intro.intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ eLpNorm (f - ⇑g) p μ = eLpNorm (f' - ⇑g) p μ

Tactic:
apply eLpNorm_congr_ae

Result:
case intro.intro.hfg
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ f - ⇑g =ᶠ[ae μ] f' - ⇑g

Proof state:
case intro.intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ eLpNorm (f - ⇑g) p μ < ε

Tactic:
suffices eLpNorm (f - ⇑g) p μ = eLpNorm (f' - ⇑g) p μ by rwa [this]

Result:
case intro.intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
⊢ eLpNorm (f - ⇑g) p μ = eLpNorm (f' - ⇑g) p μ

Proof state:
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
hf' : MemLp f' p μ
f'meas : Measurable f'
this : SeparableSpace ↑(Set.range f' ∪ {0})
⊢ ∃ g, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Tactic:
rcases ((tendsto_approxOn_range_Lp_eLpNorm hp_ne_top f'meas hf'.2).eventually <|
  gt_mem_nhds hε.bot_lt).exists with ⟨n, hn⟩

Result:
case intro
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
hf' : MemLp f' p μ
f'meas : Measurable f'
this : SeparableSpace ↑(Set.range f' ∪ {0})
n : ℕ
hn : eLpNorm (⇑(approxOn f' f'meas (Set.range f' ∪ {0}) 0 ⋯ n) - f') p μ < ε
⊢ ∃ g, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp (⇑g) p μ

Proof state:
case h
β : Type u_2
inst✝¹ : MeasurableSpace β
p : ℝ≥0∞
E : Type u_7
inst✝ : NormedAddCommGroup E
f : β → E
μ : Measure β
hf : MemLp f p μ
hp_ne_top : p ≠ ⊤
ε : ℝ≥0∞
hε : ε ≠ 0
this✝¹ : MeasurableSpace E := borel E
this✝ : BorelSpace E
f' : β → E := AEStronglyMeasurable.mk f ⋯
g : β →ₛ E
hg : eLpNorm (f' - ⇑g) p μ < ε
g_mem : MemLp (⇑g) p μ
x : β
hx : f x = AEStronglyMeasurable.mk f ⋯ x
⊢ (f - ⇑g) x = (f' - ⇑g) x

Tactic:
simpa only [Pi.sub_apply, sub_left_inj] using hx

Result:
no goals