$C(X)$ is separable when $X$ is compact?

$X$ is a compact metric space, $C(X)$ is separable when $X$ is compact where $C(X)$ denotes the space of continuous functions on $X$. How to prove it?

And if $X$ is just a compact Hausdorff space, then $C(X)$ is still separable? Or if $X$ is just a compact (not necessarily Hausdorff) space, then $C(X)$ is still separable?

Please help me. Thanks in advance.


Solution 1:

Theorem. If $X$ is compact Hausdorff then $C(X)$ is separable iff $X$ is metrizable.

There is a natural embedding $x\in X\to \delta _x\in \mathcal{M}(X)$ (more precisely in the unit ball of $\mathcal{M}(X)$). This is an homeomorphism for the weak*-topology of $\mathcal{M}(X)$. If $C(X)$ is separable then $(\mathcal{M}(X), w*)$ have a compact metrizable unit ball. So $X$ is metrizable.

For the converse, assume $X$ is a metrizable compact Hausdorff space. Let $d$ be a metric inducing the topology and $(x_n)$ a dense countable subset of $X$. Define $d_n: x\in X \to d_n(x):=d(x,x_n)$. It is a continuous function. It is easy to check that the algebra generated by $1$ and $(d_n)_n$ separate the points in $X$ so by Stone Weierstrass theorem this subalgebra is dense in $C(X)$. By considering linear combination with rational coefficient of element of this subalgebra it is easy to see that $C(X)$ is separable.