Let $(X, d)$ be a separable metric space. There exists a compact metric space $(Y, d')$ and a map $T:X\to Y$ such that $X$ is homeomorphic to $T(X)$ In proving the reverse direction of Prokhorov theorem, I have to prove this auxiliary result. Could you verify if my attempt is fine?

Let $(X, d)$ be a separable metric space. There exists a compact metric space $(Y, d')$ and a map $T: X \to Y$ such that $T$ is a homeomorphism from $X$ onto $T(X)$.

I post my proof separately as below answer. This allows me to subsequently remove this question from unanswered list.
 A: There is a quantification/uniformity of convergence problem in the redaction at the end. I would put :

Let $x, x_1,x_2,\ldots \in X$ such that $T(x_n) \to T(x)$. Then $\alpha_i(x_n) \xrightarrow{n \to \infty} \alpha_i(x)$ for all $i$. Let $I:=\{i \ge 1 \mid \alpha_i(x) <1\}$. There is a subsequence $\lambda \in I^\mathbb N$ such that $\alpha_{\lambda(i)} (x) \xrightarrow{i \to \infty} 0$.
Let now $n,i \geq 1$. We have
$$
\begin{align}
d(x_n, x) &\le  d(x_n, a_{\lambda(i)}) + d(a_{\lambda(i)}, x) 
\end{align}
$$
Let $\varepsilon>0$. There exists an $i\in I$ such that the second term is $<\varepsilon/2$. Now fix this $i$. Since $d(x_n,a_{\lambda(i)}) \to_{n\to\infty} 0$, there exists $n_0$ such that for all $n\geq n_0$, the first term is $<\varepsilon/2$.
For that choice of $i$, $n_0$ and $n\geq n_0$, we have $d(x_n, x) \le \varepsilon/2 + \varepsilon/2 = \varepsilon$. We have just shown that for every $\varepsilon > 0$, there exists $n_0$ such that for all $n\neq n_0$,  $d(x_n,x) \le \varepsilon$. i.e.
$$
\lim_n d(x_n, x) =0.
$$
A: Let $Y := [0, 1]^\mathbb N$. We define a metric $d'$ on $Y$ by
$$
d'(\xi, \eta) := \sum_{i=1}^\infty 2^{-i} | \xi_i - \eta_i|  \quad \forall \xi, \eta \in Y.
$$
The topology induced by $d'$ coincides with the product topology of $Y$. By Tychonoff theorem, $(Y, d')$ is compact. Let $D := \{a_1, a_2,\ldots\}$ be a dense subset of $X$. We define
$$
\alpha_i(x) := \min \{ d(x,a_i), 1\} \quad \forall i \ge 1, x \in X.
$$
Then $\alpha_i:X \to \mathbb R$ is continuous bounded for all $i$. We define $T:X \to Y$ by
$$
T(x) := (\alpha_i(x))_{i\ge 1} \quad \forall x \in X.
$$
Fix $x, y\in X$ such that $T(x)=T(y)$. Then
$$
\min \{ d(x,a_i), 1\} = \min \{ d(y,a_i), 1\} \quad \forall i.
$$
There is a subsequence $\lambda \in \mathbb N^\mathbb N$ such that $a_{\lambda(i)} \xrightarrow{i \to \infty} x$. WLOG, we assume $d(x, a_{\lambda(i)}) <1$ for all $i$. It follows that $d(x, a_{\lambda(i)}) = d(y, a_{\lambda(i)})$ for all $i$. Hence $a_{\lambda(i)} \xrightarrow{i \to \infty} y$. Hence $x=y$ and thus $T$ is injective.
Let $x, x_1,x_2,\ldots \in X$ such that $x_n \to x$. Then $d(x_n, a_i) \xrightarrow{n \to \infty} d(x,a_i)$ and thus $\alpha_i(x_n) \xrightarrow{n \to \infty} \alpha_i(x)$ for all $i$.  Product topology is the topology of pointwise convergence, so $T(x_n) \to T(x)$.
Let $x, x_1,x_2,\ldots \in X$ such that $T(x_n) \to T(x)$. Then $\alpha_i(x_n) \xrightarrow{n \to \infty} \alpha_i(x)$ for all $i$. Let $I:=\{i \ge 1 \mid \alpha_i(x) <1\}$. There is a subsequence $\lambda \in I^\mathbb N$ such that

*

*$\alpha_{\lambda(i)} (x) \xrightarrow{i \to \infty} 0$, and

*$d(x_n, a_{\lambda(i)}) \xrightarrow{n \to \infty} d(x, a_{\lambda(i)})$ for all $i$.

Hence $a_{\lambda(i)} \xrightarrow{i \to \infty} x$. Finally,
$$
\begin{align}
\lim_n d(x_n, x) &\le \lim_n d(x_n, a_{\lambda(i)}) + \lim_n d(a_{\lambda(i)}, x) \\
&=2 d(a_{\lambda(i)}, x) \quad \forall i.
\end{align}
$$
The proof is complete by
$$
\lim_n d(x_n, x) \le 2\lim_i d(a_{\lambda(i)}, x)=0.
$$
