real analysis(measure theory - Hilbert's cube) - challenging problem Preliminary: Hilbert's cube $\mathcal H$ is defined as the set of sequences $\{x_{1},x_{2},\dots \}$ such that $\forall i\in \mathbb{N}: x_{i} \in [0,\frac{1}{i} ]$. The distance between $x,y \in \mathcal H$ is defined as $\rho_{\infty}:=\sup\limits_{i\in \mathbb{N}} |x_{i}-y_{i}|$
Theorem: Let: $(X,d)$ be separable metric space such that $diam(X) \leq 1$. Prove that: $X$ is homeomorphic with some subset of $\mathcal H$.
What I did by far: By far I came to the conclusion that proof can be partitioned into 3 following steps:


*

*Let $\{a_{1},a_{2},\dots \}$ be dense subset in $X$. Define $f(x):=\big\{ d(a_{1},x), \dots, \frac{1}{k}d(a_{k},x),\dots \big\}$

*Prove that $f$ is an injection and is continous

*Investigate the continuity of $f^{-1}$


The problem is that I struggle with writing formal proof of these steps. Besides, I am not sure whether this outline is sufficient for proof of the aformentioned theorem.
Help very appreciated!
 A: To start off:


*

*Suppose $f(x) = f(y)$. Then $d(x,a_i) = d(y,a_i)$ for every $i \in \mathbb{N}^\star$. Let us suppose that $x \neq y$: then there exists $\varepsilon > 0$ such that $d(x,y) > \varepsilon$. Therefore, $\varepsilon < d(x,a_i) + d(a_i, y) = 2\,d(x,a_i)$ for every $i$. Nonetheless, since $\{a_i : i \in \mathbb{N}$} is a dense subset of $X$, there exists a sequence  $a_{i_j}$ that converges to $x$, which is impossible as $d(x, a_{i_j}) > \frac{\varepsilon}{2}$ for every $j \in \mathbb{N}$. Therefore $f$ is injective. 

*Let us prove that $f$ is continuous. Let $x_0 \in X$, and $x$ such that $d(x,x_0) < \varepsilon$. Then, for every $i \in \mathbb{N}^\star$, we have:
\begin{align*}
\frac{1}{i}\Big|\,d(x,a_i) - d(x_0, a_i)\,\Big| \leq \frac{1}{i}d(x,x_0) < \frac{\varepsilon}{i}
\end{align*}
Therefore $\rho_{\infty}(f(x),f(x_0)) < \varepsilon$, meaning $f(B(x_0, \varepsilon) \subset B(f(x_0), \varepsilon)$, yielding the continuity of $f$. 

*We prove that $f^{-1} : f(X) \to X$ is continuous. Let $f(x_0) \in f(X)$, and $\eta > 0$. By density, we can find $k$ such that $d(x_0,a_k) < \eta/3$. Moreover, one has:
\begin{align*}
d(x_0,y) &\leq d(x_0,a_k) + d(a_k,y)\\
&\leq 2\,d(x_0,a_k) + |d(x_0,a_k) - d(y,a_k)|\\
&\leq \frac{2}{3}\eta + k\rho_{\infty}(f(x_0), f(y))
\end{align*}
Therefore $f^{-1}(B(f(x_0), \frac{\eta}{3k})) \subset B(x_0, \eta)$, yielding continuity of $f^{-1}$ at $f(x_0)$.
