$C[0,1]$ is separable: Theorem $11.2$ Carothers' Real Analysis I have some questions about the proof of Theorem 11.2 of Carothers' Real Analysis. The theorem states that $C[0,1]$ is separable.


*

*Why is $\|f-g\|_\infty \le\epsilon$?

*Why is $h$ selected the way it is, i.e. $h(k/n) = f(k/n)$ for $k = 0,1,2...,n$ but with $h(k/n)$ rational and satisfying $|h(k/n) - g(k/n)| < \epsilon$? I think the reason we can do this is because $\mathbb Q$ is dense in $\mathbb R$, but I don't understand the motivation.

*How do we get $\|g-h\|_\infty < \epsilon$? Is the proof similar to (1)?

*The proof is concluded with: "The set of all polygonal functions taking only rational values at nodes $(k/n)_{k=0}^n$ for some $n$ is countable." Well, why is that - and how does this show that $C[0,1]$ is separable?

To show that $C[0,1]$ is separable, I would expect a countable dense subset of $C[0,1]$. Where is this set?



In case someone is curious as to what Exercise $1$ is, I'm typing it below:

For each $n$, let $Q_n$ be the set of all polygonal functions that have nodes at $x = k/n$, $k = 0,1,...,n$ and that take on only rational values at these points. Check that $Q_n$ is a countable set and hence that the union of the $Q_n$'s is a countable dense set in $C[0,1]$.

 A: (1) You get $\| f - g\|_\infty \le \epsilon$ by simply taking more and more points (i.e., increasing $n$). Since $f$ is uniformly continuous, if $g$ matches $f$ at every point $k/n$ and $n$ is large enough, you will eventually get $\lvert f(x) - g(x) \rvert \le \epsilon$ for all $x \in [0,1]$ because $$\lvert f(x) - g(x) \rvert \le \underbrace{\lvert f(x) - f(k/n)\rvert}_{\text{small by continuity of } f} + \underbrace{\lvert f(k/n) - g(k/n) \rvert}_{=0, \text{ by def. of } g} + \underbrace{\lvert g(k/n) - g(x) \rvert}_{\text{small by continuity of } g}$$ where you choose the $k/n$ closest to $x$ in the above line.
(2) You can't have $h(k/n)= f(k/n)$ because you need the values of $h(k/n)$ to be rational (to ensure the family of such $h$ remains countable) but you may have $f(k/n)$ irrational. So you first make the $g$ with $g(k/n) = f(k/n)$; $g$ is a nice polygonal function, but may have irrational values at nodes $k/n$. However, because of density of the rationals, there is a rational point as close as desired to $g(k/n)$. Define $h$ the same way as $g$ but with $h(k/n)$ a rational number such that $\lvert h(k/n) - g(k/n) \rvert \le \epsilon$. Then $h$ pretty well approximates $g$ and $g$ pretty well approximates $f$ so $h$ pretty well approximates $f$, and has rational values at nodes $k/n$.
(3) Density of the rationals: you're just taking $g$ and possibly moving its values as nodes $k/n$ by a tiny bit.
(4) The countable dense set is the set of polygonal functions $h$ such that $h(k/n)$ is rational for all $k = 0,1,\ldots,n$. This set is countable because it can be seen as a subset of $$\bigcup_{n\in\mathbb N} \mathbb Q^{n+1}$$ via the following reasoning: choose the number $n$ of nodes, then choose the $n+1$ rational values at nodes $k/n$ for $k=0,1,\ldots,n$, and you have uniquely determined your polygonal function $h$. But $\mathbb Q^{n+1}$ is countable, and a countable union of countable sets is countable, so this shows that the set of such functions $h$ is countable.
