# Show that Intermediate Value Property holds for a discontinuous function

Show that the function $f:[0,1] \to [0,1]$ defined by $$f(x)=\begin{cases}x & \text{if } x \in \mathbb{Q} \\ 1-x & \text{if } x \in \mathbb{Q}^c \end{cases}$$ has the intermediate value property.

Attempt: We want to show that for every $\mu$ between $f(a)$ and $f(b)$, there is some $c \in (a,b)$ such that $f(c) = \mu$. To show this, there will be three cases: first case will be $a,b \in \mathbb{Q}$, second is $a,b \in \mathbb{Q}^c$, and third $a \in \mathbb{Q}$ and $b \in \mathbb{Q}^c$. For the first case and second case, I can use the fact that $x$ and $1-x$ are continuous on $[0,1]$, and thus the IVT applies. However, for the third case, I am not sure.

Let $a=0$ and $b=1/2$. Let $\mu=\sqrt2/4\in(f(a),f(b))$.
Then the only value for $c$ such that $f(c)=\mu$ is $1-(\sqrt2/4)>1-(1/2)=1/2=b$.