Stone–Weierstrass Theorem

lean4-prooffunctional-analysisvisualization
AC(X) sep. pts, contains 1A=C(X)A \subseteq C(X) \text{ sep. pts, contains 1} \Rightarrow \overline{A} = C(X)

Statement

Let XX be a compact Hausdorff space and AC(X,R)A \subseteq C(X, \mathbb{R}) a subalgebra (closed under addition, multiplication, and scalar multiplication) that:

  1. Separates points: for all xyXx \neq y \in X, there exists fAf \in A with f(x)f(y)f(x) \neq f(y).
  2. Contains constants (equivalently, the topological closure of AA contains constants).

Then AA is dense in C(X,R)C(X, \mathbb{R}) with the sup-norm: every continuous g:XRg : X \to \mathbb{R} is a uniform limit of functions in AA.

The classical Weierstrass approximation theorem (X=[a,b]X = [a,b], A=A = polynomials) is the prototypical case.

Visualization

Approximate g(x)=xg(x) = |x| on [1,1][-1, 1] using Bernstein polynomials (a subalgebra containing polynomials, which separate points):

Bn,k(x)=(nk)xk(1x)k,Bn(g)(x)=k=0ng(k/n)(nk)xk(1x)nkB_{n,k}(x) = \binom{n}{k} x^k (1-x)^k, \quad B_n(g)(x) = \sum_{k=0}^n g(k/n) \binom{n}{k} x^k (1-x)^{n-k}

| xx | g(x)=xg(x) = |x| | B4(g)(x)B_4(g)(x) | B8(g)(x)B_8(g)(x) | B16(g)(x)B_{16}(g)(x) | |---|---|---|---|---| | 1.0-1.0 | 1.0001.000 | 1.0001.000 | 1.0001.000 | 1.0001.000 | | 0.5-0.5 | 0.5000.500 | 0.5000.500 | 0.5000.500 | 0.5000.500 | | 0.25-0.25 | 0.2500.250 | 0.3130.313 | 0.2810.281 | 0.2660.266 | | 0.00.0 | 0.0000.000 | 0.3750.375 | 0.2730.273 | 0.1960.196 | | 0.250.25 | 0.2500.250 | 0.3130.313 | 0.2810.281 | 0.2660.266 | | 0.50.5 | 0.5000.500 | 0.5000.500 | 0.5000.500 | 0.5000.500 | | 1.01.0 | 1.0001.000 | 1.0001.000 | 1.0001.000 | 1.0001.000 |

The Bernstein approximations improve as nn grows, converging uniformly to x|x|.

sup-norm error:
  n = 4:   max gap ≈ 0.375  (at x = 0)
  n = 8:   max gap ≈ 0.273
  n = 16:  max gap ≈ 0.196
  n → ∞:   max gap → 0      (Stone–Weierstrass)

Proof Sketch

  1. Closure under |\cdot|. Using the Weierstrass approximation of t|t| by polynomials on [f,f][-\|f\|, \|f\|], show fA|f| \in \overline{A} for any fAf \in A.
  2. Lattice structure. From f|f|, deduce fg=(f+g+fg)/2Af \vee g = (f + g + |f - g|)/2 \in \overline{A} and fgAf \wedge g \in \overline{A}.
  3. Urysohn-type construction. For any gC(X)g \in C(X), xXx \in X, and ε>0\varepsilon > 0: using separation, construct hxyAh_{xy} \in A with hxy(x)g(x)h_{xy}(x) \approx g(x) and hxy(y)g(y)h_{xy}(y) \approx g(y).
  4. Finite cover. Compactness gives a finite cover; take finite inf and sup to build fAf \in \overline{A} with fg<ε\|f - g\|_\infty < \varepsilon.

Connections

  • Heine–Borel TheoremHeine–Borel TheoremKRn  compact    K  closed and boundedK \subseteq \mathbb{R}^n \;\text{compact} \iff K \;\text{closed and bounded}In ℝⁿ, a subset is compact if and only if it is closed and boundedRead more → — compactness of XX is essential; without it the theorem fails (e.g., X=RX = \mathbb{R}, polynomials do not uniformly approximate ex2e^{-x^2}).
  • Intermediate Value TheoremIntermediate Value Theoremf(a)yf(b)c[a,b]:  f(c)=yf(a) \le y \le f(b) \Rightarrow \exists\, c \in [a,b]:\; f(c) = yA continuous function on a closed interval hits every value between its endpointsRead more → — the proof that fA|f| \in \overline{A} uses IVT-style polynomial approximation (Weierstrass) on a compact interval.
  • Taylor's TheoremTaylor's Theoremf(x)=k=0nf(k)(x0)k!(xx0)k+Rn(x)f(x) = \sum_{k=0}^{n} \frac{f^{(k)}(x_0)}{k!}(x-x_0)^k + R_n(x)Approximate smooth functions by polynomials with explicit error boundsRead more → — Taylor polynomials form a subalgebra that separates points; Stone–Weierstrass explains why Taylor-based approximation is density in C[a,b]C[a,b] (when convergent).
  • Cauchy–Schwarz InequalityCauchy–Schwarz Inequalityu,vuv|\langle u, v \rangle| \leq \|u\| \, \|v\|The inner product of two vectors is bounded by the product of their normsRead more → — in L2(X)L^2(X), the L2L^2-density of polynomials follows from Stone–Weierstrass plus Cauchy–Schwarz domination.

Lean4 Proof

import Mathlib.Topology.ContinuousMap.StoneWeierstrass

/-- **Stone–Weierstrass Theorem**: a separating subalgebra is dense in C(X, ℝ).
    Direct alias of `ContinuousMap.subalgebra_topologicalClosure_eq_top_of_separatesPoints`. -/
theorem stone_weierstrass {X : Type*} [TopologicalSpace X] [CompactSpace X]
    (A : Subalgebra  C(X, )) (hA : A.SeparatesPoints) :
    A.topologicalClosure = ⊤ :=
  ContinuousMap.subalgebra_topologicalClosure_eq_top_of_separatesPoints A hA