An sufficient and necessary condition for a metric space $X$ to be compact. The problem is this:
Show that a metric space $X$ is compact if and only if the Banach space of bounded continuous functions $C(X)$ with the norm $\|f\| = \sup_{x\in X}|f(x)|$ is a separable Banach space.
This is what I think for one direction:
Since $X$ is compact, then $X$ is bounded and separable, thus $d(x,y)$ has an upper bound. I try to use the metric $d$ on $X$ to construct continuous function but still don't know how to do this. Thank you for any help!
 A: Let $X$ a compact metric space. Let's show that the space $\mathcal{X}=C(X, [-1,1])$ of continuous functions $f \colon X \to [-1,1]$ with the $\max$  distance is separable. Imbed $\mathcal{X}$ into $\mathcal{Y}$, the space of all functions from $X \to [-1,1]$ with the $\sup$ distance. 
Here is a very simple and useful lemma. Assume that $\mathcal{X}$ is a subset of a metric space $\mathcal{Y}$ and there exists $B$ countable subset of $\mathcal{Y}$ so that $\bar B \supset \mathcal{X}$. Then there exists a countable subset $A$ of $\mathcal{X}$ so that $\bar A \supset \mathcal{X}$. The idea is to approximately project $B$ onto $\mathcal{X}$. For every $b \in B$, take $a=\phi(b) \in \mathcal{X}$ so that $d(b, a) \le 2 d(b, \mathcal{X})$. Let us show that $\bar \phi(B) \supset \mathcal{X}$. Indeed, take $x \in \mathcal{X}$, and $n >0$. There exists $b\in B$ so that $d(b,x) < \frac{1}{n}$. Now, $d(b, \mathcal{X})< \frac{1}{n}$, so $d(b, \phi(b)) < \frac{2}{n})$. We conclude that $d(x, \phi(b)) < \frac{3}{n}$.
We'll produce now a countable subset $B$ in our $\mathcal{Y}$ so that $\bar B\supset \mathcal{X}$. For that, consider for each $n$ a partitions $\mathcal{P}_n$ of $X$ into sets of size $\le \frac{1}{n}$. Let $B= \cup B_n$, where $B_n$ is the set of functions that are constant on each part of the partition $\mathcal{P}_n$ and take rational values in $[-1,1]$. It is easy to see that for every continuous function $X \to [-1,1]$ and for every $\epsilon > 0$, there exists a function $g$ in some $B_n$ so that $|f-g|< \epsilon$. Therefore, $\bar B \supset \mathcal{X}$. 
