l3lab/ntp-mathlib huggingface dataset:
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
a continuous injective map is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_continuousOn_injOn [OpensMeasurableSpace β]
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s)
    (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
tγ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
⊢ MeasurableSet (f '' s)

Next tactic:
obtain ⟨t', t't, t'_polish, s_closed, _⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s :=
    hs.isClopenable
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
a continuous injective map is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_continuousOn_injOn [OpensMeasurableSpace β]
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s)
    (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by
  obtain ⟨t', t't, t'_polish, s_closed, _⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s :=
    hs.isClopenable
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
tγ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
t' : TopologicalSpace γ
t't : t' ≤ tγ
t'_polish : PolishSpace γ
s_closed : IsClosed s
right✝ : IsOpen s
⊢ MeasurableSet (f '' s)

Next tactic:
exact
    @IsClosed.measurableSet_image_of_continuousOn_injOn γ t' t'_polish β _ _ _ _ s s_closed f
      (f_cont.mono_dom t't) f_inj
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space,
then its image under a measurable injective map taking values in a
second-countable topological space is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
    (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
    MeasurableSet (f '' s) := by
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
inst✝² : MeasurableSpace γ
inst✝¹ : StandardBorelSpace γ
inst✝ : SecondCountableTopology β
hs : MeasurableSet s
f_meas : Measurable f
f_inj : InjOn f s
⊢ MeasurableSet (f '' s)

Next tactic:
letI := upgradeStandardBorel γ
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space,
then its image under a measurable injective map taking values in a
second-countable topological space is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
    (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
    MeasurableSet (f '' s) := by
  letI := upgradeStandardBorel γ
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
inst✝² : MeasurableSpace γ
inst✝¹ : StandardBorelSpace γ
inst✝ : SecondCountableTopology β
hs : MeasurableSet s
f_meas : Measurable f
f_inj : InjOn f s
this : UpgradedStandardBorel γ := upgradeStandardBorel γ
⊢ MeasurableSet (f '' s)

Next tactic:
let tγ : TopologicalSpace γ := inferInstance
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space,
then its image under a measurable injective map taking values in a
second-countable topological space is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
    (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
    MeasurableSet (f '' s) := by
  letI := upgradeStandardBorel γ
  let tγ : TopologicalSpace γ := inferInstance
  -- for a finer Polish topology, `f` is continuous. Therefore, one may apply the corresponding
  -- result for continuous maps.
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
inst✝² : MeasurableSpace γ
inst✝¹ : StandardBorelSpace γ
inst✝ : SecondCountableTopology β
hs : MeasurableSet s
f_meas : Measurable f
f_inj : InjOn f s
this : UpgradedStandardBorel γ := upgradeStandardBorel γ
tγ : TopologicalSpace γ := inferInstance
⊢ MeasurableSet (f '' s)

Next tactic:
obtain ⟨t', t't, f_cont, t'_polish⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @Continuous γ β t' tβ f ∧ @PolishSpace γ t' :=
    f_meas.exists_continuous
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space,
then its image under a measurable injective map taking values in a
second-countable topological space is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
    (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
    MeasurableSet (f '' s) := by
  letI := upgradeStandardBorel γ
  let tγ : TopologicalSpace γ := inferInstance
  -- for a finer Polish topology, `f` is continuous. Therefore, one may apply the corresponding
  -- result for continuous maps.
  obtain ⟨t', t't, f_cont, t'_polish⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @Continuous γ β t' tβ f ∧ @PolishSpace γ t' :=
    f_meas.exists_continuous
  

Proof state:
case intro.intro.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
inst✝² : MeasurableSpace γ
inst✝¹ : StandardBorelSpace γ
inst✝ : SecondCountableTopology β
hs : MeasurableSet s
f_meas : Measurable f
f_inj : InjOn f s
this : UpgradedStandardBorel γ := upgradeStandardBorel γ
tγ : TopologicalSpace γ := inferInstance
t' : TopologicalSpace γ
t't : t' ≤ tγ
f_cont : Continuous f
t'_polish : PolishSpace γ
⊢ MeasurableSet (f '' s)

Next tactic:
have M : MeasurableSet[@borel γ t'] s :=
    @Continuous.measurable γ γ t' (@borel γ t')
      (@BorelSpace.opensMeasurable γ t' (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl))
      tγ _ _ _ (continuous_id_of_le t't) s hs
/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space,
then its image under a measurable injective map taking values in a
second-countable topological space is also Borel-measurable. -/
theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
    (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
    MeasurableSet (f '' s) := by
  letI := upgradeStandardBorel γ
  let tγ : TopologicalSpace γ := inferInstance
  -- for a finer Polish topology, `f` is continuous. Therefore, one may apply the corresponding
  -- result for continuous maps.
  obtain ⟨t', t't, f_cont, t'_polish⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @Continuous γ β t' tβ f ∧ @PolishSpace γ t' :=
    f_meas.exists_continuous
  have M : MeasurableSet[@borel γ t'] s :=
    @Continuous.measurable γ γ t' (@borel γ t')
      (@BorelSpace.opensMeasurable γ t' (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl))
      tγ _ _ _ (continuous_id_of_le t't) s hs
  

Proof state:
case intro.intro.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁵ : T2Space β
inst✝⁴ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝³ : OpensMeasurableSpace β
inst✝² : MeasurableSpace γ
inst✝¹ : StandardBorelSpace γ
inst✝ : SecondCountableTopology β
hs : MeasurableSet s
f_meas : Measurable f
f_inj : InjOn f s
this : UpgradedStandardBorel γ := upgradeStandardBorel γ
tγ : TopologicalSpace γ := inferInstance
t' : TopologicalSpace γ
t't : t' ≤ tγ
f_cont : Continuous f
t'_polish : PolishSpace γ
M : MeasurableSet s
⊢ MeasurableSet (f '' s)

Next tactic:
exact
    @MeasurableSet.image_of_continuousOn_injOn γ
      β _ _ _  s f _ t' t'_polish (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl)
      M (@Continuous.continuousOn γ β t' tβ f s f_cont) f_inj
/-- If `s` is Borel-measurable in a Polish space and `f` is continuous injective on `s`, then
the restriction of `f` to `s` is a measurable embedding. -/
theorem _root_.ContinuousOn.measurableEmbedding [BorelSpace β]
    [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
    (f_inj : InjOn f s) : MeasurableEmbedding (s.restrict f) :=
  { injective := injOn_iff_injective.1 f_inj
    measurable := (continuousOn_iff_continuous_restrict.1 f_cont).measurable
    measurableSet_image' := by
      

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝⁴ : BorelSpace β
inst✝³ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
⊢ ∀ ⦃s_1 : Set ↑s⦄, MeasurableSet s_1 → MeasurableSet (restrict s f '' s_1)

Next tactic:
intro u hu
/-- If `s` is Borel-measurable in a Polish space and `f` is continuous injective on `s`, then
the restriction of `f` to `s` is a measurable embedding. -/
theorem _root_.ContinuousOn.measurableEmbedding [BorelSpace β]
    [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
    (f_inj : InjOn f s) : MeasurableEmbedding (s.restrict f) :=
  { injective := injOn_iff_injective.1 f_inj
    measurable := (continuousOn_iff_continuous_restrict.1 f_cont).measurable
    measurableSet_image' := by
      intro u hu
      

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝⁴ : BorelSpace β
inst✝³ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
u : Set ↑s
hu : MeasurableSet u
⊢ MeasurableSet (restrict s f '' u)

Next tactic:
have A : MeasurableSet (((↑) : s → γ) '' u) :=
        (MeasurableEmbedding.subtype_coe hs).measurableSet_image.2 hu
/-- If `s` is Borel-measurable in a Polish space and `f` is continuous injective on `s`, then
the restriction of `f` to `s` is a measurable embedding. -/
theorem _root_.ContinuousOn.measurableEmbedding [BorelSpace β]
    [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
    (f_inj : InjOn f s) : MeasurableEmbedding (s.restrict f) :=
  { injective := injOn_iff_injective.1 f_inj
    measurable := (continuousOn_iff_continuous_restrict.1 f_cont).measurable
    measurableSet_image' := by
      intro u hu
      have A : MeasurableSet (((↑) : s → γ) '' u) :=
        (MeasurableEmbedding.subtype_coe hs).measurableSet_image.2 hu
      

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝⁴ : BorelSpace β
inst✝³ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
u : Set ↑s
hu : MeasurableSet u
A : MeasurableSet (Subtype.val '' u)
⊢ MeasurableSet (restrict s f '' u)

Next tactic:
have B : MeasurableSet (f '' (((↑) : s → γ) '' u)) :=
        A.image_of_continuousOn_injOn (f_cont.mono (Subtype.coe_image_subset s u))
          (f_inj.mono (Subtype.coe_image_subset s u))
/-- If `s` is Borel-measurable in a Polish space and `f` is continuous injective on `s`, then
the restriction of `f` to `s` is a measurable embedding. -/
theorem _root_.ContinuousOn.measurableEmbedding [BorelSpace β]
    [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
    (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
    (f_inj : InjOn f s) : MeasurableEmbedding (s.restrict f) :=
  { injective := injOn_iff_injective.1 f_inj
    measurable := (continuousOn_iff_continuous_restrict.1 f_cont).measurable
    measurableSet_image' := by
      intro u hu
      have A : MeasurableSet (((↑) : s → γ) '' u) :=
        (MeasurableEmbedding.subtype_coe hs).measurableSet_image.2 hu
      have B : MeasurableSet (f '' (((↑) : s → γ) '' u)) :=
        A.image_of_continuousOn_injOn (f_cont.mono (Subtype.coe_image_subset s u))
          (f_inj.mono (Subtype.coe_image_subset s u))
      

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁶ : T2Space β
inst✝⁵ : MeasurableSpace β
s : Set γ
f : γ → β
inst✝⁴ : BorelSpace β
inst✝³ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : MeasurableSet s
f_cont : ContinuousOn f s
f_inj : InjOn f s
u : Set ↑s
hu : MeasurableSet u
A : MeasurableSet (Subtype.val '' u)
B : MeasurableSet (f '' (Subtype.val '' u))
⊢ MeasurableSet (restrict s f '' u)

Next tactic:
rwa [← image_comp] at B
/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
theorem borel_eq_borel_of_le {t t' : TopologicalSpace γ}
    (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') :
    @borel _ t = @borel _ t' := by
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝¹ : T2Space β
inst✝ : MeasurableSpace β
s : Set γ
f : γ → β
t t' : TopologicalSpace γ
ht : PolishSpace γ
ht' : PolishSpace γ
hle : t ≤ t'
⊢ borel γ = borel γ

Next tactic:
refine' le_antisymm _ (borel_anti hle)
/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
theorem borel_eq_borel_of_le {t t' : TopologicalSpace γ}
    (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') :
    @borel _ t = @borel _ t' := by
  refine' le_antisymm _ (borel_anti hle)
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝¹ : T2Space β
inst✝ : MeasurableSpace β
s : Set γ
f : γ → β
t t' : TopologicalSpace γ
ht : PolishSpace γ
ht' : PolishSpace γ
hle : t ≤ t'
⊢ borel γ ≤ borel γ

Next tactic:
intro s hs
/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
theorem borel_eq_borel_of_le {t t' : TopologicalSpace γ}
    (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') :
    @borel _ t = @borel _ t' := by
  refine' le_antisymm _ (borel_anti hle)
  intro s hs
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝¹ : T2Space β
inst✝ : MeasurableSpace β
s✝ : Set γ
f : γ → β
t t' : TopologicalSpace γ
ht : PolishSpace γ
ht' : PolishSpace γ
hle : t ≤ t'
s : Set γ
hs : MeasurableSet s
⊢ MeasurableSet s

Next tactic:
have e := @Continuous.measurableEmbedding
    _ _ t' _ (@borel _ t') _ (@BorelSpace.mk _ _ (borel γ) rfl)
    t _ (@borel _ t) (@BorelSpace.mk _ t (@borel _ t) rfl) (continuous_id_of_le hle) injective_id
/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
theorem borel_eq_borel_of_le {t t' : TopologicalSpace γ}
    (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') :
    @borel _ t = @borel _ t' := by
  refine' le_antisymm _ (borel_anti hle)
  intro s hs
  have e := @Continuous.measurableEmbedding
    _ _ t' _ (@borel _ t') _ (@BorelSpace.mk _ _ (borel γ) rfl)
    t _ (@borel _ t) (@BorelSpace.mk _ t (@borel _ t) rfl) (continuous_id_of_le hle) injective_id
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝¹ : T2Space β
inst✝ : MeasurableSpace β
s✝ : Set γ
f : γ → β
t t' : TopologicalSpace γ
ht : PolishSpace γ
ht' : PolishSpace γ
hle : t ≤ t'
s : Set γ
hs : MeasurableSet s
e : MeasurableEmbedding id
⊢ MeasurableSet s

Next tactic:
convert e.measurableSet_image.2 hs
/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
theorem borel_eq_borel_of_le {t t' : TopologicalSpace γ}
    (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') :
    @borel _ t = @borel _ t' := by
  refine' le_antisymm _ (borel_anti hle)
  intro s hs
  have e := @Continuous.measurableEmbedding
    _ _ t' _ (@borel _ t') _ (@BorelSpace.mk _ _ (borel γ) rfl)
    t _ (@borel _ t) (@BorelSpace.mk _ t (@borel _ t) rfl) (continuous_id_of_le hle) injective_id
  convert e.measurableSet_image.2 hs
  

Proof state:
case h.e'_3
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝¹ : T2Space β
inst✝ : MeasurableSpace β
s✝ : Set γ
f : γ → β
t t' : TopologicalSpace γ
ht : PolishSpace γ
ht' : PolishSpace γ
hle : t ≤ t'
s : Set γ
hs : MeasurableSet s
e : MeasurableEmbedding id
⊢ s = id '' s

Next tactic:
simp only [id_eq, image_id']
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁴ : T2Space β
inst✝³ : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
⊢ IsClopenable s ↔ MeasurableSet s

Next tactic:
refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝⁴ : T2Space β
inst✝³ : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝² : PolishSpace γ
inst✝¹ : MeasurableSpace γ
inst✝ : BorelSpace γ
hs : IsClopenable s
⊢ MeasurableSet s

Next tactic:
borelize γ
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
  borelize γ
  -- consider a finer topology `t'` in which `s` is open and closed.
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝³ : T2Space β
inst✝² : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝¹ : PolishSpace γ
hs : IsClopenable s
inst✝ : BorelSpace γ
this✝ : MeasurableSpace γ := borel γ
⊢ MeasurableSet s

Next tactic:
obtain ⟨t', t't, t'_polish, _, s_open⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
  borelize γ
  -- consider a finer topology `t'` in which `s` is open and closed.
  obtain ⟨t', t't, t'_polish, _, s_open⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝³ : T2Space β
inst✝² : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝¹ : PolishSpace γ
inst✝ : BorelSpace γ
this✝ : MeasurableSpace γ := borel γ
t' : TopologicalSpace γ
t't : t' ≤ tγ
t'_polish : PolishSpace γ
left✝ : IsClosed s
s_open : IsOpen s
⊢ MeasurableSet s

Next tactic:
rw [← borel_eq_borel_of_le t'_polish _ t't]
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
  borelize γ
  -- consider a finer topology `t'` in which `s` is open and closed.
  obtain ⟨t', t't, t'_polish, _, s_open⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs
  rw [← borel_eq_borel_of_le t'_polish _ t't]
  · 

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝³ : T2Space β
inst✝² : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝¹ : PolishSpace γ
inst✝ : BorelSpace γ
this✝ : MeasurableSpace γ := borel γ
t' : TopologicalSpace γ
t't : t' ≤ tγ
t'_polish : PolishSpace γ
left✝ : IsClosed s
s_open : IsOpen s
⊢ MeasurableSet s

Next tactic:
exact MeasurableSpace.measurableSet_generateFrom s_open
/-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
theorem isClopenable_iff_measurableSet
    [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] :
    IsClopenable s ↔ MeasurableSet s := by
  -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable.
  refine' ⟨fun hs => _, fun hs => hs.isClopenable⟩
  borelize γ
  -- consider a finer topology `t'` in which `s` is open and closed.
  obtain ⟨t', t't, t'_polish, _, s_open⟩ :
    ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs
  rw [← borel_eq_borel_of_le t'_polish _ t't]
  · exact MeasurableSpace.measurableSet_generateFrom s_open
  

Proof state:
α : Type u_1
ι : Type u_2
γ : Type u_3
β : Type u_4
tβ : TopologicalSpace β
inst✝³ : T2Space β
inst✝² : MeasurableSpace β
s : Set γ
f : γ → β
tγ : TopologicalSpace γ
inst✝¹ : PolishSpace γ
inst✝ : BorelSpace γ
this✝ : MeasurableSpace γ := borel γ
t' : TopologicalSpace γ
t't : t' ≤ tγ
t'_polish : PolishSpace γ
left✝ : IsClosed s
s_open : IsOpen s
⊢ PolishSpace γ

Next tactic:
infer_instance
/-- 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
  

Proof state:
α : 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)
⊢ MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)}

Next tactic:
rcases l.eq_or_neBot with rfl | hl