Consider the metric space (C[0,1],∥⋅∥∞), where C[0,1] is the set of all continuous real-valued functions on [0,1] and
[
|f|\infty = \sup{x\in[0,1]} |f(x)|
]
is the supremum norm (which induces the metric d(f,g)=∥f−g∥∞). To show C[0,1] is separable, it suffices to exhibit a countable dense subset PQ⊂C[0,1].
Let PQ be the set of all polynomials with rational coefficients, i.e.,
[
\mathcal{P}\mathbb{Q} = \left{ \sum{k=0}^n q_k x^k ;\middle|; n\in\mathbb{N}_0, ; q_k \in \mathbb{Q} \right}.
]
This set is countable: for each fixed degree n, the set of such polynomials is in bijection with Qn+1 (which is countable), and PQ is a countable union over n∈N0 of countable sets.
We claim PQ is dense in C[0,1], i.e., for every f∈C[0,1] and ε>0, there exists p∈PQ with ∥f−p∥∞<ε. The proof proceeds in two steps:
Step 1: Polynomials are dense in C[0,1]
By the Weierstrass approximation theorem, the set P of all polynomials (with real coefficients) is dense in (C[0,1],∥⋅∥∞). Thus, for any f∈C[0,1] and ε>0, there exists p∈P with ∥f−p∥∞<ε/2.
Step 2: Rational polynomials are dense in P
Fix any p∈P of degree at most n, so p(x)=∑k=0nakxk with ak∈R. We construct q∈PQ with ∥p−q∥∞<ε/2.
On [0,1], we have ∣xk∣≤1 for all k, so
[
|p-q|\infty \leq \sum{k=0}^n |a_k - b_k| \quad \text{for any } q(x) = \sum_{k=0}^n b_k x^k.
]
Choose rationals bk∈Q such that ∣ak−bk∣<(ε/2)/(n for each k=0,…,n (possible since Q is dense in R). Then
[
|p-q|\infty < \sum{k=0}^n \frac{\varepsilon/2}{n+1} = \varepsilon/2.
]
Thus, ∥f−q∥∞≤∥f−p∥, so q∈PQ approximates f arbitrarily well.
Since ε>0 was arbitrary, PQ is dense in C[0,1]. Therefore, C[0,1] is separable.