l3lab/ntp-mathlib huggingface dataset:
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    

Proof state:
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).1, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : z ∈ {y_1 | ((x, y).2, y_1) ∈ m' ○ n}
⊢ ((x, y).1, z) ∈ (fun x => id x ○ n) (m' ○ m')

Next tactic:
dsimp [-mem_compRel] at hz ⊢
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    

Proof state:
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).1, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : (y, z) ∈ m' ○ n
⊢ (x, z) ∈ m' ○ m' ○ n

Next tactic:
rw [compRel_assoc]
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    

Proof state:
case intro.intro.intro.intro.intro.mk
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
n : Set (α × α)
x✝ : n ∈ 𝓤 α
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ m
x y : α
hp : (x, y) ∈ m'
h : {y_1 | ((x, y).1, y_1) ∈ m ○ n} ⊆ c i
z : α
hz : (y, z) ∈ m' ○ n
⊢ (x, z) ∈ m' ○ (m' ○ n)

Next tactic:
exact ⟨y, hp, hz⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
⊢ ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, {y | (x, y) ∈ n} ⊆ c i

Next tactic:
have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
x : α
hx : x ∈ s
⊢ x ∈ ⋃ n ∈ 𝓤 α, u n

Next tactic:
rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    

Proof state:
case intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
x : α
hx : x ∈ s
i : ι
h : x ∈ c i
⊢ x ∈ ⋃ n ∈ 𝓤 α, u n

Next tactic:
rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    

Proof state:
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
x : α
hx : x ∈ s
i : ι
h : x ∈ c i
m' : Set (α × α)
hm' : m' ∈ 𝓤 α
mm' : m' ○ m' ⊆ {p | p.1 = x → p.2 ∈ c i}
⊢ x ∈ ⋃ n ∈ 𝓤 α, u n

Next tactic:
exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
  

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n
⊢ ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, {y | (x, y) ∈ n} ⊆ c i

Next tactic:
rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
  

Proof state:
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ i ∈ b, u i
⊢ ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, {y | (x, y) ∈ n} ⊆ c i

Next tactic:
refine' ⟨_, (biInter_mem b_fin).2 bu, fun x hx => _⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
  refine' ⟨_, (biInter_mem b_fin).2 bu, fun x hx => _⟩
  

Proof state:
case intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ i ∈ b, u i
x : α
hx : x ∈ s
⊢ ∃ i, {y | (x, y) ∈ ⋂ i ∈ b, i} ⊆ c i

Next tactic:
rcases mem_iUnion₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
  refine' ⟨_, (biInter_mem b_fin).2 bu, fun x hx => _⟩
  rcases mem_iUnion₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ i ∈ b, u i
x : α
hx : x ∈ s
n : Set (α × α)
bn : n ∈ b
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
⊢ ∃ i, {y | (x, y) ∈ ⋂ i ∈ b, i} ⊆ c i

Next tactic:
refine' ⟨i, fun y hy => h _⟩
/-- Let `c : ι → Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}
    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i := by
  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }
  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) := by
    refine' fun n _ => isOpen_uniformity.2 _
    rintro x ⟨i, m, hm, h⟩
    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩
    apply (𝓤 α).sets_of_superset hm'
    rintro ⟨x, y⟩ hp rfl
    refine' ⟨i, m', hm', fun z hz => h (monotone_id.compRel monotone_const mm' _)⟩
    dsimp [-mem_compRel] at hz ⊢
    rw [compRel_assoc]
    exact ⟨y, hp, hz⟩
  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := fun x hx => by
    rcases mem_iUnion.1 (hc₂ hx) with ⟨i, h⟩
    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩
    exact mem_biUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩
  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩
  refine' ⟨_, (biInter_mem b_fin).2 bu, fun x hx => _⟩
  rcases mem_iUnion₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩
  refine' ⟨i, fun y hy => h _⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι✝ : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
ι : Sort u_2
c : ι → Set α
hs : IsCompact s
hc₁ : ∀ (i : ι), IsOpen (c i)
hc₂ : s ⊆ ⋃ i, c i
u : Set (α × α) → Set α := fun n => {x | ∃ i, ∃ m ∈ 𝓤 α, {y | (x, y) ∈ m ○ n} ⊆ c i}
hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n)
hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n
b : Set (Set (α × α))
bu : b ⊆ (𝓤 α).sets
b_fin : Set.Finite b
b_cover : s ⊆ ⋃ i ∈ b, u i
x : α
hx : x ∈ s
n : Set (α × α)
bn : n ∈ b
i : ι
m : Set (α × α)
hm : m ∈ 𝓤 α
h : {y | (x, y) ∈ m ○ n} ⊆ c i
y : α
hy : y ∈ {y | (x, y) ∈ ⋂ i ∈ b, i}
⊢ y ∈ {y | (x, y) ∈ m ○ n}

Next tactic:
exact prod_mk_mem_compRel (refl_mem_uniformity hm) (biInter_subset_of_mem bn hy)
/-- Let `c : Set (Set α)` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/
theorem lebesgue_number_lemma_sUnion {α : Type u} [UniformSpace α] {s : Set α} {c : Set (Set α)}
    (hs : IsCompact s) (hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t := by
  

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ t ∈ c, IsOpen t
hc₂ : s ⊆ ⋃₀ c
⊢ ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ (y : α), (x, y) ∈ n → y ∈ t

Next tactic:
rw [sUnion_eq_iUnion] at hc₂
/-- Let `c : Set (Set α)` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/
theorem lebesgue_number_lemma_sUnion {α : Type u} [UniformSpace α] {s : Set α} {c : Set (Set α)}
    (hs : IsCompact s) (hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t := by
  rw [sUnion_eq_iUnion] at hc₂; 

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ t ∈ c, IsOpen t
hc₂ : s ⊆ ⋃ i, ↑i
⊢ ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ (y : α), (x, y) ∈ n → y ∈ t

Next tactic:
simpa using lebesgue_number_lemma hs (by simpa) hc₂
/-- Let `c : Set (Set α)` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/
theorem lebesgue_number_lemma_sUnion {α : Type u} [UniformSpace α] {s : Set α} {c : Set (Set α)}
    (hs : IsCompact s) (hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) :
    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t := by
  rw [sUnion_eq_iUnion] at hc₂; simpa using lebesgue_number_lemma hs (by 

Proof state:
α✝ : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
α : Type u
inst✝ : UniformSpace α
s : Set α
c : Set (Set α)
hs : IsCompact s
hc₁ : ∀ t ∈ c, IsOpen t
hc₂ : s ⊆ ⋃ i, ↑i
⊢ ∀ (i : ↑c), IsOpen ↑i

Next tactic:
simpa
/-- A useful consequence of the Lebesgue number lemma: given any compact set `K` contained in an
open set `U`, we can find an (open) entourage `V` such that the ball of size `V` about any point of
`K` is contained in `U`. -/
theorem lebesgue_number_of_compact_open [UniformSpace α] {K U : Set α} (hK : IsCompact K)
    (hU : IsOpen U) (hKU : K ⊆ U) : ∃ V ∈ 𝓤 α, IsOpen V ∧ ∀ x ∈ K, UniformSpace.ball x V ⊆ U := by
  

Proof state:
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
⊢ ∃ V ∈ 𝓤 α, IsOpen V ∧ ∀ x ∈ K, UniformSpace.ball x V ⊆ U

Next tactic:
let W : K → Set (α × α) := fun k =>
    Classical.choose <| isOpen_iff_open_ball_subset.mp hU k.1 <| hKU k.2
/-- A useful consequence of the Lebesgue number lemma: given any compact set `K` contained in an
open set `U`, we can find an (open) entourage `V` such that the ball of size `V` about any point of
`K` is contained in `U`. -/
theorem lebesgue_number_of_compact_open [UniformSpace α] {K U : Set α} (hK : IsCompact K)
    (hU : IsOpen U) (hKU : K ⊆ U) : ∃ V ∈ 𝓤 α, IsOpen V ∧ ∀ x ∈ K, UniformSpace.ball x V ⊆ U := by
  let W : K → Set (α × α) := fun k =>
    Classical.choose <| isOpen_iff_open_ball_subset.mp hU k.1 <| hKU k.2
  

Proof state:
α : Type ua
β : Type ub
γ : Type uc
δ : Type ud
ι : Sort u_1
inst✝ : UniformSpace α
K U : Set α
hK : IsCompact K
hU : IsOpen U
hKU : K ⊆ U
W : ↑K → Set (α × α) := fun k => Classical.choose (_ : ∃ V ∈ 𝓤 α, IsOpen V ∧ UniformSpace.ball (↑k) V ⊆ U)
⊢ ∃ V ∈ 𝓤 α, IsOpen V ∧ ∀ x ∈ K, UniformSpace.ball x V ⊆ U

Next tactic:
have hW : ∀ k, W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball k.1 (W k) ⊆ U := by
    intro k
    obtain ⟨h₁, h₂, h₃⟩ := Classical.choose_spec (isOpen_iff_open_ball_subset.mp hU k.1 (hKU k.2))
    exact ⟨h₁, h₂, h₃⟩