> [!definition]
>
> Let $X$ be a [[Compactness|compact]] [[Hausdorff Space|Hausdorff space]], $\alg \subset C(X, \real)$ be a subset of the [[Space of Continuous Functions|continuous functions]].
> 1. $\alg$ **separate points** if for every $x, y \in X$ with $x \ne y$, there exists $f \in \alg$ such that $f(x) \ne f(y)$.
> 2. $\alg$ is a **lattice** if $\max(f, g), \min(f, g) \in \alg$ whenever $f, g \in \alg$.
> [!theoremb] Stone-Weierstrass
>
> Let $X$ be a [[Compactness|compact]] [[Hausdorff Space|Hausdorff space]] and $\alg \subset C(X, \real)$ be a [[Closed Set|closed]] [[Algebra over Ring|subalgebra]] that separates points, then one and only one of the following holds:
> 1. There exists $x_0 \in X$ such that $f(x) = 0$ for all $x \in \alg$.
> 2. $\alg$ contains constant functions.
>
> If $(1)$ holds, then $\alg = \bracs{f \in C(X, \real): f(x_0) = 0}$. If $(2)$ holds, then $\alg = C(X, \real)$.
> [!theorem] Stone-Weierstrass (Complex)
>
> Let $X$ be a compact Hausdorff space and $\alg \subset C(X, \complex)$ be a closed complex subalgebra that separates points and is closed under complex conjugation. If $(1)$ holds, then $\alg = \bracs{f \in C(X, \real): f(x_0) = 0}$. If $(2)$ holds, then $f = C(X, \complex)$.
>
> *Proof*. Since
> $
> \re{f} = \frac{f + \ol f}{2} \quad \im{f} = \frac{f - \ol f}{2i}
> $
> the real and imaginary parts of the functions is a subalgebra $\alg_\real$ of $C(X, \real)$. By applying the real Stone-Weierstrass theorem on those parts, and using the fact that $\alg = \bracs{f + ig: f, g \in \alg_\real}$ yields the desired result.
# Proof
## Lattice
> [!theorem]
>
> Let $\alg \subset C(X, \real)$ be a [[Closed Set|closed]] [[Algebra over Ring|subalgebra]], then
> 1. $\abs{f} \in \alg$ whenever $f \in \alg$.
> 2. $\alg$ is a lattice.
>
> *Proof*. Let $f \in \alg$. Assume without loss of generality that $\norm{f}_u \le 1$. Let $\seq{p_n} \subset \real[x]$ be [[Ring of Polynomials|polynomials]] such that $p_n(0) = 0$ for all $n \in \nat$ and $p_n \to \abs{\cdot}$ [[Uniform Convergence|uniformly]]. Since each polynomial has no constant term, $p_n(f) \in \alg$ for all $n \in \nat$. Therefore $p_n(f) \to \abs{f}$ uniformly, and $\abs{f} \in \alg$. From here,
> $
> \max(f, g) = \frac{1}{2}\paren{f + g + \abs{f - g}}
> $
> and
> $
> \min(f, g) = \frac{1}{2}\paren{f + g - \abs{f - g}}
> $
> so $\alg$ is a lattice as well.
> [!theorem]
>
> Let $\alg \subset C(X, \real)$ be a closed lattice and $f \in C(X, \real)$. Suppose that for every distinct $x, y \in X$, there exists $g_{xy} \in \alg$ such that $g_{xy}(x) = f(x)$ and $g_{xy}(y) = f(y)$, then $f \in \alg$.
>
> *Proof*. Let $\eps > 0$. For each $x, y \in X$, let $U_{xy} = \bracs{f < g_{xy} + \eps}$ and $V_{xy} = \bracs{f > g_{xy} - \eps}$. By continuity, each $U_{xy}$ and $V_{xy}$ are open, with both $\bracs{U_{xy}: x, y \in X}$ and $\bracs{V_{xy}: x, y \in X}$ forming an [[Open Cover|open cover]] of $X$.
>
> ![[stone_weierstrass1.png]]
>
> Fix $y \in X$, then there exists a finite subcover $\seqf{U_{x_jy}}$. Let $g_y = \max_{1 \le j \le n}g_{x_jy}$, then $f < g_y + \eps$ on $X$, and $f > g_y - \eps$ on $V_y = \bigcap_{j = 1}^n V_{x_jy}$.
>
> ![[stone_weierstrass2.png]]
>
> As each $V_y$ is also open, $\bracs{V_y: y \in X}$ is another open cover of $X$. Let $\bracs{V_{y_j}}_1^m$ and $g = \min_{1 \le j \le m}g_{y_j}$, then $\norm{f - g}_u < \eps$.
>
> Since $\alg$ is a lattice, $g \in \alg$. As $\alg$ is closed and $\eps$ was arbitrary, $f \in \alg$.
## Separate Points
> [!theorem]
>
> Let $\alg \subset \real^2$ be a subalgebra. If $\alg$ separates points, then
> $
> \alg \in \bracs{\real^2, \span((1, 0)), \span((0, 1))}
> $
> *Proof*. Let $(x, y) \in \alg$ such that $x \ne y$. If $x, y \ne 0$, then $(x^2, y^2)$ is linearly independent from $(x, y)$, and $\alg = \real^2$. Now suppose that $\dim \alg = 1$, in which case either $x = 0$ or $y = 0$. Since $x \ne y$, $\alg = \span((0, 1))$ and $\alg = \span((1, 0))$, respectively.
> [!theorem]
>
> Let $\alg \subset C(X, \real)$ be a closed subalgebra that separates points, then one and only one of the following holds:
> 1. There exists $x_0 \in X$ such that $f(x_0) = 0$ for all $f \in \alg$.
> 2. $\alg$ contains constants.
>
> Moreover, for any $x, y \in X$, define $\alg_{xy} = \bracs{(f(x), f(y)): f \in \alg}$, then
> 3. If $x = x_0$ or $y = x_0$, then $\alg_{xy} = \span((0, 1))$ or $\alg_{xy} = \span((1, 0))$, respectively.
> 4. Otherwise, $\alg_{xy} = \real^2$.
>
> *Proof*. If there exists $x_0$ such that $f(x_0) = 0$ for all $f \in \alg$, then any constant function in $\alg$ is zero. If $\alg$ contains constants, then such an $x_0$ cannot exist.
>
> The mapping $f \mapsto (f(x), f(y))$ is an algebra homomorphism, and the image $\alg_{xy}$ is still an algebra that separates points. By the previous results, $\alg_{xy} = \real^2$ if functions in $\alg$ do not vanish on $x$ and $y$, and is equal to $\span((0, 1))$ or $\span((1, 0))$ depending on whether $x = x_0$ or $y = x_0$.
> [!theoremb] Stone-Weierstrass
>
> Let $\alg \subset C(X, \real)$ be a closed subalgebra that separates points.
> 1. If there exists $x_0 \in X$ such that $f(x_0) = 0$ for all $f \in \alg$, then $\alg = \bracs{f \in C(X, \real): f(x_0) = 0}$.
> 2. Otherwise, $\alg = C(X, \real)$.
>
> *Proof*. From previous results, $\alg$ is also a closed lattice. Thus it's sufficient to provide two-point approximations. Let $f \in \alg$ and $x, y \in X$ be distinct points. Further assume that $f(x_0) = 0$ if $(1)$ holds.
>
> **Case 1:** Assume without loss of generality that $x = x_0$. In this case, there exists $g \in \alg$ such that $g(x) = g(x_0) = 0$ and $g(y) \ne 0$. Rescaling $g$ yields the desired function.
>
> **Case 2:** Suppose that $\alg$ does not vanish on $x$ or $y$. Since the mapping $g \mapsto (g(x), g(y))$ is an algebra homomorphism whose image is $\real^2$, there exists $g \in \alg$ such that $g(x) = f(x)$ and $g(y) = f(y)$.
>
> If $(1)$ holds, then by the lattice lemma, $f \in \alg$. On the other hand, if $(2)$ holds, then the second case always applies, and $f \in \alg$ for all $f \in C(X, \real)$.