Proof (Stone-Weierstrass)
Over $\R$
Let $A$ be an subalgebra of $C^\R(K)$ that strongly separates points of $K$. We want to show $\overline{A} = C^\R(K)$.
Fix $f\in C^\R(K)$ and $ε>0$.
Agreeing with $f$ at two points
Let $x,y\in K$ be distinct. We want to find $f_{xy}\in A$ such that $f_{xy}(x) = f(x)$ and $f_{xy}(y) = f(y)$.
As $A$ separates points of $K$, find $g\in A$ such that $g(x) \neq g(y)$.
-
If $g(x), g(y)\neq 0$, then $h := g^2\in A$.
-
If either $g(x)$ or $g(y)$ is 0, WLOG $g(x)=0$, since $A$ strongly separates points of $K$, find $h\in A$ such that $h(x) \neq 0$.
In either case, $(g(x), g(y)), (h(x), h(y))\in \R^2$ are linearly independent. Therefore there are $λ,μ\in \R$ such that $f_{xy} := λg + μh\in A$ equals $f(x)$ at $x$ and equals $f(y)$ at $y$.
Approximating $f$ on one side
For each $x\in K$, we will find $f_x\in \overline{A}$ such that $f_x(x) = f(x)$ and $f_x < f + ε$.
Define $$ \begin{align*} U_{xy} = \sb{z\in K}{f_{xy}(z) < f(z) + ε}, \end{align*} $$ which is open by the continuity of $f_{xy} - f$. Since $f_{xy}(y) = f(y)$, we have $y\in U_{xy}$, so $\sb{U_{xy}}{y\in K}$ is an open cover of $K$. Apply compactness to find $y_1, \ldots, y_n\in K$ such that $K = \bigcup_{i=1}^{n} U_{xy_i}$.
As $\overline{A}$ is a lattice, $$ \begin{align*} f_x := \min\set{f_{xy_1}, \ldots, f_{xy_n}} \in \overline{A}, \end{align*} $$ Check that $f_x$ works:
-
For each $y\in X$, there exists $i$ such that $y\in U_{xy_i}$, so $f_x(y) \leq f_{xy_i}(y) < f(y) + ε$.
-
$f_{xy_i}(x) = x$ so $f_x(x) = f(x)$.
This proves the claim.
Approximating $f$ on both sides
Now define $$ \begin{align*} V_x = \sb{z\in K}{f_x(z) > f(z) - ε}, \end{align*} $$ which is open by continuity of $f_x - f$. Since $f_x(x) = f(x)$, $\sb{V_x}{x\in K}$ is an open cover of $K$. By compactness, let $x_1, \ldots, x_m\in K$ such that $K = \bigcup_{i=1}^{m} V_{x_i}$.
Since $\overline{A}$ is a lattice, $$ \begin{align*} g := \max\set{f_{x_1}, \ldots, f_{x_m}} \in \overline{A}. \end{align*} $$
-
For each $x\in X$, there exists $i$ such that $x\in V_{x_i}$, so $g(x) \geq f_{x_i}(x) > f(x) - ε$.
-
Since $f_{x_i} < f+ε$, also $g < f + ε$.
Hence $\|g - f\|_\infty < ε$. This shows $f\in \overline{A}$.
Over $\C$
Let $A$ be a subalgebra of $C^\C(K)$ that strongly separates points of $K$ and is closed under complex conjugation.
Let $A^\R = A \cap C^\R(K)$, a subalgebra of $C^\R(K)$. $A^\R$ still strongly separates points of $K$: for any $f\in A$, since $\overline{f}\in A$, we have $\Re f = \frac{1}{2}(f + \overline{f})\in A^\R$ and $\Im f = \frac{1}{2i}(f - \overline{f})\in A^\R$.
Therefore $\overline{A^\R} = C^\R(K)$ by our result over $\R$, so $C^\R(K) \subseteq \bar A$. Then $C^\C(K) = C^\R(K) + iC^\R(K) \subseteq \bar A$, as required.