l3lab/ntp-mathlib huggingface dataset:
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι → Set α} (hs : ∀ i, IsComplete (s i))
    {U : Set (α × α)} (hU : U ∈ 𝓤 α) (hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j) :
    IsComplete (⋃ i, s i) := by
  set S := ⋃ i, s i
  intro l hl hls
  rw [le_principal_iff] at hls
  cases' cauchy_iff.1 hl with hl_ne hl'
  obtain ⟨t, htS, htl, htU⟩ : ∃ t, t ⊆ S ∧ t ∈ l ∧ t ×ˢ t ⊆ U := by
    rcases hl' U hU with ⟨t, htl, htU⟩
    exact ⟨t ∩ S, inter_subset_right _ _, inter_mem htl hls,
      (Set.prod_mono (inter_subset_left _ _) (inter_subset_left _ _)).trans htU⟩
  obtain ⟨i, hi⟩ : ∃ i, t ⊆ s i := by
    rcases Filter.nonempty_of_mem htl with ⟨x, hx⟩
    rcases mem_iUnion.1 (htS hx) with ⟨i, hi⟩
    

Proof state:
case intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
ι : Sort u_1
s : ι → Set α
hs : ∀ (i : ι), IsComplete (s i)
U : Set (α × α)
hU : U ∈ 𝓤 α
hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j
S : Set α := ⋃ i, s i
l : Filter α
hl : Cauchy l
hls : S ∈ l
hl_ne : NeBot l
hl' : ∀ s ∈ 𝓤 α, ∃ t ∈ l, t ×ˢ t ⊆ s
t : Set α
htS : t ⊆ S
htl : t ∈ l
htU : t ×ˢ t ⊆ U
x : α
hx : x ∈ t
i : ι
hi : x ∈ s i
⊢ ∃ i, t ⊆ s i

Next tactic:
refine' ⟨i, fun y hy => _⟩
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι → Set α} (hs : ∀ i, IsComplete (s i))
    {U : Set (α × α)} (hU : U ∈ 𝓤 α) (hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j) :
    IsComplete (⋃ i, s i) := by
  set S := ⋃ i, s i
  intro l hl hls
  rw [le_principal_iff] at hls
  cases' cauchy_iff.1 hl with hl_ne hl'
  obtain ⟨t, htS, htl, htU⟩ : ∃ t, t ⊆ S ∧ t ∈ l ∧ t ×ˢ t ⊆ U := by
    rcases hl' U hU with ⟨t, htl, htU⟩
    exact ⟨t ∩ S, inter_subset_right _ _, inter_mem htl hls,
      (Set.prod_mono (inter_subset_left _ _) (inter_subset_left _ _)).trans htU⟩
  obtain ⟨i, hi⟩ : ∃ i, t ⊆ s i := by
    rcases Filter.nonempty_of_mem htl with ⟨x, hx⟩
    rcases mem_iUnion.1 (htS hx) with ⟨i, hi⟩
    refine' ⟨i, fun y hy => _⟩
    

Proof state:
case intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
ι : Sort u_1
s : ι → Set α
hs : ∀ (i : ι), IsComplete (s i)
U : Set (α × α)
hU : U ∈ 𝓤 α
hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j
S : Set α := ⋃ i, s i
l : Filter α
hl : Cauchy l
hls : S ∈ l
hl_ne : NeBot l
hl' : ∀ s ∈ 𝓤 α, ∃ t ∈ l, t ×ˢ t ⊆ s
t : Set α
htS : t ⊆ S
htl : t ∈ l
htU : t ×ˢ t ⊆ U
x : α
hx : x ∈ t
i : ι
hi : x ∈ s i
y : α
hy : y ∈ t
⊢ y ∈ s i

Next tactic:
rcases mem_iUnion.1 (htS hy) with ⟨j, hj⟩
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι → Set α} (hs : ∀ i, IsComplete (s i))
    {U : Set (α × α)} (hU : U ∈ 𝓤 α) (hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j) :
    IsComplete (⋃ i, s i) := by
  set S := ⋃ i, s i
  intro l hl hls
  rw [le_principal_iff] at hls
  cases' cauchy_iff.1 hl with hl_ne hl'
  obtain ⟨t, htS, htl, htU⟩ : ∃ t, t ⊆ S ∧ t ∈ l ∧ t ×ˢ t ⊆ U := by
    rcases hl' U hU with ⟨t, htl, htU⟩
    exact ⟨t ∩ S, inter_subset_right _ _, inter_mem htl hls,
      (Set.prod_mono (inter_subset_left _ _) (inter_subset_left _ _)).trans htU⟩
  obtain ⟨i, hi⟩ : ∃ i, t ⊆ s i := by
    rcases Filter.nonempty_of_mem htl with ⟨x, hx⟩
    rcases mem_iUnion.1 (htS hx) with ⟨i, hi⟩
    refine' ⟨i, fun y hy => _⟩
    rcases mem_iUnion.1 (htS hy) with ⟨j, hj⟩
    

Proof state:
case intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
ι : Sort u_1
s : ι → Set α
hs : ∀ (i : ι), IsComplete (s i)
U : Set (α × α)
hU : U ∈ 𝓤 α
hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j
S : Set α := ⋃ i, s i
l : Filter α
hl : Cauchy l
hls : S ∈ l
hl_ne : NeBot l
hl' : ∀ s ∈ 𝓤 α, ∃ t ∈ l, t ×ˢ t ⊆ s
t : Set α
htS : t ⊆ S
htl : t ∈ l
htU : t ×ˢ t ⊆ U
x : α
hx : x ∈ t
i : ι
hi : x ∈ s i
y : α
hy : y ∈ t
j : ι
hj : y ∈ s j
⊢ y ∈ s i

Next tactic:
rwa [hd i j x hi y hj (htU <| mk_mem_prod hx hy)]
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι → Set α} (hs : ∀ i, IsComplete (s i))
    {U : Set (α × α)} (hU : U ∈ 𝓤 α) (hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j) :
    IsComplete (⋃ i, s i) := by
  set S := ⋃ i, s i
  intro l hl hls
  rw [le_principal_iff] at hls
  cases' cauchy_iff.1 hl with hl_ne hl'
  obtain ⟨t, htS, htl, htU⟩ : ∃ t, t ⊆ S ∧ t ∈ l ∧ t ×ˢ t ⊆ U := by
    rcases hl' U hU with ⟨t, htl, htU⟩
    exact ⟨t ∩ S, inter_subset_right _ _, inter_mem htl hls,
      (Set.prod_mono (inter_subset_left _ _) (inter_subset_left _ _)).trans htU⟩
  obtain ⟨i, hi⟩ : ∃ i, t ⊆ s i := by
    rcases Filter.nonempty_of_mem htl with ⟨x, hx⟩
    rcases mem_iUnion.1 (htS hx) with ⟨i, hi⟩
    refine' ⟨i, fun y hy => _⟩
    rcases mem_iUnion.1 (htS hy) with ⟨j, hj⟩
    rwa [hd i j x hi y hj (htU <| mk_mem_prod hx hy)]
  

Proof state:
case intro.intro.intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
ι : Sort u_1
s : ι → Set α
hs : ∀ (i : ι), IsComplete (s i)
U : Set (α × α)
hU : U ∈ 𝓤 α
hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j
S : Set α := ⋃ i, s i
l : Filter α
hl : Cauchy l
hls : S ∈ l
hl_ne : NeBot l
hl' : ∀ s ∈ 𝓤 α, ∃ t ∈ l, t ×ˢ t ⊆ s
t : Set α
htS : t ⊆ S
htl : t ∈ l
htU : t ×ˢ t ⊆ U
i : ι
hi : t ⊆ s i
⊢ ∃ x ∈ S, l ≤ 𝓝 x

Next tactic:
rcases hs i l hl (le_principal_iff.2 <| mem_of_superset htl hi) with ⟨x, hxs, hlx⟩
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι → Set α} (hs : ∀ i, IsComplete (s i))
    {U : Set (α × α)} (hU : U ∈ 𝓤 α) (hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j) :
    IsComplete (⋃ i, s i) := by
  set S := ⋃ i, s i
  intro l hl hls
  rw [le_principal_iff] at hls
  cases' cauchy_iff.1 hl with hl_ne hl'
  obtain ⟨t, htS, htl, htU⟩ : ∃ t, t ⊆ S ∧ t ∈ l ∧ t ×ˢ t ⊆ U := by
    rcases hl' U hU with ⟨t, htl, htU⟩
    exact ⟨t ∩ S, inter_subset_right _ _, inter_mem htl hls,
      (Set.prod_mono (inter_subset_left _ _) (inter_subset_left _ _)).trans htU⟩
  obtain ⟨i, hi⟩ : ∃ i, t ⊆ s i := by
    rcases Filter.nonempty_of_mem htl with ⟨x, hx⟩
    rcases mem_iUnion.1 (htS hx) with ⟨i, hi⟩
    refine' ⟨i, fun y hy => _⟩
    rcases mem_iUnion.1 (htS hy) with ⟨j, hj⟩
    rwa [hd i j x hi y hj (htU <| mk_mem_prod hx hy)]
  rcases hs i l hl (le_principal_iff.2 <| mem_of_superset htl hi) with ⟨x, hxs, hlx⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
ι : Sort u_1
s : ι → Set α
hs : ∀ (i : ι), IsComplete (s i)
U : Set (α × α)
hU : U ∈ 𝓤 α
hd : ∀ (i j : ι), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j
S : Set α := ⋃ i, s i
l : Filter α
hl : Cauchy l
hls : S ∈ l
hl_ne : NeBot l
hl' : ∀ s ∈ 𝓤 α, ∃ t ∈ l, t ×ˢ t ⊆ s
t : Set α
htS : t ⊆ S
htl : t ∈ l
htU : t ×ˢ t ⊆ U
i : ι
hi : t ⊆ s i
x : α
hxs : x ∈ s i
hlx : l ≤ 𝓝 x
⊢ ∃ x ∈ S, l ≤ 𝓝 x

Next tactic:
exact ⟨x, mem_iUnion.2 ⟨i, hxs⟩, hlx⟩
theorem complete_univ {α : Type u} [UniformSpace α] [CompleteSpace α] :
    IsComplete (univ : Set α) := fun f hf _ => by
  

Proof state:
α✝ : Type u
β : Type v
uniformSpace : UniformSpace α✝
α : Type u
inst✝¹ : UniformSpace α
inst✝ : CompleteSpace α
f : Filter α
hf : Cauchy f
x✝ : f ≤ 𝓟 univ
⊢ ∃ x ∈ univ, f ≤ 𝓝 x

Next tactic:
rcases CompleteSpace.complete hf with ⟨x, hx⟩
theorem complete_univ {α : Type u} [UniformSpace α] [CompleteSpace α] :
    IsComplete (univ : Set α) := fun f hf _ => by
  rcases CompleteSpace.complete hf with ⟨x, hx⟩
  

Proof state:
case intro
α✝ : Type u
β : Type v
uniformSpace : UniformSpace α✝
α : Type u
inst✝¹ : UniformSpace α
inst✝ : CompleteSpace α
f : Filter α
hf : Cauchy f
x✝ : f ≤ 𝓟 univ
x : α
hx : f ≤ 𝓝 x
⊢ ∃ x ∈ univ, f ≤ 𝓝 x

Next tactic:
exact ⟨x, mem_univ x, hx⟩
instance CompleteSpace.prod [UniformSpace β] [CompleteSpace α] [CompleteSpace β] :
    CompleteSpace (α × β) where
  complete hf :=
    let ⟨x1, hx1⟩ := CompleteSpace.complete <| hf.map uniformContinuous_fst
    let ⟨x2, hx2⟩ := CompleteSpace.complete <| hf.map uniformContinuous_snd
    ⟨(x1, x2), by 

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝² : UniformSpace β
inst✝¹ : CompleteSpace α
inst✝ : CompleteSpace β
f✝ : Filter (α × β)
hf : Cauchy f✝
x1 : α
hx1 : map (fun p => p.1) f✝ ≤ 𝓝 x1
x2 : β
hx2 : map (fun p => p.2) f✝ ≤ 𝓝 x2
⊢ f✝ ≤ 𝓝 (x1, x2)

Next tactic:
rw [nhds_prod_eq, le_prod]
instance CompleteSpace.prod [UniformSpace β] [CompleteSpace α] [CompleteSpace β] :
    CompleteSpace (α × β) where
  complete hf :=
    let ⟨x1, hx1⟩ := CompleteSpace.complete <| hf.map uniformContinuous_fst
    let ⟨x2, hx2⟩ := CompleteSpace.complete <| hf.map uniformContinuous_snd
    ⟨(x1, x2), by rw [nhds_prod_eq, le_prod]; 

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝² : UniformSpace β
inst✝¹ : CompleteSpace α
inst✝ : CompleteSpace β
f✝ : Filter (α × β)
hf : Cauchy f✝
x1 : α
hx1 : map (fun p => p.1) f✝ ≤ 𝓝 x1
x2 : β
hx2 : map (fun p => p.2) f✝ ≤ 𝓝 x2
⊢ Tendsto Prod.fst f✝ (𝓝 x1) ∧ Tendsto Prod.snd f✝ (𝓝 x2)

Next tactic:
constructor
instance CompleteSpace.prod [UniformSpace β] [CompleteSpace α] [CompleteSpace β] :
    CompleteSpace (α × β) where
  complete hf :=
    let ⟨x1, hx1⟩ := CompleteSpace.complete <| hf.map uniformContinuous_fst
    let ⟨x2, hx2⟩ := CompleteSpace.complete <| hf.map uniformContinuous_snd
    ⟨(x1, x2), by rw [nhds_prod_eq, le_prod]; constructor <;> 

Proof state:
case left
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝² : UniformSpace β
inst✝¹ : CompleteSpace α
inst✝ : CompleteSpace β
f✝ : Filter (α × β)
hf : Cauchy f✝
x1 : α
hx1 : map (fun p => p.1) f✝ ≤ 𝓝 x1
x2 : β
hx2 : map (fun p => p.2) f✝ ≤ 𝓝 x2
⊢ Tendsto Prod.fst f✝ (𝓝 x1)

Next tactic:
assumption
instance CompleteSpace.prod [UniformSpace β] [CompleteSpace α] [CompleteSpace β] :
    CompleteSpace (α × β) where
  complete hf :=
    let ⟨x1, hx1⟩ := CompleteSpace.complete <| hf.map uniformContinuous_fst
    let ⟨x2, hx2⟩ := CompleteSpace.complete <| hf.map uniformContinuous_snd
    ⟨(x1, x2), by rw [nhds_prod_eq, le_prod]; constructor <;> 

Proof state:
case right
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝² : UniformSpace β
inst✝¹ : CompleteSpace α
inst✝ : CompleteSpace β
f✝ : Filter (α × β)
hf : Cauchy f✝
x1 : α
hx1 : map (fun p => p.1) f✝ ≤ 𝓝 x1
x2 : β
hx2 : map (fun p => p.2) f✝ ≤ 𝓝 x2
⊢ Tendsto Prod.snd f✝ (𝓝 x2)

Next tactic:
assumption
lemma CompleteSpace.fst_of_prod [UniformSpace β] [CompleteSpace (α × β)] [h : Nonempty β] :
    CompleteSpace α where
  complete hf :=
    let ⟨y⟩ := h
    let ⟨(a, b), hab⟩ := CompleteSpace.complete <| hf.prod <| cauchy_pure (a := y)
    ⟨a, by 

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝¹ : UniformSpace β
inst✝ : CompleteSpace (α × β)
h : Nonempty β
f✝ : Filter α
hf : Cauchy f✝
y : β
a : α
b : β
hab : f✝ ×ˢ pure y ≤ 𝓝 (a, b)
⊢ f✝ ≤ 𝓝 a

Next tactic:
simpa only [map_fst_prod, nhds_prod_eq] using map_mono (m := Prod.fst) hab
lemma CompleteSpace.snd_of_prod [UniformSpace β] [CompleteSpace (α × β)] [h : Nonempty α] :
    CompleteSpace β where
  complete hf :=
    let ⟨x⟩ := h
    let ⟨(a, b), hab⟩ := CompleteSpace.complete <| (cauchy_pure (a := x)).prod hf
    ⟨b, by 

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝¹ : UniformSpace β
inst✝ : CompleteSpace (α × β)
h : Nonempty α
f✝ : Filter β
hf : Cauchy f✝
x a : α
b : β
hab : pure x ×ˢ f✝ ≤ 𝓝 (a, b)
⊢ f✝ ≤ 𝓝 b

Next tactic:
simpa only [map_snd_prod, nhds_prod_eq] using map_mono (m := Prod.snd) hab
theorem completeSpace_iff_ultrafilter :
    CompleteSpace α ↔ ∀ l : Ultrafilter α, Cauchy (l : Filter α) → ∃ x : α, ↑l ≤ 𝓝 x := by
  

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
⊢ CompleteSpace α ↔ ∀ (l : Ultrafilter α), Cauchy ↑l → ∃ x, ↑l ≤ 𝓝 x

Next tactic:
simp [completeSpace_iff_isComplete_univ, isComplete_iff_ultrafilter]
/-- If `K` is a complete subset, then any cauchy sequence in `K` converges to a point in `K` -/
theorem cauchySeq_tendsto_of_isComplete [Preorder β] {K : Set α} (h₁ : IsComplete K)
    {u : β → α} (h₂ : ∀ n, u n ∈ K) (h₃ : CauchySeq u) : ∃ v ∈ K, Tendsto u atTop (𝓝 v) :=
  h₁ _ h₃ <| le_principal_iff.2 <| mem_map_iff_exists_image.2
    ⟨univ, univ_mem, by 

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
inst✝ : Preorder β
K : Set α
h₁ : IsComplete K
u : β → α
h₂ : ∀ (n : β), u n ∈ K
h₃ : CauchySeq u
⊢ u '' univ ⊆ K

Next tactic:
rwa [image_univ, range_subset_iff]
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  

Proof state:
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
⊢ ∃ t ⊆ s, Set.Finite t ∧ s ⊆ ⋃ y ∈ t, {x | (x, y) ∈ U}

Next tactic:
rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  

Proof state:
case intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
⊢ ∃ t ⊆ s, Set.Finite t ∧ s ⊆ ⋃ y ∈ t, {x | (x, y) ∈ U}

Next tactic:
rcases hs r hr with ⟨k, fk, ks⟩
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  

Proof state:
case intro.intro.intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
⊢ ∃ t ⊆ s, Set.Finite t ∧ s ⊆ ⋃ y ∈ t, {x | (x, y) ∈ U}

Next tactic:
let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  

Proof state:
case intro.intro.intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
⊢ ∃ t ⊆ s, Set.Finite t ∧ s ⊆ ⋃ y ∈ t, {x | (x, y) ∈ U}

Next tactic:
choose f hfs hfr using fun x : u => x.coe_prop.2
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  

Proof state:
case intro.intro.intro.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
⊢ ∃ t ⊆ s, Set.Finite t ∧ s ⊆ ⋃ y ∈ t, {x | (x, y) ∈ U}

Next tactic:
refine' ⟨range f, _, _, _⟩
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · 

Proof state:
case intro.intro.intro.intro.intro.refine'_1
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
⊢ range f ⊆ s

Next tactic:
exact range_subset_iff.2 hfs
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · 

Proof state:
case intro.intro.intro.intro.intro.refine'_2
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
⊢ Set.Finite (range f)

Next tactic:
haveI : Fintype u := (fk.inter_of_left _).fintype
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    

Proof state:
case intro.intro.intro.intro.intro.refine'_2
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
this : Fintype ↑u
⊢ Set.Finite (range f)

Next tactic:
exact finite_range f
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    exact finite_range f
  · 

Proof state:
case intro.intro.intro.intro.intro.refine'_3
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
⊢ s ⊆ ⋃ y ∈ range f, {x | (x, y) ∈ U}

Next tactic:
intro x xs
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    exact finite_range f
  · intro x xs
    

Proof state:
case intro.intro.intro.intro.intro.refine'_3
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
x : α
xs : x ∈ s
⊢ x ∈ ⋃ y ∈ range f, {x | (x, y) ∈ U}

Next tactic:
obtain ⟨y, hy, xy⟩ := mem_iUnion₂.1 (ks xs)
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    exact finite_range f
  · intro x xs
    obtain ⟨y, hy, xy⟩ := mem_iUnion₂.1 (ks xs)
    

Proof state:
case intro.intro.intro.intro.intro.refine'_3.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
x : α
xs : x ∈ s
y : α
hy : y ∈ k
xy : x ∈ {x | (x, y) ∈ r}
⊢ x ∈ ⋃ y ∈ range f, {x | (x, y) ∈ U}

Next tactic:
rw [biUnion_range, mem_iUnion]
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    exact finite_range f
  · intro x xs
    obtain ⟨y, hy, xy⟩ := mem_iUnion₂.1 (ks xs)
    rw [biUnion_range, mem_iUnion]
    

Proof state:
case intro.intro.intro.intro.intro.refine'_3.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
x : α
xs : x ∈ s
y : α
hy : y ∈ k
xy : x ∈ {x | (x, y) ∈ r}
⊢ ∃ i, x ∈ {x | (x, f i) ∈ U}

Next tactic:
set z : ↥u := ⟨y, hy, ⟨x, xs, xy⟩⟩
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α × α)}
    (hU : U ∈ 𝓤 α) : ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, { x | (x, y) ∈ U } := by
  rcases comp_symm_of_uniformity hU with ⟨r, hr, rs, rU⟩
  rcases hs r hr with ⟨k, fk, ks⟩
  let u := k ∩ { y | ∃ x ∈ s, (x, y) ∈ r }
  choose f hfs hfr using fun x : u => x.coe_prop.2
  refine' ⟨range f, _, _, _⟩
  · exact range_subset_iff.2 hfs
  · haveI : Fintype u := (fk.inter_of_left _).fintype
    exact finite_range f
  · intro x xs
    obtain ⟨y, hy, xy⟩ := mem_iUnion₂.1 (ks xs)
    rw [biUnion_range, mem_iUnion]
    set z : ↥u := ⟨y, hy, ⟨x, xs, xy⟩⟩
    

Proof state:
case intro.intro.intro.intro.intro.refine'_3.intro.intro
α : Type u
β : Type v
uniformSpace : UniformSpace α
s : Set α
hs : TotallyBounded s
U : Set (α × α)
hU : U ∈ 𝓤 α
r : Set (α × α)
hr : r ∈ 𝓤 α
rs : ∀ {a b : α}, (a, b) ∈ r → (b, a) ∈ r
rU : r ○ r ⊆ U
k : Set α
fk : Set.Finite k
ks : s ⊆ ⋃ y ∈ k, {x | (x, y) ∈ r}
u : Set α := k ∩ {y | ∃ x ∈ s, (x, y) ∈ r}
f : ↑u → α
hfs : ∀ (x : ↑u), f x ∈ s
hfr : ∀ (x : ↑u), (f x, ↑x) ∈ r
x : α
xs : x ∈ s
y : α
hy : y ∈ k
xy : x ∈ {x | (x, y) ∈ r}
z : ↑u := { val := y, property := (_ : y ∈ k ∧ y ∈ {y | ∃ x ∈ s, (x, y) ∈ r}) }
⊢ ∃ i, x ∈ {x | (x, f i) ∈ U}

Next tactic:
exact ⟨z, rU <| mem_compRel.2 ⟨y, xy, rs (hfr z)⟩⟩