l3lab/ntp-mathlib huggingface dataset:
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        

Proof state:
p : ℕ
hp : Fact (Nat.Prime p)
x : ℚ_[p]
hx✝ : ¬‖x‖ ≤ 1
n : ℕ := Int.toNat (-Padic.valuation x)
hn : n = Int.toNat (-Padic.valuation x)
hn_coe : ↑n = -Padic.valuation x
a : ℚ_[p] := x * ↑p ^ n
ha : a = x * ↑p ^ n
hx : x ≠ 0
⊢ ↑p ≠ 0 ∨ -Padic.valuation x + -↑n ≠ 0 ∨ -Padic.valuation x = 0 ∧ -↑n = 0

Next tactic:
exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
      

Proof state:
case neg
p : ℕ
hp : Fact (Nat.Prime p)
x : ℚ_[p]
hx : ¬‖x‖ ≤ 1
n : ℕ := Int.toNat (-Padic.valuation x)
hn : n = Int.toNat (-Padic.valuation x)
hn_coe : ↑n = -Padic.valuation x
a : ℚ_[p] := x * ↑p ^ n
ha : a = x * ↑p ^ n
ha_norm : ‖a‖ = 1
⊢ ∃ x_1, x * (algebraMap ℤ_[p] ℚ_[p]) ↑x_1.2 = (algebraMap ℤ_[p] ℚ_[p]) x_1.1

Next tactic:
use
        (⟨a, le_of_eq ha_norm⟩,
          ⟨(p ^ n : ℤ_[p]), mem_nonZeroDivisors_iff_ne_zero.mpr (NeZero.ne _)⟩)
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
      use
        (⟨a, le_of_eq ha_norm⟩,
          ⟨(p ^ n : ℤ_[p]), mem_nonZeroDivisors_iff_ne_zero.mpr (NeZero.ne _)⟩)
      

Proof state:
case h
p : ℕ
hp : Fact (Nat.Prime p)
x : ℚ_[p]
hx : ¬‖x‖ ≤ 1
n : ℕ := Int.toNat (-Padic.valuation x)
hn : n = Int.toNat (-Padic.valuation x)
hn_coe : ↑n = -Padic.valuation x
a : ℚ_[p] := x * ↑p ^ n
ha : a = x * ↑p ^ n
ha_norm : ‖a‖ = 1
⊢ x *
      (algebraMap ℤ_[p] ℚ_[p])
        ↑({ val := a, property := (_ : ‖a‖ ≤ 1) },
              { val := ↑p ^ n, property := (_ : ↑p ^ n ∈ nonZeroDivisors ℤ_[p]) }).2 =
    (algebraMap ℤ_[p] ℚ_[p])
      ({ val := a, property := (_ : ‖a‖ ≤ 1) }, { val := ↑p ^ n, property := (_ : ↑p ^ n ∈ nonZeroDivisors ℤ_[p]) }).1

Next tactic:
simp only [map_pow, map_natCast, algebraMap_apply, PadicInt.coe_pow, PadicInt.coe_nat_cast,
        Subtype.coe_mk, Nat.cast_pow]
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
      use
        (⟨a, le_of_eq ha_norm⟩,
          ⟨(p ^ n : ℤ_[p]), mem_nonZeroDivisors_iff_ne_zero.mpr (NeZero.ne _)⟩)
      simp only [map_pow, map_natCast, algebraMap_apply, PadicInt.coe_pow, PadicInt.coe_nat_cast,
        Subtype.coe_mk, Nat.cast_pow]
  exists_of_eq := by
    

Proof state:
p : ℕ
hp : Fact (Nat.Prime p)
⊢ ∀ {x y : ℤ_[p]}, (algebraMap ℤ_[p] ℚ_[p]) x = (algebraMap ℤ_[p] ℚ_[p]) y → ∃ c, ↑c * x = ↑c * y

Next tactic:
simp_rw [algebraMap_apply, Subtype.coe_inj]
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
      use
        (⟨a, le_of_eq ha_norm⟩,
          ⟨(p ^ n : ℤ_[p]), mem_nonZeroDivisors_iff_ne_zero.mpr (NeZero.ne _)⟩)
      simp only [map_pow, map_natCast, algebraMap_apply, PadicInt.coe_pow, PadicInt.coe_nat_cast,
        Subtype.coe_mk, Nat.cast_pow]
  exists_of_eq := by
    simp_rw [algebraMap_apply, Subtype.coe_inj]
    

Proof state:
p : ℕ
hp : Fact (Nat.Prime p)
⊢ ∀ {x y : ℤ_[p]}, x = y → ∃ c, ↑c * x = ↑c * y

Next tactic:
exact fun h => ⟨1, by rw [h]⟩
instance isFractionRing : IsFractionRing ℤ_[p] ℚ_[p] where
  map_units' := fun ⟨x, hx⟩ => by
    rwa [algebraMap_apply, isUnit_iff_ne_zero, PadicInt.coe_ne_zero, ←
      mem_nonZeroDivisors_iff_ne_zero]
  surj' x := by
    by_cases hx : ‖x‖ ≤ 1
    · use (⟨x, hx⟩, 1)
      rw [Submonoid.coe_one, map_one, mul_one, PadicInt.algebraMap_apply, Subtype.coe_mk]
    · set n := Int.toNat (-x.valuation) with hn
      have hn_coe : (n : ℤ) = -x.valuation := by
        rw [hn, Int.toNat_of_nonneg]
        rw [Right.nonneg_neg_iff]
        rw [Padic.norm_le_one_iff_val_nonneg, not_le] at hx
        exact hx.le
      set a := x * (p : ℚ_[p]) ^ n with ha
      have ha_norm : ‖a‖ = 1 := by
        have hx : x ≠ 0 := by
          intro h0
          rw [h0, norm_zero] at hx
          exact hx zero_le_one
        rw [ha, padicNormE.mul, padicNormE.norm_p_pow, Padic.norm_eq_pow_val hx, ← zpow_add',
          hn_coe, neg_neg, add_left_neg, zpow_zero]
        exact Or.inl (Nat.cast_ne_zero.mpr (NeZero.ne p))
      use
        (⟨a, le_of_eq ha_norm⟩,
          ⟨(p ^ n : ℤ_[p]), mem_nonZeroDivisors_iff_ne_zero.mpr (NeZero.ne _)⟩)
      simp only [map_pow, map_natCast, algebraMap_apply, PadicInt.coe_pow, PadicInt.coe_nat_cast,
        Subtype.coe_mk, Nat.cast_pow]
  exists_of_eq := by
    simp_rw [algebraMap_apply, Subtype.coe_inj]
    exact fun h => ⟨1, by 

Proof state:
p : ℕ
hp : Fact (Nat.Prime p)
x✝ y✝ : ℤ_[p]
h : x✝ = y✝
⊢ ↑1 * x✝ = ↑1 * y✝

Next tactic:
rw [h]
/-- 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
rewrite with `eq_borel_upgradeStandardBorel α`.
TODO: fix the corresponding bug in `borelize`. -/
noncomputable
def upgradeStandardBorel [MeasurableSpace α] [h : StandardBorelSpace α] :
    UpgradedStandardBorel α := by
  

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
h : StandardBorelSpace α
⊢ UpgradedStandardBorel α

Next tactic:
choose τ hb hp using h.polish
/-- 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
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
  

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
h : StandardBorelSpace α
τ : TopologicalSpace α
hb : BorelSpace α
hp : PolishSpace α
⊢ UpgradedStandardBorel α

Next tactic:
constructor
instance standardBorel_of_polish [τ : TopologicalSpace α]
    [BorelSpace α] [PolishSpace α] : StandardBorelSpace α := by 

Proof state:
α : Type u_1
inst✝² : MeasurableSpace α
τ : TopologicalSpace α
inst✝¹ : BorelSpace α
inst✝ : PolishSpace α
⊢ StandardBorelSpace α

Next tactic:
exists τ
theorem analyticSet_empty : AnalyticSet (∅ : Set α) := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
⊢ AnalyticSet ∅

Next tactic:
rw [AnalyticSet]
theorem analyticSet_empty : AnalyticSet (∅ : Set α) := by
  rw [AnalyticSet]
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
⊢ ∅ = ∅ ∨ ∃ f, Continuous f ∧ range f = ∅

Next tactic:
exact Or.inl rfl
theorem analyticSet_range_of_polishSpace {β : Type*} [TopologicalSpace β] [PolishSpace β]
    {f : β → α} (f_cont : Continuous f) : AnalyticSet (range f) := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
⊢ AnalyticSet (range f)

Next tactic:
cases isEmpty_or_nonempty β
theorem analyticSet_range_of_polishSpace {β : Type*} [TopologicalSpace β] [PolishSpace β]
    {f : β → α} (f_cont : Continuous f) : AnalyticSet (range f) := by
  cases isEmpty_or_nonempty β
  · 

Proof state:
case inl
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : IsEmpty β
⊢ AnalyticSet (range f)

Next tactic:
rw [range_eq_empty]
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]
    

Proof state:
case inl
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : IsEmpty β
⊢ AnalyticSet ∅

Next tactic:
exact analyticSet_empty
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]
    exact analyticSet_empty
  · 

Proof state:
case inr
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : Nonempty β
⊢ AnalyticSet (range f)

Next tactic:
rw [AnalyticSet]
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]
    exact analyticSet_empty
  · rw [AnalyticSet]
    

Proof state:
case inr
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : Nonempty β
⊢ range f = ∅ ∨ ∃ f_1, Continuous f_1 ∧ range f_1 = range f

Next tactic:
obtain ⟨g, g_cont, hg⟩ : ∃ g : (ℕ → ℕ) → β, Continuous g ∧ Surjective g :=
      exists_nat_nat_continuous_surjective β
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]
    exact analyticSet_empty
  · rw [AnalyticSet]
    obtain ⟨g, g_cont, hg⟩ : ∃ g : (ℕ → ℕ) → β, Continuous g ∧ Surjective g :=
      exists_nat_nat_continuous_surjective β
    

Proof state:
case inr.intro.intro
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : Nonempty β
g : (ℕ → ℕ) → β
g_cont : Continuous g
hg : Surjective g
⊢ range f = ∅ ∨ ∃ f_1, Continuous f_1 ∧ range f_1 = range f

Next tactic:
refine' Or.inr ⟨f ∘ g, f_cont.comp g_cont, _⟩
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]
    exact analyticSet_empty
  · rw [AnalyticSet]
    obtain ⟨g, g_cont, hg⟩ : ∃ g : (ℕ → ℕ) → β, Continuous g ∧ Surjective g :=
      exists_nat_nat_continuous_surjective β
    refine' Or.inr ⟨f ∘ g, f_cont.comp g_cont, _⟩
    

Proof state:
case inr.intro.intro
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
f : β → α
f_cont : Continuous f
h✝ : Nonempty β
g : (ℕ → ℕ) → β
g_cont : Continuous g
hg : Surjective g
⊢ range (f ∘ g) = range f

Next tactic:
rw [hg.range_comp]
/-- The image of an open set under a continuous map is analytic. -/
theorem _root_.IsOpen.analyticSet_image {β : Type*} [TopologicalSpace β] [PolishSpace β]
    {s : Set β} (hs : IsOpen s) {f : β → α} (f_cont : Continuous f) : AnalyticSet (f '' s) := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
s : Set β
hs : IsOpen s
f : β → α
f_cont : Continuous f
⊢ AnalyticSet (f '' s)

Next tactic:
rw [image_eq_range]
/-- The image of an open set under a continuous map is analytic. -/
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]
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
s : Set β
hs : IsOpen s
f : β → α
f_cont : Continuous f
⊢ AnalyticSet (range fun x => f ↑x)

Next tactic:
haveI : PolishSpace s := hs.polishSpace
/-- The image of an open set under a continuous map is analytic. -/
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
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝² : TopologicalSpace α
β : Type u_3
inst✝¹ : TopologicalSpace β
inst✝ : PolishSpace β
s : Set β
hs : IsOpen s
f : β → α
f_cont : Continuous f
this : PolishSpace ↑s
⊢ AnalyticSet (range fun x => f ↑x)

Next tactic:
exact analyticSet_range_of_polishSpace (f_cont.comp continuous_subtype_val)
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  

Proof state:
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
⊢ AnalyticSet s ↔ ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
constructor
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
⊢ AnalyticSet s → ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
intro h
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    

Proof state:
case mp
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : AnalyticSet s
⊢ ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
rw [AnalyticSet] at h
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    

Proof state:
case mp
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : s = ∅ ∨ ∃ f, Continuous f ∧ range f = s
⊢ ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
cases' h with h h
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · 

Proof state:
case mp.inl
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : s = ∅
⊢ ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      

Proof state:
case mp.inl
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : s = ∅
⊢ range Empty.elim = s

Next tactic:
rw [h]
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      rw [h]
      

Proof state:
case mp.inl
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : s = ∅
⊢ range Empty.elim = ∅

Next tactic:
exact range_eq_empty _
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      rw [h]
      exact range_eq_empty _
    · 

Proof state:
case mp.inr
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
h : ∃ f, Continuous f ∧ range f = s
⊢ ∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s

Next tactic:
exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      rw [h]
      exact range_eq_empty _
    · exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩
  · 

Proof state:
case mpr
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
⊢ (∃ β h, ∃ (_ : PolishSpace β), ∃ f, Continuous f ∧ range f = s) → AnalyticSet s

Next tactic:
rintro ⟨β, h, h', f, f_cont, f_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 ↔
      ∃ (β : Type) (h : TopologicalSpace β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      rw [h]
      exact range_eq_empty _
    · exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩
  · rintro ⟨β, h, h', f, f_cont, f_range⟩
    

Proof state:
case mpr.intro.intro.intro.intro.intro
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
β : Type
h : TopologicalSpace β
h' : PolishSpace β
f : β → α
f_cont : Continuous f
f_range : range f = s
⊢ AnalyticSet s

Next tactic:
skip
/-- 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 β) (_ : @PolishSpace β h) (f : β → α),
        @Continuous _ _ h _ f ∧ range f = s := by
  constructor
  · intro h
    rw [AnalyticSet] at h
    cases' h with h h
    · refine' ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, _⟩
      rw [h]
      exact range_eq_empty _
    · exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩
  · rintro ⟨β, h, h', f, f_cont, f_range⟩
    skip
    

Proof state:
case mpr.intro.intro.intro.intro.intro
α : Type u_1
ι : Type u_2
inst✝ : TopologicalSpace α
s : Set α
β : Type
h : TopologicalSpace β
h' : PolishSpace β
f : β → α
f_cont : Continuous f
f_range : range f = s
⊢ AnalyticSet s

Next tactic:
rw [← f_range]