Let $X$ be a metrizable compact space. I want to show that $C(X, mathbb{C})$ is separable in the uniform topology.

**Attempt**: By our assumption, $X$ is separable, so we can pick a countable dense subset ${x_n:n geq 1}$. Let $d$ be a metric inducing the topology on $X$. Define for $n geq 1$

$$d_n: X to mathbb{R}: x mapsto d(x,x_n)$$

Let $$mathcal{A}= bigcup_{n=1}^infty mathbb{C}[d_1, dots, d_n]$$

where $mathbb{C}[d_1, dots, d_n]$ is the set of complex polynomials in the functions $d_1, dots, d_n$.

It is easily checked that $mathcal{A}$ is a subalgebra of $C(X, mathbb{C})$, since $mathcal{A}$ is closed under addition, multiplication and scalar multiplication. Moreover, $1 in mathbb{C}[d_1]subseteq mathcal{A}$ so the algebra is unital. Clearly $mathcal{A}$ is closed under complex conjugation, since the functions $d_1, d_2, dots$ are all real-valued. We know that $mathcal{A}$ separates the functions of $C(X, mathbb{C})$:

If $x neq y$ with $x, y in X$. Use density to choose $n geq 1$ with $d(x_n,x) < d(x,y)/2$. Then we have $d(x_n,x) neq d(x_n,y)$. Otherwise $d(x_n,x) = d(x_n,y)$ and we get $d(x,y) leq d(x,x_n) + d(x_n,y) = 2d(x,x_n)<d(x,y)$ which is impossible. Thus $d_n(x) neq d_n(y)$ so our algebra separates the points.

By Stone-Weierstrass, $mathcal{A}$ is dense in $C(X, mathbb{C})$. Let $D$ be a countable dense subset of $mathbb{C}$, for example $D= mathbb{Q}+ i mathbb{Q}$. Any element of $mathcal{A}$ can be approximated by an element in $$mathcal{B}:= bigcup_{n=1}^infty D[d_1, dots, d_n]$$ and we conclude that $mathcal{B}$ is dense in $C(X, mathbb{C})$. Clearly $mathcal{B}$ is countable, and thus we conclude the proof. $quad square$

Is this proof correct?

The idea of the proof is fine, and standard, I think. Maybe you might want to add details about why your $mathcal{B}$ is dense, so why replacing the coefficients of the members of the algebra by a dense subset is OK. Maybe you’re relying on an earlier lemma? The countability might warrant a few words too, depending on the target audience (how much set theory do they know)?