measure_theory.constructions.polishMathlib.MeasureTheory.Constructions.Polish

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

feat(measure_theory/constructions/polish): quotient group is a Borel space (#19186)
  • Suslin's theorem: an analytic set with analytic complement is measurable.
  • Image of a measurable set in a Polish space under a measurable map is an analytic set.
  • Preimage of a set under a measurable surjective map from a Polish space is measurable iff the original set is measurable.
  • Quotient space of a Polish space with quotient σ-algebra is a Borel space provided that it has second countable topology.
  • In particular, quotient group of a Polish topological group is a Borel space.
  • Change instance for measurable_space on add_circle.
Diff
@@ -253,24 +253,42 @@ end
 a finer Polish topology on the source space for which the function is continuous. -/
 lemma _root_.measurable.exists_continuous {α β : Type*}
   [t : topological_space α] [polish_space α] [measurable_space α] [borel_space α]
-  [tβ : topological_space β] [second_countable_topology β] [measurable_space β] [borel_space β]
-  {f : α → β} (hf : measurable f) :
+  [tβ : topological_space β] [measurable_space β] [opens_measurable_space β]
+  {f : α → β} [second_countable_topology (range f)] (hf : measurable f) :
   ∃ (t' : topological_space α), t' ≤ t ∧ @continuous α β t' tβ f ∧ @polish_space α t' :=
 begin
-  obtain ⟨b, b_count, -, hb⟩ : ∃b : set (set β), b.countable ∧ ∅ ∉ b ∧ is_topological_basis b :=
-    exists_countable_basis β,
-  haveI : encodable b := b_count.to_encodable,
-  have : ∀ (s : b), is_clopenable (f ⁻¹' s),
+  obtain ⟨b, b_count, -, hb⟩ :
+    ∃ b : set (set (range f)), b.countable ∧ ∅ ∉ b ∧ is_topological_basis b :=
+    exists_countable_basis (range f),
+  haveI : countable b := b_count.to_subtype,
+  have : ∀ (s : b), is_clopenable (range_factorization f ⁻¹' s),
   { assume s,
     apply measurable_set.is_clopenable,
-    exact hf (hb.is_open s.2).measurable_set },
+    exact hf.subtype_mk (hb.is_open s.2).measurable_set },
   choose T Tt Tpolish Tclosed Topen using this,
   obtain ⟨t', t'T, t't, t'_polish⟩ :
     ∃ (t' : topological_space α), (∀ i, t' ≤ T i) ∧ (t' ≤ t) ∧ @polish_space α t' :=
       exists_polish_space_forall_le T Tt Tpolish,
+  letI := t', -- not needed in Lean 4
   refine ⟨t', t't, _, t'_polish⟩,
-  apply hb.continuous _ (λ s hs, _),
-  exact t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩),
+  have : @continuous _ _ t' _ (range_factorization f) :=
+    hb.continuous _ (λ s hs, t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)),
+  exact continuous_subtype_coe.comp this
+end
+
+/-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
+theorem _root_.measurable_set.analytic_set_image {X Y : Type*}
+  [topological_space X] [polish_space X] [measurable_space X] [borel_space X]
+  [topological_space Y] [measurable_space Y] [opens_measurable_space Y]
+  {f : X → Y} [second_countable_topology (range f)] {s : set X} (hs : measurable_set s)
+  (hf : measurable f) : analytic_set (f '' s) :=
+begin
+  borelize X,
+  rcases hf.exists_continuous with ⟨τ', hle, hfc, hτ'⟩,
+  letI m' : measurable_space X := @borel _ τ',
+  haveI b' : borel_space X := ⟨rfl⟩,
+  have hle := borel_anti hle,
+  exact (hle _ hs).analytic_set.image_of_continuous hfc
 end
 
 /-! ### Separating sets with measurable sets -/
@@ -302,8 +320,9 @@ end
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
 -/
-lemma measurably_separable_range_of_disjoint [t2_space α] [measurable_space α] [borel_space α]
-  {f g : (ℕ → ℕ) → α} (hf : continuous f) (hg : continuous g) (h : disjoint (range f) (range g)) :
+lemma measurably_separable_range_of_disjoint [t2_space α] [measurable_space α]
+  [opens_measurable_space α] {f g : (ℕ → ℕ) → α} (hf : continuous f) (hg : continuous g)
+  (h : disjoint (range f) (range g)) :
   measurably_separable (range f) (range g) :=
 begin
   /- We follow [Kechris, *Classical Descriptive Set Theory* (Theorem 14.7)][kechris1995].
@@ -416,8 +435,9 @@ end
 
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
-theorem analytic_set.measurably_separable [t2_space α] [measurable_space α] [borel_space α]
-  {s t : set α} (hs : analytic_set s) (ht : analytic_set t) (h : disjoint s t) :
+theorem analytic_set.measurably_separable [t2_space α] [measurable_space α]
+  [opens_measurable_space α] {s t : set α} (hs : analytic_set s) (ht : analytic_set t)
+  (h : disjoint s t) :
   measurably_separable s t :=
 begin
   rw analytic_set at hs ht,
@@ -428,6 +448,135 @@ begin
   exact measurably_separable_range_of_disjoint f_cont g_cont h,
 end
 
+/-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic
+complement is measurable. -/
+theorem analytic_set.measurable_set_of_compl [t2_space α] [measurable_space α]
+  [opens_measurable_space α] {s : set α} (hs : analytic_set s) (hsc : analytic_set (sᶜ)) :
+  measurable_set s :=
+begin
+  rcases hs.measurably_separable hsc disjoint_compl_right with ⟨u, hsu, hdu, hmu⟩,
+  obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu),
+  exact hmu
+end
+
+end measure_theory
+
+/-!
+### Measurability of preimages under measurable maps
+-/
+
+namespace measurable
+
+variables {X Y β : Type*}
+  [topological_space X] [polish_space X] [measurable_space X] [borel_space X]
+  [topological_space Y] [t2_space Y] [measurable_space Y] [opens_measurable_space Y]
+  [measurable_space β]
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then the preimage of a set `s` is measurable if and only if the set
+is measurable.
+One implication is the definition of measurability, the other one heavily relies on `X` being a
+Polish space. -/
+theorem measurable_set_preimage_iff_of_surjective [second_countable_topology Y] {f : X → Y}
+  (hf : measurable f) (hsurj : surjective f) {s : set Y} :
+  measurable_set (f ⁻¹' s) ↔ measurable_set s :=
+begin
+  refine ⟨λ h, _, λ h, hf h⟩,
+  apply measure_theory.analytic_set.measurable_set_of_compl,
+  { rw [← image_preimage_eq s hsurj],
+    exact h.analytic_set_image hf },
+  { rw [← image_preimage_eq (sᶜ) hsurj],
+    exact h.compl.analytic_set_image hf }
+end
+
+theorem map_measurable_space_eq [second_countable_topology Y] {f : X → Y} (hf : measurable f)
+  (hsurj : surjective f) : measurable_space.map f ‹measurable_space X› = ‹measurable_space Y› :=
+measurable_space.ext $ λ _, hf.measurable_set_preimage_iff_of_surjective hsurj
+
+theorem map_measurable_space_eq_borel [second_countable_topology Y] {f : X → Y} (hf : measurable f)
+  (hsurj : surjective f) : measurable_space.map f ‹measurable_space X› = borel Y :=
+begin
+  have := hf.mono le_rfl opens_measurable_space.borel_le, 
+  letI := borel Y, haveI : borel_space Y := ⟨rfl⟩,
+  exact this.map_measurable_space_eq hsurj
+end
+
+theorem borel_space_codomain [second_countable_topology Y] {f : X → Y} (hf : measurable f)
+  (hsurj : surjective f) : borel_space Y :=
+⟨(hf.map_measurable_space_eq hsurj).symm.trans $ hf.map_measurable_space_eq_borel hsurj⟩
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then the preimage of a set `s` is measurable if and only if the set is
+measurable in `set.range f`. -/
+theorem measurable_set_preimage_iff_preimage_coe {f : X → Y} [second_countable_topology (range f)]
+  (hf : measurable f) {s : set Y} :
+  measurable_set (f ⁻¹' s) ↔ measurable_set (coe ⁻¹' s : set (range f)) :=
+have hf' : measurable (range_factorization f) := hf.subtype_mk,
+by rw [← hf'.measurable_set_preimage_iff_of_surjective surjective_onto_range]; refl
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology and the range of `f` is measurable, then the preimage of a set `s` is measurable
+if and only if the intesection with `set.range f` is measurable. -/
+theorem measurable_set_preimage_iff_inter_range {f : X → Y} [second_countable_topology (range f)]
+  (hf : measurable f) (hr : measurable_set (range f)) {s : set Y} :
+  measurable_set (f ⁻¹' s) ↔ measurable_set (s ∩ range f) :=
+begin
+  rw [hf.measurable_set_preimage_iff_preimage_coe,
+    ← (measurable_embedding.subtype_coe hr).measurable_set_image, subtype.image_preimage_coe]
+end
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
+measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
+theorem measurable_comp_iff_restrict {f : X → Y} [second_countable_topology (range f)]
+  (hf : measurable f) {g : Y → β} :
+  measurable (g ∘ f) ↔ measurable (restrict (range f) g) :=
+forall₂_congr $ λ s _,
+  @measurable.measurable_set_preimage_iff_preimage_coe _ _ _ _ _ _ _ _ _ _ _ _ hf (g ⁻¹' s)
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then for any measurable space `α` and `g : Y → α`, the composition
+`g ∘ f` is measurable if and only if `g` is measurable. -/
+theorem measurable_comp_iff_of_surjective [second_countable_topology Y] {f : X → Y}
+  (hf : measurable f) (hsurj : surjective f) {g : Y → β} :
+  measurable (g ∘ f) ↔ measurable g :=
+forall₂_congr $ λ s _,
+  @measurable.measurable_set_preimage_iff_of_surjective _ _ _ _ _ _ _ _ _ _ _ _ hf hsurj (g ⁻¹' s)
+
+end measurable
+
+theorem continuous.map_eq_borel {X Y : Type*}
+  [topological_space X] [polish_space X] [measurable_space X] [borel_space X]
+  [topological_space Y] [t2_space Y] [second_countable_topology Y]
+  {f : X → Y} (hf : continuous f) (hsurj : surjective f) :
+  measurable_space.map f ‹measurable_space X› = borel Y :=
+begin
+  borelize Y,
+  exact hf.measurable.map_measurable_space_eq hsurj
+end
+
+theorem continuous.map_borel_eq {X Y : Type*} [topological_space X] [polish_space X]
+  [topological_space Y] [t2_space Y] [second_countable_topology Y]
+  {f : X → Y} (hf : continuous f) (hsurj : surjective f) :
+  measurable_space.map f (borel X) = borel Y :=
+begin
+  borelize X,
+  exact hf.map_eq_borel hsurj
+end
+
+instance quotient.borel_space {X : Type*} [topological_space X] [polish_space X]
+  [measurable_space X] [borel_space X] {s : setoid X} [t2_space (quotient s)]
+  [second_countable_topology (quotient s)] : borel_space (quotient s) :=
+⟨continuous_quotient_mk.map_eq_borel (surjective_quotient_mk _)⟩
+
+@[to_additive]
+instance quotient_group.borel_space {G : Type*} [topological_space G] [polish_space G]
+  [group G] [topological_group G] [measurable_space G] [borel_space G]
+  {N : subgroup G} [N.normal] [is_closed (N : set G)] : borel_space (G ⧸ N) :=
+by haveI := polish_space.second_countable G; exact quotient.borel_space
+
+namespace measure_theory
+
 /-! ### Injective images of Borel sets -/
 
 variables {γ : Type*} [tγ : topological_space γ] [polish_space γ]

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 -/
 import Data.Real.Cardinality
-import Topology.Perfect
+import Topology.MetricSpace.Perfect
 import MeasureTheory.Constructions.BorelSpace.Basic
 
 #align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
Diff
@@ -1003,7 +1003,7 @@ just be added as an instance soon after the definition of `polish_space`.-/
 private theorem second_countable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
   h.second_countable
 
-attribute [-instance] polishSpace_of_complete_second_countable
+attribute [-instance] PolishSpace.of_separableSpace_completeSpace_metrizable
 
 attribute [local instance] second_countable_of_polish
 
Diff
@@ -128,7 +128,7 @@ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
   by
   constructor
   · intro h
-    rw [analytic_set] at h 
+    rw [analytic_set] at h
     cases h
     · refine' ⟨Empty, by infer_instance, by infer_instance, Empty.elim, continuous_bot, _⟩
       rw [h]
@@ -472,14 +472,14 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
     · rw [image_subset_iff]
       apply subset.trans _ hεx
       intro z hz
-      rw [mem_cylinder_iff_dist_le] at hz 
+      rw [mem_cylinder_iff_dist_le] at hz
       exact hz.trans_lt (hn.trans_le (min_le_left _ _))
     · refine' Disjoint.mono_left _ huv.symm
       change g '' cylinder y n ⊆ v
       rw [image_subset_iff]
       apply subset.trans _ hεy
       intro z hz
-      rw [mem_cylinder_iff_dist_le] at hz 
+      rw [mem_cylinder_iff_dist_le] at hz
       exact hz.trans_lt (hn.trans_le (min_le_right _ _))
   -- this is a contradiction.
   exact M n B
@@ -492,7 +492,7 @@ disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
     {s t : Set α} (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) :
     MeasurablySeparable s t := by
-  rw [analytic_set] at hs ht 
+  rw [analytic_set] at hs ht
   rcases hs with (rfl | ⟨f, f_cont, rfl⟩)
   · refine' ⟨∅, subset.refl _, by simp, MeasurableSet.empty⟩
   rcases ht with (rfl | ⟨g, g_cont, rfl⟩)
@@ -762,7 +762,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       rw [nonempty_iff_ne_empty]
       intro hn
       have := (s n).2
-      rw [hn] at this 
+      rw [hn] at this
       exact b_nonempty this
     -- choose a point `y n ∈ s n`.
     choose y hy using C2
@@ -834,8 +834,8 @@ theorem IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [Topolo
   rw [image_eq_range]
   haveI : PolishSpace s := IsClosed.polishSpace hs
   apply measurable_set_range_of_continuous_injective
-  · rwa [continuousOn_iff_continuous_restrict] at f_cont 
-  · rwa [inj_on_iff_injective] at f_inj 
+  · rwa [continuousOn_iff_continuous_restrict] at f_cont
+  · rwa [inj_on_iff_injective] at f_inj
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
 -/
 
@@ -904,7 +904,7 @@ theorem ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : Contin
       have B : MeasurableSet (f '' ((coe : s → γ) '' u)) :=
         A.image_of_continuous_on_inj_on (f_cont.mono (Subtype.coe_image_subset s u))
           (f_inj.mono (Subtype.coe_image_subset s u))
-      rwa [← image_comp] at B  }
+      rwa [← image_comp] at B }
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
 -/
 
@@ -953,7 +953,7 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
     MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)} :=
   by
   by_cases hl : l.ne_bot
-  swap; · rw [not_ne_bot] at hl ; simp [hl]
+  swap; · rw [not_ne_bot] at hl; simp [hl]
   letI := upgradePolishSpace γ
   rcases l.exists_antitone_basis with ⟨u, hu⟩
   simp_rw [← cauchy_map_iff_exists_tendsto]
@@ -1050,7 +1050,7 @@ noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
     letI := Countable.of_equiv α e
     use e <;> apply measurable_of_countable
   refine' measurable_equiv_of_not_countable h _
-  rwa [e.countable_iff] at h 
+  rwa [e.countable_iff] at h
 #align polish_space.equiv.measurable_equiv PolishSpace.Equiv.measurableEquiv
 -/
 
Diff
@@ -770,7 +770,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       by
       intro m n
       rw [← not_disjoint_iff_nonempty_inter]
-      by_contra' h
+      by_contra! h
       have A : x ∈ q ⟨(s m, s n), h⟩ \ q ⟨(s n, s m), h.symm⟩ :=
         haveI := mem_Inter.1 (hxs m).2 (s n)
         (mem_Inter.1 this h : _)
@@ -797,7 +797,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
     have y_lim : tendsto y at_top (𝓝 z) := cauchy_y.tendsto_lim
     suffices f z = x by rw [← this]; exact mem_range_self _
     -- assume for a contradiction that `f z ≠ x`.
-    by_contra' hne
+    by_contra! hne
     -- introduce disjoint open sets `v` and `w` separating `f z` from `x`.
     obtain ⟨v, w, v_open, w_open, fzv, xw, hvw⟩ := t2_separation hne
     obtain ⟨δ, δpos, hδ⟩ : ∃ δ > (0 : ℝ), ball z δ ⊆ f ⁻¹' v :=
Diff
@@ -3,9 +3,9 @@ Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 -/
-import Mathbin.Data.Real.Cardinality
-import Mathbin.Topology.Perfect
-import Mathbin.MeasureTheory.Constructions.BorelSpace.Basic
+import Data.Real.Cardinality
+import Topology.Perfect
+import MeasureTheory.Constructions.BorelSpace.Basic
 
 #align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
 
Diff
@@ -744,7 +744,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       convert diam_ball (half_pos (u_pos n)).le
       ring
     refine' mem_Union.2 ⟨⟨s, sb⟩, _⟩
-    refine' mem_Union.2 ⟨⟨Metric.Bounded.mono hs bounded_ball, diam_s⟩, _⟩
+    refine' mem_Union.2 ⟨⟨Bornology.IsBounded.subset hs bounded_ball, diam_s⟩, _⟩
     apply mem_inter (subset_closure (mem_image_of_mem _ ys))
     refine' mem_Inter.2 fun t => mem_Inter.2 fun ht => ⟨_, _⟩
     · apply hq1
Diff
@@ -642,7 +642,7 @@ theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace
 instance Quotient.borelSpace {X : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
     [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
     BorelSpace (Quotient s) :=
-  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
+  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk' _)⟩
 #align quotient.borel_space Quotient.borelSpace
 -/
 
Diff
@@ -982,9 +982,9 @@ end MeasureTheory
 /-! ### The Borel Isomorphism Theorem -/
 
 
-#print polish_of_countable /-
+#print PolishSpace.polish_of_countable /-
 --Note: Move to topology/metric_space/polish when porting.
-instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
+instance (priority := 50) PolishSpace.polish_of_countable [h : Countable α] [DiscreteTopology α] :
     PolishSpace α := by
   obtain ⟨f, hf⟩ := h.exists_injective_nat
   have : ClosedEmbedding f :=
@@ -992,7 +992,7 @@ instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopolo
     apply closedEmbedding_of_continuous_injective_closed continuous_of_discreteTopology hf
     exact fun t _ => isClosed_discrete _
   exact this.polish_space
-#align polish_of_countable polish_of_countable
+#align polish_of_countable PolishSpace.polish_of_countable
 -/
 
 namespace PolishSpace
Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
-
-! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 9f55d0d4363ae59948c33864cbc52e0b12e0e8ce
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Real.Cardinality
 import Mathbin.Topology.Perfect
 import Mathbin.MeasureTheory.Constructions.BorelSpace.Basic
 
+#align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
+
 /-!
 # The Borel sigma-algebra on Polish spaces
 
Diff
@@ -308,6 +308,7 @@ theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α]
 #align measurable.exists_continuous Measurable.exists_continuous
 -/
 
+#print MeasurableSet.analyticSet_image /-
 /-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
 theorem MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
     [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
@@ -321,6 +322,7 @@ theorem MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace X] [Pol
   have hle := borel_anti hle
   exact (hle _ hs).AnalyticSet.image_of_continuous hfc
 #align measurable_set.analytic_set_image MeasurableSet.analyticSet_image
+-/
 
 /-! ### Separating sets with measurable sets -/
 
@@ -502,6 +504,7 @@ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [Opens
 #align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparable
 -/
 
+#print MeasureTheory.AnalyticSet.measurableSet_of_compl /-
 /-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic
 complement is measurable. -/
 theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
@@ -511,6 +514,7 @@ theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [Op
   obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu)
   exact hmu
 #align measure_theory.analytic_set.measurable_set_of_compl MeasureTheory.AnalyticSet.measurableSet_of_compl
+-/
 
 end MeasureTheory
 
@@ -524,6 +528,7 @@ namespace Measurable
 variable {X Y β : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
   [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
 
+#print Measurable.measurableSet_preimage_iff_of_surjective /-
 /-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
 with second countable topology, then the preimage of a set `s` is measurable if and only if the set
 is measurable.
@@ -540,12 +545,16 @@ theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f
   · rw [← image_preimage_eq (sᶜ) hsurj]
     exact h.compl.analytic_set_image hf
 #align measurable.measurable_set_preimage_iff_of_surjective Measurable.measurableSet_preimage_iff_of_surjective
+-/
 
+#print Measurable.map_measurableSpace_eq /-
 theorem map_measurableSpace_eq [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
     (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Y› :=
   MeasurableSpace.ext fun _ => hf.measurableSet_preimage_iff_of_surjective hsurj
 #align measurable.map_measurable_space_eq Measurable.map_measurableSpace_eq
+-/
 
+#print Measurable.map_measurableSpace_eq_borel /-
 theorem map_measurableSpace_eq_borel [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
     (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = borel Y :=
   by
@@ -553,23 +562,29 @@ theorem map_measurableSpace_eq_borel [SecondCountableTopology Y] {f : X → Y} (
   letI := borel Y; haveI : BorelSpace Y := ⟨rfl⟩
   exact this.map_measurable_space_eq hsurj
 #align measurable.map_measurable_space_eq_borel Measurable.map_measurableSpace_eq_borel
+-/
 
+#print Measurable.borelSpace_codomain /-
 theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
     (hsurj : Surjective f) : BorelSpace Y :=
   ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩
 #align measurable.borel_space_codomain Measurable.borelSpace_codomain
+-/
 
+#print Measurable.measurableSet_preimage_iff_preimage_val /-
 /-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
 countable topology, then the preimage of a set `s` is measurable if and only if the set is
 measurable in `set.range f`. -/
-theorem measurableSet_preimage_iff_preimage_coe {f : X → Y} [SecondCountableTopology (range f)]
+theorem measurableSet_preimage_iff_preimage_val {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) {s : Set Y} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (coe ⁻¹' s : Set (range f)) :=
   by
   have hf' : Measurable (rangeFactorization f) := hf.subtype_mk
   rw [← hf'.measurable_set_preimage_iff_of_surjective surjective_onto_range] <;> rfl
-#align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_coe
+#align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_val
+-/
 
+#print Measurable.measurableSet_preimage_iff_inter_range /-
 /-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
 countable topology and the range of `f` is measurable, then the preimage of a set `s` is measurable
 if and only if the intesection with `set.range f` is measurable. -/
@@ -579,16 +594,20 @@ theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTop
   rw [hf.measurable_set_preimage_iff_preimage_coe, ←
     (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
 #align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
+-/
 
+#print Measurable.measurable_comp_iff_restrict /-
 /-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
 countable topology, then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
 measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
 theorem measurable_comp_iff_restrict {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
   forall₂_congr fun s _ =>
-    @Measurable.measurableSet_preimage_iff_preimage_coe _ _ _ _ _ _ _ _ _ _ _ _ hf (g ⁻¹' s)
+    @Measurable.measurableSet_preimage_iff_preimage_val _ _ _ _ _ _ _ _ _ _ _ _ hf (g ⁻¹' s)
 #align measurable.measurable_comp_iff_restrict Measurable.measurable_comp_iff_restrict
+-/
 
+#print Measurable.measurable_comp_iff_of_surjective /-
 /-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
 with second countable topology, then for any measurable space `α` and `g : Y → α`, the composition
 `g ∘ f` is measurable if and only if `g` is measurable. -/
@@ -597,9 +616,11 @@ theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X →
   forall₂_congr fun s _ =>
     @Measurable.measurableSet_preimage_iff_of_surjective _ _ _ _ _ _ _ _ _ _ _ _ hf hsurj (g ⁻¹' s)
 #align measurable.measurable_comp_iff_of_surjective Measurable.measurable_comp_iff_of_surjective
+-/
 
 end Measurable
 
+#print Continuous.map_eq_borel /-
 theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
     [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y]
     {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) :
@@ -608,7 +629,9 @@ theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace
   borelize Y
   exact hf.measurable.map_measurable_space_eq hsurj
 #align continuous.map_eq_borel Continuous.map_eq_borel
+-/
 
+#print Continuous.map_borel_eq /-
 theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
     [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
     (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y :=
@@ -616,13 +639,17 @@ theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace
   borelize X
   exact hf.map_eq_borel hsurj
 #align continuous.map_borel_eq Continuous.map_borel_eq
+-/
 
+#print Quotient.borelSpace /-
 instance Quotient.borelSpace {X : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
     [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
     BorelSpace (Quotient s) :=
   ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
 #align quotient.borel_space Quotient.borelSpace
+-/
 
+#print QuotientGroup.borelSpace /-
 @[to_additive]
 instance QuotientGroup.borelSpace {G : Type _} [TopologicalSpace G] [PolishSpace G] [Group G]
     [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.normal]
@@ -630,7 +657,8 @@ instance QuotientGroup.borelSpace {G : Type _} [TopologicalSpace G] [PolishSpace
   haveI := PolishSpace.second_countable G
   Quotient.borelSpace
 #align quotient_group.borel_space QuotientGroup.borelSpace
-#align quotient_add_group.borel_space quotientAddGroup.borelSpace
+#align quotient_add_group.borel_space QuotientAddGroup.borelSpace
+-/
 
 namespace MeasureTheory
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 4280f5f32e16755ec7985ce11e189b6cd6ff6735
+! leanprover-community/mathlib commit 9f55d0d4363ae59948c33864cbc52e0b12e0e8ce
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -282,27 +282,46 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
 theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
-    [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [SecondCountableTopology β]
-    [MeasurableSpace β] [BorelSpace β] {f : α → β} (hf : Measurable f) :
+    [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [MeasurableSpace β]
+    [OpensMeasurableSpace β] {f : α → β} [SecondCountableTopology (range f)] (hf : Measurable f) :
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @Continuous α β t' tβ f ∧ @PolishSpace α t' :=
   by
-  obtain ⟨b, b_count, -, hb⟩ : ∃ b : Set (Set β), b.Countable ∧ ∅ ∉ b ∧ is_topological_basis b :=
-    exists_countable_basis β
-  haveI : Encodable b := b_count.to_encodable
-  have : ∀ s : b, is_clopenable (f ⁻¹' s) := by
+  obtain ⟨b, b_count, -, hb⟩ :
+    ∃ b : Set (Set (range f)), b.Countable ∧ ∅ ∉ b ∧ is_topological_basis b :=
+    exists_countable_basis (range f)
+  haveI : Countable b := b_count.to_subtype
+  have : ∀ s : b, is_clopenable (range_factorization f ⁻¹' s) :=
+    by
     intro s
     apply MeasurableSet.isClopenable
-    exact hf (hb.is_open s.2).MeasurableSet
+    exact hf.subtype_mk (hb.is_open s.2).MeasurableSet
   choose T Tt Tpolish Tclosed Topen using this
   obtain ⟨t', t'T, t't, t'_polish⟩ :
     ∃ t' : TopologicalSpace α, (∀ i, t' ≤ T i) ∧ t' ≤ t ∧ @PolishSpace α t' :=
     exists_polish_space_forall_le T Tt Tpolish
+  letI := t'
+  -- not needed in Lean 4
   refine' ⟨t', t't, _, t'_polish⟩
-  apply hb.continuous _ fun s hs => _
-  exact t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
+  have : @Continuous _ _ t' _ (range_factorization f) :=
+    hb.continuous _ fun s hs => t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
+  exact continuous_subtype_coe.comp this
 #align measurable.exists_continuous Measurable.exists_continuous
 -/
 
+/-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
+theorem MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
+    [OpensMeasurableSpace Y] {f : X → Y} [SecondCountableTopology (range f)] {s : Set X}
+    (hs : MeasurableSet s) (hf : Measurable f) : AnalyticSet (f '' s) :=
+  by
+  borelize X
+  rcases hf.exists_continuous with ⟨τ', hle, hfc, hτ'⟩
+  letI m' : MeasurableSpace X := @borel _ τ'
+  haveI b' : BorelSpace X := ⟨rfl⟩
+  have hle := borel_anti hle
+  exact (hle _ hs).AnalyticSet.image_of_continuous hfc
+#align measurable_set.analytic_set_image MeasurableSet.analyticSet_image
+
 /-! ### Separating sets with measurable sets -/
 
 
@@ -337,9 +356,9 @@ theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
 -/
-theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α] [BorelSpace α]
-    {f g : (ℕ → ℕ) → α} (hf : Continuous f) (hg : Continuous g) (h : Disjoint (range f) (range g)) :
-    MeasurablySeparable (range f) (range g) :=
+theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
+    [OpensMeasurableSpace α] {f g : (ℕ → ℕ) → α} (hf : Continuous f) (hg : Continuous g)
+    (h : Disjoint (range f) (range g)) : MeasurablySeparable (range f) (range g) :=
   by
   /- We follow [Kechris, *Classical Descriptive Set Theory* (Theorem 14.7)][kechris1995].
     If the ranges are not Borel-separated, then one can find two cylinders of length one whose images
@@ -471,9 +490,9 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
 #print MeasureTheory.AnalyticSet.measurablySeparable /-
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
-theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
-    (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) : MeasurablySeparable s t :=
-  by
+theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
+    {s t : Set α} (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) :
+    MeasurablySeparable s t := by
   rw [analytic_set] at hs ht 
   rcases hs with (rfl | ⟨f, f_cont, rfl⟩)
   · refine' ⟨∅, subset.refl _, by simp, MeasurableSet.empty⟩
@@ -483,6 +502,138 @@ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [Borel
 #align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparable
 -/
 
+/-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic
+complement is measurable. -/
+theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
+    {s : Set α} (hs : AnalyticSet s) (hsc : AnalyticSet (sᶜ)) : MeasurableSet s :=
+  by
+  rcases hs.measurably_separable hsc disjoint_compl_right with ⟨u, hsu, hdu, hmu⟩
+  obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu)
+  exact hmu
+#align measure_theory.analytic_set.measurable_set_of_compl MeasureTheory.AnalyticSet.measurableSet_of_compl
+
+end MeasureTheory
+
+/-!
+### Measurability of preimages under measurable maps
+-/
+
+
+namespace Measurable
+
+variable {X Y β : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
+  [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then the preimage of a set `s` is measurable if and only if the set
+is measurable.
+One implication is the definition of measurability, the other one heavily relies on `X` being a
+Polish space. -/
+theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
+    (hf : Measurable f) (hsurj : Surjective f) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet s :=
+  by
+  refine' ⟨fun h => _, fun h => hf h⟩
+  apply MeasureTheory.AnalyticSet.measurableSet_of_compl
+  · rw [← image_preimage_eq s hsurj]
+    exact h.analytic_set_image hf
+  · rw [← image_preimage_eq (sᶜ) hsurj]
+    exact h.compl.analytic_set_image hf
+#align measurable.measurable_set_preimage_iff_of_surjective Measurable.measurableSet_preimage_iff_of_surjective
+
+theorem map_measurableSpace_eq [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Y› :=
+  MeasurableSpace.ext fun _ => hf.measurableSet_preimage_iff_of_surjective hsurj
+#align measurable.map_measurable_space_eq Measurable.map_measurableSpace_eq
+
+theorem map_measurableSpace_eq_borel [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = borel Y :=
+  by
+  have := hf.mono le_rfl OpensMeasurableSpace.borel_le
+  letI := borel Y; haveI : BorelSpace Y := ⟨rfl⟩
+  exact this.map_measurable_space_eq hsurj
+#align measurable.map_measurable_space_eq_borel Measurable.map_measurableSpace_eq_borel
+
+theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : BorelSpace Y :=
+  ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩
+#align measurable.borel_space_codomain Measurable.borelSpace_codomain
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then the preimage of a set `s` is measurable if and only if the set is
+measurable in `set.range f`. -/
+theorem measurableSet_preimage_iff_preimage_coe {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (coe ⁻¹' s : Set (range f)) :=
+  by
+  have hf' : Measurable (rangeFactorization f) := hf.subtype_mk
+  rw [← hf'.measurable_set_preimage_iff_of_surjective surjective_onto_range] <;> rfl
+#align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_coe
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology and the range of `f` is measurable, then the preimage of a set `s` is measurable
+if and only if the intesection with `set.range f` is measurable. -/
+theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by
+  rw [hf.measurable_set_preimage_iff_preimage_coe, ←
+    (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
+#align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
+measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
+theorem measurable_comp_iff_restrict {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
+  forall₂_congr fun s _ =>
+    @Measurable.measurableSet_preimage_iff_preimage_coe _ _ _ _ _ _ _ _ _ _ _ _ hf (g ⁻¹' s)
+#align measurable.measurable_comp_iff_restrict Measurable.measurable_comp_iff_restrict
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then for any measurable space `α` and `g : Y → α`, the composition
+`g ∘ f` is measurable if and only if `g` is measurable. -/
+theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
+    (hf : Measurable f) (hsurj : Surjective f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable g :=
+  forall₂_congr fun s _ =>
+    @Measurable.measurableSet_preimage_iff_of_surjective _ _ _ _ _ _ _ _ _ _ _ _ hf hsurj (g ⁻¹' s)
+#align measurable.measurable_comp_iff_of_surjective Measurable.measurable_comp_iff_of_surjective
+
+end Measurable
+
+theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y]
+    {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) :
+    MeasurableSpace.map f ‹MeasurableSpace X› = borel Y :=
+  by
+  borelize Y
+  exact hf.measurable.map_measurable_space_eq hsurj
+#align continuous.map_eq_borel Continuous.map_eq_borel
+
+theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
+    (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y :=
+  by
+  borelize X
+  exact hf.map_eq_borel hsurj
+#align continuous.map_borel_eq Continuous.map_borel_eq
+
+instance Quotient.borelSpace {X : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
+    [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
+    BorelSpace (Quotient s) :=
+  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
+#align quotient.borel_space Quotient.borelSpace
+
+@[to_additive]
+instance QuotientGroup.borelSpace {G : Type _} [TopologicalSpace G] [PolishSpace G] [Group G]
+    [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.normal]
+    [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) :=
+  haveI := PolishSpace.second_countable G
+  Quotient.borelSpace
+#align quotient_group.borel_space QuotientGroup.borelSpace
+#align quotient_add_group.borel_space quotientAddGroup.borelSpace
+
+namespace MeasureTheory
+
 /-! ### Injective images of Borel sets -/
 
 
Diff
@@ -278,6 +278,7 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
 #align measurable_set.analytic_set MeasurableSet.analyticSet
 -/
 
+#print Measurable.exists_continuous /-
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
 theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
@@ -300,6 +301,7 @@ theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α]
   apply hb.continuous _ fun s hs => _
   exact t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
 #align measurable.exists_continuous Measurable.exists_continuous
+-/
 
 /-! ### Separating sets with measurable sets -/
 
@@ -313,6 +315,7 @@ def MeasurablySeparable {α : Type _} [MeasurableSpace α] (s t : Set α) : Prop
 #align measure_theory.measurably_separable MeasureTheory.MeasurablySeparable
 -/
 
+#print MeasureTheory.MeasurablySeparable.iUnion /-
 theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
     (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) :=
   by
@@ -327,7 +330,9 @@ theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace
   · refine' MeasurableSet.iUnion fun m => _
     exact MeasurableSet.iInter fun n => hu m n
 #align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnion
+-/
 
+#print MeasureTheory.measurablySeparable_range_of_disjoint /-
 /-- The hard part of the Lusin separation theorem saying that two disjoint analytic sets are
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
@@ -461,7 +466,9 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   -- this is a contradiction.
   exact M n B
 #align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjoint
+-/
 
+#print MeasureTheory.AnalyticSet.measurablySeparable /-
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
@@ -474,14 +481,13 @@ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [Borel
   · exact ⟨univ, subset_univ _, by simp, MeasurableSet.univ⟩
   exact measurably_separable_range_of_disjoint f_cont g_cont h
 #align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparable
+-/
 
 /-! ### Injective images of Borel sets -/
 
 
 variable {γ : Type _} [tγ : TopologicalSpace γ] [PolishSpace γ]
 
-include tγ
-
 #print MeasureTheory.measurableSet_range_of_continuous_injective /-
 /-- The Lusin-Souslin theorem: the range of a continuous injective function defined on a Polish
 space is Borel-measurable. -/
@@ -660,8 +666,7 @@ theorem IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [Topolo
 variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type _} [tβ : TopologicalSpace β] [T2Space β]
   [MeasurableSpace β] [BorelSpace β] {s : Set γ} {f : γ → β}
 
-include tβ hγb
-
+#print MeasurableSet.image_of_continuousOn_injOn /-
 /-- 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 MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -674,6 +679,7 @@ theorem MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s) (f_cont
     @IsClosed.measurableSet_image_of_continuousOn_injOn γ t' t'_polish β _ _ _ _ s s_closed f
       (f_cont.mono_dom t't) f_inj
 #align measurable_set.image_of_continuous_on_inj_on MeasurableSet.image_of_continuousOn_injOn
+-/
 
 #print MeasurableSet.image_of_measurable_injOn /-
 /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
@@ -697,6 +703,7 @@ theorem MeasurableSet.image_of_measurable_injOn [SecondCountableTopology β] (hs
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
 -/
 
+#print Continuous.measurableEmbedding /-
 /-- An injective continuous function on a Polish space is a measurable embedding. -/
 theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableEmbedding f :=
@@ -705,7 +712,9 @@ theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injectiv
     measurableSet_image' := fun u hu =>
       hu.image_of_continuousOn_injOn f_cont.ContinuousOn (f_inj.InjOn _) }
 #align continuous.measurable_embedding Continuous.measurableEmbedding
+-/
 
+#print ContinuousOn.measurableEmbedding /-
 /-- 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 ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -721,6 +730,7 @@ theorem ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : Contin
           (f_inj.mono (Subtype.coe_image_subset s u))
       rwa [← image_comp] at B  }
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
+-/
 
 #print Measurable.measurableEmbedding /-
 /-- An injective measurable function from a Polish space to a second-countable topological space
@@ -733,8 +743,6 @@ theorem Measurable.measurableEmbedding [SecondCountableTopology β] (f_meas : Me
 #align measurable.measurable_embedding Measurable.measurableEmbedding
 -/
 
-omit tβ
-
 #print MeasureTheory.isClopenable_iff_measurableSet /-
 /-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
 theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
@@ -760,9 +768,8 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
 #align measure_theory.is_clopenable_iff_measurable_set MeasureTheory.isClopenable_iff_measurableSet
 -/
 
-omit hγb
-
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print MeasureTheory.measurableSet_exists_tendsto /-
 /-- The set of points for which a measurable sequence of functions converges is measurable. -/
 @[measurability]
 theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
@@ -792,6 +799,7 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
       MeasurableSet.biInter (to_countable (u N)) fun j _ =>
         measurableSet_lt (Measurable.dist (hf i) (hf j)) measurable_const
 #align measure_theory.measurable_set_exists_tendsto MeasureTheory.measurableSet_exists_tendsto
+-/
 
 end MeasureTheory
 
@@ -880,6 +888,7 @@ instance [PolishSpace α] : PolishSpace (univ : Set α) :=
 
 variable (α) [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
 
+#print MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite /-
 theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
     ∃ n : ℕ, Nonempty (α ≃ᵐ range (coe : Fin n → ℝ)) :=
   by
@@ -887,7 +896,9 @@ theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
   refine' ⟨n, ⟨PolishSpace.Equiv.measurableEquiv (n_equiv.trans _)⟩⟩
   exact Equiv.ofInjective _ (nat.cast_injective.comp Fin.val_injective)
 #align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite
+-/
 
+#print MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable /-
 theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] :
     Nonempty (α ≃ᵐ range (coe : ℕ → ℝ)) :=
   by
@@ -897,6 +908,7 @@ theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Co
   refine' (nonempty_equiv_of_countable.some : α ≃ ℕ).trans _
   exact Equiv.ofInjective coe Nat.cast_injective
 #align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable
+-/
 
 #print MeasureTheory.exists_subset_real_measurableEquiv /-
 /-- Any Polish Borel space is measurably equivalent to a subset of the reals. -/
Diff
@@ -609,7 +609,6 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
           (add_le_add ((dist_le_diam_of_mem (hs m).1 (hy m) zsm).trans (hs m).2)
             ((dist_le_diam_of_mem (hs n).1 zsn (hy n)).trans (hs n).2))
         _ ≤ 2 * u m := by linarith [u_anti.antitone hmn]
-        
     haveI : Nonempty γ := ⟨y 0⟩
     -- let `z` be its limit.
     let z := limUnder at_top y
@@ -637,7 +636,6 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
         _ ≤ u n + dist (y n) z :=
           (add_le_add_right ((dist_le_diam_of_mem (hs n).1 ha (hy n)).trans (hs n).2) _)
         _ < δ := hn
-        
     -- as `x` belongs to the closure of `f '' (s n)`, it belongs to the closure of `v`.
     have : x ∈ closure v := closure_mono fsnv (hxs n).1
     -- this is a contradiction, as `x` is supposed to belong to `w`, which is disjoint from
Diff
@@ -181,7 +181,7 @@ theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s :
     analytic_set_iff_exists_polish_space_range.1 (hs n)
   skip
   let γ := ∀ n, β n
-  let t : Set γ := ⋂ n, { x | f n (x n) = f i₀ (x i₀) }
+  let t : Set γ := ⋂ n, {x | f n (x n) = f i₀ (x i₀)}
   have t_closed : IsClosed t := by
     apply isClosed_iInter
     intro n
@@ -273,7 +273,7 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ is_closed[t'] s ∧ is_open[t'] s :=
     hs.is_clopenable
   have A := @IsClosed.analyticSet α t' t'_polish s s_closed
-  convert@analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
+  convert @analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
   simp only [id.def, image_id']
 #align measurable_set.analytic_set MeasurableSet.analyticSet
 -/
@@ -416,7 +416,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   have M : ∀ n, ¬measurably_separable (f '' cylinder x n) (g '' cylinder y n) :=
     by
     intro n
-    convert(p n).2 using 3
+    convert (p n).2 using 3
     · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff]
       intro i hi
       rw [hx]
@@ -769,14 +769,14 @@ omit hγb
 @[measurability]
 theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
     [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) :
-    MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } :=
+    MeasurableSet {x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c)} :=
   by
   by_cases hl : l.ne_bot
   swap; · rw [not_ne_bot] at hl ; simp [hl]
   letI := upgradePolishSpace γ
   rcases l.exists_antitone_basis with ⟨u, hu⟩
   simp_rw [← cauchy_map_iff_exists_tendsto]
-  change MeasurableSet { x | _ ∧ _ }
+  change MeasurableSet {x | _ ∧ _}
   have :
     ∀ x,
       (map (fun i => f i x) l ×ᶠ map (fun i => f i x) l).HasAntitoneBasis fun n =>
Diff
@@ -126,12 +126,12 @@ theorem IsOpen.analyticSet_image {β : Type _} [TopologicalSpace β] [PolishSpac
 /-- A set is analytic if and only if it is the continuous image of some Polish space. -/
 theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
     AnalyticSet s ↔
-      ∃ (β : Type)(h : TopologicalSpace β)(h' : @PolishSpace β h)(f : β → α),
+      ∃ (β : Type) (h : TopologicalSpace β) (h' : @PolishSpace β h) (f : β → α),
         @Continuous _ _ h _ f ∧ range f = s :=
   by
   constructor
   · intro h
-    rw [analytic_set] at h
+    rw [analytic_set] at h 
     cases h
     · refine' ⟨Empty, by infer_instance, by infer_instance, Empty.elim, continuous_bot, _⟩
       rw [h]
@@ -225,7 +225,7 @@ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, Analy
   choose β hβ h'β f f_cont f_range using fun n =>
     analytic_set_iff_exists_polish_space_range.1 (hs n)
   skip
-  let γ := Σn, β n
+  let γ := Σ n, β n
   let F : γ → α := by rintro ⟨n, x⟩; exact f n x
   have F_cont : Continuous F := continuous_sigma f_cont
   have F_range : range F = ⋃ n, s n :=
@@ -432,11 +432,11 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
     apply t2_separation
     exact disjoint_iff_forall_ne.1 h _ (mem_range_self _) _ (mem_range_self _)
   letI : MetricSpace (ℕ → ℕ) := metric_space_nat_nat
-  obtain ⟨εx, εxpos, hεx⟩ : ∃ (εx : ℝ)(H : εx > 0), Metric.ball x εx ⊆ f ⁻¹' u :=
+  obtain ⟨εx, εxpos, hεx⟩ : ∃ (εx : ℝ) (H : εx > 0), Metric.ball x εx ⊆ f ⁻¹' u :=
     by
     apply Metric.mem_nhds_iff.1
     exact hf.continuous_at.preimage_mem_nhds (u_open.mem_nhds xu)
-  obtain ⟨εy, εypos, hεy⟩ : ∃ (εy : ℝ)(H : εy > 0), Metric.ball y εy ⊆ g ⁻¹' v :=
+  obtain ⟨εy, εypos, hεy⟩ : ∃ (εy : ℝ) (H : εy > 0), Metric.ball y εy ⊆ g ⁻¹' v :=
     by
     apply Metric.mem_nhds_iff.1
     exact hg.continuous_at.preimage_mem_nhds (v_open.mem_nhds yv)
@@ -449,14 +449,14 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
     · rw [image_subset_iff]
       apply subset.trans _ hεx
       intro z hz
-      rw [mem_cylinder_iff_dist_le] at hz
+      rw [mem_cylinder_iff_dist_le] at hz 
       exact hz.trans_lt (hn.trans_le (min_le_left _ _))
     · refine' Disjoint.mono_left _ huv.symm
       change g '' cylinder y n ⊆ v
       rw [image_subset_iff]
       apply subset.trans _ hεy
       intro z hz
-      rw [mem_cylinder_iff_dist_le] at hz
+      rw [mem_cylinder_iff_dist_le] at hz 
       exact hz.trans_lt (hn.trans_le (min_le_right _ _))
   -- this is a contradiction.
   exact M n B
@@ -467,7 +467,7 @@ disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
     (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) : MeasurablySeparable s t :=
   by
-  rw [analytic_set] at hs ht
+  rw [analytic_set] at hs ht 
   rcases hs with (rfl | ⟨f, f_cont, rfl⟩)
   · refine' ⟨∅, subset.refl _, by simp, MeasurableSet.empty⟩
   rcases ht with (rfl | ⟨g, g_cont, rfl⟩)
@@ -552,7 +552,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
   -- we start with the easy inclusion `range f ⊆ ⋂ F n`. One just needs to unfold the definitions.
   · rintro x ⟨y, rfl⟩
     apply mem_Inter.2 fun n => _
-    obtain ⟨s, sb, ys, hs⟩ : ∃ (s : Set γ)(H : s ∈ b), y ∈ s ∧ s ⊆ ball y (u n / 2) :=
+    obtain ⟨s, sb, ys, hs⟩ : ∃ (s : Set γ) (H : s ∈ b), y ∈ s ∧ s ⊆ ball y (u n / 2) :=
       by
       apply hb.mem_nhds_iff.1
       exact ball_mem_nhds _ (half_pos (u_pos n))
@@ -572,7 +572,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
   -- Now, let us prove the harder inclusion `⋂ F n ⊆ range f`.
   · intro x hx
     -- pick for each `n` a good set `s n` of small diameter for which `x ∈ E (s n)`.
-    have C1 : ∀ n, ∃ (s : b)(hs : bounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by
+    have C1 : ∀ n, ∃ (s : b) (hs : bounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by
       simpa only [mem_Union] using mem_Inter.1 hx n
     choose s hs hxs using C1
     have C2 : ∀ n, (s n).1.Nonempty := by
@@ -580,7 +580,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       rw [nonempty_iff_ne_empty]
       intro hn
       have := (s n).2
-      rw [hn] at this
+      rw [hn] at this 
       exact b_nonempty this
     -- choose a point `y n ∈ s n`.
     choose y hy using C2
@@ -654,8 +654,8 @@ theorem IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [Topolo
   rw [image_eq_range]
   haveI : PolishSpace s := IsClosed.polishSpace hs
   apply measurable_set_range_of_continuous_injective
-  · rwa [continuousOn_iff_continuous_restrict] at f_cont
-  · rwa [inj_on_iff_injective] at f_inj
+  · rwa [continuousOn_iff_continuous_restrict] at f_cont 
+  · rwa [inj_on_iff_injective] at f_inj 
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
 -/
 
@@ -721,7 +721,7 @@ theorem ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : Contin
       have B : MeasurableSet (f '' ((coe : s → γ) '' u)) :=
         A.image_of_continuous_on_inj_on (f_cont.mono (Subtype.coe_image_subset s u))
           (f_inj.mono (Subtype.coe_image_subset s u))
-      rwa [← image_comp] at B }
+      rwa [← image_comp] at B  }
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
 
 #print Measurable.measurableEmbedding /-
@@ -772,7 +772,7 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
     MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } :=
   by
   by_cases hl : l.ne_bot
-  swap; · rw [not_ne_bot] at hl; simp [hl]
+  swap; · rw [not_ne_bot] at hl ; simp [hl]
   letI := upgradePolishSpace γ
   rcases l.exists_antitone_basis with ⟨u, hu⟩
   simp_rw [← cauchy_map_iff_exists_tendsto]
@@ -868,7 +868,7 @@ noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
     letI := Countable.of_equiv α e
     use e <;> apply measurable_of_countable
   refine' measurable_equiv_of_not_countable h _
-  rwa [e.countable_iff] at h
+  rwa [e.countable_iff] at h 
 #align polish_space.equiv.measurable_equiv PolishSpace.Equiv.measurableEquiv
 -/
 
Diff
@@ -64,7 +64,7 @@ We use this to prove several versions of the Borel isomorphism theorem.
 
 open Set Function PolishSpace PiNat TopologicalSpace Metric Filter
 
-open Topology MeasureTheory Filter
+open scoped Topology MeasureTheory Filter
 
 variable {α : Type _} [TopologicalSpace α] {ι : Type _}
 
Diff
@@ -278,12 +278,6 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
 #align measurable_set.analytic_set MeasurableSet.analyticSet
 -/
 
-/- warning: measurable.exists_continuous -> Measurable.exists_continuous is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [t : TopologicalSpace.{u1} α] [_inst_2 : PolishSpace.{u1} α t] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α t _inst_3] [tβ : TopologicalSpace.{u2} β] [_inst_5 : TopologicalSpace.SecondCountableTopology.{u2} β tβ] [_inst_6 : MeasurableSpace.{u2} β] [_inst_7 : BorelSpace.{u2} β tβ _inst_6] {f : α -> β}, (Measurable.{u1, u2} α β _inst_3 _inst_6 f) -> (Exists.{succ u1} (TopologicalSpace.{u1} α) (fun (t' : TopologicalSpace.{u1} α) => And (LE.le.{u1} (TopologicalSpace.{u1} α) (Preorder.toHasLe.{u1} (TopologicalSpace.{u1} α) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.partialOrder.{u1} α))) t' t) (And (Continuous.{u1, u2} α β t' tβ f) (PolishSpace.{u1} α t'))))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [t : TopologicalSpace.{u2} α] [_inst_2 : PolishSpace.{u2} α t] [_inst_3 : MeasurableSpace.{u2} α] [_inst_4 : BorelSpace.{u2} α t _inst_3] [tβ : TopologicalSpace.{u1} β] [_inst_5 : TopologicalSpace.SecondCountableTopology.{u1} β tβ] [_inst_6 : MeasurableSpace.{u1} β] [_inst_7 : BorelSpace.{u1} β tβ _inst_6] {f : α -> β}, (Measurable.{u2, u1} α β _inst_3 _inst_6 f) -> (Exists.{succ u2} (TopologicalSpace.{u2} α) (fun (t' : TopologicalSpace.{u2} α) => And (LE.le.{u2} (TopologicalSpace.{u2} α) (Preorder.toLE.{u2} (TopologicalSpace.{u2} α) (PartialOrder.toPreorder.{u2} (TopologicalSpace.{u2} α) (TopologicalSpace.instPartialOrderTopologicalSpace.{u2} α))) t' t) (And (Continuous.{u2, u1} α β t' tβ f) (PolishSpace.{u2} α t'))))
-Case conversion may be inaccurate. Consider using '#align measurable.exists_continuous Measurable.exists_continuousₓ'. -/
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
 theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
@@ -319,12 +313,6 @@ def MeasurablySeparable {α : Type _} [MeasurableSpace α] (s t : Set α) : Prop
 #align measure_theory.measurably_separable MeasureTheory.MeasurablySeparable
 -/
 
-/- warning: measure_theory.measurably_separable.Union -> MeasureTheory.MeasurablySeparable.iUnion is a dubious translation:
-lean 3 declaration is
-  forall {ι : Type.{u1}} [_inst_2 : Countable.{succ u1} ι] {α : Type.{u2}} [_inst_3 : MeasurableSpace.{u2} α] {s : ι -> (Set.{u2} α)} {t : ι -> (Set.{u2} α)}, (forall (m : ι) (n : ι), MeasureTheory.MeasurablySeparable.{u2} α _inst_3 (s m) (t n)) -> (MeasureTheory.MeasurablySeparable.{u2} α _inst_3 (Set.iUnion.{u2, succ u1} α ι (fun (n : ι) => s n)) (Set.iUnion.{u2, succ u1} α ι (fun (m : ι) => t m)))
-but is expected to have type
-  forall {ι : Type.{u2}} [_inst_2 : Countable.{succ u2} ι] {α : Type.{u1}} [_inst_3 : MeasurableSpace.{u1} α] {s : ι -> (Set.{u1} α)} {t : ι -> (Set.{u1} α)}, (forall (m : ι) (n : ι), MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (s m) (t n)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.iUnion.{u1, succ u2} α ι (fun (n : ι) => s n)) (Set.iUnion.{u1, succ u2} α ι (fun (m : ι) => t m)))
-Case conversion may be inaccurate. Consider using '#align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnionₓ'. -/
 theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
     (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) :=
   by
@@ -340,12 +328,6 @@ theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace
     exact MeasurableSet.iInter fun n => hu m n
 #align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnion
 
-/- warning: measure_theory.measurably_separable_range_of_disjoint -> MeasureTheory.measurablySeparable_range_of_disjoint is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {f : (Nat -> Nat) -> α} {g : (Nat -> Nat) -> α}, (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => Nat.topologicalSpace)) _inst_1 f) -> (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => Nat.topologicalSpace)) _inst_1 g) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {f : (Nat -> Nat) -> α} {g : (Nat -> Nat) -> α}, (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => instTopologicalSpaceNat)) _inst_1 f) -> (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => instTopologicalSpaceNat)) _inst_1 g) -> (Disjoint.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g))
-Case conversion may be inaccurate. Consider using '#align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjointₓ'. -/
 /-- The hard part of the Lusin separation theorem saying that two disjoint analytic sets are
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
@@ -480,12 +462,6 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   exact M n B
 #align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjoint
 
-/- warning: measure_theory.analytic_set.measurably_separable -> MeasureTheory.AnalyticSet.measurablySeparable is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {s : Set.{u1} α} {t : Set.{u1} α}, (MeasureTheory.AnalyticSet.{u1} α _inst_1 s) -> (MeasureTheory.AnalyticSet.{u1} α _inst_1 t) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) s t) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 s t)
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {s : Set.{u1} α} {t : Set.{u1} α}, (MeasureTheory.AnalyticSet.{u1} α _inst_1 s) -> (MeasureTheory.AnalyticSet.{u1} α _inst_1 t) -> (Disjoint.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) s t) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 s t)
-Case conversion may be inaccurate. Consider using '#align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparableₓ'. -/
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
@@ -688,12 +664,6 @@ variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type _} [tβ : Topolo
 
 include tβ hγb
 
-/- warning: measurable_set.image_of_continuous_on_inj_on -> MeasurableSet.image_of_continuousOn_injOn is a dubious translation:
-lean 3 declaration is
-  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {s : Set.{u1} γ} {f : γ -> β}, (MeasurableSet.{u1} γ _inst_3 s) -> (ContinuousOn.{u1, u2} γ β tγ tβ f s) -> (Set.InjOn.{u1, u2} γ β f s) -> (MeasurableSet.{u2} β _inst_5 (Set.image.{u1, u2} γ β f s))
-but is expected to have type
-  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {s : Set.{u2} γ} {f : γ -> β}, (MeasurableSet.{u2} γ _inst_3 s) -> (ContinuousOn.{u2, u1} γ β tγ tβ f s) -> (Set.InjOn.{u2, u1} γ β f s) -> (MeasurableSet.{u1} β _inst_5 (Set.image.{u2, u1} γ β f s))
-Case conversion may be inaccurate. Consider using '#align measurable_set.image_of_continuous_on_inj_on MeasurableSet.image_of_continuousOn_injOnₓ'. -/
 /-- 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 MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -729,12 +699,6 @@ theorem MeasurableSet.image_of_measurable_injOn [SecondCountableTopology β] (hs
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
 -/
 
-/- warning: continuous.measurable_embedding -> Continuous.measurableEmbedding is a dubious translation:
-lean 3 declaration is
-  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {f : γ -> β}, (Continuous.{u1, u2} γ β tγ tβ f) -> (Function.Injective.{succ u1, succ u2} γ β f) -> (MeasurableEmbedding.{u1, u2} γ β _inst_3 _inst_5 f)
-but is expected to have type
-  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {f : γ -> β}, (Continuous.{u2, u1} γ β tγ tβ f) -> (Function.Injective.{succ u2, succ u1} γ β f) -> (MeasurableEmbedding.{u2, u1} γ β _inst_3 _inst_5 f)
-Case conversion may be inaccurate. Consider using '#align continuous.measurable_embedding Continuous.measurableEmbeddingₓ'. -/
 /-- An injective continuous function on a Polish space is a measurable embedding. -/
 theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableEmbedding f :=
@@ -744,12 +708,6 @@ theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injectiv
       hu.image_of_continuousOn_injOn f_cont.ContinuousOn (f_inj.InjOn _) }
 #align continuous.measurable_embedding Continuous.measurableEmbedding
 
-/- warning: continuous_on.measurable_embedding -> ContinuousOn.measurableEmbedding is a dubious translation:
-lean 3 declaration is
-  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {s : Set.{u1} γ} {f : γ -> β}, (MeasurableSet.{u1} γ _inst_3 s) -> (ContinuousOn.{u1, u2} γ β tγ tβ f s) -> (Set.InjOn.{u1, u2} γ β f s) -> (MeasurableEmbedding.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} γ) Type.{u1} (Set.hasCoeToSort.{u1} γ) s) β (Subtype.instMeasurableSpace.{u1} γ (fun (x : γ) => Membership.Mem.{u1, u1} γ (Set.{u1} γ) (Set.hasMem.{u1} γ) x s) _inst_3) _inst_5 (Set.restrict.{u1, u2} γ (fun (ᾰ : γ) => β) s f))
-but is expected to have type
-  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {s : Set.{u2} γ} {f : γ -> β}, (MeasurableSet.{u2} γ _inst_3 s) -> (ContinuousOn.{u2, u1} γ β tγ tβ f s) -> (Set.InjOn.{u2, u1} γ β f s) -> (MeasurableEmbedding.{u2, u1} (Set.Elem.{u2} γ s) β (Subtype.instMeasurableSpace.{u2} γ (fun (x : γ) => Membership.mem.{u2, u2} γ (Set.{u2} γ) (Set.instMembershipSet.{u2} γ) x s) _inst_3) _inst_5 (Set.restrict.{u2, u1} γ (fun (ᾰ : γ) => β) s f))
-Case conversion may be inaccurate. Consider using '#align continuous_on.measurable_embedding ContinuousOn.measurableEmbeddingₓ'. -/
 /-- 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 ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -806,12 +764,6 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
 
 omit hγb
 
-/- warning: measure_theory.measurable_set_exists_tendsto -> MeasureTheory.measurableSet_exists_tendsto is a dubious translation:
-lean 3 declaration is
-  forall {ι : Type.{u1}} {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] {β : Type.{u3}} [_inst_5 : MeasurableSpace.{u3} β] [hγ : OpensMeasurableSpace.{u2} γ tγ _inst_3] [_inst_7 : Countable.{succ u1} ι] {l : Filter.{u1} ι} [_inst_8 : Filter.IsCountablyGenerated.{u1} ι l] {f : ι -> β -> γ}, (forall (i : ι), Measurable.{u3, u2} β γ _inst_5 _inst_3 (f i)) -> (MeasurableSet.{u3} β _inst_5 (setOf.{u3} β (fun (x : β) => Exists.{succ u2} γ (fun (c : γ) => Filter.Tendsto.{u1, u2} ι γ (fun (n : ι) => f n x) l (nhds.{u2} γ tγ c)))))
-but is expected to have type
-  forall {ι : Type.{u2}} {γ : Type.{u3}} [tγ : TopologicalSpace.{u3} γ] [_inst_2 : PolishSpace.{u3} γ tγ] [_inst_3 : MeasurableSpace.{u3} γ] {β : Type.{u1}} [_inst_5 : MeasurableSpace.{u1} β] [hγ : OpensMeasurableSpace.{u3} γ tγ _inst_3] [_inst_7 : Countable.{succ u2} ι] {l : Filter.{u2} ι} [_inst_8 : Filter.IsCountablyGenerated.{u2} ι l] {f : ι -> β -> γ}, (forall (i : ι), Measurable.{u1, u3} β γ _inst_5 _inst_3 (f i)) -> (MeasurableSet.{u1} β _inst_5 (setOf.{u1} β (fun (x : β) => Exists.{succ u3} γ (fun (c : γ) => Filter.Tendsto.{u2, u3} ι γ (fun (n : ι) => f n x) l (nhds.{u3} γ tγ c)))))
-Case conversion may be inaccurate. Consider using '#align measure_theory.measurable_set_exists_tendsto MeasureTheory.measurableSet_exists_tendstoₓ'. -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- The set of points for which a measurable sequence of functions converges is measurable. -/
 @[measurability]
@@ -930,12 +882,6 @@ instance [PolishSpace α] : PolishSpace (univ : Set α) :=
 
 variable (α) [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
 
-/- warning: measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite -> MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite is a dubious translation:
-lean 3 declaration is
-  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Finite.{succ u1} α], Exists.{1} Nat (fun (n : Nat) => Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (coeSort.{1, 2} (Set.{0} Real) Type (Set.hasCoeToSort.{0} Real) (Set.range.{0, 1} Real (Fin n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) (Fin n) Real (HasLiftT.mk.{1, 1} (Fin n) Real (CoeTCₓ.coe.{1, 1} (Fin n) Real (coeTrans.{1, 1, 1} (Fin n) Nat Real (Nat.castCoe.{0} Real Real.hasNatCast) (Fin.coeToNat n))))))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.range.{0, 1} Real (Fin n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) (Fin n) Real (HasLiftT.mk.{1, 1} (Fin n) Real (CoeTCₓ.coe.{1, 1} (Fin n) Real (coeTrans.{1, 1, 1} (Fin n) Nat Real (Nat.castCoe.{0} Real Real.hasNatCast) (Fin.coeToNat n))))))) Real.measurableSpace)))
-but is expected to have type
-  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Finite.{succ u1} α], Exists.{1} Nat (fun (n : Nat) => Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (Set.Elem.{0} Real (Set.range.{0, 1} Real (Fin n) (fun (x : Fin n) => Nat.cast.{0} Real Real.natCast (Fin.val n x)))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.range.{0, 1} Real (Fin n) (fun (x : Fin n) => Nat.cast.{0} Real Real.natCast (Fin.val n x)))) Real.measurableSpace)))
-Case conversion may be inaccurate. Consider using '#align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finiteₓ'. -/
 theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
     ∃ n : ℕ, Nonempty (α ≃ᵐ range (coe : Fin n → ℝ)) :=
   by
@@ -944,12 +890,6 @@ theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
   exact Equiv.ofInjective _ (nat.cast_injective.comp Fin.val_injective)
 #align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite
 
-/- warning: measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable -> MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable is a dubious translation:
-lean 3 declaration is
-  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Infinite.{succ u1} α] [_inst_6 : Countable.{succ u1} α], Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (coeSort.{1, 2} (Set.{0} Real) Type (Set.hasCoeToSort.{0} Real) (Set.range.{0, 1} Real Nat ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast)))))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.range.{0, 1} Real Nat ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast)))))) Real.measurableSpace))
-but is expected to have type
-  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Infinite.{succ u1} α] [_inst_6 : Countable.{succ u1} α], Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (Set.Elem.{0} Real (Set.range.{0, 1} Real Nat (Nat.cast.{0} Real Real.natCast))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.range.{0, 1} Real Nat (Nat.cast.{0} Real Real.natCast))) Real.measurableSpace))
-Case conversion may be inaccurate. Consider using '#align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countableₓ'. -/
 theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] :
     Nonempty (α ≃ᵐ range (coe : ℕ → ℝ)) :=
   by
Diff
@@ -226,9 +226,7 @@ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, Analy
     analytic_set_iff_exists_polish_space_range.1 (hs n)
   skip
   let γ := Σn, β n
-  let F : γ → α := by
-    rintro ⟨n, x⟩
-    exact f n x
+  let F : γ → α := by rintro ⟨n, x⟩; exact f n x
   have F_cont : Continuous F := continuous_sigma f_cont
   have F_range : range F = ⋃ n, s n :=
     by
@@ -640,9 +638,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
     -- let `z` be its limit.
     let z := limUnder at_top y
     have y_lim : tendsto y at_top (𝓝 z) := cauchy_y.tendsto_lim
-    suffices f z = x by
-      rw [← this]
-      exact mem_range_self _
+    suffices f z = x by rw [← this]; exact mem_range_self _
     -- assume for a contradiction that `f z ≠ x`.
     by_contra' hne
     -- introduce disjoint open sets `v` and `w` separating `f z` from `x`.
@@ -725,17 +721,11 @@ theorem MeasurableSet.image_of_measurable_injOn [SecondCountableTopology β] (hs
     f_meas.exists_continuous
   have M : measurable_set[@borel γ t'] s :=
     @Continuous.measurable γ γ t' (@borel γ t')
-      (@BorelSpace.opensMeasurable γ t' (@borel γ t')
-        (by
-          constructor
-          rfl))
-      tγ _ _ _ (continuous_id_of_le t't) s hs
+      (@BorelSpace.opensMeasurable γ t' (@borel γ t') (by constructor; rfl)) tγ _ _ _
+      (continuous_id_of_le t't) s hs
   exact
-    @MeasurableSet.image_of_continuousOn_injOn γ t' t'_polish (@borel γ t')
-      (by
-        constructor
-        rfl)
-      β _ _ _ _ s f M (@Continuous.continuousOn γ β t' tβ f s f_cont) f_inj
+    @MeasurableSet.image_of_continuousOn_injOn γ t' t'_polish (@borel γ t') (by constructor; rfl) β
+      _ _ _ _ s f M (@Continuous.continuousOn γ β t' tβ f s f_cont) f_inj
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
 -/
 
@@ -802,19 +792,12 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
   have C : @Continuous γ γ t' tγ id := continuous_id_of_le t't
   -- therefore, it is also a measurable embedding, by the Lusin-Souslin theorem
   have E :=
-    @Continuous.measurableEmbedding γ t' t'_polish (@borel γ t')
-      (by
-        constructor
-        rfl)
-      γ tγ (PolishSpace.t2Space γ) _ _ id C injective_id
+    @Continuous.measurableEmbedding γ t' t'_polish (@borel γ t') (by constructor; rfl) γ tγ
+      (PolishSpace.t2Space γ) _ _ id C injective_id
   -- the set `s` is measurable for `t'` as it is closed.
   have M : @MeasurableSet γ (@borel γ t') s :=
     @IsClosed.measurableSet γ s t' (@borel γ t')
-      (@BorelSpace.opensMeasurable γ t' (@borel γ t')
-        (by
-          constructor
-          rfl))
-      s_closed
+      (@BorelSpace.opensMeasurable γ t' (@borel γ t') (by constructor; rfl)) s_closed
   -- therefore, its image under the measurable embedding `id` is also measurable for `tγ`.
   convert E.measurable_set_image.2 M
   simp only [id.def, image_id']
@@ -837,9 +820,7 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
     MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } :=
   by
   by_cases hl : l.ne_bot
-  swap;
-  · rw [not_ne_bot] at hl
-    simp [hl]
+  swap; · rw [not_ne_bot] at hl; simp [hl]
   letI := upgradePolishSpace γ
   rcases l.exists_antitone_basis with ⟨u, hu⟩
   simp_rw [← cauchy_map_iff_exists_tendsto]
Diff
@@ -887,7 +887,6 @@ be necessary, and `second_countable_of_polish` should probably
 just be added as an instance soon after the definition of `polish_space`.-/
 private theorem second_countable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
   h.second_countable
-#align polish_space.second_countable_of_polish polish_space.second_countable_of_polish
 
 attribute [-instance] polishSpace_of_complete_second_countable
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf
+! leanprover-community/mathlib commit 4280f5f32e16755ec7985ce11e189b6cd6ff6735
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.MeasureTheory.Constructions.BorelSpace.Basic
 /-!
 # The Borel sigma-algebra on Polish spaces
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 We discuss several results pertaining to the relationship between the topology and the Borel
 structure on Polish spaces.
 
Diff
@@ -70,6 +70,7 @@ namespace MeasureTheory
 /-! ### Analytic sets -/
 
 
+#print MeasureTheory.AnalyticSet /-
 /-- An analytic set is a set which is the continuous image of some Polish space. There are several
 equivalent characterizations of this definition. For the definition, we pick one that avoids
 universe issues: a set is analytic if and only if it is a continuous image of `ℕ → ℕ` (or if it
@@ -82,13 +83,17 @@ context of complex analysis. -/
 irreducible_def AnalyticSet (s : Set α) : Prop :=
   s = ∅ ∨ ∃ f : (ℕ → ℕ) → α, Continuous f ∧ range f = s
 #align measure_theory.analytic_set MeasureTheory.AnalyticSet
+-/
 
+#print MeasureTheory.analyticSet_empty /-
 theorem analyticSet_empty : AnalyticSet (∅ : Set α) :=
   by
   rw [analytic_set]
   exact Or.inl rfl
 #align measure_theory.analytic_set_empty MeasureTheory.analyticSet_empty
+-/
 
+#print MeasureTheory.analyticSet_range_of_polishSpace /-
 theorem analyticSet_range_of_polishSpace {β : Type _} [TopologicalSpace β] [PolishSpace β]
     {f : β → α} (f_cont : Continuous f) : AnalyticSet (range f) :=
   by
@@ -101,7 +106,9 @@ theorem analyticSet_range_of_polishSpace {β : Type _} [TopologicalSpace β] [Po
     refine' Or.inr ⟨f ∘ g, f_cont.comp g_cont, _⟩
     rwa [hg.range_comp]
 #align measure_theory.analytic_set_range_of_polish_space MeasureTheory.analyticSet_range_of_polishSpace
+-/
 
+#print IsOpen.analyticSet_image /-
 /-- The image of an open set under a continuous map is analytic. -/
 theorem IsOpen.analyticSet_image {β : Type _} [TopologicalSpace β] [PolishSpace β] {s : Set β}
     (hs : IsOpen s) {f : β → α} (f_cont : Continuous f) : AnalyticSet (f '' s) :=
@@ -110,7 +117,9 @@ theorem IsOpen.analyticSet_image {β : Type _} [TopologicalSpace β] [PolishSpac
   haveI : PolishSpace s := hs.polish_space
   exact analytic_set_range_of_polish_space (f_cont.comp continuous_subtype_val)
 #align is_open.analytic_set_image IsOpen.analyticSet_image
+-/
 
+#print MeasureTheory.analyticSet_iff_exists_polishSpace_range /-
 /-- A set is analytic if and only if it is the continuous image of some Polish space. -/
 theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
     AnalyticSet s ↔
@@ -130,7 +139,9 @@ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
     rw [← f_range]
     exact analytic_set_range_of_polish_space f_cont
 #align measure_theory.analytic_set_iff_exists_polish_space_range MeasureTheory.analyticSet_iff_exists_polishSpace_range
+-/
 
+#print MeasureTheory.AnalyticSet.image_of_continuousOn /-
 /-- The continuous image of an analytic set is analytic -/
 theorem AnalyticSet.image_of_continuousOn {β : Type _} [TopologicalSpace β] {s : Set α}
     (hs : AnalyticSet s) {f : α → β} (hf : ContinuousOn f s) : AnalyticSet (f '' s) :=
@@ -144,12 +155,16 @@ theorem AnalyticSet.image_of_continuousOn {β : Type _} [TopologicalSpace β] {s
   rw [← gs]
   exact mem_range_self _
 #align measure_theory.analytic_set.image_of_continuous_on MeasureTheory.AnalyticSet.image_of_continuousOn
+-/
 
+#print MeasureTheory.AnalyticSet.image_of_continuous /-
 theorem AnalyticSet.image_of_continuous {β : Type _} [TopologicalSpace β] {s : Set α}
     (hs : AnalyticSet s) {f : α → β} (hf : Continuous f) : AnalyticSet (f '' s) :=
   hs.image_of_continuousOn hf.ContinuousOn
 #align measure_theory.analytic_set.image_of_continuous MeasureTheory.AnalyticSet.image_of_continuous
+-/
 
+#print MeasureTheory.AnalyticSet.iInter /-
 /-- A countable intersection of analytic sets is analytic. -/
 theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s : ι → Set α}
     (hs : ∀ n, AnalyticSet (s n)) : AnalyticSet (⋂ n, s n) :=
@@ -194,7 +209,9 @@ theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s :
   rw [← F_range]
   exact analytic_set_range_of_polish_space F_cont
 #align measure_theory.analytic_set.Inter MeasureTheory.AnalyticSet.iInter
+-/
 
+#print MeasureTheory.AnalyticSet.iUnion /-
 /-- A countable union of analytic sets is analytic. -/
 theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, AnalyticSet (s n)) :
     AnalyticSet (⋃ n, s n) :=
@@ -219,14 +236,18 @@ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, Analy
   rw [← F_range]
   exact analytic_set_range_of_polish_space F_cont
 #align measure_theory.analytic_set.Union MeasureTheory.AnalyticSet.iUnion
+-/
 
+#print IsClosed.analyticSet /-
 theorem IsClosed.analyticSet [PolishSpace α] {s : Set α} (hs : IsClosed s) : AnalyticSet s :=
   by
   haveI : PolishSpace s := hs.polish_space
   rw [← @Subtype.range_val α s]
   exact analytic_set_range_of_polish_space continuous_subtype_val
 #align is_closed.analytic_set IsClosed.analyticSet
+-/
 
+#print MeasurableSet.isClopenable /-
 /-- Given a Borel-measurable set in a Polish space, there exists a finer Polish topology making
 it clopen. This is in fact an equivalence, see `is_clopenable_iff_measurable_set`. -/
 theorem MeasurableSet.isClopenable [PolishSpace α] [MeasurableSpace α] [BorelSpace α] {s : Set α}
@@ -238,7 +259,9 @@ theorem MeasurableSet.isClopenable [PolishSpace α] [MeasurableSpace α] [BorelS
   · exact fun u hu h'u => h'u.compl
   · exact fun f f_disj f_meas hf => is_clopenable.Union hf
 #align measurable_set.is_clopenable MeasurableSet.isClopenable
+-/
 
+#print MeasurableSet.analyticSet /-
 theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [PolishSpace α]
     [MeasurableSpace α] [BorelSpace α] {s : Set α} (hs : MeasurableSet s) : AnalyticSet s :=
   by
@@ -252,7 +275,14 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
   convert@analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
   simp only [id.def, image_id']
 #align measurable_set.analytic_set MeasurableSet.analyticSet
+-/
 
+/- warning: measurable.exists_continuous -> Measurable.exists_continuous is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} [t : TopologicalSpace.{u1} α] [_inst_2 : PolishSpace.{u1} α t] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α t _inst_3] [tβ : TopologicalSpace.{u2} β] [_inst_5 : TopologicalSpace.SecondCountableTopology.{u2} β tβ] [_inst_6 : MeasurableSpace.{u2} β] [_inst_7 : BorelSpace.{u2} β tβ _inst_6] {f : α -> β}, (Measurable.{u1, u2} α β _inst_3 _inst_6 f) -> (Exists.{succ u1} (TopologicalSpace.{u1} α) (fun (t' : TopologicalSpace.{u1} α) => And (LE.le.{u1} (TopologicalSpace.{u1} α) (Preorder.toHasLe.{u1} (TopologicalSpace.{u1} α) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.partialOrder.{u1} α))) t' t) (And (Continuous.{u1, u2} α β t' tβ f) (PolishSpace.{u1} α t'))))
+but is expected to have type
+  forall {α : Type.{u2}} {β : Type.{u1}} [t : TopologicalSpace.{u2} α] [_inst_2 : PolishSpace.{u2} α t] [_inst_3 : MeasurableSpace.{u2} α] [_inst_4 : BorelSpace.{u2} α t _inst_3] [tβ : TopologicalSpace.{u1} β] [_inst_5 : TopologicalSpace.SecondCountableTopology.{u1} β tβ] [_inst_6 : MeasurableSpace.{u1} β] [_inst_7 : BorelSpace.{u1} β tβ _inst_6] {f : α -> β}, (Measurable.{u2, u1} α β _inst_3 _inst_6 f) -> (Exists.{succ u2} (TopologicalSpace.{u2} α) (fun (t' : TopologicalSpace.{u2} α) => And (LE.le.{u2} (TopologicalSpace.{u2} α) (Preorder.toLE.{u2} (TopologicalSpace.{u2} α) (PartialOrder.toPreorder.{u2} (TopologicalSpace.{u2} α) (TopologicalSpace.instPartialOrderTopologicalSpace.{u2} α))) t' t) (And (Continuous.{u2, u1} α β t' tβ f) (PolishSpace.{u2} α t'))))
+Case conversion may be inaccurate. Consider using '#align measurable.exists_continuous Measurable.exists_continuousₓ'. -/
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
 theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
@@ -279,13 +309,21 @@ theorem Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α]
 /-! ### Separating sets with measurable sets -/
 
 
+#print MeasureTheory.MeasurablySeparable /-
 /-- Two sets `u` and `v` in a measurable space are measurably separable if there
 exists a measurable set containing `u` and disjoint from `v`.
 This is mostly interesting for Borel-separable sets. -/
 def MeasurablySeparable {α : Type _} [MeasurableSpace α] (s t : Set α) : Prop :=
   ∃ u, s ⊆ u ∧ Disjoint t u ∧ MeasurableSet u
 #align measure_theory.measurably_separable MeasureTheory.MeasurablySeparable
+-/
 
+/- warning: measure_theory.measurably_separable.Union -> MeasureTheory.MeasurablySeparable.iUnion is a dubious translation:
+lean 3 declaration is
+  forall {ι : Type.{u1}} [_inst_2 : Countable.{succ u1} ι] {α : Type.{u2}} [_inst_3 : MeasurableSpace.{u2} α] {s : ι -> (Set.{u2} α)} {t : ι -> (Set.{u2} α)}, (forall (m : ι) (n : ι), MeasureTheory.MeasurablySeparable.{u2} α _inst_3 (s m) (t n)) -> (MeasureTheory.MeasurablySeparable.{u2} α _inst_3 (Set.iUnion.{u2, succ u1} α ι (fun (n : ι) => s n)) (Set.iUnion.{u2, succ u1} α ι (fun (m : ι) => t m)))
+but is expected to have type
+  forall {ι : Type.{u2}} [_inst_2 : Countable.{succ u2} ι] {α : Type.{u1}} [_inst_3 : MeasurableSpace.{u1} α] {s : ι -> (Set.{u1} α)} {t : ι -> (Set.{u1} α)}, (forall (m : ι) (n : ι), MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (s m) (t n)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.iUnion.{u1, succ u2} α ι (fun (n : ι) => s n)) (Set.iUnion.{u1, succ u2} α ι (fun (m : ι) => t m)))
+Case conversion may be inaccurate. Consider using '#align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnionₓ'. -/
 theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
     (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) :=
   by
@@ -301,6 +339,12 @@ theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace
     exact MeasurableSet.iInter fun n => hu m n
 #align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnion
 
+/- warning: measure_theory.measurably_separable_range_of_disjoint -> MeasureTheory.measurablySeparable_range_of_disjoint is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {f : (Nat -> Nat) -> α} {g : (Nat -> Nat) -> α}, (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => Nat.topologicalSpace)) _inst_1 f) -> (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => Nat.topologicalSpace)) _inst_1 g) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g))
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {f : (Nat -> Nat) -> α} {g : (Nat -> Nat) -> α}, (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => instTopologicalSpaceNat)) _inst_1 f) -> (Continuous.{0, u1} (Nat -> Nat) α (Pi.topologicalSpace.{0, 0} Nat (fun (ᾰ : Nat) => Nat) (fun (a : Nat) => instTopologicalSpaceNat)) _inst_1 g) -> (Disjoint.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g)) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 (Set.range.{u1, 1} α (Nat -> Nat) f) (Set.range.{u1, 1} α (Nat -> Nat) g))
+Case conversion may be inaccurate. Consider using '#align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjointₓ'. -/
 /-- The hard part of the Lusin separation theorem saying that two disjoint analytic sets are
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
@@ -435,6 +479,12 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   exact M n B
 #align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjoint
 
+/- warning: measure_theory.analytic_set.measurably_separable -> MeasureTheory.AnalyticSet.measurablySeparable is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {s : Set.{u1} α} {t : Set.{u1} α}, (MeasureTheory.AnalyticSet.{u1} α _inst_1 s) -> (MeasureTheory.AnalyticSet.{u1} α _inst_1 t) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) s t) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 s t)
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : T2Space.{u1} α _inst_1] [_inst_3 : MeasurableSpace.{u1} α] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_3] {s : Set.{u1} α} {t : Set.{u1} α}, (MeasureTheory.AnalyticSet.{u1} α _inst_1 s) -> (MeasureTheory.AnalyticSet.{u1} α _inst_1 t) -> (Disjoint.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) s t) -> (MeasureTheory.MeasurablySeparable.{u1} α _inst_3 s t)
+Case conversion may be inaccurate. Consider using '#align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparableₓ'. -/
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
@@ -455,6 +505,7 @@ variable {γ : Type _} [tγ : TopologicalSpace γ] [PolishSpace γ]
 
 include tγ
 
+#print MeasureTheory.measurableSet_range_of_continuous_injective /-
 /-- The Lusin-Souslin theorem: the range of a continuous injective function defined on a Polish
 space is Borel-measurable. -/
 theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSpace β] [T2Space β]
@@ -618,7 +669,9 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
     -- the closure of `v`.
     exact disjoint_left.1 (hvw.closure_left w_open) this xw
 #align measure_theory.measurable_set_range_of_continuous_injective MeasureTheory.measurableSet_range_of_continuous_injective
+-/
 
+#print IsClosed.measurableSet_image_of_continuousOn_injOn /-
 theorem IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [TopologicalSpace β]
     [T2Space β] [MeasurableSpace β] [BorelSpace β] {s : Set γ} (hs : IsClosed s) {f : γ → β}
     (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) :=
@@ -629,12 +682,19 @@ theorem IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [Topolo
   · rwa [continuousOn_iff_continuous_restrict] at f_cont
   · rwa [inj_on_iff_injective] at f_inj
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
+-/
 
 variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type _} [tβ : TopologicalSpace β] [T2Space β]
   [MeasurableSpace β] [BorelSpace β] {s : Set γ} {f : γ → β}
 
 include tβ hγb
 
+/- warning: measurable_set.image_of_continuous_on_inj_on -> MeasurableSet.image_of_continuousOn_injOn is a dubious translation:
+lean 3 declaration is
+  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {s : Set.{u1} γ} {f : γ -> β}, (MeasurableSet.{u1} γ _inst_3 s) -> (ContinuousOn.{u1, u2} γ β tγ tβ f s) -> (Set.InjOn.{u1, u2} γ β f s) -> (MeasurableSet.{u2} β _inst_5 (Set.image.{u1, u2} γ β f s))
+but is expected to have type
+  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {s : Set.{u2} γ} {f : γ -> β}, (MeasurableSet.{u2} γ _inst_3 s) -> (ContinuousOn.{u2, u1} γ β tγ tβ f s) -> (Set.InjOn.{u2, u1} γ β f s) -> (MeasurableSet.{u1} β _inst_5 (Set.image.{u2, u1} γ β f s))
+Case conversion may be inaccurate. Consider using '#align measurable_set.image_of_continuous_on_inj_on MeasurableSet.image_of_continuousOn_injOnₓ'. -/
 /-- 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 MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -648,6 +708,7 @@ theorem MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s) (f_cont
       (f_cont.mono_dom t't) f_inj
 #align measurable_set.image_of_continuous_on_inj_on MeasurableSet.image_of_continuousOn_injOn
 
+#print MeasurableSet.image_of_measurable_injOn /-
 /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
 a measurable injective map taking values in a second-countable topological space
 is also Borel-measurable. -/
@@ -673,7 +734,14 @@ theorem MeasurableSet.image_of_measurable_injOn [SecondCountableTopology β] (hs
         rfl)
       β _ _ _ _ s f M (@Continuous.continuousOn γ β t' tβ f s f_cont) f_inj
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
+-/
 
+/- warning: continuous.measurable_embedding -> Continuous.measurableEmbedding is a dubious translation:
+lean 3 declaration is
+  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {f : γ -> β}, (Continuous.{u1, u2} γ β tγ tβ f) -> (Function.Injective.{succ u1, succ u2} γ β f) -> (MeasurableEmbedding.{u1, u2} γ β _inst_3 _inst_5 f)
+but is expected to have type
+  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {f : γ -> β}, (Continuous.{u2, u1} γ β tγ tβ f) -> (Function.Injective.{succ u2, succ u1} γ β f) -> (MeasurableEmbedding.{u2, u1} γ β _inst_3 _inst_5 f)
+Case conversion may be inaccurate. Consider using '#align continuous.measurable_embedding Continuous.measurableEmbeddingₓ'. -/
 /-- An injective continuous function on a Polish space is a measurable embedding. -/
 theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableEmbedding f :=
@@ -683,6 +751,12 @@ theorem Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injectiv
       hu.image_of_continuousOn_injOn f_cont.ContinuousOn (f_inj.InjOn _) }
 #align continuous.measurable_embedding Continuous.measurableEmbedding
 
+/- warning: continuous_on.measurable_embedding -> ContinuousOn.measurableEmbedding is a dubious translation:
+lean 3 declaration is
+  forall {γ : Type.{u1}} [tγ : TopologicalSpace.{u1} γ] [_inst_2 : PolishSpace.{u1} γ tγ] [_inst_3 : MeasurableSpace.{u1} γ] [hγb : BorelSpace.{u1} γ tγ _inst_3] {β : Type.{u2}} [tβ : TopologicalSpace.{u2} β] [_inst_4 : T2Space.{u2} β tβ] [_inst_5 : MeasurableSpace.{u2} β] [_inst_6 : BorelSpace.{u2} β tβ _inst_5] {s : Set.{u1} γ} {f : γ -> β}, (MeasurableSet.{u1} γ _inst_3 s) -> (ContinuousOn.{u1, u2} γ β tγ tβ f s) -> (Set.InjOn.{u1, u2} γ β f s) -> (MeasurableEmbedding.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} γ) Type.{u1} (Set.hasCoeToSort.{u1} γ) s) β (Subtype.instMeasurableSpace.{u1} γ (fun (x : γ) => Membership.Mem.{u1, u1} γ (Set.{u1} γ) (Set.hasMem.{u1} γ) x s) _inst_3) _inst_5 (Set.restrict.{u1, u2} γ (fun (ᾰ : γ) => β) s f))
+but is expected to have type
+  forall {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] [hγb : BorelSpace.{u2} γ tγ _inst_3] {β : Type.{u1}} [tβ : TopologicalSpace.{u1} β] [_inst_4 : T2Space.{u1} β tβ] [_inst_5 : MeasurableSpace.{u1} β] [_inst_6 : BorelSpace.{u1} β tβ _inst_5] {s : Set.{u2} γ} {f : γ -> β}, (MeasurableSet.{u2} γ _inst_3 s) -> (ContinuousOn.{u2, u1} γ β tγ tβ f s) -> (Set.InjOn.{u2, u1} γ β f s) -> (MeasurableEmbedding.{u2, u1} (Set.Elem.{u2} γ s) β (Subtype.instMeasurableSpace.{u2} γ (fun (x : γ) => Membership.mem.{u2, u2} γ (Set.{u2} γ) (Set.instMembershipSet.{u2} γ) x s) _inst_3) _inst_5 (Set.restrict.{u2, u1} γ (fun (ᾰ : γ) => β) s f))
+Case conversion may be inaccurate. Consider using '#align continuous_on.measurable_embedding ContinuousOn.measurableEmbeddingₓ'. -/
 /-- 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 ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
@@ -699,6 +773,7 @@ theorem ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont : Contin
       rwa [← image_comp] at B }
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
 
+#print Measurable.measurableEmbedding /-
 /-- An injective measurable function from a Polish space to a second-countable topological space
 is a measurable embedding. -/
 theorem Measurable.measurableEmbedding [SecondCountableTopology β] (f_meas : Measurable f)
@@ -707,9 +782,11 @@ theorem Measurable.measurableEmbedding [SecondCountableTopology β] (f_meas : Me
     Measurable := f_meas
     measurableSet_image' := fun u hu => hu.image_of_measurable_injOn f_meas (f_inj.InjOn _) }
 #align measurable.measurable_embedding Measurable.measurableEmbedding
+-/
 
 omit tβ
 
+#print MeasureTheory.isClopenable_iff_measurableSet /-
 /-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/
 theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
   by
@@ -739,9 +816,16 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
   convert E.measurable_set_image.2 M
   simp only [id.def, image_id']
 #align measure_theory.is_clopenable_iff_measurable_set MeasureTheory.isClopenable_iff_measurableSet
+-/
 
 omit hγb
 
+/- warning: measure_theory.measurable_set_exists_tendsto -> MeasureTheory.measurableSet_exists_tendsto is a dubious translation:
+lean 3 declaration is
+  forall {ι : Type.{u1}} {γ : Type.{u2}} [tγ : TopologicalSpace.{u2} γ] [_inst_2 : PolishSpace.{u2} γ tγ] [_inst_3 : MeasurableSpace.{u2} γ] {β : Type.{u3}} [_inst_5 : MeasurableSpace.{u3} β] [hγ : OpensMeasurableSpace.{u2} γ tγ _inst_3] [_inst_7 : Countable.{succ u1} ι] {l : Filter.{u1} ι} [_inst_8 : Filter.IsCountablyGenerated.{u1} ι l] {f : ι -> β -> γ}, (forall (i : ι), Measurable.{u3, u2} β γ _inst_5 _inst_3 (f i)) -> (MeasurableSet.{u3} β _inst_5 (setOf.{u3} β (fun (x : β) => Exists.{succ u2} γ (fun (c : γ) => Filter.Tendsto.{u1, u2} ι γ (fun (n : ι) => f n x) l (nhds.{u2} γ tγ c)))))
+but is expected to have type
+  forall {ι : Type.{u2}} {γ : Type.{u3}} [tγ : TopologicalSpace.{u3} γ] [_inst_2 : PolishSpace.{u3} γ tγ] [_inst_3 : MeasurableSpace.{u3} γ] {β : Type.{u1}} [_inst_5 : MeasurableSpace.{u1} β] [hγ : OpensMeasurableSpace.{u3} γ tγ _inst_3] [_inst_7 : Countable.{succ u2} ι] {l : Filter.{u2} ι} [_inst_8 : Filter.IsCountablyGenerated.{u2} ι l] {f : ι -> β -> γ}, (forall (i : ι), Measurable.{u1, u3} β γ _inst_5 _inst_3 (f i)) -> (MeasurableSet.{u1} β _inst_5 (setOf.{u1} β (fun (x : β) => Exists.{succ u3} γ (fun (c : γ) => Filter.Tendsto.{u2, u3} ι γ (fun (n : ι) => f n x) l (nhds.{u3} γ tγ c)))))
+Case conversion may be inaccurate. Consider using '#align measure_theory.measurable_set_exists_tendsto MeasureTheory.measurableSet_exists_tendstoₓ'. -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- The set of points for which a measurable sequence of functions converges is measurable. -/
 @[measurability]
@@ -780,6 +864,7 @@ end MeasureTheory
 /-! ### The Borel Isomorphism Theorem -/
 
 
+#print polish_of_countable /-
 --Note: Move to topology/metric_space/polish when porting.
 instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
     PolishSpace α := by
@@ -790,6 +875,7 @@ instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopolo
     exact fun t _ => isClosed_discrete _
   exact this.polish_space
 #align polish_of_countable polish_of_countable
+-/
 
 namespace PolishSpace
 
@@ -808,13 +894,16 @@ variable {β : Type _} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
 
 variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
 
+#print PolishSpace.borelSchroederBernstein /-
 /-- If two Polish spaces admit Borel measurable injections to one another,
 then they are Borel isomorphic.-/
 noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
     (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β :=
   (fmeas.MeasurableEmbedding finj).schroeder_bernstein (gmeas.MeasurableEmbedding ginj)
 #align polish_space.borel_schroeder_bernstein PolishSpace.borelSchroederBernstein
+-/
 
+#print PolishSpace.measurableEquivNatBoolOfNotCountable /-
 /-- Any uncountable Polish space is Borel isomorphic to the Cantor space `ℕ → bool`.-/
 noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) :=
   by
@@ -825,12 +914,16 @@ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α
   obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_nat_bool_of_countablyGenerated α
   exact ⟨borel_schroeder_bernstein gmeas ginj fcts.measurable finj⟩
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
+-/
 
+#print PolishSpace.measurableEquivOfNotCountable /-
 /-- The **Borel Isomorphism Theorem**: Any two uncountable Polish spaces are Borel isomorphic.-/
 noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
   (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm
 #align polish_space.measurable_equiv_of_not_countable PolishSpace.measurableEquivOfNotCountable
+-/
 
+#print PolishSpace.Equiv.measurableEquiv /-
 /-- The **Borel Isomorphism Theorem**: If two Polish spaces have the same cardinality,
 they are Borel isomorphic.-/
 noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
@@ -842,6 +935,7 @@ noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
   refine' measurable_equiv_of_not_countable h _
   rwa [e.countable_iff] at h
 #align polish_space.equiv.measurable_equiv PolishSpace.Equiv.measurableEquiv
+-/
 
 end PolishSpace
 
@@ -853,6 +947,12 @@ instance [PolishSpace α] : PolishSpace (univ : Set α) :=
 
 variable (α) [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
 
+/- warning: measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite -> MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite is a dubious translation:
+lean 3 declaration is
+  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Finite.{succ u1} α], Exists.{1} Nat (fun (n : Nat) => Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (coeSort.{1, 2} (Set.{0} Real) Type (Set.hasCoeToSort.{0} Real) (Set.range.{0, 1} Real (Fin n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) (Fin n) Real (HasLiftT.mk.{1, 1} (Fin n) Real (CoeTCₓ.coe.{1, 1} (Fin n) Real (coeTrans.{1, 1, 1} (Fin n) Nat Real (Nat.castCoe.{0} Real Real.hasNatCast) (Fin.coeToNat n))))))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.range.{0, 1} Real (Fin n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) (Fin n) Real (HasLiftT.mk.{1, 1} (Fin n) Real (CoeTCₓ.coe.{1, 1} (Fin n) Real (coeTrans.{1, 1, 1} (Fin n) Nat Real (Nat.castCoe.{0} Real Real.hasNatCast) (Fin.coeToNat n))))))) Real.measurableSpace)))
+but is expected to have type
+  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Finite.{succ u1} α], Exists.{1} Nat (fun (n : Nat) => Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (Set.Elem.{0} Real (Set.range.{0, 1} Real (Fin n) (fun (x : Fin n) => Nat.cast.{0} Real Real.natCast (Fin.val n x)))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.range.{0, 1} Real (Fin n) (fun (x : Fin n) => Nat.cast.{0} Real Real.natCast (Fin.val n x)))) Real.measurableSpace)))
+Case conversion may be inaccurate. Consider using '#align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finiteₓ'. -/
 theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
     ∃ n : ℕ, Nonempty (α ≃ᵐ range (coe : Fin n → ℝ)) :=
   by
@@ -861,6 +961,12 @@ theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
   exact Equiv.ofInjective _ (nat.cast_injective.comp Fin.val_injective)
 #align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite
 
+/- warning: measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable -> MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable is a dubious translation:
+lean 3 declaration is
+  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Infinite.{succ u1} α] [_inst_6 : Countable.{succ u1} α], Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (coeSort.{1, 2} (Set.{0} Real) Type (Set.hasCoeToSort.{0} Real) (Set.range.{0, 1} Real Nat ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast)))))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.Mem.{0, 0} Real (Set.{0} Real) (Set.hasMem.{0} Real) x (Set.range.{0, 1} Real Nat ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast)))))) Real.measurableSpace))
+but is expected to have type
+  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : MeasurableSpace.{u1} α] [_inst_3 : PolishSpace.{u1} α _inst_1] [_inst_4 : BorelSpace.{u1} α _inst_1 _inst_2] [_inst_5 : Infinite.{succ u1} α] [_inst_6 : Countable.{succ u1} α], Nonempty.{succ u1} (MeasurableEquiv.{u1, 0} α (Set.Elem.{0} Real (Set.range.{0, 1} Real Nat (Nat.cast.{0} Real Real.natCast))) _inst_2 (Subtype.instMeasurableSpace.{0} Real (fun (x : Real) => Membership.mem.{0, 0} Real (Set.{0} Real) (Set.instMembershipSet.{0} Real) x (Set.range.{0, 1} Real Nat (Nat.cast.{0} Real Real.natCast))) Real.measurableSpace))
+Case conversion may be inaccurate. Consider using '#align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countableₓ'. -/
 theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] :
     Nonempty (α ≃ᵐ range (coe : ℕ → ℝ)) :=
   by
@@ -871,6 +977,7 @@ theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Co
   exact Equiv.ofInjective coe Nat.cast_injective
 #align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable
 
+#print MeasureTheory.exists_subset_real_measurableEquiv /-
 /-- Any Polish Borel space is measurably equivalent to a subset of the reals. -/
 theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s ∧ Nonempty (α ≃ᵐ s) :=
   by
@@ -896,13 +1003,16 @@ theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s 
     rw [countable_coe_iff]
     exact Cardinal.not_countable_real
 #align measure_theory.exists_subset_real_measurable_equiv MeasureTheory.exists_subset_real_measurableEquiv
+-/
 
+#print MeasureTheory.exists_measurableEmbedding_real /-
 /-- Any Polish Borel space embeds measurably into the reals. -/
 theorem exists_measurableEmbedding_real : ∃ f : α → ℝ, MeasurableEmbedding f :=
   by
   obtain ⟨s, hs, ⟨e⟩⟩ := exists_subset_real_measurable_equiv α
   exact ⟨coe ∘ e, (MeasurableEmbedding.subtype_coe hs).comp e.measurable_embedding⟩
 #align measure_theory.exists_measurable_embedding_real MeasureTheory.exists_measurableEmbedding_real
+-/
 
 end MeasureTheory
 
Diff
@@ -661,7 +661,7 @@ theorem MeasurableSet.image_of_measurable_injOn [SecondCountableTopology β] (hs
     f_meas.exists_continuous
   have M : measurable_set[@borel γ t'] s :=
     @Continuous.measurable γ γ t' (@borel γ t')
-      (@BorelSpace.opens_measurable γ t' (@borel γ t')
+      (@BorelSpace.opensMeasurable γ t' (@borel γ t')
         (by
           constructor
           rfl))
@@ -730,7 +730,7 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s :=
   -- the set `s` is measurable for `t'` as it is closed.
   have M : @MeasurableSet γ (@borel γ t') s :=
     @IsClosed.measurableSet γ s t' (@borel γ t')
-      (@BorelSpace.opens_measurable γ t' (@borel γ t')
+      (@BorelSpace.opensMeasurable γ t' (@borel γ t')
         (by
           constructor
           rfl))
Diff
@@ -4,13 +4,13 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 3905fa80e62c0898131285baab35559fbc4e5cda
+! leanprover-community/mathlib commit bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Data.Real.Cardinality
 import Mathbin.Topology.Perfect
-import Mathbin.MeasureTheory.Constructions.BorelSpace
+import Mathbin.MeasureTheory.Constructions.BorelSpace.Basic
 
 /-!
 # The Borel sigma-algebra on Polish spaces
Diff
@@ -151,7 +151,7 @@ theorem AnalyticSet.image_of_continuous {β : Type _} [TopologicalSpace β] {s :
 #align measure_theory.analytic_set.image_of_continuous MeasureTheory.AnalyticSet.image_of_continuous
 
 /-- A countable intersection of analytic sets is analytic. -/
-theorem AnalyticSet.interᵢ [hι : Nonempty ι] [Countable ι] [T2Space α] {s : ι → Set α}
+theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s : ι → Set α}
     (hs : ∀ n, AnalyticSet (s n)) : AnalyticSet (⋂ n, s n) :=
   by
   rcases hι with ⟨i₀⟩
@@ -165,7 +165,7 @@ theorem AnalyticSet.interᵢ [hι : Nonempty ι] [Countable ι] [T2Space α] {s
   let γ := ∀ n, β n
   let t : Set γ := ⋂ n, { x | f n (x n) = f i₀ (x i₀) }
   have t_closed : IsClosed t := by
-    apply isClosed_interᵢ
+    apply isClosed_iInter
     intro n
     exact
       isClosed_eq ((f_cont n).comp (continuous_apply n)) ((f_cont i₀).comp (continuous_apply i₀))
@@ -193,10 +193,10 @@ theorem AnalyticSet.interᵢ [hι : Nonempty ι] [Countable ι] [T2Space α] {s
       exact hx i₀
   rw [← F_range]
   exact analytic_set_range_of_polish_space F_cont
-#align measure_theory.analytic_set.Inter MeasureTheory.AnalyticSet.interᵢ
+#align measure_theory.analytic_set.Inter MeasureTheory.AnalyticSet.iInter
 
 /-- A countable union of analytic sets is analytic. -/
-theorem AnalyticSet.unionᵢ [Countable ι] {s : ι → Set α} (hs : ∀ n, AnalyticSet (s n)) :
+theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, AnalyticSet (s n)) :
     AnalyticSet (⋃ n, s n) :=
   by
   /- For the proof, write each `s n` as the continuous image under a map `f n` of a
@@ -218,7 +218,7 @@ theorem AnalyticSet.unionᵢ [Countable ι] {s : ι → Set α} (hs : ∀ n, Ana
     rw [← f_range n]
   rw [← F_range]
   exact analytic_set_range_of_polish_space F_cont
-#align measure_theory.analytic_set.Union MeasureTheory.AnalyticSet.unionᵢ
+#align measure_theory.analytic_set.Union MeasureTheory.AnalyticSet.iUnion
 
 theorem IsClosed.analyticSet [PolishSpace α] {s : Set α} (hs : IsClosed s) : AnalyticSet s :=
   by
@@ -286,7 +286,7 @@ def MeasurablySeparable {α : Type _} [MeasurableSpace α] (s t : Set α) : Prop
   ∃ u, s ⊆ u ∧ Disjoint t u ∧ MeasurableSet u
 #align measure_theory.measurably_separable MeasureTheory.MeasurablySeparable
 
-theorem MeasurablySeparable.unionᵢ [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
+theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
     (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) :=
   by
   choose u hsu htu hu using h
@@ -297,9 +297,9 @@ theorem MeasurablySeparable.unionᵢ [Countable ι] {α : Type _} [MeasurableSpa
     intro n m
     apply Disjoint.mono_right _ (htu m n)
     apply Inter_subset
-  · refine' MeasurableSet.unionᵢ fun m => _
-    exact MeasurableSet.interᵢ fun n => hu m n
-#align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.unionᵢ
+  · refine' MeasurableSet.iUnion fun m => _
+    exact MeasurableSet.iInter fun n => hu m n
+#align measure_theory.measurably_separable.Union MeasureTheory.MeasurablySeparable.iUnion
 
 /-- The hard part of the Lusin separation theorem saying that two disjoint analytic sets are
 contained in disjoint Borel sets (see the full statement in `analytic_set.measurably_separable`).
@@ -511,14 +511,14 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       by
       intro b
       refine' is_closed_closure.measurable_set.inter _
-      refine' MeasurableSet.interᵢ fun s => _
-      exact MeasurableSet.interᵢ fun hs => (q_meas _).diffₓ (q_meas _)
+      refine' MeasurableSet.iInter fun s => _
+      exact MeasurableSet.iInter fun hs => (q_meas _).diffₓ (q_meas _)
     have F_meas : ∀ n, MeasurableSet (F n) := by
       intro n
-      refine' MeasurableSet.unionᵢ fun s => _
-      exact MeasurableSet.unionᵢ fun hs => E_meas _
+      refine' MeasurableSet.iUnion fun s => _
+      exact MeasurableSet.iUnion fun hs => E_meas _
     rw [this]
-    exact MeasurableSet.interᵢ fun n => F_meas n
+    exact MeasurableSet.iInter fun n => F_meas n
   -- we check both inclusions.
   apply subset.antisymm
   -- we start with the easy inclusion `range f ⊆ ⋂ F n`. One just needs to unfold the definitions.
@@ -765,13 +765,13 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
   simp_rw [and_iff_right (hl.map _),
     Filter.HasBasis.le_basis_iff (this _).to_hasBasis Metric.uniformity_basis_dist_inv_nat_succ,
     Set.setOf_forall]
-  refine' MeasurableSet.binterᵢ Set.countable_univ fun K _ => _
+  refine' MeasurableSet.biInter Set.countable_univ fun K _ => _
   simp_rw [Set.setOf_exists]
-  refine' MeasurableSet.bunionᵢ Set.countable_univ fun N hN => _
+  refine' MeasurableSet.biUnion Set.countable_univ fun N hN => _
   simp_rw [prod_image_image_eq, image_subset_iff, prod_subset_iff, Set.setOf_forall]
   exact
-    MeasurableSet.binterᵢ (to_countable (u N)) fun i _ =>
-      MeasurableSet.binterᵢ (to_countable (u N)) fun j _ =>
+    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
 #align measure_theory.measurable_set_exists_tendsto MeasureTheory.measurableSet_exists_tendsto
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 11d5ff217c07a8070cddfc5d94608854306f7f68
+! leanprover-community/mathlib commit 3905fa80e62c0898131285baab35559fbc4e5cda
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -52,8 +52,10 @@ analytic sets.
 
 We use this to prove several versions of the Borel isomorphism theorem.
 
-* `measurable_equiv_of_not_countable` : Any two uncountable Polish spaces are Borel isomorphic.
-* `equiv.measurable_equiv` : Any two Polish spaces of the same cardinality are Borel. isomorphic.
+* `polish_space.measurable_equiv_of_not_countable` : Any two uncountable Polish spaces
+  are Borel isomorphic.
+* `polish_space.equiv.measurable_equiv` : Any two Polish spaces of the same cardinality
+  are Borel isomorphic.
 -/
 
 
@@ -820,7 +822,7 @@ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α
   obtain ⟨f, -, fcts, finj⟩ :=
     is_closed_univ.exists_nat_bool_injection_of_not_countable
       (by rwa [← countable_coe_iff, (Equiv.Set.univ _).countable_iff])
-  obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_cantor_of_countablyGenerated α
+  obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_nat_bool_of_countablyGenerated α
   exact ⟨borel_schroeder_bernstein gmeas ginj fcts.measurable finj⟩
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
 
Diff
@@ -4,10 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 9b2b58d6b14b895b2f375108e765cb47de71aebd
+! leanprover-community/mathlib commit 11d5ff217c07a8070cddfc5d94608854306f7f68
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
+import Mathbin.Data.Real.Cardinality
 import Mathbin.Topology.Perfect
 import Mathbin.MeasureTheory.Constructions.BorelSpace
 
@@ -788,34 +789,32 @@ instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopolo
   exact this.polish_space
 #align polish_of_countable polish_of_countable
 
+namespace PolishSpace
+
 /-Note: This is to avoid a loop in TC inference. When ported to Lean 4, this will not
 be necessary, and `second_countable_of_polish` should probably
 just be added as an instance soon after the definition of `polish_space`.-/
 private theorem second_countable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
   h.second_countable
-#align second_countable_of_polish second_countable_of_polish
+#align polish_space.second_countable_of_polish polish_space.second_countable_of_polish
 
 attribute [-instance] polishSpace_of_complete_second_countable
 
 attribute [local instance] second_countable_of_polish
 
-namespace PolishSpace
-
 variable {β : Type _} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
 
 variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
 
-noncomputable section
-
 /-- If two Polish spaces admit Borel measurable injections to one another,
 then they are Borel isomorphic.-/
-def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
+noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
     (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β :=
   (fmeas.MeasurableEmbedding finj).schroeder_bernstein (gmeas.MeasurableEmbedding ginj)
 #align polish_space.borel_schroeder_bernstein PolishSpace.borelSchroederBernstein
 
 /-- Any uncountable Polish space is Borel isomorphic to the Cantor space `ℕ → bool`.-/
-def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) :=
+noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) :=
   by
   apply Nonempty.some
   obtain ⟨f, -, fcts, finj⟩ :=
@@ -826,13 +825,13 @@ def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ 
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
 
 /-- The **Borel Isomorphism Theorem**: Any two uncountable Polish spaces are Borel isomorphic.-/
-def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
+noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
   (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm
 #align polish_space.measurable_equiv_of_not_countable PolishSpace.measurableEquivOfNotCountable
 
 /-- The **Borel Isomorphism Theorem**: If two Polish spaces have the same cardinality,
 they are Borel isomorphic.-/
-def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
+noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
   by
   by_cases h : Countable α
   · letI := h
@@ -844,3 +843,64 @@ def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
 
 end PolishSpace
 
+namespace MeasureTheory
+
+-- todo after the port: move to topology/metric_space/polish
+instance [PolishSpace α] : PolishSpace (univ : Set α) :=
+  isClosed_univ.PolishSpace
+
+variable (α) [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
+
+theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
+    ∃ n : ℕ, Nonempty (α ≃ᵐ range (coe : Fin n → ℝ)) :=
+  by
+  obtain ⟨n, ⟨n_equiv⟩⟩ := Finite.exists_equiv_fin α
+  refine' ⟨n, ⟨PolishSpace.Equiv.measurableEquiv (n_equiv.trans _)⟩⟩
+  exact Equiv.ofInjective _ (nat.cast_injective.comp Fin.val_injective)
+#align measure_theory.exists_nat_measurable_equiv_range_coe_fin_of_finite MeasureTheory.exists_nat_measurableEquiv_range_coe_fin_of_finite
+
+theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] :
+    Nonempty (α ≃ᵐ range (coe : ℕ → ℝ)) :=
+  by
+  have : PolishSpace (range (coe : ℕ → ℝ)) :=
+    nat.closed_embedding_coe_real.is_closed_map.closed_range.polish_space
+  refine' ⟨PolishSpace.Equiv.measurableEquiv _⟩
+  refine' (nonempty_equiv_of_countable.some : α ≃ ℕ).trans _
+  exact Equiv.ofInjective coe Nat.cast_injective
+#align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable
+
+/-- Any Polish Borel space is measurably equivalent to a subset of the reals. -/
+theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s ∧ Nonempty (α ≃ᵐ s) :=
+  by
+  by_cases hα : Countable α
+  · cases finite_or_infinite α
+    · obtain ⟨n, h_nonempty_equiv⟩ := exists_nat_measurable_equiv_range_coe_fin_of_finite α
+      refine' ⟨_, _, h_nonempty_equiv⟩
+      letI : MeasurableSpace (Fin n) := borel (Fin n)
+      haveI : BorelSpace (Fin n) := ⟨rfl⟩
+      refine' MeasurableEmbedding.measurableSet_range _
+      · infer_instance
+      ·
+        exact
+          continuous_of_discrete_topology.measurable_embedding
+            (nat.cast_injective.comp Fin.val_injective)
+    · refine' ⟨_, _, measurable_equiv_range_coe_nat_of_infinite_of_countable α⟩
+      refine' MeasurableEmbedding.measurableSet_range _
+      · infer_instance
+      · exact continuous_of_discrete_topology.measurable_embedding Nat.cast_injective
+  · refine'
+      ⟨univ, MeasurableSet.univ,
+        ⟨(PolishSpace.measurableEquivOfNotCountable hα _ : α ≃ᵐ (univ : Set ℝ))⟩⟩
+    rw [countable_coe_iff]
+    exact Cardinal.not_countable_real
+#align measure_theory.exists_subset_real_measurable_equiv MeasureTheory.exists_subset_real_measurableEquiv
+
+/-- Any Polish Borel space embeds measurably into the reals. -/
+theorem exists_measurableEmbedding_real : ∃ f : α → ℝ, MeasurableEmbedding f :=
+  by
+  obtain ⟨s, hs, ⟨e⟩⟩ := exists_subset_real_measurable_equiv α
+  exact ⟨coe ∘ e, (MeasurableEmbedding.subtype_coe hs).comp e.measurable_embedding⟩
+#align measure_theory.exists_measurable_embedding_real MeasureTheory.exists_measurableEmbedding_real
+
+end MeasureTheory
+
Diff
@@ -1,14 +1,14 @@
 /-
 Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Sébastien Gouëzel
+Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit bcfa726826abd57587355b4b5b7e78ad6527b7e4
+! leanprover-community/mathlib commit 9b2b58d6b14b895b2f375108e765cb47de71aebd
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.Topology.MetricSpace.Polish
+import Mathbin.Topology.Perfect
 import Mathbin.MeasureTheory.Constructions.BorelSpace
 
 /-!
@@ -34,7 +34,7 @@ Then, we show Lusin's theorem that two disjoint analytic sets can be separated b
 * `analytic_set.measurably_separable` shows that two disjoint analytic sets are separated by a
   Borel set.
 
-Finally, we prove the Lusin-Souslin theorem that a continuous injective image of a Borel subset of
+We then prove the Lusin-Souslin theorem that a continuous injective image of a Borel subset of
 a Polish space is Borel. The proof of this nontrivial result relies on the above results on
 analytic sets.
 
@@ -48,6 +48,11 @@ analytic sets.
   to a second-countable topological space is a measurable embedding.
 * `is_clopenable_iff_measurable_set`: in a Polish space, a set is clopenable (i.e., it can be made
   open and closed by using a finer Polish topology) if and only if it is Borel-measurable.
+
+We use this to prove several versions of the Borel isomorphism theorem.
+
+* `measurable_equiv_of_not_countable` : Any two uncountable Polish spaces are Borel isomorphic.
+* `equiv.measurable_equiv` : Any two Polish spaces of the same cardinality are Borel. isomorphic.
 -/
 
 
@@ -769,3 +774,73 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
 
 end MeasureTheory
 
+/-! ### The Borel Isomorphism Theorem -/
+
+
+--Note: Move to topology/metric_space/polish when porting.
+instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
+    PolishSpace α := by
+  obtain ⟨f, hf⟩ := h.exists_injective_nat
+  have : ClosedEmbedding f :=
+    by
+    apply closedEmbedding_of_continuous_injective_closed continuous_of_discreteTopology hf
+    exact fun t _ => isClosed_discrete _
+  exact this.polish_space
+#align polish_of_countable polish_of_countable
+
+/-Note: This is to avoid a loop in TC inference. When ported to Lean 4, this will not
+be necessary, and `second_countable_of_polish` should probably
+just be added as an instance soon after the definition of `polish_space`.-/
+private theorem second_countable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
+  h.second_countable
+#align second_countable_of_polish second_countable_of_polish
+
+attribute [-instance] polishSpace_of_complete_second_countable
+
+attribute [local instance] second_countable_of_polish
+
+namespace PolishSpace
+
+variable {β : Type _} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
+
+variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
+
+noncomputable section
+
+/-- If two Polish spaces admit Borel measurable injections to one another,
+then they are Borel isomorphic.-/
+def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
+    (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β :=
+  (fmeas.MeasurableEmbedding finj).schroeder_bernstein (gmeas.MeasurableEmbedding ginj)
+#align polish_space.borel_schroeder_bernstein PolishSpace.borelSchroederBernstein
+
+/-- Any uncountable Polish space is Borel isomorphic to the Cantor space `ℕ → bool`.-/
+def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) :=
+  by
+  apply Nonempty.some
+  obtain ⟨f, -, fcts, finj⟩ :=
+    is_closed_univ.exists_nat_bool_injection_of_not_countable
+      (by rwa [← countable_coe_iff, (Equiv.Set.univ _).countable_iff])
+  obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_cantor_of_countablyGenerated α
+  exact ⟨borel_schroeder_bernstein gmeas ginj fcts.measurable finj⟩
+#align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
+
+/-- The **Borel Isomorphism Theorem**: Any two uncountable Polish spaces are Borel isomorphic.-/
+def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
+  (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm
+#align polish_space.measurable_equiv_of_not_countable PolishSpace.measurableEquivOfNotCountable
+
+/-- The **Borel Isomorphism Theorem**: If two Polish spaces have the same cardinality,
+they are Borel isomorphic.-/
+def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β :=
+  by
+  by_cases h : Countable α
+  · letI := h
+    letI := Countable.of_equiv α e
+    use e <;> apply measurable_of_countable
+  refine' measurable_equiv_of_not_countable h _
+  rwa [e.countable_iff] at h
+#align polish_space.equiv.measurable_equiv PolishSpace.Equiv.measurableEquiv
+
+end PolishSpace
+
Diff
@@ -241,7 +241,7 @@ theorem MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [Polis
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ is_closed[t'] s ∧ is_open[t'] s :=
     hs.is_clopenable
   have A := @IsClosed.analyticSet α t' t'_polish s s_closed
-  convert @analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
+  convert@analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
   simp only [id.def, image_id']
 #align measurable_set.analytic_set MeasurableSet.analyticSet
 
@@ -381,7 +381,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   have M : ∀ n, ¬measurably_separable (f '' cylinder x n) (g '' cylinder y n) :=
     by
     intro n
-    convert (p n).2 using 3
+    convert(p n).2 using 3
     · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff]
       intro i hi
       rw [hx]
Diff
@@ -564,7 +564,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
     have cauchy_y : CauchySeq y :=
       by
       have : tendsto (fun n => 2 * u n) at_top (𝓝 0) := by
-        simpa only [mul_zero] using u_lim.const_mul 2
+        simpa only [MulZeroClass.mul_zero] using u_lim.const_mul 2
       apply cauchySeq_of_le_tendsto_0' (fun n => 2 * u n) (fun m n hmn => _) this
       rcases I m n with ⟨z, zsm, zsn⟩
       calc
Diff
@@ -570,8 +570,8 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       calc
         dist (y m) (y n) ≤ dist (y m) z + dist z (y n) := dist_triangle _ _ _
         _ ≤ u m + u n :=
-          add_le_add ((dist_le_diam_of_mem (hs m).1 (hy m) zsm).trans (hs m).2)
-            ((dist_le_diam_of_mem (hs n).1 zsn (hy n)).trans (hs n).2)
+          (add_le_add ((dist_le_diam_of_mem (hs m).1 (hy m) zsm).trans (hs m).2)
+            ((dist_le_diam_of_mem (hs n).1 zsn (hy n)).trans (hs n).2))
         _ ≤ 2 * u m := by linarith [u_anti.antitone hmn]
         
     haveI : Nonempty γ := ⟨y 0⟩
@@ -601,7 +601,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
       calc
         dist a z ≤ dist a (y n) + dist (y n) z := dist_triangle _ _ _
         _ ≤ u n + dist (y n) z :=
-          add_le_add_right ((dist_le_diam_of_mem (hs n).1 ha (hy n)).trans (hs n).2) _
+          (add_le_add_right ((dist_le_diam_of_mem (hs n).1 ha (hy n)).trans (hs n).2) _)
         _ < δ := hn
         
     -- as `x` belongs to the closure of `f '' (s n)`, it belongs to the closure of `v`.

Changes in mathlib4

mathlib3
mathlib4
feat(MeasureTheory/Constructions/Polish): generalize topological assumptions to measurable ones. (#12069)

Several theorems in MeasureTheory/Constructions/Polish.lean about measurable sets, functions, etc. assume that a space is a BorelSpace or OpensMeasurableSpace for some nice topology. This PR removes the topological data from such theorems when possible, replacing them with sufficient and natural assumptions on MeasurableSpace's.

The old versions of the theorems still work automatically thanks to TC inference.

TODO: Add CountablySeparated typeclass abbreviating HasCountableSeparatingOn _ MeasurableSet univ.

Co-authored-by: Felix-Weilacher <112423742+Felix-Weilacher@users.noreply.github.com>

Diff
@@ -6,6 +6,7 @@ Authors: Sébastien Gouëzel, Felix Weilacher
 import Mathlib.Data.Real.Cardinality
 import Mathlib.Topology.MetricSpace.Perfect
 import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
+import Mathlib.Topology.CountableSeparatingOn
 
 #align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
 
@@ -533,18 +534,20 @@ end MeasureTheory
 
 namespace Measurable
 
-variable {X Y β : Type*} [MeasurableSpace X] [StandardBorelSpace X]
-  [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
+variable {X Y Z β : Type*} [MeasurableSpace X] [StandardBorelSpace X]
+  [TopologicalSpace Y] [T0Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
+  [MeasurableSpace Z]
 
-/-- If `f : X → Y` is a surjective Borel measurable map from a standard Borel space
-to a topological space with second countable topology, then the preimage of a set `s`
+/-- If `f : X → Z` is a surjective Borel measurable map from a standard Borel space
+to a countably separated measurable space, then the preimage of a set `s`
 is measurable if and only if the set is measurable.
 One implication is the definition of measurability, the other one heavily relies on `X` being a
 standard Borel space. -/
-theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
-    (hf : Measurable f) (hsurj : Surjective f) {s : Set Y} :
+theorem measurableSet_preimage_iff_of_surjective [HasCountableSeparatingOn Z MeasurableSet univ]
+    {f : X → Z} (hf : Measurable f) (hsurj : Surjective f) {s : Set Z} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet s := by
   refine ⟨fun h => ?_, fun h => hf h⟩
+  rcases exists_opensMeasurableSpace_of_hasCountableSeparatingOn Z with ⟨τ, _, _, _⟩
   apply AnalyticSet.measurableSet_of_compl
   · rw [← image_preimage_eq s hsurj]
     exact h.analyticSet_image hf
@@ -552,8 +555,9 @@ theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f
     exact h.compl.analyticSet_image hf
 #align measurable.measurable_set_preimage_iff_of_surjective Measurable.measurableSet_preimage_iff_of_surjective
 
-theorem map_measurableSpace_eq [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
-    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Y› :=
+theorem map_measurableSpace_eq  [HasCountableSeparatingOn Z MeasurableSet univ]
+    {f : X → Z} (hf : Measurable f)
+    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Z› :=
   MeasurableSpace.ext fun _ => hf.measurableSet_preimage_iff_of_surjective hsurj
 #align measurable.map_measurable_space_eq Measurable.map_measurableSpace_eq
 
@@ -569,49 +573,53 @@ theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Meas
   ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩
 #align measurable.borel_space_codomain Measurable.borelSpace_codomain
 
-/-- If `f : X → Y` is a Borel measurable map from a standard Borel space to a topological space
-with second countable topology, then the preimage of a set `s` is measurable if and only if
-the set is measurable in `Set.range f`. -/
-theorem measurableSet_preimage_iff_preimage_val {f : X → Y} [SecondCountableTopology (range f)]
-    (hf : Measurable f) {s : Set Y} :
+/-- If `f : X → Z` is a Borel measurable map from a standard Borel space to a
+countably separated measurable space then the preimage of a set `s` is measurable
+if and only if the set is measurable in `Set.range f`. -/
+theorem measurableSet_preimage_iff_preimage_val {f : X → Z}
+    [HasCountableSeparatingOn (range f) MeasurableSet univ]
+    (hf : Measurable f) {s : Set Z} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet ((↑) ⁻¹' s : Set (range f)) :=
   have hf' : Measurable (rangeFactorization f) := hf.subtype_mk
   hf'.measurableSet_preimage_iff_of_surjective (s := Subtype.val ⁻¹' s) surjective_onto_range
 #align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_val
 
-/-- If `f : X → Y` is a Borel measurable map from a standard Borel space to a
-topological space with second countable topology and the range of `f` is measurable,
+/-- If `f : X → Z` is a Borel measurable map from a standard Borel space to a
+countably separated measurable space and the range of `f` is measurable,
 then the preimage of a set `s` is measurable
 if and only if the intesection with `Set.range f` is measurable. -/
-theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTopology (range f)]
-    (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Y} :
+theorem measurableSet_preimage_iff_inter_range {f : X → Z}
+    [HasCountableSeparatingOn (range f) MeasurableSet univ]
+    (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Z} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by
   rw [hf.measurableSet_preimage_iff_preimage_val, inter_comm,
     ← (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
 #align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
 
-/-- If `f : X → Y` is a Borel measurable map from a standard Borel space
-to a topological space with second countable topology,
-then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
+/-- If `f : X → Z` is a Borel measurable map from a standard Borel space
+to a countably separated measurable space,
+then for any measurable space `β` and `g : Z → β`, the composition `g ∘ f` is
 measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
-theorem measurable_comp_iff_restrict {f : X → Y} [SecondCountableTopology (range f)]
-    (hf : Measurable f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
+theorem measurable_comp_iff_restrict {f : X → Z}
+    [HasCountableSeparatingOn (range f) MeasurableSet univ]
+    (hf : Measurable f) {g : Z → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
   forall₂_congr fun s _ => measurableSet_preimage_iff_preimage_val hf (s := g ⁻¹' s)
 #align measurable.measurable_comp_iff_restrict Measurable.measurable_comp_iff_restrict
 
-/-- If `f : X → Y` is a surjective Borel measurable map from a standard Borel space
-to a topological space with second countable topology,
-then for any measurable space `α` and `g : Y → α`, the composition
+/-- If `f : X → Z` is a surjective Borel measurable map from a standard Borel space
+to a countably separated measurable space,
+then for any measurable space `α` and `g : Z → α`, the composition
 `g ∘ f` is measurable if and only if `g` is measurable. -/
-theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
-    (hf : Measurable f) (hsurj : Surjective f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable g :=
+theorem measurable_comp_iff_of_surjective [HasCountableSeparatingOn Z MeasurableSet univ]
+    {f : X → Z} (hf : Measurable f) (hsurj : Surjective f)
+    {g : Z → β} : Measurable (g ∘ f) ↔ Measurable g :=
   forall₂_congr fun s _ => measurableSet_preimage_iff_of_surjective hf hsurj (s := g ⁻¹' s)
 #align measurable.measurable_comp_iff_of_surjective Measurable.measurable_comp_iff_of_surjective
 
 end Measurable
 
 theorem Continuous.map_eq_borel {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
-    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y]
+    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T0Space Y] [SecondCountableTopology Y]
     {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) :
     MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by
   borelize Y
@@ -619,14 +627,14 @@ theorem Continuous.map_eq_borel {X Y : Type*} [TopologicalSpace X] [PolishSpace
 #align continuous.map_eq_borel Continuous.map_eq_borel
 
 theorem Continuous.map_borel_eq {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
-    [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
+    [TopologicalSpace Y] [T0Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
     (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y := by
   borelize X
   exact hf.map_eq_borel hsurj
 #align continuous.map_borel_eq Continuous.map_borel_eq
 
 instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
-    [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
+    [BorelSpace X] {s : Setoid X} [T0Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
     BorelSpace (Quotient s) :=
   ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk' _)⟩
 #align quotient.borel_space Quotient.borelSpace
@@ -822,7 +830,8 @@ theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn
   · rwa [injOn_iff_injective] at f_inj
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
 
-variable {β : Type*} [tβ : TopologicalSpace β] [T2Space β] [MeasurableSpace β]
+variable {α β : Type*} [tβ : TopologicalSpace β] [T2Space β] [MeasurableSpace β]
+  [MeasurableSpace α]
   {s : Set γ} {f : γ → β}
 
 /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
@@ -841,17 +850,19 @@ theorem _root_.MeasurableSet.image_of_continuousOn_injOn [OpensMeasurableSpace 
 
 /-- 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 β]
+countably separate measurable space is also Borel-measurable. -/
+theorem _root_.MeasurableSet.image_of_measurable_injOn {f : γ → α}
+    [HasCountableSeparatingOn α MeasurableSet univ]
+    [MeasurableSpace γ] [StandardBorelSpace γ]
     (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) :
     MeasurableSet (f '' s) := by
   letI := upgradeStandardBorel γ
   let tγ : TopologicalSpace γ := inferInstance
+  rcases exists_opensMeasurableSpace_of_hasCountableSeparatingOn α with ⟨τ, _, _, _⟩
   -- 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' :=
+      ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @Continuous γ _ t' _ f ∧ @PolishSpace γ t' :=
     f_meas.exists_continuous
   have M : MeasurableSet[@borel γ t'] s :=
     @Continuous.measurable γ γ t' (@borel γ t')
@@ -859,8 +870,8 @@ theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
       tγ _ _ _ (continuous_id_of_le t't) s hs
   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
+      _ _ _ _  s f _ t' t'_polish (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl)
+      M (@Continuous.continuousOn γ _ t' _ f s f_cont) f_inj
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
 
 /-- An injective continuous function on a Polish space is a measurable embedding. -/
@@ -893,9 +904,10 @@ theorem _root_.ContinuousOn.measurableEmbedding [BorelSpace β]
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
 
 /-- An injective measurable function from a standard Borel space to a
-second-countable topological space is a measurable embedding. -/
-theorem _root_.Measurable.measurableEmbedding [OpensMeasurableSpace β]
-    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
+countably separated measurable space is a measurable embedding. -/
+theorem _root_.Measurable.measurableEmbedding {f : γ → α}
+    [HasCountableSeparatingOn α MeasurableSet univ]
+    [MeasurableSpace γ] [StandardBorelSpace γ]
     (f_meas : Measurable f) (f_inj : Injective f) : MeasurableEmbedding f :=
   { injective := f_inj
     measurable := f_meas
feat(Probability/Kernel): disintegration of finite kernels (#10603)

Let κ : kernel α (β × Ω) be a finite kernel, where Ω is a standard Borel space. Then if α is countable or β has a countably generated σ-algebra (for example if it is standard Borel), then there exists a kernel (α × β) Ω called conditional kernel and denoted by condKernel κ such that κ = fst κ ⊗ₖ condKernel κ.

Properties of integrals involving condKernel are collated in the file Integral.lean. The conditional kernel is unique (almost everywhere w.r.t. fst κ): this is proved in the file Unique.lean.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

Diff
@@ -1091,4 +1091,13 @@ theorem exists_measurableEmbedding_real : ∃ f : α → ℝ, MeasurableEmbeddin
   exact ⟨(↑) ∘ e, (MeasurableEmbedding.subtype_coe hs).comp e.measurableEmbedding⟩
 #align measure_theory.exists_measurable_embedding_real MeasureTheory.exists_measurableEmbedding_real
 
+/-- A measurable embedding of a standard Borel space into `ℝ`. -/
+noncomputable
+def embeddingReal (Ω : Type*) [MeasurableSpace Ω] [StandardBorelSpace Ω] : Ω → ℝ :=
+  (exists_measurableEmbedding_real Ω).choose
+
+lemma measurableEmbedding_embeddingReal (Ω : Type*) [MeasurableSpace Ω] [StandardBorelSpace Ω] :
+    MeasurableEmbedding (embeddingReal Ω) :=
+  (exists_measurableEmbedding_real Ω).choose_spec
+
 end MeasureTheory
chore: avoid id.def (adaptation for nightly-2024-03-27) (#11829)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -313,7 +313,7 @@ theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α]
     hs.isClopenable
   have A := @IsClosed.analyticSet α t' t'_polish s s_closed
   convert @AnalyticSet.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
-  simp only [id.def, image_id']
+  simp only [id, image_id']
 #align measurable_set.analytic_set MeasurableSet.analyticSet
 
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
style: replace '.-/' by '. -/' (#11938)

Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.

Diff
@@ -73,7 +73,7 @@ the natural topology in a space is non-Polish.
 
 To endow a standard Borel space `α` with a compatible Polish topology, use
 `letI := upgradeStandardBorel α`. One can then use `eq_borel_upgradeStandardBorel α` to
-rewrite the `MeasurableSpace α` instance to `borel α t`, where `t` is the new topology.-/
+rewrite the `MeasurableSpace α` instance to `borel α t`, where `t` is the new topology. -/
 class StandardBorelSpace [MeasurableSpace α] : Prop where
   /-- There exists a compatible Polish topology. -/
   polish : ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α
@@ -96,7 +96,7 @@ def upgradeStandardBorel [MeasurableSpace α] [h : StandardBorelSpace α] :
   constructor
 
 /-- The `MeasurableSpace α` instance on a `StandardBorelSpace` `α` is equal to
-the borel sets of `upgradeStandardBorel α`.-/
+the borel sets of `upgradeStandardBorel α`. -/
 theorem eq_borel_upgradeStandardBorel [MeasurableSpace α] [StandardBorelSpace α] :
     ‹MeasurableSpace α› = @borel _ (upgradeStandardBorel α).toTopologicalSpace :=
   @BorelSpace.measurable_eq _ (upgradeStandardBorel α).toTopologicalSpace _
@@ -902,7 +902,7 @@ theorem _root_.Measurable.measurableEmbedding [OpensMeasurableSpace β]
     measurableSet_image' := fun _u hu => hu.image_of_measurable_injOn f_meas (f_inj.injOn _) }
 #align measurable.measurable_embedding Measurable.measurableEmbedding
 
-/-- If one Polish topology on a type refines another, they have the same Borel sets.-/
+/-- 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
@@ -1002,7 +1002,7 @@ variable {β : Type*}
 variable [MeasurableSpace α] [MeasurableSpace β] [StandardBorelSpace α] [StandardBorelSpace β]
 
 /-- If two standard Borel spaces admit Borel measurable injections to one another,
-then they are Borel isomorphic.-/
+then they are Borel isomorphic. -/
 noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
     (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β :=
   letI := upgradeStandardBorel α
@@ -1010,7 +1010,7 @@ noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas
   (fmeas.measurableEmbedding finj).schroederBernstein (gmeas.measurableEmbedding ginj)
 #align polish_space.borel_schroeder_bernstein PolishSpace.borelSchroederBernstein
 
-/-- Any uncountable standard Borel space is Borel isomorphic to the Cantor space `ℕ → Bool`.-/
+/-- Any uncountable standard Borel space is Borel isomorphic to the Cantor space `ℕ → Bool`. -/
 noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) := by
   apply Nonempty.some
   letI := upgradeStandardBorel α
@@ -1023,13 +1023,13 @@ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
 
 /-- The **Borel Isomorphism Theorem**: Any two uncountable standard Borel spaces are
-Borel isomorphic.-/
+Borel isomorphic. -/
 noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
   (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm
 #align polish_space.measurable_equiv_of_not_countable PolishSpace.measurableEquivOfNotCountable
 
 /-- The **Borel Isomorphism Theorem**: If two standard Borel spaces have the same cardinality,
-they are Borel isomorphic.-/
+they are Borel isomorphic. -/
 noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β := by
   by_cases h : Countable α
   · letI := Countable.of_equiv α e
refactor: typeclasses for measures on quotient spaces and groups (#7506)

We introduce a new typeclass QuotientMeasureEqMeasurePreimage which expresses a relationship between a measure on a space and a measure on its quotient under a discrete group action. Namely, the volume of a measurable set in the quotient is equal to the volume of its preimage, intersected with any fundamental domain.

Our main application is in the context of a discrete normal subgroup of a topological group acting on the group itself, so as to compare Haar measures on a group and its quotient. Before this typeclass, you could have Haar measure upstairs and downstairs and you would have ugly scaling factors if you wanted to compare the two. This typeclass more accurately reflects what is needed in order to have a clear relationship between the upstairs and downstairs measures.

Two big theorems (proved under various technical assumptions, like finiteness of the volume - which shouldn't be necessary):

(1) if you're Haar upstairs and satisfy QuotientMeasureEqMeasurePreimage, then you're Haar downstairs.

And conversely (2): if you're Haar upstairs and downstairs, and scale correctly on a single measurable set, then you satisfy QuotientMeasureEqMeasurePreimage.

Contains the forward-port of https://github.com/leanprover-community/mathlib/pull/18863

Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com>

Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com>

Diff
@@ -631,6 +631,16 @@ instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [M
   ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk' _)⟩
 #align quotient.borel_space Quotient.borelSpace
 
+/-- When the subgroup `N < G` is not necessarily `Normal`, we have a `CosetSpace` as opposed
+to `QuotientGroup` (the next `instance`).
+TODO: typeclass inference should normally find this, but currently doesn't.
+E.g., `MeasurableSMul G (G ⧸ Γ)` fails to synthesize, even though `G ⧸ Γ` is the quotient
+of `G` by the action of `Γ`; it seems unable to pick up the `BorelSpace` instance. -/
+@[to_additive AddCosetSpace.borelSpace]
+instance CosetSpace.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G]
+    [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [T2Space (G ⧸ N)]
+    [SecondCountableTopology (G ⧸ N)] : BorelSpace (G ⧸ N) := Quotient.borelSpace
+
 @[to_additive]
 instance QuotientGroup.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G]
     [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.Normal]
feat(MeasureTheory.MeasurableSpace.CountablyGenerated): add SeparatesPoints and related theorems (#11048)

the goal of the PR is to clarify the relationship between the following closely related assumptions on a measurable space:

  • Being countably generated (CountablyGenerated)
  • Separating points (SeparatesPoints)
  • Having a countable separating family of measurable sets (HasCountableSeparatingOn _ MeasurableSet univ)
  • Having singletons be measurable (MeasurableSingletonClass)

It defines SeparatesPoints and registers all implications between combinations of these properties as instances (or rather a minimal set needed to deduce all others).

It also proves an optimal theorem regarding when a measurable space appears as an induced subspace of the Cantor Space Nat -> Bool. This will be used to generalize topological assumptions to measure theoretic ones in some theorems in MeasureTheory.Constructions.Polish.

Co-authored-by: Felix-Weilacher <112423742+Felix-Weilacher@users.noreply.github.com>

Diff
@@ -1007,7 +1007,8 @@ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α
   obtain ⟨f, -, fcts, finj⟩ :=
     isClosed_univ.exists_nat_bool_injection_of_not_countable
       (by rwa [← countable_coe_iff, (Equiv.Set.univ _).countable_iff])
-  obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_nat_bool_of_countablyGenerated α
+  obtain ⟨g, gmeas, ginj⟩ :=
+    MeasurableSpace.measurable_injection_nat_bool_of_hasCountableSeparatingOn α
   exact ⟨borelSchroederBernstein gmeas ginj fcts.measurable finj⟩
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
 
chore: rename open_range to isOpen_range, closed_range to isClosed_range (#11438)

All these lemmas refer to the range of some function being open/range (i.e. isOpen or isClosed).

Diff
@@ -1044,7 +1044,7 @@ theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
 theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] :
     Nonempty (α ≃ᵐ range ((↑) : ℕ → ℝ)) := by
   have : PolishSpace (range ((↑) : ℕ → ℝ)) :=
-    Nat.closedEmbedding_coe_real.isClosedMap.closed_range.polishSpace
+    Nat.closedEmbedding_coe_real.isClosedMap.isClosed_range.polishSpace
   refine' ⟨PolishSpace.Equiv.measurableEquiv _⟩
   refine' (nonempty_equiv_of_countable.some : α ≃ ℕ).trans _
   exact Equiv.ofInjective ((↑) : ℕ → ℝ) Nat.cast_injective
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -989,7 +989,6 @@ end StandardBorelSpace
 namespace PolishSpace
 
 variable {β : Type*}
-
 variable [MeasurableSpace α] [MeasurableSpace β] [StandardBorelSpace α] [StandardBorelSpace β]
 
 /-- If two standard Borel spaces admit Borel measurable injections to one another,
chore: remove tactics (#11365)

More tactics that are not used, found using the linter at #11308.

The PR consists of tactic removals, whitespace changes and replacing a porting note by an explanation.

Diff
@@ -204,7 +204,6 @@ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
       exact range_eq_empty _
     · exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩
   · rintro ⟨β, h, h', f, f_cont, f_range⟩
-    skip
     rw [← f_range]
     exact analyticSet_range_of_polishSpace f_cont
 #align measure_theory.analytic_set_iff_exists_polish_space_range MeasureTheory.analyticSet_iff_exists_polishSpace_range
@@ -213,7 +212,6 @@ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
 theorem AnalyticSet.image_of_continuousOn {β : Type*} [TopologicalSpace β] {s : Set α}
     (hs : AnalyticSet s) {f : α → β} (hf : ContinuousOn f s) : AnalyticSet (f '' s) := by
   rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨γ, γtop, γpolish, g, g_cont, gs⟩
-  skip
   have : f '' s = range (f ∘ g) := by rw [range_comp, gs]
   rw [this]
   apply analyticSet_range_of_polishSpace
@@ -237,7 +235,6 @@ theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s :
     the range of `x ↦ f 0 (x 0)` on `t` is exactly `⋂ n, s n`, so this set is analytic. -/
   choose β hβ h'β f f_cont f_range using fun n =>
     analyticSet_iff_exists_polishSpace_range.1 (hs n)
-  skip
   let γ := ∀ n, β n
   let t : Set γ := ⋂ n, { x | f n (x n) = f i₀ (x i₀) }
   have t_closed : IsClosed t := by
feat(UniformSpace/CompactConvergence): prove metrizability (#10942)
Diff
@@ -946,11 +946,8 @@ theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [Mea
   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
+  have : ∀ x, (map (f · x) l ×ˢ map (f · x) l).HasAntitoneBasis fun n =>
+      ((f · x) '' u n) ×ˢ ((f · 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]
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -638,7 +638,7 @@ instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [M
 instance QuotientGroup.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G]
     [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.Normal]
     [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) :=
-  -- porting note: 1st and 3rd `haveI`s were not needed in Lean 3
+  -- Porting note: 1st and 3rd `haveI`s were not needed in Lean 3
   haveI := Subgroup.t3_quotient_of_isClosed N
   haveI := QuotientGroup.secondCountableTopology (Γ := N)
   Quotient.borelSpace
chore: remove stream-of-conciousness syntax for obtain (#11045)

This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.

Diff
@@ -312,7 +312,7 @@ theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α]
     topology `t'`. It is analytic for this topology. As the identity from `t'` to `t` is continuous
     and the image of an analytic set is analytic, it follows that `s` is also analytic for `t`. -/
   obtain ⟨t', t't, t'_polish, s_closed, _⟩ :
-    ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s :=
+      ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s :=
     hs.isClopenable
   have A := @IsClosed.analyticSet α t' t'_polish s s_closed
   convert @AnalyticSet.image_of_continuous α t' α t s A id (continuous_id_of_le t't)
@@ -326,7 +326,7 @@ theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpac
     [OpensMeasurableSpace β] {f : α → β} [SecondCountableTopology (range f)] (hf : Measurable f) :
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @Continuous α β t' tβ f ∧ @PolishSpace α t' := by
   obtain ⟨b, b_count, -, hb⟩ :
-    ∃ b : Set (Set (range f)), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b :=
+      ∃ b : Set (Set (range f)), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b :=
     exists_countable_basis (range f)
   haveI : Countable b := b_count.to_subtype
   have : ∀ s : b, IsClopenable (rangeFactorization f ⁻¹' s) := fun s ↦ by
@@ -334,7 +334,7 @@ theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpac
     exact hf.subtype_mk (hb.isOpen s.2).measurableSet
   choose T Tt Tpolish _ Topen using this
   obtain ⟨t', t'T, t't, t'_polish⟩ :
-    ∃ t' : TopologicalSpace α, (∀ i, t' ≤ T i) ∧ t' ≤ t ∧ @PolishSpace α t' :=
+      ∃ t' : TopologicalSpace α, (∀ i, t' ≤ T i) ∧ t' ≤ t ∧ @PolishSpace α t' :=
     exists_polishSpace_forall_le T Tt Tpolish
   refine' ⟨t', t't, _, t'_polish⟩
   have : Continuous[t', _] (rangeFactorization f) :=
@@ -475,7 +475,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
       exact (Iy i n hi).symm
   -- consider two open sets separating `f x` and `g y`.
   obtain ⟨u, v, u_open, v_open, xu, yv, huv⟩ :
-    ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ f x ∈ u ∧ g y ∈ v ∧ Disjoint u v := by
+      ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ f x ∈ u ∧ g y ∈ v ∧ Disjoint u v := by
     apply t2_separation
     exact disjoint_iff_forall_ne.1 h (mem_range_self _) (mem_range_self _)
   letI : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
@@ -695,7 +695,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
   let E : b → Set β := fun s =>
     closure (f '' s) ∩ ⋂ (t : b) (ht : Disjoint s.1 t.1), q ⟨(s, t), ht⟩ \ q ⟨(t, s), ht.symm⟩
   obtain ⟨u, u_anti, u_pos, u_lim⟩ :
-    ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) :=
+      ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) :=
     exists_seq_strictAnti_tendsto (0 : ℝ)
   let F : ℕ → Set β := fun n => ⋃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), E s
   -- it is enough to show that `range f = ⋂ F n`, as the latter set is obviously measurable.
@@ -825,7 +825,7 @@ theorem _root_.MeasurableSet.image_of_continuousOn_injOn [OpensMeasurableSpace 
     (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 :=
+      ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s :=
     hs.isClopenable
   exact
     @IsClosed.measurableSet_image_of_continuousOn_injOn γ t' t'_polish β _ _ _ _ s s_closed f
@@ -844,7 +844,7 @@ theorem _root_.MeasurableSet.image_of_measurable_injOn [OpensMeasurableSpace β]
   -- 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' :=
+      ∃ 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')
chore: more backporting of simp changes from #10995 (#11001)

Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -282,7 +282,7 @@ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, Analy
   let F : γ → α := fun ⟨n, x⟩ ↦ f n x
   have F_cont : Continuous F := continuous_sigma f_cont
   have F_range : range F = ⋃ n, s n := by
-    simp only [range_sigma_eq_iUnion_range, f_range]
+    simp only [γ, range_sigma_eq_iUnion_range, f_range]
   rw [← F_range]
   exact analyticSet_range_of_polishSpace F_cont
 #align measure_theory.analytic_set.Union MeasureTheory.AnalyticSet.iUnion
@@ -429,7 +429,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   let p0 : A := ⟨⟨0, fun _ => 0, fun _ => 0⟩, by simp [hfg]⟩
   -- construct inductively decreasing sequences of cylinders whose images are not separated
   let p : ℕ → A := fun n => F^[n] p0
-  have prec : ∀ n, p (n + 1) = F (p n) := fun n => by simp only [iterate_succ', Function.comp]
+  have prec : ∀ n, p (n + 1) = F (p n) := fun n => by simp only [p, iterate_succ', Function.comp]
   -- check that at the `n`-th step we deal with cylinders of length `n`
   have pn_fst : ∀ n, (p n).1.1 = n := by
     intro n
@@ -735,7 +735,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
   · intro x hx
     -- pick for each `n` a good set `s n` of small diameter for which `x ∈ E (s n)`.
     have C1 : ∀ n, ∃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by
-      simpa only [mem_iUnion] using mem_iInter.1 hx n
+      simpa only [F, mem_iUnion] using mem_iInter.1 hx n
     choose s hs hxs using C1
     have C2 : ∀ n, (s n).1.Nonempty := by
       intro n
feat: add measurableSet_tendsto_nhds (#10146)

Add measurableSet_tendsto: the set of points for which a measurable sequence of functions converges to a given filter is measurable.

Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

Diff
@@ -921,6 +921,19 @@ theorem isClopenable_iff_measurableSet
   · exact MeasurableSpace.measurableSet_generateFrom s_open
   infer_instance
 
+/-- The set of points for which a sequence of measurable functions converges to a given function
+is measurable. -/
+@[measurability]
+lemma measurableSet_tendsto_fun [MeasurableSpace γ] [Countable ι]
+    {l : Filter ι} [l.IsCountablyGenerated]
+    [TopologicalSpace γ] [SecondCountableTopology γ] [PseudoMetrizableSpace γ]
+    [OpensMeasurableSpace γ]
+    {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) {g : β → γ} (hg : Measurable g) :
+    MeasurableSet { x | Tendsto (fun n ↦ f n x) l (𝓝 (g x)) } := by
+  letI := TopologicalSpace.pseudoMetrizableSpacePseudoMetric γ
+  simp_rw [tendsto_iff_dist_tendsto_zero (f := fun n ↦ f n _)]
+  exact measurableSet_tendsto (𝓝 0) (fun n ↦ (hf n).dist hg)
+
 /-- The set of points for which a measurable sequence of functions converges is measurable. -/
 @[measurability]
 theorem measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ]
refactor: prefer s ∩ . when passing to a subset of s (#10433)

This is partial work to make s ∩ . be consistently used for passing to a subset of s. This is sort of an adjoint to (Subtype.val : s -> _) '' ., except for the fact that it does not produce a Set s.

The main API changes are to Subtype.image_preimage_val and Subtype.preimage_val_eq_preimage_val_iff in Mathlib.Data.Set.Image. Changes in other modules are all proof fixups.

Zulip discussion

Diff
@@ -589,7 +589,7 @@ if and only if the intesection with `Set.range f` is measurable. -/
 theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Y} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by
-  rw [hf.measurableSet_preimage_iff_preimage_val,
+  rw [hf.measurableSet_preimage_iff_preimage_val, inter_comm,
     ← (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
 #align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
 
refactor(Topology): split Topology.Perfect into two modules (#10272)

Splits Topology.Perfect into two modules: Topology.Perfect, where the existing definition of Perfect and Preperfect are kept, and Topology.MetricSpace.Perfect, in which the theorems specific to metric spaces are moved.

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 -/
 import Mathlib.Data.Real.Cardinality
-import Mathlib.Topology.Perfect
+import Mathlib.Topology.MetricSpace.Perfect
 import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
 
 #align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
feat(Topology/Order): upgrade continuous_generateFrom to an iff (#9259)

Similarly, upgrade tendsto_nhds_generateFrom, IsTopologicalBasis.continuous, Topology.IsLower.continuous_of_Ici, and Topology.IsUpper.continuous_iff_Iic.

The old lemmas are now deprecated, and the new ones have _iff in their names. Once we remove the old lemmas, we can drop the _iff suffixes.

Diff
@@ -338,7 +338,7 @@ theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpac
     exists_polishSpace_forall_le T Tt Tpolish
   refine' ⟨t', t't, _, t'_polish⟩
   have : Continuous[t', _] (rangeFactorization f) :=
-    hb.continuous _ fun s hs => t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
+    hb.continuous_iff.2 fun s hs => t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
   exact continuous_subtype_val.comp this
 #align measurable.exists_continuous Measurable.exists_continuous
 
doc: Mark named theorems (#8749)
Diff
@@ -651,7 +651,7 @@ namespace MeasureTheory
 
 variable {γ : Type*}
 
-/-- The Lusin-Souslin theorem: the range of a continuous injective function defined on a Polish
+/-- The **Lusin-Souslin theorem**: the range of a continuous injective function defined on a Polish
 space is Borel-measurable. -/
 theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpace γ]
     [PolishSpace γ] [TopologicalSpace β] [T2Space β] [MeasurableSpace β] [OpensMeasurableSpace β]
chore: rename by_contra' to by_contra! (#8797)

To fit with the "please try harder" convention of ! tactics.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -749,7 +749,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
     have I : ∀ m n, ((s m).1 ∩ (s n).1).Nonempty := by
       intro m n
       rw [← not_disjoint_iff_nonempty_inter]
-      by_contra' h
+      by_contra! h
       have A : x ∈ q ⟨(s m, s n), h⟩ \ q ⟨(s n, s m), h.symm⟩ :=
         haveI := mem_iInter.1 (hxs m).2 (s n)
         (mem_iInter.1 this h : _)
@@ -777,7 +777,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
       rw [← this]
       exact mem_range_self _
     -- assume for a contradiction that `f z ≠ x`.
-    by_contra' hne
+    by_contra! hne
     -- introduce disjoint open sets `v` and `w` separating `f z` from `x`.
     obtain ⟨v, w, v_open, w_open, fzv, xw, hvw⟩ := t2_separation hne
     obtain ⟨δ, δpos, hδ⟩ : ∃ δ > (0 : ℝ), ball z δ ⊆ f ⁻¹' v := by
chore: use StandardBorelSpace everywhere in the probability folder instead of PolishSpace (#8746)
Diff
@@ -72,18 +72,18 @@ This is useful in situations where a space has no natural topology or
 the natural topology in a space is non-Polish.
 
 To endow a standard Borel space `α` with a compatible Polish topology, use
-`letI := upgradePolishSpace α`. One can then use `eq_borel_upgradeStandardBorel α` to
+`letI := upgradeStandardBorel α`. One can then use `eq_borel_upgradeStandardBorel α` to
 rewrite the `MeasurableSpace α` instance to `borel α t`, where `t` is the new topology.-/
 class StandardBorelSpace [MeasurableSpace α] : Prop where
   /-- There exists a compatible Polish topology. -/
   polish : ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α
 
 /-- A convenience class similar to `UpgradedPolishSpace`. No instance should be registered.
-Instead one should use `letI := upgradePolishSpace α`. -/
+Instead one should use `letI := upgradeStandardBorel α`. -/
 class UpgradedStandardBorel extends MeasurableSpace α, TopologicalSpace α,
   BorelSpace α, PolishSpace α
 
-/-- Use as `letI := upgradePolishSpace α` to endow a standard Borel space `α` with
+/-- Use as `letI := upgradeStandardBorel α` to endow a standard Borel space `α` with
 a compatible Polish topology.
 
 Warning: following this with `borelize α` will cause an error. Instead, one can
feat: preimage of an analytic set is an analytic set (#7805)

Also golf a proof.

Diff
@@ -278,17 +278,11 @@ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, Analy
     coincides with `f n` on `β n` sends it to `⋃ n, s n`. -/
   choose β hβ h'β f f_cont f_range using fun n =>
     analyticSet_iff_exists_polishSpace_range.1 (hs n)
-  skip
   let γ := Σn, β n
-  let F : γ → α := by
-    rintro ⟨n, x⟩
-    exact f n x
+  let F : γ → α := fun ⟨n, x⟩ ↦ f n x
   have F_cont : Continuous F := continuous_sigma f_cont
   have F_range : range F = ⋃ n, s n := by
-    rw [range_sigma_eq_iUnion_range]
-    apply congr_arg
-    ext1 n
-    rw [← f_range n]
+    simp only [range_sigma_eq_iUnion_range, f_range]
   rw [← F_range]
   exact analyticSet_range_of_polishSpace F_cont
 #align measure_theory.analytic_set.Union MeasureTheory.AnalyticSet.iUnion
@@ -311,6 +305,7 @@ theorem _root_.MeasurableSet.isClopenable [PolishSpace α] [MeasurableSpace α]
   · exact fun f _ _ hf => IsClopenable.iUnion hf
 #align measurable_set.is_clopenable MeasurableSet.isClopenable
 
+/-- A Borel-measurable set in a Polish space is analytic. -/
 theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α] [PolishSpace α]
     [MeasurableSpace α] [BorelSpace α] {s : Set α} (hs : MeasurableSet s) : AnalyticSet s := by
   /- For a short proof (avoiding measurable induction), one sees `s` as a closed set for a finer
@@ -362,6 +357,16 @@ theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [MeasurableSpace X]
   exact (hle _ hs).analyticSet.image_of_continuous hfc
 #align measurable_set.analytic_set_image MeasurableSet.analyticSet_image
 
+/-- Preimage of an analytic set is an analytic set. -/
+protected lemma AnalyticSet.preimage {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
+    [PolishSpace X] [T2Space Y] {s : Set Y} (hs : AnalyticSet s) {f : X → Y} (hf : Continuous f) :
+    AnalyticSet (f ⁻¹' s) := by
+  rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨Z, _, _, g, hg, rfl⟩
+  have : IsClosed {x : X × Z | f x.1 = g x.2} := isClosed_diagonal.preimage (hf.prod_map hg)
+  convert this.analyticSet.image_of_continuous continuous_fst
+  ext x
+  simp [eq_comm]
+
 /-! ### Separating sets with measurable sets -/
 
 /-- Two sets `u` and `v` in a measurable space are measurably separable if there
@@ -501,7 +506,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   exact M n B
 #align measure_theory.measurably_separable_range_of_disjoint MeasureTheory.measurablySeparable_range_of_disjoint
 
-/-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
+/-- The **Lusin separation theorem**: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
 theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
     {s t : Set α} (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) :
chore: missing spaces after rcases, convert and congrm (#7725)

Replace rcases( with rcases (. Same thing for convert( and congrm(. No other change.

Diff
@@ -459,7 +459,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   -- by design, the cylinders around these points have images which are not Borel-separable.
   have M : ∀ n, ¬MeasurablySeparable (f '' cylinder x n) (g '' cylinder y n) := by
     intro n
-    convert(p n).2 using 3
+    convert (p n).2 using 3
     · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff]
       intro i hi
       rw [hx]
doc(MeasureTheory/Constructions/Polish): fix typo (#7571)
Diff
@@ -17,7 +17,7 @@ structure on Polish spaces.
 
 ## Main definitions and results
 
-First, we define standard Borel apaces.
+First, we define standard Borel spaces.
 
 * A `StandardBorelSpace α` is a typeclass for measurable spaces which arise as the Borel sets
   of some Polish topology.
feat: add standard Borel space class (#7243)

add a class StandardBorelSpace, whose relationship to PolishSpace is analogous to the relationship between PolishSpace and complete metric space. The usefulness is shown by _root_.MeasurableSet.standardBorel: A measurable subset of a standard Borel space is Polish. Note that a borel measurable subset of a Polish space will not typically be Polish in the induced topology!

Specific things done in this PR:

  • added some basic instances for StandardBorelSpace
  • changed theorems with hypotheses [MeasurableSpace X] [TopologicalSpace X] [BorelSpace X] [PolishSpace X] but which do not refer to the topology on X to depend instead on [MeasurableSpace X][StandardBorelSpace X]. These automatically generalize the old theorems thanks to standardBorel_of_polish.

I believe this sort of refactoring can be pushed a lot farther in future PRs.

Co-authored-by: Felix-Weilacher <112423742+Felix-Weilacher@users.noreply.github.com>

Diff
@@ -17,7 +17,12 @@ structure on Polish spaces.
 
 ## Main definitions and results
 
-First, we define the class of analytic sets and establish its basic properties.
+First, we define standard Borel apaces.
+
+* A `StandardBorelSpace α` is a typeclass for measurable spaces which arise as the Borel sets
+  of some Polish topology.
+
+Next, we define the class of analytic sets and establish its basic properties.
 
 * `MeasureTheory.AnalyticSet s`: a set in a topological space is analytic if it is the continuous
   image of a Polish space. Equivalently, it is empty, or the image of `ℕ → ℕ`.
@@ -42,28 +47,110 @@ analytic sets.
   is a measurable embedding for the Borel sigma-algebra.
 * `ContinuousOn.measurableEmbedding` is the same result for a map restricted to a measurable set
   on which it is continuous.
-* `Measurable.measurableEmbedding` states that a measurable injective map from a Polish space
-  to a second-countable topological space is a measurable embedding.
+* `Measurable.measurableEmbedding` states that a measurable injective map from
+  a standard Borel space to a second-countable topological space is a measurable embedding.
 * `isClopenable_iff_measurableSet`: in a Polish space, a set is clopenable (i.e., it can be made
   open and closed by using a finer Polish topology) if and only if it is Borel-measurable.
 
 We use this to prove several versions of the Borel isomorphism theorem.
 
-* `PolishSpace.measurableEquivOfNotCountable` : Any two uncountable Polish spaces
+* `PolishSpace.measurableEquivOfNotCountable` : Any two uncountable standard Borel spaces
   are Borel isomorphic.
-* `PolishSpace.Equiv.measurableEquiv` : Any two Polish spaces of the same cardinality
+* `PolishSpace.Equiv.measurableEquiv` : Any two standard Borel spaces of the same cardinality
   are Borel isomorphic.
 -/
 
 
 open Set Function PolishSpace PiNat TopologicalSpace Bornology Metric Filter Topology MeasureTheory
 
-variable {α : Type*} [TopologicalSpace α] {ι : Type*}
+/-! ### Standard Borel Spaces -/
+
+variable (α : Type*)
+
+/-- A standard Borel space is a measurable space arising as the Borel sets of some Polish topology.
+This is useful in situations where a space has no natural topology or
+the natural topology in a space is non-Polish.
+
+To endow a standard Borel space `α` with a compatible Polish topology, use
+`letI := upgradePolishSpace α`. One can then use `eq_borel_upgradeStandardBorel α` to
+rewrite the `MeasurableSpace α` instance to `borel α t`, where `t` is the new topology.-/
+class StandardBorelSpace [MeasurableSpace α] : Prop where
+  /-- There exists a compatible Polish topology. -/
+  polish : ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α
+
+/-- A convenience class similar to `UpgradedPolishSpace`. No instance should be registered.
+Instead one should use `letI := upgradePolishSpace α`. -/
+class UpgradedStandardBorel extends MeasurableSpace α, TopologicalSpace α,
+  BorelSpace α, PolishSpace α
+
+/-- Use as `letI := upgradePolishSpace α` to endow a standard Borel space `α` with
+a compatible Polish topology.
+
+Warning: following this with `borelize α` will cause an error. Instead, one can
+rewrite with `eq_borel_upgradeStandardBorel α`.
+TODO: fix the corresponding bug in `borelize`. -/
+noncomputable
+def upgradeStandardBorel [MeasurableSpace α] [h : StandardBorelSpace α] :
+    UpgradedStandardBorel α := by
+  choose τ hb hp using h.polish
+  constructor
+
+/-- The `MeasurableSpace α` instance on a `StandardBorelSpace` `α` is equal to
+the borel sets of `upgradeStandardBorel α`.-/
+theorem eq_borel_upgradeStandardBorel [MeasurableSpace α] [StandardBorelSpace α] :
+    ‹MeasurableSpace α› = @borel _ (upgradeStandardBorel α).toTopologicalSpace :=
+  @BorelSpace.measurable_eq _ (upgradeStandardBorel α).toTopologicalSpace _
+    (upgradeStandardBorel α).toBorelSpace
+
+variable {α}
+
+section
+
+variable [MeasurableSpace α]
+
+instance standardBorel_of_polish [τ : TopologicalSpace α]
+    [BorelSpace α] [PolishSpace α] : StandardBorelSpace α := by exists τ
+
+instance countablyGenerated_of_standardBorel [StandardBorelSpace α] :
+    MeasurableSpace.CountablyGenerated α :=
+  letI := upgradeStandardBorel α
+  inferInstance
+
+instance measurableSingleton_of_standardBorel [StandardBorelSpace α] : MeasurableSingletonClass α :=
+  letI := upgradeStandardBorel α
+  inferInstance
+
+namespace StandardBorelSpace
+
+variable {β : Type*} [MeasurableSpace β]
+
+section instances
+
+/-- A product of two standard Borel spaces is standard Borel. -/
+instance prod [StandardBorelSpace α] [StandardBorelSpace β] : StandardBorelSpace (α × β) :=
+  letI := upgradeStandardBorel α
+  letI := upgradeStandardBorel β
+  inferInstance
+
+/-- A product of countably many standard Borel spaces is standard Borel. -/
+instance pi_countable {ι : Type*} [Countable ι] {α : ι → Type*} [∀ n, MeasurableSpace (α n)]
+    [∀ n, StandardBorelSpace (α n)] : StandardBorelSpace (∀ n, α n) :=
+  letI := fun n => upgradeStandardBorel (α n)
+  inferInstance
+
+end instances
+
+end StandardBorelSpace
+
+end section
+
+variable {ι : Type*}
 
 namespace MeasureTheory
 
-/-! ### Analytic sets -/
+variable [TopologicalSpace α]
 
+/-! ### Analytic sets -/
 
 /-- An analytic set is a set which is the continuous image of some Polish space. There are several
 equivalent characterizations of this definition. For the definition, we pick one that avoids
@@ -260,12 +347,14 @@ theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpac
   exact continuous_subtype_val.comp this
 #align measurable.exists_continuous Measurable.exists_continuous
 
-/-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
-theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
-    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
+/-- The image of a measurable set in a standard Borel space under a measurable map
+is an analytic set. -/
+theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [MeasurableSpace X]
+    [StandardBorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
     [OpensMeasurableSpace Y] {f : X → Y} [SecondCountableTopology (range f)] {s : Set X}
     (hs : MeasurableSet s) (hf : Measurable f) : AnalyticSet (f '' s) := by
-  borelize X
+  letI := upgradeStandardBorel X
+  rw [eq_borel_upgradeStandardBorel X] at hs
   rcases hf.exists_continuous with ⟨τ', hle, hfc, hτ'⟩
   letI m' : MeasurableSpace X := @borel _ τ'
   haveI b' : BorelSpace X := ⟨rfl⟩
@@ -275,7 +364,6 @@ theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [TopologicalSpace X
 
 /-! ### Separating sets with measurable sets -/
 
-
 /-- Two sets `u` and `v` in a measurable space are measurably separable if there
 exists a measurable set containing `u` and disjoint from `v`.
 This is mostly interesting for Borel-separable sets. -/
@@ -443,14 +531,14 @@ end MeasureTheory
 
 namespace Measurable
 
-variable {X Y β : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
+variable {X Y β : Type*} [MeasurableSpace X] [StandardBorelSpace X]
   [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
 
-/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
-with second countable topology, then the preimage of a set `s` is measurable if and only if the set
-is measurable.
+/-- If `f : X → Y` is a surjective Borel measurable map from a standard Borel space
+to a topological space with second countable topology, then the preimage of a set `s`
+is measurable if and only if the set is measurable.
 One implication is the definition of measurability, the other one heavily relies on `X` being a
-Polish space. -/
+standard Borel space. -/
 theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
     (hf : Measurable f) (hsurj : Surjective f) {s : Set Y} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet s := by
@@ -479,9 +567,9 @@ theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Meas
   ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩
 #align measurable.borel_space_codomain Measurable.borelSpace_codomain
 
-/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
-countable topology, then the preimage of a set `s` is measurable if and only if the set is
-measurable in `Set.range f`. -/
+/-- If `f : X → Y` is a Borel measurable map from a standard Borel space to a topological space
+with second countable topology, then the preimage of a set `s` is measurable if and only if
+the set is measurable in `Set.range f`. -/
 theorem measurableSet_preimage_iff_preimage_val {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) {s : Set Y} :
     MeasurableSet (f ⁻¹' s) ↔ MeasurableSet ((↑) ⁻¹' s : Set (range f)) :=
@@ -489,8 +577,9 @@ theorem measurableSet_preimage_iff_preimage_val {f : X → Y} [SecondCountableTo
   hf'.measurableSet_preimage_iff_of_surjective (s := Subtype.val ⁻¹' s) surjective_onto_range
 #align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_val
 
-/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
-countable topology and the range of `f` is measurable, then the preimage of a set `s` is measurable
+/-- If `f : X → Y` is a Borel measurable map from a standard Borel space to a
+topological space with second countable topology and the range of `f` is measurable,
+then the preimage of a set `s` is measurable
 if and only if the intesection with `Set.range f` is measurable. -/
 theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Y} :
@@ -499,16 +588,18 @@ theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTop
     ← (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
 #align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
 
-/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
-countable topology, then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
+/-- If `f : X → Y` is a Borel measurable map from a standard Borel space
+to a topological space with second countable topology,
+then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
 measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
 theorem measurable_comp_iff_restrict {f : X → Y} [SecondCountableTopology (range f)]
     (hf : Measurable f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
   forall₂_congr fun s _ => measurableSet_preimage_iff_preimage_val hf (s := g ⁻¹' s)
 #align measurable.measurable_comp_iff_restrict Measurable.measurable_comp_iff_restrict
 
-/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
-with second countable topology, then for any measurable space `α` and `g : Y → α`, the composition
+/-- If `f : X → Y` is a surjective Borel measurable map from a standard Borel space
+to a topological space with second countable topology,
+then for any measurable space `α` and `g : Y → α`, the composition
 `g ∘ f` is measurable if and only if `g` is measurable. -/
 theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
     (hf : Measurable f) (hsurj : Surjective f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable g :=
@@ -553,12 +644,13 @@ namespace MeasureTheory
 
 /-! ### Injective images of Borel sets -/
 
-variable {γ : Type*} [tγ : TopologicalSpace γ] [PolishSpace γ]
+variable {γ : Type*}
 
 /-- The Lusin-Souslin theorem: the range of a continuous injective function defined on a Polish
 space is Borel-measurable. -/
-theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpace β] [T2Space β]
-    [MeasurableSpace β] [BorelSpace β] {f : γ → β} (f_cont : Continuous f) (f_inj : Injective f) :
+theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpace γ]
+    [PolishSpace γ] [TopologicalSpace β] [T2Space β] [MeasurableSpace β] [OpensMeasurableSpace β]
+    {f : γ → β} (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableSet (range f) := by
   /- We follow [Fremlin, *Measure Theory* (volume 4, 423I)][fremlin_vol4].
     Let `b = {s i}` be a countable basis for `α`. When `s i` and `s j` are disjoint, their images
@@ -707,8 +799,9 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
     exact disjoint_left.1 (hvw.closure_left w_open) this xw
 #align measure_theory.measurable_set_range_of_continuous_injective MeasureTheory.measurableSet_range_of_continuous_injective
 
-theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type*} [TopologicalSpace β]
-    [T2Space β] [MeasurableSpace β] [BorelSpace β] {s : Set γ} (hs : IsClosed s) {f : γ → β}
+theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn
+    [TopologicalSpace γ] [PolishSpace γ] {β : Type*} [TopologicalSpace β] [T2Space β]
+    [MeasurableSpace β] [OpensMeasurableSpace β] {s : Set γ} (hs : IsClosed s) {f : γ → β}
     (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by
   rw [image_eq_range]
   haveI : PolishSpace s := IsClosed.polishSpace hs
@@ -717,12 +810,14 @@ theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type*} [
   · rwa [injOn_iff_injective] at f_inj
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
 
-variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type*} [tβ : TopologicalSpace β] [T2Space β]
-  [MeasurableSpace β] [BorelSpace β] {s : Set γ} {f : γ → β}
+variable {β : Type*} [tβ : TopologicalSpace β] [T2Space β] [MeasurableSpace β]
+  {s : Set γ} {f : γ → β}
 
 /-- 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 (hs : MeasurableSet s)
+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 :=
@@ -732,12 +827,15 @@ theorem _root_.MeasurableSet.image_of_continuousOn_injOn (hs : MeasurableSet s)
       (f_cont.mono_dom t't) f_inj
 #align measurable_set.image_of_continuous_on_inj_on MeasurableSet.image_of_continuousOn_injOn
 
-/-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish 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 [SecondCountableTopology β]
+/-- 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⟩ :
@@ -748,13 +846,15 @@ theorem _root_.MeasurableSet.image_of_measurable_injOn [SecondCountableTopology
       (@BorelSpace.opensMeasurable γ t' (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl))
       tγ _ _ _ (continuous_id_of_le t't) s hs
   exact
-    @MeasurableSet.image_of_continuousOn_injOn γ t' t'_polish (@borel γ t')
-      (@BorelSpace.mk _ _ (borel γ) rfl)
-      β _ _ _ _ s f M (@Continuous.continuousOn γ β t' tβ f s f_cont) f_inj
+    @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
 #align measurable_set.image_of_measurable_inj_on MeasurableSet.image_of_measurable_injOn
 
 /-- An injective continuous function on a Polish space is a measurable embedding. -/
-theorem _root_.Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : Injective f) :
+theorem _root_.Continuous.measurableEmbedding [BorelSpace β]
+    [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ]
+    (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableEmbedding f :=
   { injective := f_inj
     measurable := f_cont.measurable
@@ -764,7 +864,9 @@ theorem _root_.Continuous.measurableEmbedding (f_cont : Continuous f) (f_inj : I
 
 /-- 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 (hs : MeasurableSet s) (f_cont : ContinuousOn f s)
+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
@@ -778,42 +880,46 @@ theorem _root_.ContinuousOn.measurableEmbedding (hs : MeasurableSet s) (f_cont :
       rwa [← image_comp] at B }
 #align continuous_on.measurable_embedding ContinuousOn.measurableEmbedding
 
-/-- An injective measurable function from a Polish space to a second-countable topological space
-is a measurable embedding. -/
-theorem _root_.Measurable.measurableEmbedding [SecondCountableTopology β] (f_meas : Measurable f)
-    (f_inj : Injective f) : MeasurableEmbedding f :=
+/-- An injective measurable function from a standard Borel space to a
+second-countable topological space is a measurable embedding. -/
+theorem _root_.Measurable.measurableEmbedding [OpensMeasurableSpace β]
+    [MeasurableSpace γ] [StandardBorelSpace γ] [SecondCountableTopology β]
+    (f_meas : Measurable f) (f_inj : Injective f) : MeasurableEmbedding f :=
   { injective := f_inj
     measurable := f_meas
     measurableSet_image' := fun _u hu => hu.image_of_measurable_injOn f_meas (f_inj.injOn _) }
 #align measurable.measurable_embedding Measurable.measurableEmbedding
 
+/-- 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
+  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 : IsClopenable s ↔ MeasurableSet s := by
+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_closed, _⟩ :
+  obtain ⟨t', t't, t'_polish, _, s_open⟩ :
     ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs
-  -- the identity is continuous from `t'` to `tγ`.
-  have C : @Continuous γ γ t' tγ id := continuous_id_of_le t't
-  -- therefore, it is also a measurable embedding, by the Lusin-Souslin theorem
-  have E :=
-    @Continuous.measurableEmbedding γ t' t'_polish (@borel γ t')
-      (@BorelSpace.mk _ _ (borel γ) rfl)
-      γ tγ (@PolishSpace.t2Space γ tγ _) _ _ id C injective_id
-  -- the set `s` is measurable for `t'` as it is closed.
-  have M : @MeasurableSet γ (@borel γ t') s :=
-    @IsClosed.measurableSet γ s t' (@borel γ t')
-      (@BorelSpace.opensMeasurable γ t' (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl))
-      s_closed
-  -- therefore, its image under the measurable embedding `id` is also measurable for `tγ`.
-  convert E.measurableSet_image.2 M
-  simp only [id.def, image_id']
-#align measure_theory.is_clopenable_iff_measurable_set MeasureTheory.isClopenable_iff_measurableSet
+  rw [← borel_eq_borel_of_le t'_polish _ t't]
+  · exact MeasurableSpace.measurableSet_generateFrom s_open
+  infer_instance
 
 /-- The set of points for which a measurable sequence of functions converges is measurable. -/
 @[measurability]
-theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι}
+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
@@ -842,24 +948,51 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
 
 end MeasureTheory
 
+namespace StandardBorelSpace
+
+variable [MeasurableSpace α] [StandardBorelSpace α]
+
+/-- 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]
+  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
+  obtain ⟨_, _, _, s_closed, _⟩ := hs.isClopenable'
+  haveI := s_closed.polishSpace
+  infer_instance
+
+end StandardBorelSpace
+
 /-! ### The Borel Isomorphism Theorem -/
 
 namespace PolishSpace
 
-variable {β : Type*} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
+variable {β : Type*}
 
-variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
+variable [MeasurableSpace α] [MeasurableSpace β] [StandardBorelSpace α] [StandardBorelSpace β]
 
-/-- If two Polish spaces admit Borel measurable injections to one another,
+/-- If two standard Borel spaces admit Borel measurable injections to one another,
 then they are Borel isomorphic.-/
 noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f)
     (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β :=
+  letI := upgradeStandardBorel α
+  letI := upgradeStandardBorel β
   (fmeas.measurableEmbedding finj).schroederBernstein (gmeas.measurableEmbedding ginj)
 #align polish_space.borel_schroeder_bernstein PolishSpace.borelSchroederBernstein
 
-/-- Any uncountable Polish space is Borel isomorphic to the Cantor space `ℕ → Bool`.-/
+/-- Any uncountable standard Borel space is Borel isomorphic to the Cantor space `ℕ → Bool`.-/
 noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) := by
   apply Nonempty.some
+  letI := upgradeStandardBorel α
   obtain ⟨f, -, fcts, finj⟩ :=
     isClosed_univ.exists_nat_bool_injection_of_not_countable
       (by rwa [← countable_coe_iff, (Equiv.Set.univ _).countable_iff])
@@ -867,12 +1000,13 @@ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α
   exact ⟨borelSchroederBernstein gmeas ginj fcts.measurable finj⟩
 #align polish_space.measurable_equiv_nat_bool_of_not_countable PolishSpace.measurableEquivNatBoolOfNotCountable
 
-/-- The **Borel Isomorphism Theorem**: Any two uncountable Polish spaces are Borel isomorphic.-/
+/-- The **Borel Isomorphism Theorem**: Any two uncountable standard Borel spaces are
+Borel isomorphic.-/
 noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β :=
   (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm
 #align polish_space.measurable_equiv_of_not_countable PolishSpace.measurableEquivOfNotCountable
 
-/-- The **Borel Isomorphism Theorem**: If two Polish spaces have the same cardinality,
+/-- The **Borel Isomorphism Theorem**: If two standard Borel spaces have the same cardinality,
 they are Borel isomorphic.-/
 noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β := by
   by_cases h : Countable α
@@ -887,7 +1021,7 @@ end PolishSpace
 namespace MeasureTheory
 
 variable (α)
-variable [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
+variable [MeasurableSpace α] [StandardBorelSpace α]
 
 theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] :
     ∃ n : ℕ, Nonempty (α ≃ᵐ range ((↑) : Fin n → ℝ)) := by
@@ -905,7 +1039,7 @@ theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Co
   exact Equiv.ofInjective ((↑) : ℕ → ℝ) Nat.cast_injective
 #align measure_theory.measurable_equiv_range_coe_nat_of_infinite_of_countable MeasureTheory.measurableEquiv_range_coe_nat_of_infinite_of_countable
 
-/-- Any Polish Borel space is measurably equivalent to a subset of the reals. -/
+/-- Any standard Borel space is measurably equivalent to a subset of the reals. -/
 theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s ∧ Nonempty (α ≃ᵐ s) := by
   by_cases hα : Countable α
   · cases finite_or_infinite α
@@ -929,7 +1063,7 @@ theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s 
     exact Cardinal.not_countable_real
 #align measure_theory.exists_subset_real_measurable_equiv MeasureTheory.exists_subset_real_measurableEquiv
 
-/-- Any Polish Borel space embeds measurably into the reals. -/
+/-- Any standard Borel space embeds measurably into the reals. -/
 theorem exists_measurableEmbedding_real : ∃ f : α → ℝ, MeasurableEmbedding f := by
   obtain ⟨s, hs, ⟨e⟩⟩ := exists_subset_real_measurableEquiv α
   exact ⟨(↑) ∘ e, (MeasurableEmbedding.subtype_coe hs).comp e.measurableEmbedding⟩
refactor(Topology/MetricSpace): remove Metric.Bounded (#7240)

Use Bornology.IsBounded instead.

Diff
@@ -56,7 +56,7 @@ We use this to prove several versions of the Borel isomorphism theorem.
 -/
 
 
-open Set Function PolishSpace PiNat TopologicalSpace Metric Filter Topology MeasureTheory
+open Set Function PolishSpace PiNat TopologicalSpace Bornology Metric Filter Topology MeasureTheory
 
 variable {α : Type*} [TopologicalSpace α] {ι : Type*}
 
@@ -600,7 +600,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
   obtain ⟨u, u_anti, u_pos, u_lim⟩ :
     ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) :=
     exists_seq_strictAnti_tendsto (0 : ℝ)
-  let F : ℕ → Set β := fun n => ⋃ (s : b) (_ : Bounded s.1 ∧ diam s.1 ≤ u n), E s
+  let F : ℕ → Set β := fun n => ⋃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), E s
   -- it is enough to show that `range f = ⋂ F n`, as the latter set is obviously measurable.
   suffices range f = ⋂ n, F n by
     have E_meas : ∀ s : b, MeasurableSet (E s) := by
@@ -623,11 +623,11 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
       apply hb.mem_nhds_iff.1
       exact ball_mem_nhds _ (half_pos (u_pos n))
     have diam_s : diam s ≤ u n := by
-      apply (diam_mono hs bounded_ball).trans
+      apply (diam_mono hs isBounded_ball).trans
       convert diam_ball (x := y) (half_pos (u_pos n)).le
       ring
     refine' mem_iUnion.2 ⟨⟨s, sb⟩, _⟩
-    refine' mem_iUnion.2 ⟨⟨Metric.Bounded.mono hs bounded_ball, diam_s⟩, _⟩
+    refine' mem_iUnion.2 ⟨⟨isBounded_ball.subset hs, diam_s⟩, _⟩
     apply mem_inter (subset_closure (mem_image_of_mem _ ys))
     refine' mem_iInter.2 fun t => mem_iInter.2 fun ht => ⟨_, _⟩
     · apply hq1
@@ -637,7 +637,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
   -- Now, let us prove the harder inclusion `⋂ F n ⊆ range f`.
   · intro x hx
     -- pick for each `n` a good set `s n` of small diameter for which `x ∈ E (s n)`.
-    have C1 : ∀ n, ∃ (s : b) (_ : Bounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by
+    have C1 : ∀ n, ∃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by
       simpa only [mem_iUnion] using mem_iInter.1 hx n
     choose s hs hxs using C1
     have C2 : ∀ n, (s n).1.Nonempty := by
chore: fix port of surjective_quotient_mk (#7096)

The mathlib3 lemma is about quotient.mk, which takes an instance argument and is translated into mathlib4 as Quotient.mk'.

Diff
@@ -535,7 +535,7 @@ theorem Continuous.map_borel_eq {X Y : Type*} [TopologicalSpace X] [PolishSpace
 instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
     [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
     BorelSpace (Quotient s) :=
-  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
+  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk' _)⟩
 #align quotient.borel_space Quotient.borelSpace
 
 @[to_additive]
chore: implement porting notes about Polish spaces (#6991)

Make the following changes which were intentionally left till after the port:

  • Move several instances of PolishSpace from MeasureTheory.Constructions.Polish to Topology.MetricSpace.Polish

  • Remove instance of PolishSpace for nat -> nat, since lean4 can find this automatically

  • Change PolishSpace to extend SecondCountableTopology, since lean4 now allows loops in TC inference.

Diff
@@ -544,7 +544,6 @@ instance QuotientGroup.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace
     [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) :=
   -- porting note: 1st and 3rd `haveI`s were not needed in Lean 3
   haveI := Subgroup.t3_quotient_of_isClosed N
-  haveI := @PolishSpace.secondCountableTopology G
   haveI := QuotientGroup.secondCountableTopology (Γ := N)
   Quotient.borelSpace
 #align quotient_group.borel_space QuotientGroup.borelSpace
@@ -845,28 +844,8 @@ end MeasureTheory
 
 /-! ### The Borel Isomorphism Theorem -/
 
--- Porting note: Move to topology/metric_space/polish when porting.
-instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
-    PolishSpace α := by
-  obtain ⟨f, hf⟩ := h.exists_injective_nat
-  have : ClosedEmbedding f := by
-    apply closedEmbedding_of_continuous_injective_closed continuous_of_discreteTopology hf
-    exact fun t _ => isClosed_discrete _
-  exact this.polishSpace
-#align polish_of_countable polish_of_countable
-
 namespace PolishSpace
 
-/- Porting note: This is to avoid a loop in TC inference. When ported to Lean 4, this will not
-be necessary, and `secondCountable_of_polish` should probably
-just be added as an instance soon after the definition of `PolishSpace`.-/
-private theorem secondCountable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
-  h.secondCountableTopology
-
-attribute [-instance] polishSpace_of_complete_second_countable
-
-attribute [local instance] secondCountable_of_polish
-
 variable {β : Type*} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
 
 variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
@@ -907,11 +886,6 @@ end PolishSpace
 
 namespace MeasureTheory
 
--- Porting note: todo after the port: move to topology/metric_space/polish
-instance instPolishSpaceUniv [PolishSpace α] : PolishSpace (univ : Set α) :=
-  isClosed_univ.polishSpace
-#align measure_theory.set.univ.polish_space MeasureTheory.instPolishSpaceUniv
-
 variable (α)
 variable [MeasurableSpace α] [PolishSpace α] [BorelSpace α]
 
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -664,7 +664,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpa
     -- the points `y n` are nearby, and therefore they form a Cauchy sequence.
     have cauchy_y : CauchySeq y := by
       have : Tendsto (fun n => 2 * u n) atTop (𝓝 0) := by
-        simpa only [MulZeroClass.mul_zero] using u_lim.const_mul 2
+        simpa only [mul_zero] using u_lim.const_mul 2
       refine cauchySeq_of_le_tendsto_0' (fun n => 2 * u n) (fun m n hmn => ?_) this
       rcases I m n with ⟨z, zsm, zsn⟩
       calc
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -58,7 +58,7 @@ We use this to prove several versions of the Borel isomorphism theorem.
 
 open Set Function PolishSpace PiNat TopologicalSpace Metric Filter Topology MeasureTheory
 
-variable {α : Type _} [TopologicalSpace α] {ι : Type _}
+variable {α : Type*} [TopologicalSpace α] {ι : Type*}
 
 namespace MeasureTheory
 
@@ -83,7 +83,7 @@ theorem analyticSet_empty : AnalyticSet (∅ : Set α) := by
   exact Or.inl rfl
 #align measure_theory.analytic_set_empty MeasureTheory.analyticSet_empty
 
-theorem analyticSet_range_of_polishSpace {β : Type _} [TopologicalSpace β] [PolishSpace β]
+theorem analyticSet_range_of_polishSpace {β : Type*} [TopologicalSpace β] [PolishSpace β]
     {f : β → α} (f_cont : Continuous f) : AnalyticSet (range f) := by
   cases isEmpty_or_nonempty β
   · rw [range_eq_empty]
@@ -96,7 +96,7 @@ theorem analyticSet_range_of_polishSpace {β : Type _} [TopologicalSpace β] [Po
 #align measure_theory.analytic_set_range_of_polish_space MeasureTheory.analyticSet_range_of_polishSpace
 
 /-- The image of an open set under a continuous map is analytic. -/
-theorem _root_.IsOpen.analyticSet_image {β : Type _} [TopologicalSpace β] [PolishSpace β]
+theorem _root_.IsOpen.analyticSet_image {β : Type*} [TopologicalSpace β] [PolishSpace β]
     {s : Set β} (hs : IsOpen s) {f : β → α} (f_cont : Continuous f) : AnalyticSet (f '' s) := by
   rw [image_eq_range]
   haveI : PolishSpace s := hs.polishSpace
@@ -123,7 +123,7 @@ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} :
 #align measure_theory.analytic_set_iff_exists_polish_space_range MeasureTheory.analyticSet_iff_exists_polishSpace_range
 
 /-- The continuous image of an analytic set is analytic -/
-theorem AnalyticSet.image_of_continuousOn {β : Type _} [TopologicalSpace β] {s : Set α}
+theorem AnalyticSet.image_of_continuousOn {β : Type*} [TopologicalSpace β] {s : Set α}
     (hs : AnalyticSet s) {f : α → β} (hf : ContinuousOn f s) : AnalyticSet (f '' s) := by
   rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨γ, γtop, γpolish, g, g_cont, gs⟩
   skip
@@ -135,7 +135,7 @@ theorem AnalyticSet.image_of_continuousOn {β : Type _} [TopologicalSpace β] {s
   exact mem_range_self
 #align measure_theory.analytic_set.image_of_continuous_on MeasureTheory.AnalyticSet.image_of_continuousOn
 
-theorem AnalyticSet.image_of_continuous {β : Type _} [TopologicalSpace β] {s : Set α}
+theorem AnalyticSet.image_of_continuous {β : Type*} [TopologicalSpace β] {s : Set α}
     (hs : AnalyticSet s) {f : α → β} (hf : Continuous f) : AnalyticSet (f '' s) :=
   hs.image_of_continuousOn hf.continuousOn
 #align measure_theory.analytic_set.image_of_continuous MeasureTheory.AnalyticSet.image_of_continuous
@@ -224,7 +224,7 @@ theorem _root_.MeasurableSet.isClopenable [PolishSpace α] [MeasurableSpace α]
   · exact fun f _ _ hf => IsClopenable.iUnion hf
 #align measurable_set.is_clopenable MeasurableSet.isClopenable
 
-theorem _root_.MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α] [PolishSpace α]
+theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α] [PolishSpace α]
     [MeasurableSpace α] [BorelSpace α] {s : Set α} (hs : MeasurableSet s) : AnalyticSet s := by
   /- For a short proof (avoiding measurable induction), one sees `s` as a closed set for a finer
     topology `t'`. It is analytic for this topology. As the identity from `t'` to `t` is continuous
@@ -239,7 +239,7 @@ theorem _root_.MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α]
 
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
-theorem _root_.Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
+theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpace α] [PolishSpace α]
     [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [MeasurableSpace β]
     [OpensMeasurableSpace β] {f : α → β} [SecondCountableTopology (range f)] (hf : Measurable f) :
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @Continuous α β t' tβ f ∧ @PolishSpace α t' := by
@@ -261,7 +261,7 @@ theorem _root_.Measurable.exists_continuous {α β : Type _} [t : TopologicalSpa
 #align measurable.exists_continuous Measurable.exists_continuous
 
 /-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
-theorem _root_.MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
     [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
     [OpensMeasurableSpace Y] {f : X → Y} [SecondCountableTopology (range f)] {s : Set X}
     (hs : MeasurableSet s) (hf : Measurable f) : AnalyticSet (f '' s) := by
@@ -279,11 +279,11 @@ theorem _root_.MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace
 /-- Two sets `u` and `v` in a measurable space are measurably separable if there
 exists a measurable set containing `u` and disjoint from `v`.
 This is mostly interesting for Borel-separable sets. -/
-def MeasurablySeparable {α : Type _} [MeasurableSpace α] (s t : Set α) : Prop :=
+def MeasurablySeparable {α : Type*} [MeasurableSpace α] (s t : Set α) : Prop :=
   ∃ u, s ⊆ u ∧ Disjoint t u ∧ MeasurableSet u
 #align measure_theory.measurably_separable MeasureTheory.MeasurablySeparable
 
-theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace α] {s t : ι → Set α}
+theorem MeasurablySeparable.iUnion [Countable ι] {α : Type*} [MeasurableSpace α] {s t : ι → Set α}
     (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) := by
   choose u hsu htu hu using h
   refine' ⟨⋃ m, ⋂ n, u m n, _, _, _⟩
@@ -443,7 +443,7 @@ end MeasureTheory
 
 namespace Measurable
 
-variable {X Y β : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
+variable {X Y β : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
   [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
 
 /-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
@@ -517,7 +517,7 @@ theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X →
 
 end Measurable
 
-theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+theorem Continuous.map_eq_borel {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
     [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y]
     {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) :
     MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by
@@ -525,21 +525,21 @@ theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace
   exact hf.measurable.map_measurableSpace_eq hsurj
 #align continuous.map_eq_borel Continuous.map_eq_borel
 
-theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+theorem Continuous.map_borel_eq {X Y : Type*} [TopologicalSpace X] [PolishSpace X]
     [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
     (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y := by
   borelize X
   exact hf.map_eq_borel hsurj
 #align continuous.map_borel_eq Continuous.map_borel_eq
 
-instance Quotient.borelSpace {X : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
+instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
     [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
     BorelSpace (Quotient s) :=
   ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
 #align quotient.borel_space Quotient.borelSpace
 
 @[to_additive]
-instance QuotientGroup.borelSpace {G : Type _} [TopologicalSpace G] [PolishSpace G] [Group G]
+instance QuotientGroup.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G]
     [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.Normal]
     [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) :=
   -- porting note: 1st and 3rd `haveI`s were not needed in Lean 3
@@ -554,11 +554,11 @@ namespace MeasureTheory
 
 /-! ### Injective images of Borel sets -/
 
-variable {γ : Type _} [tγ : TopologicalSpace γ] [PolishSpace γ]
+variable {γ : Type*} [tγ : TopologicalSpace γ] [PolishSpace γ]
 
 /-- The Lusin-Souslin theorem: the range of a continuous injective function defined on a Polish
 space is Borel-measurable. -/
-theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSpace β] [T2Space β]
+theorem measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpace β] [T2Space β]
     [MeasurableSpace β] [BorelSpace β] {f : γ → β} (f_cont : Continuous f) (f_inj : Injective f) :
     MeasurableSet (range f) := by
   /- We follow [Fremlin, *Measure Theory* (volume 4, 423I)][fremlin_vol4].
@@ -708,7 +708,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
     exact disjoint_left.1 (hvw.closure_left w_open) this xw
 #align measure_theory.measurable_set_range_of_continuous_injective MeasureTheory.measurableSet_range_of_continuous_injective
 
-theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _} [TopologicalSpace β]
+theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type*} [TopologicalSpace β]
     [T2Space β] [MeasurableSpace β] [BorelSpace β] {s : Set γ} (hs : IsClosed s) {f : γ → β}
     (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by
   rw [image_eq_range]
@@ -718,7 +718,7 @@ theorem _root_.IsClosed.measurableSet_image_of_continuousOn_injOn {β : Type _}
   · rwa [injOn_iff_injective] at f_inj
 #align is_closed.measurable_set_image_of_continuous_on_inj_on IsClosed.measurableSet_image_of_continuousOn_injOn
 
-variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type _} [tβ : TopologicalSpace β] [T2Space β]
+variable [MeasurableSpace γ] [hγb : BorelSpace γ] {β : Type*} [tβ : TopologicalSpace β] [T2Space β]
   [MeasurableSpace β] [BorelSpace β] {s : Set γ} {f : γ → β}
 
 /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under
@@ -867,7 +867,7 @@ attribute [-instance] polishSpace_of_complete_second_countable
 
 attribute [local instance] secondCountable_of_polish
 
-variable {β : Type _} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
+variable {β : Type*} [TopologicalSpace β] [PolishSpace α] [PolishSpace β]
 
 variable [MeasurableSpace α] [MeasurableSpace β] [BorelSpace α] [BorelSpace β]
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
-
-! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit 9f55d0d4363ae59948c33864cbc52e0b12e0e8ce
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Real.Cardinality
 import Mathlib.Topology.Perfect
 import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
 
+#align_import measure_theory.constructions.polish from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
+
 /-!
 # The Borel sigma-algebra on Polish spaces
 
fix: change compl precedence (#5586)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -432,7 +432,7 @@ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [Opens
 /-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic
 complement is measurable. -/
 theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
-    {s : Set α} (hs : AnalyticSet s) (hsc : AnalyticSet (sᶜ)) : MeasurableSet s := by
+    {s : Set α} (hs : AnalyticSet s) (hsc : AnalyticSet sᶜ) : MeasurableSet s := by
   rcases hs.measurablySeparable hsc disjoint_compl_right with ⟨u, hsu, hdu, hmu⟩
   obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu)
   exact hmu
@@ -461,7 +461,7 @@ theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f
   apply AnalyticSet.measurableSet_of_compl
   · rw [← image_preimage_eq s hsurj]
     exact h.analyticSet_image hf
-  · rw [← image_preimage_eq (sᶜ) hsurj]
+  · rw [← image_preimage_eq sᶜ hsurj]
     exact h.compl.analyticSet_image hf
 #align measurable.measurable_set_preimage_iff_of_surjective Measurable.measurableSet_preimage_iff_of_surjective
 
fix precedence of Nat.iterate (#5589)
Diff
@@ -338,7 +338,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
   choose F hFn hFx hFy using this
   let p0 : A := ⟨⟨0, fun _ => 0, fun _ => 0⟩, by simp [hfg]⟩
   -- construct inductively decreasing sequences of cylinders whose images are not separated
-  let p : ℕ → A := fun n => (F^[n]) p0
+  let p : ℕ → A := fun n => F^[n] p0
   have prec : ∀ n, p (n + 1) = F (p n) := fun n => by simp only [iterate_succ', Function.comp]
   -- check that at the `n`-th step we deal with cylinders of length `n`
   have pn_fst : ∀ n, (p n).1.1 = n := by
feat: add Filter.eq_or_neBot (#5230)

Also add Filter.limsup_bot, Filter.liminf_bot, and golf some proofs using new lemmas.

Diff
@@ -820,10 +820,8 @@ theorem isClopenable_iff_measurableSet : IsClopenable s ↔ MeasurableSet s := b
 theorem measurableSet_exists_tendsto [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
-  by_cases hl : l.NeBot
-  swap;
-  · rw [not_neBot] at hl
-    simp [hl]
+  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]
chore: forward port leanprover-community/mathlib#19186 (#5080)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Sébastien Gouëzel, Felix Weilacher
 
 ! This file was ported from Lean 3 source module measure_theory.constructions.polish
-! leanprover-community/mathlib commit bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf
+! leanprover-community/mathlib commit 9f55d0d4363ae59948c33864cbc52e0b12e0e8ce
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -243,25 +243,39 @@ theorem _root_.MeasurableSet.analyticSet {α : Type _} [t : TopologicalSpace α]
 /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists
 a finer Polish topology on the source space for which the function is continuous. -/
 theorem _root_.Measurable.exists_continuous {α β : Type _} [t : TopologicalSpace α] [PolishSpace α]
-    [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [SecondCountableTopology β]
-    [MeasurableSpace β] [BorelSpace β] {f : α → β} (hf : Measurable f) :
+    [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [MeasurableSpace β]
+    [OpensMeasurableSpace β] {f : α → β} [SecondCountableTopology (range f)] (hf : Measurable f) :
     ∃ t' : TopologicalSpace α, t' ≤ t ∧ @Continuous α β t' tβ f ∧ @PolishSpace α t' := by
-  obtain ⟨b, b_count, -, hb⟩ : ∃ b : Set (Set β), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b :=
-    exists_countable_basis β
-  haveI : Encodable b := b_count.toEncodable
-  have : ∀ s : b, IsClopenable (f ⁻¹' s) := by
-    intro s
+  obtain ⟨b, b_count, -, hb⟩ :
+    ∃ b : Set (Set (range f)), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b :=
+    exists_countable_basis (range f)
+  haveI : Countable b := b_count.to_subtype
+  have : ∀ s : b, IsClopenable (rangeFactorization f ⁻¹' s) := fun s ↦ by
     apply MeasurableSet.isClopenable
-    exact hf (hb.isOpen s.2).measurableSet
+    exact hf.subtype_mk (hb.isOpen s.2).measurableSet
   choose T Tt Tpolish _ Topen using this
   obtain ⟨t', t'T, t't, t'_polish⟩ :
     ∃ t' : TopologicalSpace α, (∀ i, t' ≤ T i) ∧ t' ≤ t ∧ @PolishSpace α t' :=
     exists_polishSpace_forall_le T Tt Tpolish
   refine' ⟨t', t't, _, t'_polish⟩
-  refine hb.continuous _ fun s hs => ?_
-  exact t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
+  have : Continuous[t', _] (rangeFactorization f) :=
+    hb.continuous _ fun s hs => t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩)
+  exact continuous_subtype_val.comp this
 #align measurable.exists_continuous Measurable.exists_continuous
 
+/-- The image of a measurable set in a Polish space under a measurable map is an analytic set. -/
+theorem _root_.MeasurableSet.analyticSet_image {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y]
+    [OpensMeasurableSpace Y] {f : X → Y} [SecondCountableTopology (range f)] {s : Set X}
+    (hs : MeasurableSet s) (hf : Measurable f) : AnalyticSet (f '' s) := by
+  borelize X
+  rcases hf.exists_continuous with ⟨τ', hle, hfc, hτ'⟩
+  letI m' : MeasurableSpace X := @borel _ τ'
+  haveI b' : BorelSpace X := ⟨rfl⟩
+  have hle := borel_anti hle
+  exact (hle _ hs).analyticSet.image_of_continuous hfc
+#align measurable_set.analytic_set_image MeasurableSet.analyticSet_image
+
 /-! ### Separating sets with measurable sets -/
 
 
@@ -290,8 +304,8 @@ theorem MeasurablySeparable.iUnion [Countable ι] {α : Type _} [MeasurableSpace
 contained in disjoint Borel sets (see the full statement in `AnalyticSet.measurablySeparable`).
 Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`.
 -/
-theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α] [BorelSpace α]
-    {f g : (ℕ → ℕ) → α} (hf : Continuous f) (hg : Continuous g)
+theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
+    [OpensMeasurableSpace α] {f g : (ℕ → ℕ) → α} (hf : Continuous f) (hg : Continuous g)
     (h : Disjoint (range f) (range g)) : MeasurablySeparable (range f) (range g) := by
   /- We follow [Kechris, *Classical Descriptive Set Theory* (Theorem 14.7)][kechris1995].
     If the ranges are not Borel-separated, then one can find two cylinders of length one whose
@@ -404,8 +418,9 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α]
 
 /-- The Lusin separation theorem: if two analytic sets are disjoint, then they are contained in
 disjoint Borel sets. -/
-theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [BorelSpace α] {s t : Set α}
-    (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) : MeasurablySeparable s t := by
+theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
+    {s t : Set α} (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) :
+    MeasurablySeparable s t := by
   rw [AnalyticSet] at hs ht
   rcases hs with (rfl | ⟨f, f_cont, rfl⟩)
   · refine' ⟨∅, Subset.refl _, by simp, MeasurableSet.empty⟩
@@ -414,8 +429,133 @@ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [Borel
   exact measurablySeparable_range_of_disjoint f_cont g_cont h
 #align measure_theory.analytic_set.measurably_separable MeasureTheory.AnalyticSet.measurablySeparable
 
-/-! ### Injective images of Borel sets -/
+/-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic
+complement is measurable. -/
+theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α]
+    {s : Set α} (hs : AnalyticSet s) (hsc : AnalyticSet (sᶜ)) : MeasurableSet s := by
+  rcases hs.measurablySeparable hsc disjoint_compl_right with ⟨u, hsu, hdu, hmu⟩
+  obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu)
+  exact hmu
+#align measure_theory.analytic_set.measurable_set_of_compl MeasureTheory.AnalyticSet.measurableSet_of_compl
 
+end MeasureTheory
+
+/-!
+### Measurability of preimages under measurable maps
+-/
+
+namespace Measurable
+
+variable {X Y β : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X]
+  [TopologicalSpace Y] [T2Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β]
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then the preimage of a set `s` is measurable if and only if the set
+is measurable.
+One implication is the definition of measurability, the other one heavily relies on `X` being a
+Polish space. -/
+theorem measurableSet_preimage_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
+    (hf : Measurable f) (hsurj : Surjective f) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet s := by
+  refine ⟨fun h => ?_, fun h => hf h⟩
+  apply AnalyticSet.measurableSet_of_compl
+  · rw [← image_preimage_eq s hsurj]
+    exact h.analyticSet_image hf
+  · rw [← image_preimage_eq (sᶜ) hsurj]
+    exact h.compl.analyticSet_image hf
+#align measurable.measurable_set_preimage_iff_of_surjective Measurable.measurableSet_preimage_iff_of_surjective
+
+theorem map_measurableSpace_eq [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Y› :=
+  MeasurableSpace.ext fun _ => hf.measurableSet_preimage_iff_of_surjective hsurj
+#align measurable.map_measurable_space_eq Measurable.map_measurableSpace_eq
+
+theorem map_measurableSpace_eq_borel [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by
+  have d := hf.mono le_rfl OpensMeasurableSpace.borel_le
+  letI := borel Y; haveI : BorelSpace Y := ⟨rfl⟩
+  exact d.map_measurableSpace_eq hsurj
+#align measurable.map_measurable_space_eq_borel Measurable.map_measurableSpace_eq_borel
+
+theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f)
+    (hsurj : Surjective f) : BorelSpace Y :=
+  ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩
+#align measurable.borel_space_codomain Measurable.borelSpace_codomain
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then the preimage of a set `s` is measurable if and only if the set is
+measurable in `Set.range f`. -/
+theorem measurableSet_preimage_iff_preimage_val {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet ((↑) ⁻¹' s : Set (range f)) :=
+  have hf' : Measurable (rangeFactorization f) := hf.subtype_mk
+  hf'.measurableSet_preimage_iff_of_surjective (s := Subtype.val ⁻¹' s) surjective_onto_range
+#align measurable.measurable_set_preimage_iff_preimage_coe Measurable.measurableSet_preimage_iff_preimage_val
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology and the range of `f` is measurable, then the preimage of a set `s` is measurable
+if and only if the intesection with `Set.range f` is measurable. -/
+theorem measurableSet_preimage_iff_inter_range {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Y} :
+    MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by
+  rw [hf.measurableSet_preimage_iff_preimage_val,
+    ← (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe]
+#align measurable.measurable_set_preimage_iff_inter_range Measurable.measurableSet_preimage_iff_inter_range
+
+/-- If `f : X → Y` is a Borel measurable map from a Polish space to a topological space with second
+countable topology, then for any measurable space `β` and `g : Y → β`, the composition `g ∘ f` is
+measurable if and only if the restriction of `g` to the range of `f` is measurable. -/
+theorem measurable_comp_iff_restrict {f : X → Y} [SecondCountableTopology (range f)]
+    (hf : Measurable f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) :=
+  forall₂_congr fun s _ => measurableSet_preimage_iff_preimage_val hf (s := g ⁻¹' s)
+#align measurable.measurable_comp_iff_restrict Measurable.measurable_comp_iff_restrict
+
+/-- If `f : X → Y` is a surjective Borel measurable map from a Polish space to a topological space
+with second countable topology, then for any measurable space `α` and `g : Y → α`, the composition
+`g ∘ f` is measurable if and only if `g` is measurable. -/
+theorem measurable_comp_iff_of_surjective [SecondCountableTopology Y] {f : X → Y}
+    (hf : Measurable f) (hsurj : Surjective f) {g : Y → β} : Measurable (g ∘ f) ↔ Measurable g :=
+  forall₂_congr fun s _ => measurableSet_preimage_iff_of_surjective hf hsurj (s := g ⁻¹' s)
+#align measurable.measurable_comp_iff_of_surjective Measurable.measurable_comp_iff_of_surjective
+
+end Measurable
+
+theorem Continuous.map_eq_borel {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y]
+    {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) :
+    MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by
+  borelize Y
+  exact hf.measurable.map_measurableSpace_eq hsurj
+#align continuous.map_eq_borel Continuous.map_eq_borel
+
+theorem Continuous.map_borel_eq {X Y : Type _} [TopologicalSpace X] [PolishSpace X]
+    [TopologicalSpace Y] [T2Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f)
+    (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y := by
+  borelize X
+  exact hf.map_eq_borel hsurj
+#align continuous.map_borel_eq Continuous.map_borel_eq
+
+instance Quotient.borelSpace {X : Type _} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X]
+    [BorelSpace X] {s : Setoid X} [T2Space (Quotient s)] [SecondCountableTopology (Quotient s)] :
+    BorelSpace (Quotient s) :=
+  ⟨continuous_quotient_mk'.map_eq_borel (surjective_quotient_mk _)⟩
+#align quotient.borel_space Quotient.borelSpace
+
+@[to_additive]
+instance QuotientGroup.borelSpace {G : Type _} [TopologicalSpace G] [PolishSpace G] [Group G]
+    [TopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.Normal]
+    [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) :=
+  -- porting note: 1st and 3rd `haveI`s were not needed in Lean 3
+  haveI := Subgroup.t3_quotient_of_isClosed N
+  haveI := @PolishSpace.secondCountableTopology G
+  haveI := QuotientGroup.secondCountableTopology (Γ := N)
+  Quotient.borelSpace
+#align quotient_group.borel_space QuotientGroup.borelSpace
+#align quotient_add_group.borel_space QuotientAddGroup.borelSpace
+
+namespace MeasureTheory
+
+/-! ### Injective images of Borel sets -/
 
 variable {γ : Type _} [tγ : TopologicalSpace γ] [PolishSpace γ]
 
@@ -710,7 +850,6 @@ end MeasureTheory
 
 /-! ### The Borel Isomorphism Theorem -/
 
-
 -- Porting note: Move to topology/metric_space/polish when porting.
 instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
     PolishSpace α := by
style: allow _ for an argument in notation3 & replace _foo with _ in notation3 (#4652)
Diff
@@ -464,7 +464,7 @@ theorem measurableSet_range_of_continuous_injective {β : Type _} [TopologicalSp
   obtain ⟨u, u_anti, u_pos, u_lim⟩ :
     ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) :=
     exists_seq_strictAnti_tendsto (0 : ℝ)
-  let F : ℕ → Set β := fun n => ⋃ (s : b) (_hs : Bounded s.1 ∧ diam s.1 ≤ u n), E s
+  let F : ℕ → Set β := fun n => ⋃ (s : b) (_ : Bounded s.1 ∧ diam s.1 ≤ u n), E s
   -- it is enough to show that `range f = ⋂ F n`, as the latter set is obviously measurable.
   suffices range f = ⋂ n, F n by
     have E_meas : ∀ s : b, MeasurableSet (E s) := by
refactor: use the typeclass SProd to implement overloaded notation · ×ˢ · (#4200)

Currently, the following notations are changed from · ×ˢ · because Lean 4 can't deal with ambiguous notations. | Definition | Notation | | :

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>

Diff
@@ -690,7 +690,7 @@ theorem measurableSet_exists_tendsto [hγ : OpensMeasurableSpace γ] [Countable
   change MeasurableSet { x | _ ∧ _ }
   have :
     ∀ x,
-      (map (fun i => f i x) l ×ᶠ map (fun i => f i x) l).HasAntitoneBasis fun n =>
+      (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 _),
chore: tidy various files (#4304)

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>

Diff
@@ -59,9 +59,7 @@ We use this to prove several versions of the Borel isomorphism theorem.
 -/
 
 
-open Set Function PolishSpace PiNat TopologicalSpace Metric Filter
-
-open Topology MeasureTheory Filter
+open Set Function PolishSpace PiNat TopologicalSpace Metric Filter Topology MeasureTheory
 
 variable {α : Type _} [TopologicalSpace α] {ι : Type _}
 
@@ -713,7 +711,7 @@ end MeasureTheory
 /-! ### The Borel Isomorphism Theorem -/
 
 
---Note: Move to topology/metric_space/polish when porting.
+-- Porting note: Move to topology/metric_space/polish when porting.
 instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopology α] :
     PolishSpace α := by
   obtain ⟨f, hf⟩ := h.exists_injective_nat
@@ -725,7 +723,7 @@ instance (priority := 50) polish_of_countable [h : Countable α] [DiscreteTopolo
 
 namespace PolishSpace
 
-/-Note: This is to avoid a loop in TC inference. When ported to Lean 4, this will not
+/- Porting note: This is to avoid a loop in TC inference. When ported to Lean 4, this will not
 be necessary, and `secondCountable_of_polish` should probably
 just be added as an instance soon after the definition of `PolishSpace`.-/
 private theorem secondCountable_of_polish [h : PolishSpace α] : SecondCountableTopology α :=
@@ -765,8 +763,7 @@ noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬
 they are Borel isomorphic.-/
 noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β := by
   by_cases h : Countable α
-  · letI := h
-    letI := Countable.of_equiv α e
+  · letI := Countable.of_equiv α e
     refine ⟨e, ?_, ?_⟩ <;> apply measurable_of_countable
   refine' measurableEquivOfNotCountable h _
   rwa [e.countable_iff] at h
@@ -776,7 +773,7 @@ end PolishSpace
 
 namespace MeasureTheory
 
--- todo after the port: move to topology/metric_space/polish
+-- Porting note: todo after the port: move to topology/metric_space/polish
 instance instPolishSpaceUniv [PolishSpace α] : PolishSpace (univ : Set α) :=
   isClosed_univ.polishSpace
 #align measure_theory.set.univ.polish_space MeasureTheory.instPolishSpaceUniv
feat: port MeasureTheory.Constructions.Polish (#4064)

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com>

Dependencies 10 + 653

654 files ported (98.5%)
296927 lines ported (98.2%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file