/-- Any nonempty perfect set in a complete metric space admits a continuous injection
from the Cantor space, `ℕ → Bool`. -/
theorem Perfect.exists_nat_bool_injection [CompleteSpace α] :
    ∃ f : (ℕ → Bool) → α, range f ⊆ C ∧ Continuous f ∧ Injective f := by
  obtain ⟨u, -, upos', hu⟩ := exists_seq_strictAnti_tendsto' (zero_lt_one' ℝ≥0∞)
  have upos := fun n => (upos' n).1
  let P := Subtype fun E : Set α => Perfect E ∧ E.Nonempty
  choose C0 C1 h0 h1 hdisj using
    fun {C : Set α} (hC : Perfect C) (hnonempty : C.Nonempty) {ε : ℝ≥0∞} (hε : 0 < ε) =>
    hC.small_diam_splitting hnonempty hε
  let DP : List Bool → P := fun l => by
    induction' l with a l ih; · exact ⟨C, ⟨hC, hnonempty⟩⟩
    cases a
    · use C0 ih.property.1 ih.property.2 (upos l.length.succ)
      exact ⟨(h0 _ _ _).1, (h0 _ _ _).2.1⟩
    use C1 ih.property.1 ih.property.2 (upos l.length.succ)
    exact ⟨(h1 _ _ _).1, (h1 _ _ _).2.1⟩
  let D : List Bool → Set α := fun l => (DP l).val
  have hanti : ClosureAntitone D := by
    refine' Antitone.closureAntitone _ fun l => (DP l).property.1.closed
    intro l a
    cases a
    · exact (h0 _ _ _).2.2.1
    exact (h1 _ _ _).2.2.1
  have hdiam : VanishingDiam D := by
    intro x
    apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hu
    · simp
    rw [eventually_atTop]
    refine' ⟨1, fun m (hm : 1 ≤ m) => _⟩
    rw [Nat.one_le_iff_ne_zero] at hm
    rcases Nat.exists_eq_succ_of_ne_zero hm with ⟨n, rfl⟩
    dsimp
    cases x n
    · convert (h0 _ _ _).2.2.2
      rw [PiNat.res_length]
    convert (h1 _ _ _).2.2.2
    rw [PiNat.res_length]
  have hdisj' : CantorScheme.Disjoint D := by
    rintro l (a | a) (b | b) hab <;> try contradiction
    · exact hdisj _ _ _
    exact (hdisj _ _ _).symm
  have hdom : ∀ {x : ℕ → Bool}, x ∈ (inducedMap D).1 := fun {x} => by
    rw [hanti.map_of_vanishingDiam hdiam fun l => (DP l).property.2]
    apply mem_univ
  refine' ⟨fun x => (inducedMap D).2 ⟨x, hdom⟩, _, _, _⟩
  · rintro y ⟨x, rfl⟩
    

Proof state:
case intro.intro.intro.refine'_1.intro
α : Type u_1
inst✝¹ : MetricSpace α
C : Set α
hC : Perfect C
ε : ℝ≥0∞
hnonempty : Set.Nonempty C
inst✝ : CompleteSpace α
u : ℕ → ℝ≥0∞
upos' : ∀ (n : ℕ), u n ∈ Ioo 0 1
hu : Tendsto u atTop (𝓝 0)
upos : ∀ (n : ℕ), 0 < u n
P : Type u_1 := { E // Perfect E ∧ Set.Nonempty E }
C0 C1 : {C : Set α} → Perfect C → Set.Nonempty C → {ε : ℝ≥0∞} → 0 < ε → Set α
h0 :
  ∀ {C : Set α} (hC : Perfect C) (hnonempty : Set.Nonempty C) {ε : ℝ≥0∞} (hε : 0 < ε),
    Perfect (C0 hC hnonempty hε) ∧
      Set.Nonempty (C0 hC hnonempty hε) ∧ C0 hC hnonempty hε ⊆ C ∧ EMetric.diam (C0 hC hnonempty hε) ≤ ε
h1 :
  ∀ {C : Set α} (hC : Perfect C) (hnonempty : Set.Nonempty C) {ε : ℝ≥0∞} (hε : 0 < ε),
    Perfect (C1 hC hnonempty hε) ∧
      Set.Nonempty (C1 hC hnonempty hε) ∧ C1 hC hnonempty hε ⊆ C ∧ EMetric.diam (C1 hC hnonempty hε) ≤ ε
hdisj :
  ∀ {C : Set α} (hC : Perfect C) (hnonempty : Set.Nonempty C) {ε : ℝ≥0∞} (hε : 0 < ε),
    Disjoint (C0 hC hnonempty hε) (C1 hC hnonempty hε)
DP : List Bool → P :=
  fun l =>
    List.rec { val := C, property := (_ : Perfect C ∧ Set.Nonempty C) }
      (fun a l ih =>
        Bool.casesOn (motive := fun t => a = t → P) a
          (fun h =>
            { val := C0 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l))),
              property :=
                (_ :
                  Perfect (C0 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l)))) ∧
                    Set.Nonempty
                      (C0 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l))))) })
          (fun h =>
            { val := C1 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l))),
              property :=
                (_ :
                  Perfect (C1 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l)))) ∧
                    Set.Nonempty
                      (C1 (_ : Perfect ↑ih) (_ : Set.Nonempty ↑ih) (_ : 0 < u (Nat.succ (List.length l))))) })
          (_ : a = a))
      l
D : List Bool → Set α := fun l => ↑(DP l)
hanti : ClosureAntitone D
hdiam : VanishingDiam D
hdisj' : CantorScheme.Disjoint D
hdom : ∀ {x : ℕ → Bool}, x ∈ (inducedMap D).fst
x : ℕ → Bool
⊢ (fun x => Sigma.snd (inducedMap D) { val := x, property := (_ : x ∈ (inducedMap D).fst) }) x ∈ C

Next tactic:
exact map_mem ⟨_, hdom⟩ 0