I would like to know if I understand the details in the proof of Stone-Weierstrass (in $\mathbb R$) so I'd like to post it here in my own words. Can you please check it and tell me if it's correct? Thank you!
Thm. (Stone-Weierstrass) Let $A$ be a unital subalgebra of $(C(K),\|\cdot\|_\infty)$ that separates points, where $K$ is a compact topological space and $C(K)$ are continuous functions $K \to \mathbb R$. Then $\overline{A} = C(K)$.
Proof: We use (without proof) that
(i) if $A$ is a subalgebra then so is $\overline{A}$
(ii) if $f,g$ in $\overline{A}$ then $\min (f,g)$ and $\max(f,g)$ are in $\overline{A}$
Let $f \in C(K)$ and $\varepsilon > 0$. We construct $h \in \overline{A}$ such that $h(x) - \varepsilon \leq f(x) \leq h(x) + \varepsilon$.
To this end let $x_0 \in K$ be fixed. Then since $\overline{A}$ separates points, for each $x \in K$ we can find $h_x \in \overline{A}$ such that $h_x(x_0) = f(x_0)$ and $h_x(x) = f(x)$. Since $h_x - f$ is continuous and $h_x(x) = f(x)$ there are $O_x$ open such that for $x^\prime \in O_x$ we have $|(h_x -f)(x) - (h_x -f)(x^\prime)| = |h_x(x^\prime) - f(x^\prime)| < \varepsilon $. In particular, $h_x(x^\prime) - \varepsilon\leq f(x^\prime) $ for all $x^\prime \in O_x$. Since $K$ is compact and $O_x$ cover $K$ there is a finite subcover $\{O_{x_i} \}_{i=1}^N$. Let $h_{x_0} (x) : = \min_i h_{x_i} (x)$. Then for all $x \in K$ we have $h_{x_0}(x) - \varepsilon \leq f(x) $.
$h_{x_0}$ is continuous and $h_{x_0}(x_0) = f(x_0)$ hence for each $x_0 \in K$ there is $U_{x_0}$ open such that for $x^\prime \in U_{x_0}$ we have $|(h_{x_0} -f)(x^\prime) - (h_{x_0} -f)(x_0)| = |h_{x_0}(x^\prime) - f(x^\prime)| < \varepsilon$. In particular, $f(x^\prime) \leq h_{x_0}(x^\prime)+\varepsilon$. Since $U_{x_0}$ are open and cover $K$ there is a finite subcover $\{U_{x_i} \}_{i=1}^M$. Let $h(x) = \max_i h_{x_i}(x)$ then $h(x) \in \overline{A}$ and $h(x) - \varepsilon \leq f(x) \leq h(x) + \varepsilon$. Let $\varepsilon \to 0$.