Theorem: StieltjesFunction.outer_trim
File: Mathlib/MeasureTheory/Measure/Stieltjes.lean

tactic: refine' le_antisymm (fun s => _) (OuterMeasure.le_trim _)
state_before: f : StieltjesFunction
⊢ OuterMeasure.trim (StieltjesFunction.outer f) = StieltjesFunction.outer f

tactic: rw [OuterMeasure.trim_eq_iInf]
state_before: f : StieltjesFunction
s : Set ℝ
⊢ ↑(OuterMeasure.trim (StieltjesFunction.outer f)) s ≤ ↑(StieltjesFunction.outer f) s

tactic: refine' le_iInf fun t => le_iInf fun ht => ENNReal.le_of_forall_pos_le_add fun ε ε0 h => _
state_before: f : StieltjesFunction
s : Set ℝ
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤ ↑(StieltjesFunction.outer f) s

tactic: rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 ε0).ne' ℕ with ⟨ε', ε'0, hε⟩
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤ (∑' (i : ℕ), length f (t i)) + ↑ε

tactic: refine' le_trans _ (add_le_add_left (le_of_lt hε) _)
state_before: case intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤ (∑' (i : ℕ), length f (t i)) + ↑ε

tactic: rw [← ENNReal.tsum_add]
state_before: case intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤
    (∑' (i : ℕ), length f (t i)) + ∑' (i : ℕ), ↑(ε' i)

tactic: choose g hg using
  show ∀ i, ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ f.outer s ≤ f.length (t i) + ofReal (ε' i) by
    intro i
    have hl :=
      ENNReal.lt_add_right ((ENNReal.le_tsum i).trans_lt h).ne (ENNReal.coe_pos.2 (ε'0 i)).ne'
    conv at hl =>
      lhs
      rw [length]
    simp only [iInf_lt_iff] at hl
    rcases hl with ⟨a, b, h₁, h₂⟩
    rw [← f.outer_Ioc] at h₂
    exact ⟨_, h₁, measurableSet_Ioc, le_of_lt <| by simpa using h₂⟩
state_before: case intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤
    ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: simp only [ofReal_coe_nnreal] at hg
state_before: case intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ ↑(StieltjesFunction.outer f) (g i) ≤ length f (t i) + ofReal ↑(ε' i)
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤
    ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: apply iInf_le_of_le (iUnion g) _
state_before: case intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ ↑(StieltjesFunction.outer f) (g i) ≤ length f (t i) + ↑(ε' i)
⊢ (⨅ (t : Set ℝ) (_ : s ⊆ t) (_ : MeasurableSet t), ↑(StieltjesFunction.outer f) t) ≤
    ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: apply iInf_le_of_le (ht.trans <| iUnion_mono fun i => (hg i).1) _
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ ↑(StieltjesFunction.outer f) (g i) ≤ length f (t i) + ↑(ε' i)
⊢ (⨅ (_ : s ⊆ iUnion g) (_ : MeasurableSet (iUnion g)), ↑(StieltjesFunction.outer f) (iUnion g)) ≤
    ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: apply iInf_le_of_le (MeasurableSet.iUnion fun i => (hg i).2.1) _
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ ↑(StieltjesFunction.outer f) (g i) ≤ length f (t i) + ↑(ε' i)
⊢ (⨅ (_ : MeasurableSet (iUnion g)), ↑(StieltjesFunction.outer f) (iUnion g)) ≤ ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: exact le_trans (f.outer.iUnion _) (ENNReal.tsum_le_tsum fun i => (hg i).2.2)
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ ↑(StieltjesFunction.outer f) (g i) ≤ length f (t i) + ↑(ε' i)
⊢ ↑(StieltjesFunction.outer f) (iUnion g) ≤ ∑' (a : ℕ), length f (t a) + ↑(ε' a)

tactic: intro i
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
⊢ ∀ (i : ℕ), ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: have hl :=
  ENNReal.lt_add_right ((ENNReal.le_tsum i).trans_lt h).ne (ENNReal.coe_pos.2 (ε'0 i)).ne'
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: conv at hl =>
  lhs
  rw [length]
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
hl : length f (t i) < length f (t i) + ↑(ε' i)
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: simp only [iInf_lt_iff] at hl
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
hl : (⨅ (a : ℝ) (b : ℝ) (_ : t i ⊆ Ioc a b), ofReal (↑f b - ↑f a)) < length f (t i) + ↑(ε' i)
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: rcases hl with ⟨a, b, h₁, h₂⟩
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
hl : ∃ i_1 i_2 i_3, ofReal (↑f i_2 - ↑f i_1) < length f (t i) + ↑(ε' i)
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: rw [← f.outer_Ioc] at h₂
state_before: case intro.intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
a b : ℝ
h₁ : t i ⊆ Ioc a b
h₂ : ofReal (↑f b - ↑f a) < length f (t i) + ↑(ε' i)
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: exact ⟨_, h₁, measurableSet_Ioc, le_of_lt <| by simpa using h₂⟩
state_before: case intro.intro.intro
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
a b : ℝ
h₁ : t i ⊆ Ioc a b
h₂ : ↑(StieltjesFunction.outer f) (Ioc a b) < length f (t i) + ↑(ε' i)
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ ↑(StieltjesFunction.outer f) s ≤ length f (t i) + ofReal ↑(ε' i)

tactic: simpa using h₂
state_before: f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ (i : ℕ), t i
ε : ℝ≥0
ε0 : 0 < ε
h : (∑' (i : ℕ), length f (t i)) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : (∑' (i : ℕ), ↑(ε' i)) < ↑ε
i : ℕ
a b : ℝ
h₁ : t i ⊆ Ioc a b
h₂ : ↑(StieltjesFunction.outer f) (Ioc a b) < length f (t i) + ↑(ε' i)
⊢ ↑(StieltjesFunction.outer f) (Ioc a b) < length f (t i) + ofReal ↑(ε' i)