l3lab/ntp-mathlib huggingface dataset:
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · 

Proof state:
case inl
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
inst✝ : IsCountablyGenerated ⊥
⊢ MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) ⊥ (𝓝 c)}

Next tactic:
simp
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  

Proof state:
case inr
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
⊢ MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)}

Next tactic:
letI := upgradePolishSpace γ
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  

Proof state:
case inr
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this : UpgradedPolishSpace γ := upgradePolishSpace γ
⊢ MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)}

Next tactic:
rcases l.exists_antitone_basis with ⟨u, hu⟩
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
⊢ MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)}

Next tactic:
simp_rw [← cauchy_map_iff_exists_tendsto]
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
⊢ MeasurableSet {x | Cauchy (map (fun n => f n x) l)}

Next tactic:
change MeasurableSet { x | _ ∧ _ }
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
⊢ MeasurableSet {x | NeBot (map (fun n => f n x) l) ∧ map (fun n => f n x) l ×ˢ map (fun n => f n x) l ≤ uniformity γ}

Next tactic:
have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
⊢ MeasurableSet {x | NeBot (map (fun n => f n x) l) ∧ map (fun n => f n x) l ×ˢ map (fun n => f n x) l ≤ uniformity γ}

Next tactic:
simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
⊢ MeasurableSet
    (⋂ i,
      ⋂ (_ : True),
        {x |
          ∃ i_2, True ∧ ((fun n => f n x) '' u i_2) ×ˢ ((fun n => f n x) '' u i_2) ⊆ {p | dist p.1 p.2 < 1 / (↑i + 1)}})

Next tactic:
refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
  refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
K : ℕ
x✝ : K ∈ fun i => True
⊢ MeasurableSet
    {x | ∃ i, True ∧ ((fun n => f n x) '' u i) ×ˢ ((fun n => f n x) '' u i) ⊆ {p | dist p.1 p.2 < 1 / (↑K + 1)}}

Next tactic:
simp_rw [Set.setOf_exists, true_and]
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
  refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
  simp_rw [Set.setOf_exists, true_and]
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
K : ℕ
x✝ : K ∈ fun i => True
⊢ MeasurableSet (⋃ i, {x | ((fun n => f n x) '' u i) ×ˢ ((fun n => f n x) '' u i) ⊆ {p | dist p.1 p.2 < 1 / (↑K + 1)}})

Next tactic:
refine' MeasurableSet.iUnion fun N => _
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
  refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
  simp_rw [Set.setOf_exists, true_and]
  refine' MeasurableSet.iUnion fun N => _
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
K : ℕ
x✝ : K ∈ fun i => True
N : ℕ
⊢ MeasurableSet {x | ((fun n => f n x) '' u N) ×ˢ ((fun n => f n x) '' u N) ⊆ {p | dist p.1 p.2 < 1 / (↑K + 1)}}

Next tactic:
simp_rw [prod_image_image_eq, image_subset_iff, prod_subset_iff, Set.setOf_forall]
/-- The set of points for which a measurable sequence of functions converges is measurable. -/
@[measurability]
theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
    [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
    [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by
  rcases l.eq_or_neBot with rfl | hl
  · simp
  letI := upgradePolishSpace γ
  rcases l.exists_antitone_basis with ⟨u, hu⟩
  simp_rw [← cauchy_map_iff_exists_tendsto]
  change MeasurableSet { x | _ ∧ _ }
  have :
    ∀ x,
      (map (fun i => f i x) l ×ˢ map (fun i => f i x) l).HasAntitoneBasis fun n =>
        ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n) :=
    fun x => hu.map.prod hu.map
  simp_rw [and_iff_right (hl.map _),
    Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ,
    Set.setOf_forall]
  refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
  simp_rw [Set.setOf_exists, true_and]
  refine' MeasurableSet.iUnion fun N => _
  simp_rw [prod_image_image_eq, image_subset_iff, prod_subset_iff, Set.setOf_forall]
  

Proof state:
case inr.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f✝ : γ → β
inst✝⁴ : TopologicalSpace γ
inst✝³ : PolishSpace γ
inst✝² : MeasurableSpace γ
hγ : OpensMeasurableSpace γ
inst✝¹ : Countable ι
l : Filter ι
inst✝ : IsCountablyGenerated l
f : ι → β → γ
hf : ∀ (i : ι), Measurable (f i)
hl : NeBot l
this✝ : UpgradedPolishSpace γ := upgradePolishSpace γ
u : ℕ → Set ι
hu : HasAntitoneBasis l u
this :
  ∀ (x : β),
    HasAntitoneBasis (map (fun i => f i x) l ×ˢ map (fun i => f i x) l) fun n =>
      ((fun i => f i x) '' u n) ×ˢ ((fun i => f i x) '' u n)
K : ℕ
x✝ : K ∈ fun i => True
N : ℕ
⊢ MeasurableSet
    (⋂ i ∈ u N, ⋂ i_1 ∈ u N, {x | (i, i_1) ∈ (fun p => (f p.1 x, f p.2 x)) ⁻¹' {p | dist p.1 p.2 < 1 / (↑K + 1)}})

Next tactic:
exact
    MeasurableSet.biInter (to_countable (u N)) fun i _ =>
      MeasurableSet.biInter (to_countable (u N)) fun j _ =>
        measurableSet_lt (Measurable.dist (hf i) (hf j)) measurable_const
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
⊢ ∃ x, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s

Next tactic:
letI := upgradeStandardBorel α
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  letI := upgradeStandardBorel α
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
this : UpgradedStandardBorel α := upgradeStandardBorel α
⊢ ∃ x, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s

Next tactic:
obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  letI := upgradeStandardBorel α
  obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable
  

Proof state:
case intro.intro.intro
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
this : UpgradedStandardBorel α := upgradeStandardBorel α
t : TopologicalSpace α
hle : t ≤ UpgradedStandardBorel.toTopologicalSpace
ht : PolishSpace α
s_clopen : IsClosed s ∧ IsOpen s
⊢ ∃ x, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s

Next tactic:
refine' ⟨t, _, ht, s_clopen⟩
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  letI := upgradeStandardBorel α
  obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable
  refine' ⟨t, _, ht, s_clopen⟩
  

Proof state:
case intro.intro.intro
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
this : UpgradedStandardBorel α := upgradeStandardBorel α
t : TopologicalSpace α
hle : t ≤ UpgradedStandardBorel.toTopologicalSpace
ht : PolishSpace α
s_clopen : IsClosed s ∧ IsOpen s
⊢ BorelSpace α

Next tactic:
constructor
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  letI := upgradeStandardBorel α
  obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable
  refine' ⟨t, _, ht, s_clopen⟩
  constructor
  

Proof state:
case intro.intro.intro.measurable_eq
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
this : UpgradedStandardBorel α := upgradeStandardBorel α
t : TopologicalSpace α
hle : t ≤ UpgradedStandardBorel.toTopologicalSpace
ht : PolishSpace α
s_clopen : IsClosed s ∧ IsOpen s
⊢ inst✝¹ = borel α

Next tactic:
rw [eq_borel_upgradeStandardBorel α, borel_eq_borel_of_le ht _ hle]
/-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology
making `s` clopen. -/
theorem _root_.MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) :
    ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by
  letI := upgradeStandardBorel α
  obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable
  refine' ⟨t, _, ht, s_clopen⟩
  constructor
  rw [eq_borel_upgradeStandardBorel α, borel_eq_borel_of_le ht _ hle]
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
this : UpgradedStandardBorel α := upgradeStandardBorel α
t : TopologicalSpace α
hle : t ≤ UpgradedStandardBorel.toTopologicalSpace
ht : PolishSpace α
s_clopen : IsClosed s ∧ IsOpen s
⊢ PolishSpace α

Next tactic:
infer_instance
/-- A measurable subspace of a standard Borel space is standard Borel. -/
theorem _root_.MeasurableSet.standardBorel {s : Set α} (hs : MeasurableSet s) :
    StandardBorelSpace s := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
⊢ StandardBorelSpace ↑s

Next tactic:
obtain ⟨_, _, _, s_closed, _⟩ := hs.isClopenable'
/-- A measurable subspace of a standard Borel space is standard Borel. -/
theorem _root_.MeasurableSet.standardBorel {s : Set α} (hs : MeasurableSet s) :
    StandardBorelSpace s := by
  obtain ⟨_, _, _, s_closed, _⟩ := hs.isClopenable'
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_2
inst✝¹ : MeasurableSpace α
inst✝ : StandardBorelSpace α
s : Set α
hs : MeasurableSet s
w✝ : TopologicalSpace α
left✝¹ : BorelSpace α
left✝ : PolishSpace α
s_closed : IsClosed s
right✝ : IsOpen s
⊢ StandardBorelSpace ↑s

Next tactic:
haveI := s_closed.polishSpace