Cantor injection into a perfect complete metric set

See it in Lean

Axioms
ZFC only

Statement

A nonempty perfect subset \(C\) of a complete metric space admits a continuous injection from \(\{0,1\}^{\mathbb N}\) whose range lies in \(C\). A subset is perfect when it is closed and has no isolated points.

Proof

Construct a binary tree of nonempty relatively open subsets of \(C\). At each vertex choose two distinct points and disjoint small neighbourhoods whose closures lie in the current relatively open set. Choose their diameters at level \(n\) at most \(2^{-n}\), and continue within these neighbourhoods. This is possible because every nonempty relatively open subset of \(C\) has no isolated points.

Along each infinite binary branch, the closures are nested nonempty closed sets with diameters tending to zero. Completeness gives a unique common point, lying in \(C\). Branches which first differ at a vertex have their limit points in disjoint child closures, so the map is injective. Branches agreeing through level \(n\) have image points at distance at most \(2^{-n}\), proving continuity. \(\blacksquare\)

Where it is used

Cited on space pages