-- Mathlib/MeasureTheory/Measure/Stieltjes.lean
theorem outer_trim : f.outer.trim = f.outer

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

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₂⟩

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

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

Tactic:
rw [← ENNReal.tsum_add]

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

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

Tactic:
apply iInf_le_of_le (MeasurableSet.iUnion fun i => (hg i).2.1) _

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

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

Tactic:
intro i

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

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

Tactic:
conv at hl =>
  lhs
  rw [length]

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

Proof state:
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ i, t i
ε : ℝ≥0
ε0 : 0 < ε
h : ∑' (i : ℕ), f.length (t i) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : ∑' (i : ℕ), ↑(ε' i) < ↑ε
g : ℕ → Set ℝ
hg : ∀ (i : ℕ), t i ⊆ g i ∧ MeasurableSet (g i) ∧ f.outer (g i) ≤ f.length (t i) + ↑(ε' i)
⊢ f.outer (iUnion g) ≤ ∑' (a : ℕ), (f.length (t a) + ↑(ε' a))

Tactic:
exact le_trans (measure_iUnion_le _) (ENNReal.tsum_le_tsum fun i => (hg i).2.2)

Result:
no goals

Proof state:
f : StieltjesFunction
s : Set ℝ
t : ℕ → Set ℝ
ht : s ⊆ ⋃ i, t i
ε : ℝ≥0
ε0 : 0 < ε
h : ∑' (i : ℕ), f.length (t i) < ⊤
ε' : ℕ → ℝ≥0
ε'0 : ∀ (i : ℕ), 0 < ε' i
hε : ∑' (i : ℕ), ↑(ε' i) < ↑ε
i : ℕ
⊢ ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ f.outer s ≤ f.length (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'

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

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

Tactic:
simpa using h₂

Result:
no goals