[proofplan]
We reduce the complex case to the real case. Self-adjointness of $\mathcal{A}$ implies that the real and imaginary parts of every $f \in \mathcal{A}$ also belong to $\overline{\mathcal{A}}$, and that the set $\mathcal{A}_{\mathbb{R}} := \{\operatorname{Re} f : f \in \mathcal{A}\}$ is a real subalgebra of $C(K; \mathbb{R})$ that separates points and vanishes at no point. The [Stone--Weierstrass Theorem (Real Version)](/theorems/1217) then gives $\overline{\mathcal{A}_{\mathbb{R}}} = C(K; \mathbb{R})$, from which $\overline{\mathcal{A}} = C(K; \mathbb{C})$ follows by writing any complex-valued function as a sum of real and imaginary parts.
[/proofplan]
[step:Extract real parts using self-adjointness]
For any $f \in \mathcal{A}$, self-adjointness gives $\overline{f} \in \mathcal{A}$, and therefore
\begin{align*}
\operatorname{Re} f = \frac{f + \overline{f}}{2} \in \mathcal{A}, \qquad \operatorname{Im} f = \frac{f - \overline{f}}{2i} \in \mathcal{A}.
\end{align*}
Both $\operatorname{Re} f$ and $\operatorname{Im} f$ are real-valued functions in $\mathcal{A}$. Define
\begin{align*}
\mathcal{A}_{\mathbb{R}} := \{g \in \mathcal{A} : g(K) \subset \mathbb{R}\} = \{\operatorname{Re} f : f \in \mathcal{A}\}.
\end{align*}
The second equality holds because every real-valued $g \in \mathcal{A}$ satisfies $g = \operatorname{Re} g$, and conversely every $\operatorname{Re} f$ is real-valued and belongs to $\mathcal{A}$.
[guided]
Self-adjointness is the hypothesis that distinguishes the complex version from the real version. Without it, the decomposition into real and imaginary parts would leave $\mathcal{A}$: we would have $f \in \mathcal{A}$ but no guarantee that $\overline{f} \in \mathcal{A}$, and so $(f + \overline{f})/2$ might not belong to $\mathcal{A}$.
A classical example showing that self-adjointness cannot be dropped: let $K = \overline{D}$, the closed unit disc in $\mathbb{C}$, and let $\mathcal{A}$ be the disc algebra — the uniform closure of polynomials in $z$. Then $\mathcal{A}$ is a subalgebra of $C(K; \mathbb{C})$ that separates points (the function $z \mapsto z$ does) and vanishes at no point (constants belong to $\mathcal{A}$). But $\mathcal{A}$ is not self-adjoint (the function $z \mapsto \overline{z}$ is not holomorphic and does not belong to $\mathcal{A}$), and $\mathcal{A} \neq C(K; \mathbb{C})$.
[/guided]
[/step]
[step:Verify that $\mathcal{A}_{\mathbb{R}}$ is a real subalgebra separating points and vanishing nowhere]
**Subalgebra.** If $g_1, g_2 \in \mathcal{A}_{\mathbb{R}}$, then $g_1 + g_2$, $\alpha g_1$ (for $\alpha \in \mathbb{R}$), and $g_1 g_2$ all belong to $\mathcal{A}$ (since $\mathcal{A}$ is a complex subalgebra) and are real-valued (products and sums of real-valued functions are real-valued). Hence $\mathcal{A}_{\mathbb{R}}$ is a subalgebra of $C(K; \mathbb{R})$.
**Separates points.** Let $x, y \in K$ with $x \neq y$. Since $\mathcal{A}$ separates points, there exists $f \in \mathcal{A}$ with $f(x) \neq f(y)$. Then either $\operatorname{Re} f(x) \neq \operatorname{Re} f(y)$ or $\operatorname{Im} f(x) \neq \operatorname{Im} f(y)$ (since two complex numbers that agree in both real and imaginary parts are equal). In either case, we obtain a function in $\mathcal{A}_{\mathbb{R}}$ that separates $x$ and $y$.
**Vanishes at no point.** Let $x \in K$. Since $\mathcal{A}$ vanishes at no point, there exists $f \in \mathcal{A}$ with $f(x) \neq 0$. Then $|f(x)|^2 = f(x)\overline{f(x)} \neq 0$. The function $f \overline{f} \in \mathcal{A}$ (using self-adjointness: $\overline{f} \in \mathcal{A}$ and $\mathcal{A}$ is closed under multiplication) is real-valued and non-zero at $x$, so $f\overline{f} \in \mathcal{A}_{\mathbb{R}}$ with $(f\overline{f})(x) \neq 0$.
[guided]
Each verification uses a different aspect of the hypotheses:
- **Separation** uses the decomposition $f = \operatorname{Re} f + i \operatorname{Im} f$: if $f(x) \neq f(y)$, at least one of the two real components must differ. This is a consequence of $\mathbb{C} \cong \mathbb{R}^2$ as a real vector space.
- **Non-vanishing** uses self-adjointness crucially. The function $f\overline{f}$ is guaranteed to be in $\mathcal{A}$ only because $\overline{f} \in \mathcal{A}$. Without self-adjointness, we could have $f(x) \neq 0$ but no real-valued function in $\mathcal{A}$ that is non-zero at $x$.
[/guided]
[/step]
[step:Apply the real Stone--Weierstrass theorem and recover the complex case]
By the [Stone--Weierstrass Theorem (Real Version)](/theorems/1217), since $\mathcal{A}_{\mathbb{R}}$ is a real subalgebra of $C(K; \mathbb{R})$ that separates points and vanishes at no point, $\overline{\mathcal{A}_{\mathbb{R}}} = C(K; \mathbb{R})$.
Now let $f \in C(K; \mathbb{C})$. Write $f = u + iv$ where $u := \operatorname{Re} f$ and $v := \operatorname{Im} f$ are continuous real-valued functions on $K$. Since $u, v \in C(K; \mathbb{R}) = \overline{\mathcal{A}_{\mathbb{R}}}$, for every $\varepsilon > 0$ there exist $g, h \in \mathcal{A}_{\mathbb{R}} \subset \mathcal{A}$ with $\|u - g\|_\infty < \varepsilon/2$ and $\|v - h\|_\infty < \varepsilon/2$. Then $g + ih \in \mathcal{A}$ (since $\mathcal{A}$ is a complex algebra containing the real-valued functions $g$ and $h$, and $ih = i \cdot h$ is a complex scalar multiple of $h$), and
\begin{align*}
\|f - (g + ih)\|_\infty &= \|(u - g) + i(v - h)\|_\infty \\
&\leq \|u - g\|_\infty + \|v - h\|_\infty < \varepsilon.
\end{align*}
Since $\varepsilon > 0$ was arbitrary, $f \in \overline{\mathcal{A}}$. As $f$ was an arbitrary element of $C(K; \mathbb{C})$, we conclude $\overline{\mathcal{A}} = C(K; \mathbb{C})$.
[/step]