Dense subset of $C(X)$ I am trying to prove the next proposition, but i need some help:
Let $ (X,\rho)$ be compact metric space. Prove that there exist a compact subset $K$ of $C(X)$ whose linear span is dense in $C(X)$
Thanks.
 A: Hints:


*

*$C(X)$ is separable.

*Given any sequence in a Banach space, you can rescale the terms of the sequence so that it converges to 0.

*In any metric space. if $x_n \to x$, then $\{x_n\} \cup \{x\}$ is compact. 

A: Nate's answer is slick, but I am a slow thinker who would not have been able to discover his route (I prefer the word route over the word trick, whose usage is subjective). I will give a solution that appeals only to the beginner analyst's knowledge of the Arzelà-Ascoli Theorem and the Stone-Weierstrass Theorem. This so happens to build upon Thomas' idea, which, unfortunately, he was not able to carry through to completion.
For each $ a \in A $, define a ‘distance’ function $ \phi_{a}: X \to \mathbb{R}_{\geq 0} $ by
$$
\forall x \in X: \quad {\phi_{a}}(x) \stackrel{\text{def}}{=} \rho(a,x).
$$
Each $ \phi_{a} $ is clearly continuous. As $ (X,\rho) $ is a compact metric space, it is totally bounded, hence bounded. Consequently, the family of functions $ \mathcal{F} := \{ \phi_{a} \}_{a \in X} $ is uniformly bounded with respect to the sup-norm on $ C(X,\mathbb{R}) $. We can thus find a scalar constant $ M > 0 $ large enough so that the (continuous) function $ \psi_{a} := \dfrac{1}{M} \cdot \phi_{a} $ has sup-norm $ \leq 1 $ for each $ a \in A $. We now show that the family $ \mathcal{G} $ of continuous functions on $ X $ given by
$$
\mathcal{G} := \{ \psi_{a_{1}} \times \cdots \times \psi_{a_{n}} ~|~ n \in \mathbb{N} ~ \text{and} ~ a_{1},\ldots,a_{n} \in X \}
$$
is pointwise-bounded and equicontinuous.


*

*As the sup-norm of $ \psi_{a} $ for each $ a \in A $ is $ \leq 1 $, the same can be said of a finite product of such functions. This immediately yields the pointwise-boundedness of $ \mathcal{G} $.

*Choose $ a_{1},\ldots,a_{n} \in X $ and also $ x_{0} \in X $. Then
\begin{align}
\forall x \in X: \quad
     &|{\psi_{a_{1}}}(x_{0}) \times \cdots \times {\psi_{a_{n}}}(x_{0}) - {\psi_{a_{1}}}(x) \times \cdots \times {\psi_{a_{n}}}(x)| \\
\leq &|{\psi_{a_{1}}}(x_{0}) \times \cdots \times {\psi_{a_{n}}}(x_{0})| + |{\psi_{a_{1}}}(x) \times \cdots \times {\psi_{a_{n}}}(x)| \\
=    &|{\psi_{a_{1}}}(x_{0})| \cdots |{\psi_{a_{n}}}(x_{0})| + |{\psi_{a_{1}}}(x)| \cdots |{\psi_{a_{n}}}(x)| \\
\leq &|{\psi_{a_{1}}}(x_{0})| + |{\psi_{a_{1}}}(x)| \quad (\text{$ \| \psi_{a} \|_{\infty} \leq 1 $ for each $ a \in X $.}) \\
=    &\frac{1}{M} \cdot \rho(a_{1},x_{0}) + \frac{1}{M} \cdot \rho(a_{1},x) \\
=    &\frac{1}{M} \cdot \rho(x_{0},a_{1}) + \frac{1}{M} \cdot \rho(a_{1},x) \\
=    &\frac{1}{M} [\rho(x_{0},a_{1}) + \rho(a_{1},x)] \\
\leq &\frac{1}{M} \cdot \rho(x_{0},x). \quad (\text{By the Triangle Inequality.})
\end{align}
Hence, for any $ \epsilon > 0 $, if we set $ \delta := M \epsilon $, then for any $ x \in X $ satisfying $ \rho(x_{0},x) < \delta $, we will surely have
$$
|{\psi_{a_{1}}}(x_{0}) \times \cdots \times {\psi_{a_{n}}}(x_{0}) - {\psi_{a_{1}}}(x) \times \cdots \times {\psi_{a_{n}}}(x)| < \epsilon.
$$
As $ \delta $ works for any choice of $ a_{1},\ldots,a_{n} \in X $, and as $ x_{0} $ is arbitrary, the equicontinuity of $ \mathcal{G} $ is therefore established.
Now, by the Arzelà-Ascoli Theorem, the sup-norm closure of $ \mathcal{G} $, which we denote by $ \overline{\mathcal{G}} $, must be a compact subset of $ C(X,\mathbb{R}) $. It remains to show that its linear span is dense.
Assuming that $ X $ contains more than one point (if $ X $ is a singleton set, then $ C(X,\mathbb{R}) $ is homeomorphic to $ \mathbb{R} $, so just use the obvious fact that the $ \mathbb{R} $-linear span of the compact singleton set $ \{ 1 \} $ is dense in $ \mathbb{R} $), we see that:
(1) $ \mathcal{G} $ separates points in $ X $.
Explanation: Given distinct $ x,y \in X $, observe that $ {\psi_{x}}(x) = \dfrac{1}{M} \cdot \rho(x,x) = 0 $, whereas $ {\psi_{x}}(y) = \dfrac{1}{M} \cdot \rho(x,y) \neq 0 $.
(2) $ \mathcal{G} $ vanishes at no point of $ X $.
Explanation: Given any $ x \in X $, observe that $ \psi_{y} $ does not vanish at $ x $ if $ y \neq x $.
These two conditions fulfilled, we can apply the Stone-Weierstrass Theorem to deduce that the $ \mathbb{R} $-algebra generated by $ \mathcal{G} $ is a dense subset of $ C(X,\mathbb{R}) $. However, this $ \mathbb{R} $-algebra is simply the $ \mathbb{R} $-linear span of $ \mathcal{G} $, because $ \mathcal{G} $ was deliberately designed to be closed under finite products (this is the crux of the solution; you may call it a trick, if you want). Therefore, the $ \mathbb{R} $-linear span of $ \overline{\mathcal{G}} $, which contains the $ \mathbb{R} $-linear span of $ \mathcal{G} $, must also be dense in $ C(X,\mathbb{R}) $. We are therefore done.
As can be seen, the solution here gives a pretty explicit construction of a compact subset of $ C(X,\mathbb{R}) $ with the desired properties.
A: This is an answer to Dan's question and Haskell Curry's comment.
Let $K$ be the set of $1$-Lipschitz functions $f\colon X\to \mathbb{R}$ with $\sup_X |f| \leq 1$.

Lemma 1. $K$ is a compact subset of $C(X)$.

Hint. Use Arzelà-Ascoli theorem.

Lemma 2. The linear span of $K$ is the set of bounded Lipschitz functions $X\to \mathbb{R}$.

Proof. If $f \colon X \to \mathbb{R}$ be a $k$-Lipschitz function bounded by $M > 0$, then $f \in \max\{k,M\} K$. The conclusion follows from lemma 3.

Lemma 3. The set of bounded Lipschitz functions $X\to \mathbb{R}$ is a subalgebra of $C(X)$.

Hint. Use the following triangle inequalities:
$$
|(f(x) + \lambda g(x)) - (f(y) + \lambda g(y))| \leq |f(x)-f(y)| + |\lambda| |g(x) - g(y)|
$$
and
$$
|f(x)g(x) - f(y)g(y)| \leq |g(x)||f(x)-f(y)| + |f(y)||g(x)-g(y)|.
$$

Lemma 4. The set of bounded Lipschitz functions $X\to \mathbb{R}$ is a dense subset of $C(X)$.

Hint. Use lemma 3 and Stone-Weierstrass theorem.
