Theorem: MeasureTheory.OuterMeasure.ofFunction_union_of_top_of_nonempty_inter
File: Mathlib/MeasureTheory/Measure/OuterMeasure.lean

tactic: refine' le_antisymm (OuterMeasure.union _ _ _) (le_iInf fun f => le_iInf fun hf => _)
state_before: α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
⊢ ↑(OuterMeasure.ofFunction m m_empty) (s ∪ t) =
    ↑(OuterMeasure.ofFunction m m_empty) s + ↑(OuterMeasure.ofFunction m m_empty) t

tactic: set μ := OuterMeasure.ofFunction m m_empty
state_before: α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
⊢ ↑(OuterMeasure.ofFunction m m_empty) s + ↑(OuterMeasure.ofFunction m m_empty) t ≤ ∑' (i : ℕ), m (f i)

tactic: rcases Classical.em (∃ i, (s ∩ f i).Nonempty ∧ (t ∩ f i).Nonempty) with (⟨i, hs, ht⟩ | he)
state_before: α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)

tactic: set I := fun s => { i : ℕ | (s ∩ f i).Nonempty }
state_before: case inr
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
he : ¬∃ i, Set.Nonempty (s ∩ f i) ∧ Set.Nonempty (t ∩ f i)
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)

tactic: have hd : Disjoint (I s) (I t) := disjoint_iff_inf_le.mpr fun i hi => he ⟨i, hi⟩
state_before: case inr
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
he : ¬∃ i, Set.Nonempty (s ∩ f i) ∧ Set.Nonempty (t ∩ f i)
I : Set α → Set ℕ := fun s => {i | Set.Nonempty (s ∩ f i)}
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)

tactic: have hI : ∀ (u) (_ : u ⊆ s ∪ t), μ u ≤ ∑' i : I u, μ (f i) := fun u hu =>
  calc
    μ u ≤ μ (⋃ i : I u, f i) :=
      μ.mono fun x hx =>
        let ⟨i, hi⟩ := mem_iUnion.1 (hf (hu hx))
        mem_iUnion.2 ⟨⟨i, ⟨x, hx, hi⟩⟩, hi⟩
    _ ≤ ∑' i : I u, μ (f i) := μ.iUnion _
state_before: case inr
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
he : ¬∃ i, Set.Nonempty (s ∩ f i) ∧ Set.Nonempty (t ∩ f i)
I : Set α → Set ℕ := fun s => {i | Set.Nonempty (s ∩ f i)}
hd : Disjoint (I s) (I t)
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)

tactic: calc
  μ s + μ t ≤ (∑' i : I s, μ (f i)) + ∑' i : I t, μ (f i) :=
    add_le_add (hI _ <| subset_union_left _ _) (hI _ <| subset_union_right _ _)
  _ = ∑' i : ↑(I s ∪ I t), μ (f i) :=
    (@tsum_union_disjoint _ _ _ _ _ (fun i => μ (f i)) _ _ _ hd ENNReal.summable
        ENNReal.summable).symm
  _ ≤ ∑' i, μ (f i) :=
    (tsum_le_tsum_of_inj (↑) Subtype.coe_injective (fun _ _ => zero_le _) (fun _ => le_rfl)
      ENNReal.summable ENNReal.summable)
  _ ≤ ∑' i, m (f i) := ENNReal.tsum_le_tsum fun i => ofFunction_le _
state_before: case inr
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
he : ¬∃ i, Set.Nonempty (s ∩ f i) ∧ Set.Nonempty (t ∩ f i)
I : Set α → Set ℕ := fun s => {i | Set.Nonempty (s ∩ f i)}
hd : Disjoint (I s) (I t)
hI : ∀ (u : Set α), u ⊆ s ∪ t → ↑μ u ≤ ∑' (i : ↑(I u)), ↑μ (f ↑i)
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)

tactic: calc
  μ s + μ t ≤ ∞ := le_top
  _ = m (f i) := (h (f i) hs ht).symm
  _ ≤ ∑' i, m (f i) := ENNReal.le_tsum i
state_before: case inl.intro.intro
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
s t : Set α
h : ∀ (u : Set α), Set.Nonempty (s ∩ u) → Set.Nonempty (t ∩ u) → m u = ⊤
f : ℕ → Set α
hf : s ∪ t ⊆ ⋃ (i : ℕ), f i
μ : OuterMeasure α := OuterMeasure.ofFunction m m_empty
i : ℕ
hs : Set.Nonempty (s ∩ f i)
ht : Set.Nonempty (t ∩ f i)
⊢ ↑μ s + ↑μ t ≤ ∑' (i : ℕ), m (f i)