l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem sup_apply (m₁ m₂ : OuterMeasure α) (s : Set α) : (m₁ ⊔ m₂) s = m₁ s ⊔ m₂ s := by
  have := iSup_apply (fun b => cond b m₁ m₂) s; 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m m₁ m₂ : OuterMeasure α
s : Set α
this : ↑(⨆ i, bif i then m₁ else m₂) s = ⨆ i, ↑(bif i then m₁ else m₂) s
⊢ ↑(m₁ ⊔ m₂) s = ↑m₁ s ⊔ ↑m₂ s

Next tactic:
rwa [iSup_bool_eq, iSup_bool_eq] at this
theorem smul_iSup [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] {ι} (f : ι → OuterMeasure α) (c : R) :
    (c • ⨆ i, f i) = ⨆ i, c • f i :=
  ext fun s => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
inst✝¹ : SMul R ℝ≥0∞
inst✝ : IsScalarTower R ℝ≥0∞ ℝ≥0∞
ι : Sort u_5
f : ι → OuterMeasure α
c : R
s : Set α
⊢ ↑(c • ⨆ i, f i) s = ↑(⨆ i, c • f i) s

Next tactic:
simp only [smul_apply, iSup_apply, ENNReal.smul_iSup]
/-- The pushforward of `m` along `f`. The outer measure on `s` is defined to be `m (f ⁻¹' s)`. -/
def map {β} (f : α → β) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β where
  toFun m :=
    { measureOf := fun s => m (f ⁻¹' s)
      empty := m.empty
      mono := fun {s t} h => m.mono (preimage_mono h)
      iUnion_nat := fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.67471
f : α → β
m : OuterMeasure α
s : ℕ → Set β
⊢ (fun s => ↑m (f ⁻¹' s)) (⋃ i, s i) ≤ ∑' (i : ℕ), (fun s => ↑m (f ⁻¹' s)) (s i)

Next tactic:
simp
/-- The pushforward of `m` along `f`. The outer measure on `s` is defined to be `m (f ⁻¹' s)`. -/
def map {β} (f : α → β) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β where
  toFun m :=
    { measureOf := fun s => m (f ⁻¹' s)
      empty := m.empty
      mono := fun {s t} h => m.mono (preimage_mono h)
      iUnion_nat := fun s => by simp; 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.67471
f : α → β
m : OuterMeasure α
s : ℕ → Set β
⊢ ↑m (⋃ i, f ⁻¹' s i) ≤ ∑' (i : ℕ), ↑m (f ⁻¹' s i)

Next tactic:
apply m.iUnion_nat fun i => f ⁻¹' s i
@[simp]
theorem map_sup {β} (f : α → β) (m m' : OuterMeasure α) : map f (m ⊔ m') = map f m ⊔ map f m' :=
  ext fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
f : α → β
m m' : OuterMeasure α
s : Set β
⊢ ↑((map f) (m ⊔ m')) s = ↑((map f) m ⊔ (map f) m') s

Next tactic:
simp only [map_apply, sup_apply]
@[simp]
theorem map_iSup {β ι} (f : α → β) (m : ι → OuterMeasure α) : map f (⨆ i, m i) = ⨆ i, map f (m i) :=
  ext fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
ι : Sort u_6
f : α → β
m : ι → OuterMeasure α
s : Set β
⊢ ↑((map f) (⨆ i, m i)) s = ↑(⨆ i, (map f) (m i)) s

Next tactic:
simp only [map_apply, iSup_apply]
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
⊢ LawfulFunctor OuterMeasure

Next tactic:
constructor
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> 

Proof state:
case map_const
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
⊢ ∀ {α β : Type ?u.77651}, Functor.mapConst = Functor.map ∘ const β

Next tactic:
intros
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> 

Proof state:
case id_map
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
⊢ ∀ {α : Type ?u.77651} (x : OuterMeasure α), id <$> x = x

Next tactic:
intros
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> 

Proof state:
case comp_map
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
⊢ ∀ {α β γ : Type ?u.77651} (g : α → β) (h : β → γ) (x : OuterMeasure α), (h ∘ g) <$> x = h <$> g <$> x

Next tactic:
intros
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> intros <;> 

Proof state:
case map_const
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
α✝ β✝ : Type ?u.77651
⊢ Functor.mapConst = Functor.map ∘ const β✝

Next tactic:
rfl
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> intros <;> 

Proof state:
case id_map
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
α✝ : Type ?u.77651
x✝ : OuterMeasure α✝
⊢ id <$> x✝ = x✝

Next tactic:
rfl
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> intros <;> 

Proof state:
case comp_map
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
α✝ β✝ γ✝ : Type ?u.77651
g✝ : α✝ → β✝
h✝ : β✝ → γ✝
x✝ : OuterMeasure α✝
⊢ (h✝ ∘ g✝) <$> x✝ = h✝ <$> g✝ <$> x✝

Next tactic:
rfl
/-- The dirac outer measure. -/
def dirac (a : α) : OuterMeasure α where
  measureOf s := indicator s (fun _ => 1) a
  empty := by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
a : α
⊢ (fun s => indicator s (fun x => 1) a) ∅ = 0

Next tactic:
simp
/-- The dirac outer measure. -/
def dirac (a : α) : OuterMeasure α where
  measureOf s := indicator s (fun _ => 1) a
  empty := by simp
  mono {s t} h := indicator_le_indicator_of_subset h (fun _ => zero_le _) a
  iUnion_nat s :=
    if hs : a ∈ ⋃ n, s n then
      let ⟨i, hi⟩ := mem_iUnion.1 hs
      calc
        indicator (⋃ n, s n) (fun _ => (1 : ℝ≥0∞)) a = 1 := indicator_of_mem hs _
        _ = indicator (s i) (fun _ => 1) a := Eq.symm (indicator_of_mem hi _)
        _ ≤ ∑' n, indicator (s n) (fun _ => 1) a := ENNReal.le_tsum _

    else by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
a : α
s : ℕ → Set α
hs : a ∉ ⋃ n, s n
⊢ (fun s => indicator s (fun x => 1) a) (⋃ i, s i) ≤ ∑' (i : ℕ), (fun s => indicator s (fun x => 1) a) (s i)

Next tactic:
simp only [indicator_of_not_mem hs, zero_le]
/-- The sum of an (arbitrary) collection of outer measures. -/
def sum {ι} (f : ι → OuterMeasure α) : OuterMeasure α where
  measureOf s := ∑' i, f i s
  empty := by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
ι : Type ?u.81637
f : ι → OuterMeasure α
⊢ (fun s => ∑' (i : ι), ↑(f i) s) ∅ = 0

Next tactic:
simp
/-- The sum of an (arbitrary) collection of outer measures. -/
def sum {ι} (f : ι → OuterMeasure α) : OuterMeasure α where
  measureOf s := ∑' i, f i s
  empty := by simp
  mono {s t} h := ENNReal.tsum_le_tsum fun i => (f i).mono' h
  iUnion_nat s := by
    

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
ι : Type ?u.81637
f : ι → OuterMeasure α
s : ℕ → Set α
⊢ (fun s => ∑' (i : ι), ↑(f i) s) (⋃ i, s i) ≤ ∑' (i : ℕ), (fun s => ∑' (i : ι), ↑(f i) s) (s i)

Next tactic:
rw [ENNReal.tsum_comm]
/-- The sum of an (arbitrary) collection of outer measures. -/
def sum {ι} (f : ι → OuterMeasure α) : OuterMeasure α where
  measureOf s := ∑' i, f i s
  empty := by simp
  mono {s t} h := ENNReal.tsum_le_tsum fun i => (f i).mono' h
  iUnion_nat s := by
    rw [ENNReal.tsum_comm]; 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
ι : Type ?u.81637
f : ι → OuterMeasure α
s : ℕ → Set α
⊢ (fun s => ∑' (i : ι), ↑(f i) s) (⋃ i, s i) ≤ ∑' (b : ι) (a : ℕ), ↑(f b) (s a)

Next tactic:
exact ENNReal.tsum_le_tsum fun i => (f i).iUnion_nat _
theorem smul_dirac_apply (a : ℝ≥0∞) (b : α) (s : Set α) :
    (a • dirac b) s = indicator s (fun _ => a) b := by
  

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
a : ℝ≥0∞
b : α
s : Set α
⊢ ↑(a • dirac b) s = indicator s (fun x => a) b

Next tactic:
simp only [smul_apply, smul_eq_mul, dirac_apply, ← indicator_mul_right _ fun _ => a, mul_one]
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
  toFun m :=
    { measureOf := fun s => m (f '' s)
      empty := by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.85050
f : α → β
m : OuterMeasure β
⊢ (fun s => ↑m (f '' s)) ∅ = 0

Next tactic:
simp
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
  toFun m :=
    { measureOf := fun s => m (f '' s)
      empty := by simp
      mono := fun {s t} h => m.mono <| image_subset f h
      iUnion_nat := fun s => by
        

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.85050
f : α → β
m : OuterMeasure β
s : ℕ → Set α
⊢ (fun s => ↑m (f '' s)) (⋃ i, s i) ≤ ∑' (i : ℕ), (fun s => ↑m (f '' s)) (s i)

Next tactic:
simp only
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
  toFun m :=
    { measureOf := fun s => m (f '' s)
      empty := by simp
      mono := fun {s t} h => m.mono <| image_subset f h
      iUnion_nat := fun s => by
        simp only
        

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.85050
f : α → β
m : OuterMeasure β
s : ℕ → Set α
⊢ ↑m (f '' ⋃ i, s i) ≤ ∑' (i : ℕ), ↑m (f '' s i)

Next tactic:
rw [image_iUnion]
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
  toFun m :=
    { measureOf := fun s => m (f '' s)
      empty := by simp
      mono := fun {s t} h => m.mono <| image_subset f h
      iUnion_nat := fun s => by
        simp only
        rw [image_iUnion]
        

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type ?u.85050
f : α → β
m : OuterMeasure β
s : ℕ → Set α
⊢ ↑m (⋃ i, f '' s i) ≤ ∑' (i : ℕ), ↑m (f '' s i)

Next tactic:
apply m.iUnion_nat
@[simp]
theorem comap_iSup {β ι} (f : α → β) (m : ι → OuterMeasure β) :
    comap f (⨆ i, m i) = ⨆ i, comap f (m i) :=
  ext fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
ι : Sort u_6
f : α → β
m : ι → OuterMeasure β
s : Set α
⊢ ↑((comap f) (⨆ i, m i)) s = ↑(⨆ i, (comap f) (m i)) s

Next tactic:
simp only [comap_apply, iSup_apply]
@[simp]
theorem restrict_apply (s t : Set α) (m : OuterMeasure α) : restrict s m t = m (t ∩ s) := by
  

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
s t : Set α
m : OuterMeasure α
⊢ ↑((restrict s) m) t = ↑m (t ∩ s)

Next tactic:
simp [restrict]
@[mono]
theorem restrict_mono {s t : Set α} (h : s ⊆ t) {m m' : OuterMeasure α} (hm : m ≤ m') :
    restrict s m ≤ restrict t m' := fun u => by
  

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
s t : Set α
h : s ⊆ t
m m' : OuterMeasure α
hm : m ≤ m'
u : Set α
⊢ ↑((restrict s) m) u ≤ ↑((restrict t) m') u

Next tactic:
simp only [restrict_apply]
@[mono]
theorem restrict_mono {s t : Set α} (h : s ⊆ t) {m m' : OuterMeasure α} (hm : m ≤ m') :
    restrict s m ≤ restrict t m' := fun u => by
  simp only [restrict_apply]
  

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
s t : Set α
h : s ⊆ t
m m' : OuterMeasure α
hm : m ≤ m'
u : Set α
⊢ ↑m (u ∩ s) ≤ ↑m' (u ∩ t)

Next tactic:
exact (hm _).trans (m'.mono <| inter_subset_inter_right _ h)
@[simp]
theorem restrict_univ (m : OuterMeasure α) : restrict univ m = m :=
  ext fun s => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ m : OuterMeasure α
s : Set α
⊢ ↑((restrict univ) m) s = ↑m s

Next tactic:
simp
@[simp]
theorem restrict_empty (m : OuterMeasure α) : restrict ∅ m = 0 :=
  ext fun s => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ m : OuterMeasure α
s : Set α
⊢ ↑((restrict ∅) m) s = ↑0 s

Next tactic:
simp
@[simp]
theorem restrict_iSup {ι} (s : Set α) (m : ι → OuterMeasure α) :
    restrict s (⨆ i, m i) = ⨆ i, restrict s (m i) := by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
ι : Sort u_5
s : Set α
m : ι → OuterMeasure α
⊢ (restrict s) (⨆ i, m i) = ⨆ i, (restrict s) (m i)

Next tactic:
simp [restrict]
theorem map_comap {β} (f : α → β) (m : OuterMeasure β) : map f (comap f m) = restrict (range f) m :=
  ext fun s => congr_arg m <| by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
f : α → β
m : OuterMeasure β
s : Set β
⊢ f '' (f ⁻¹' s) = Subtype.val '' (Subtype.val ⁻¹' s)

Next tactic:
simp only [image_preimage_eq_inter_range, Subtype.range_coe]
@[simp]
theorem map_le_restrict_range {β} {ma : OuterMeasure α} {mb : OuterMeasure β} {f : α → β} :
    map f ma ≤ restrict (range f) mb ↔ map f ma ≤ mb :=
  ⟨fun h => h.trans (restrict_le_self _ _), fun h s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
β : Type u_5
ma : OuterMeasure α
mb : OuterMeasure β
f : α → β
h : (map f) ma ≤ mb
s : Set β
⊢ ↑((map f) ma) s ≤ ↑((restrict (range f)) mb) s

Next tactic:
simpa using h (s ∩ range f)
theorem map_comap_of_surjective {β} {f : α → β} (hf : Surjective f) (m : OuterMeasure β) :
    map f (comap f m) = m :=
  ext fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
f : α → β
hf : Surjective f
m : OuterMeasure β
s : Set β
⊢ ↑((map f) ((comap f) m)) s = ↑m s

Next tactic:
rw [map_apply, comap_apply, hf.image_preimage]
theorem comap_map {β} {f : α → β} (hf : Injective f) (m : OuterMeasure α) : comap f (map f m) = m :=
  ext fun s => by 

Proof state:
α : Type u_1
β✝ : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m✝ : OuterMeasure α
β : Type u_5
f : α → β
hf : Injective f
m : OuterMeasure α
s : Set α
⊢ ↑((comap f) ((map f) m)) s = ↑m s

Next tactic:
rw [comap_apply, map_apply, hf.preimage_image]
@[simp]
theorem top_apply {s : Set α} (h : s.Nonempty) : (⊤ : OuterMeasure α) s = ∞ :=
  let ⟨a, as⟩ := h
  top_unique <| le_trans (by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
s : Set α
h : Set.Nonempty s
a : α
as : a ∈ s
⊢ ⊤ ≤ ↑(⊤ • dirac a) s

Next tactic:
simp [smul_dirac_apply, as]
theorem top_apply' (s : Set α) : (⊤ : OuterMeasure α) s = ⨅ h : s = ∅, 0 :=
  s.eq_empty_or_nonempty.elim (fun h => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
s : Set α
h : s = ∅
⊢ ↑⊤ s = ⨅ (_ : s = ∅), 0

Next tactic:
simp [h]
theorem top_apply' (s : Set α) : (⊤ : OuterMeasure α) s = ⨅ h : s = ∅, 0 :=
  s.eq_empty_or_nonempty.elim (fun h => by simp [h]) fun h => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
s : Set α
h : Set.Nonempty s
⊢ ↑⊤ s = ⨅ (_ : s = ∅), 0

Next tactic:
simp [h, h.ne_empty]
@[simp]
theorem comap_top (f : α → β) : comap f ⊤ = ⊤ :=
  ext_nonempty fun s hs => by 

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
f : α → β
s : Set α
hs : Set.Nonempty s
⊢ ↑((comap f) ⊤) s = ↑⊤ s

Next tactic:
rw [comap_apply, top_apply hs, top_apply (hs.image _)]
theorem map_top (f : α → β) : map f ⊤ = restrict (range f) ⊤ :=
  ext fun s => by
    

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
f : α → β
s : Set β
⊢ ↑((map f) ⊤) s = ↑((restrict (range f)) ⊤) s

Next tactic:
rw [map_apply, restrict_apply, ← image_preimage_eq_inter_range, top_apply', top_apply',
      Set.image_eq_empty]
@[simp]
theorem map_top_of_surjective (f : α → β) (hf : Surjective f) : map f ⊤ = ⊤ := by
  

Proof state:
α : Type u_1
β : Type u_2
R : Type u_3
R' : Type u_4
ms : Set (OuterMeasure α)
m : OuterMeasure α
f : α → β
hf : Surjective f
⊢ (map f) ⊤ = ⊤

Next tactic:
rw [map_top, hf.range_eq, restrict_univ]
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by 

Proof state:
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
⊢ ∑' (i : ℕ), m ((fun x => ∅) i) ≤ 0

Next tactic:
simp [m_empty]
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
        (zero_le _)
    mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
    iUnion_nat := fun s =>
      ENNReal.le_of_forall_pos_le_add <| by
        

Proof state:
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
s : ℕ → Set α
⊢ ∀ (ε : ℝ≥0), 0 < ε → ∑' (i : ℕ), μ (s i) < ⊤ → μ (⋃ i, s i) ≤ ∑' (i : ℕ), μ (s i) + ↑ε

Next tactic:
intro ε hε (hb : (∑' i, μ (s i)) < ∞)
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
        (zero_le _)
    mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
    iUnion_nat := fun s =>
      ENNReal.le_of_forall_pos_le_add <| by
        intro ε hε (hb : (∑' i, μ (s i)) < ∞)
        

Proof state:
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
s : ℕ → Set α
ε : ℝ≥0
hε : 0 < ε
hb : ∑' (i : ℕ), μ (s i) < ⊤
⊢ μ (⋃ i, s i) ≤ ∑' (i : ℕ), μ (s i) + ↑ε

Next tactic:
rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
        (zero_le _)
    mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
    iUnion_nat := fun s =>
      ENNReal.le_of_forall_pos_le_add <| by
        intro ε hε (hb : (∑' i, μ (s i)) < ∞)
        rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩
        

Proof state:
case intro.intro
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
s : ℕ → Set α
ε : ℝ≥0
hε : 0 < ε
hb : ∑' (i : ℕ), μ (s i) < ⊤
ε' : ℕ → ℝ≥0
hε' : ∀ (i : ℕ), 0 < ε' i
hl : ∑' (i : ℕ), ↑(ε' i) < ↑ε
⊢ μ (⋃ i, s i) ≤ ∑' (i : ℕ), μ (s i) + ↑ε

Next tactic:
refine' le_trans _ (add_le_add_left (le_of_lt hl) _)
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
        (zero_le _)
    mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
    iUnion_nat := fun s =>
      ENNReal.le_of_forall_pos_le_add <| by
        intro ε hε (hb : (∑' i, μ (s i)) < ∞)
        rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩
        refine' le_trans _ (add_le_add_left (le_of_lt hl) _)
        

Proof state:
case intro.intro
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
s : ℕ → Set α
ε : ℝ≥0
hε : 0 < ε
hb : ∑' (i : ℕ), μ (s i) < ⊤
ε' : ℕ → ℝ≥0
hε' : ∀ (i : ℕ), 0 < ε' i
hl : ∑' (i : ℕ), ↑(ε' i) < ↑ε
⊢ μ (⋃ i, s i) ≤ ∑' (i : ℕ), μ (s i) + ∑' (i : ℕ), ↑(ε' i)

Next tactic:
rw [← ENNReal.tsum_add]
/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is
  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction : OuterMeasure α :=
  let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
  { measureOf := μ
    empty :=
      le_antisymm
        ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
        (zero_le _)
    mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
    iUnion_nat := fun s =>
      ENNReal.le_of_forall_pos_le_add <| by
        intro ε hε (hb : (∑' i, μ (s i)) < ∞)
        rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩
        refine' le_trans _ (add_le_add_left (le_of_lt hl) _)
        rw [← ENNReal.tsum_add]
        

Proof state:
case intro.intro
α : Type u_1
m : Set α → ℝ≥0∞
m_empty : m ∅ = 0
μ : Set α → ℝ≥0∞ := fun s => ⨅ f, ⨅ (_ : s ⊆ ⋃ i, f i), ∑' (i : ℕ), m (f i)
s : ℕ → Set α
ε : ℝ≥0
hε : 0 < ε
hb : ∑' (i : ℕ), μ (s i) < ⊤
ε' : ℕ → ℝ≥0
hε' : ∀ (i : ℕ), 0 < ε' i
hl : ∑' (i : ℕ), ↑(ε' i) < ↑ε
⊢ μ (⋃ i, s i) ≤ ∑' (a : ℕ), (μ (s a) + ↑(ε' a))

Next tactic:
choose f hf using
          show ∀ i, ∃ f : ℕ → Set α, (s i ⊆ ⋃ i, f i) ∧ (∑' i, m (f i)) < μ (s i) + ε' i by
            intro i
            have : μ (s i) < μ (s i) + ε' i :=
              ENNReal.lt_add_right (ne_top_of_le_ne_top hb.ne <| ENNReal.le_tsum _)
                (by simpa using (hε' i).ne')
            rcases iInf_lt_iff.mp this with ⟨t, ht⟩
            exists t
            contrapose! ht
            exact le_iInf ht