Prove that $S = \{ f: [0,1]\rightarrow \mathbb{R} \ \text{continuous} : x\in\mathbb{Q}\implies f(x) \in \mathbb{Q}\}$ is. uncountable

I would probably start with the uncountable set of all increasing sequences of integers and assign $f(1/n) = 1/a_n$ for a sequence $a_n$.

Extend this step-wise linearly; it should map $\mathbb{Q}$ to $\mathbb{Q}$.


Given a real number $a\in [0,1]$ with decimal expansion $a=0.a_1a_2a_3a_4...$ consider the piecewise linear function defined by $f\left(\frac{1}{i}\right) = a_i/i \in S$.

This gives you an injection of the uncountable set $[0,1]$ in $S$, therefore $S$ also uncountable.

EDIT: Thanks for the commenters pointing out that the function needs to be continuous at $0$ as well.


Let $X $ be the set of all sequences r = $\{r_n \}_1^{\infty}$ such that $r_n=\{ 1,-1\}$ it is an uncountable !!

For $r$ in $X$ let $f_r$ be function defined on [0, 1] such that

  • $f_r (0) =0$

  • $ f_r(1/n) = r_n / n$ for n positive integer ;

  • on each interval $ [ 1/(n+1), 1/n] , f_r$ is linear function whose values at the endpoints agree with those given by (2)

Each function $f_r $ is continuous at point of $(0, 1] $ is obvious, and continuity at $0$ follows because $|f(x) | \leq x$

Each $f_r$ takes rational values at rational points :

if $x$ is rational point between $ a=1/(n+1) $ and $b = 1/n$ , then

$x= (1-t) a+tb $ with $t$ a rational points of [0, 1] , so

$f_r(x)= (1-t) f_r (a) + tf_r(b) $ is rational because $ f_r( a) $ and $ f_r(b)$ are.

The functions $ f_r$ thus form an uncountable subset of S, showing that S is uncountable