Can the function defined in this way be everywhere discontinuous? Suppose that we have some real function of a real variable $f$ defined on the set $[a,b]$ which has the properties that:
1) $f$ takes values in the set on which it is defined
2) for every $y \in [a,b]$ there exists one and only one $x \in [a,b]$ such that $f(x)=y$.
The question is:

Can such function be everywhere discontinuous?

The question can be asked also in this form:

Does there exist everywhere discontinuous bijection defined on the set $[a,b]$ which also takes values in the set $[a,b]$.

I guess that the answer is yes but at the moment I am not smart enough to prove the existence or to construct such an example.
Thank you for your response and co-operation.
 A: If $[a,b]=[0,1]$, try $$f_0(x)= \begin{cases}x&{x\in\Bbb Q,}\\x+\frac12&x\notin \Bbb Q, x<\frac12,\\x-\frac12&x\notin\Bbb Q,x>\frac12.\end{cases}$$
For general $[a,b]$ take $f(x)=a+(b-a)f_0(\frac{x-a}{b-a})$.
(Note that $f$ is nowhere continuos, but $f(f(x))=x$.)
A: For a non-constructive proof that such a function exists, note that there are $2^c$ many such bijective functions and only $c$ many continuous functions.
Ooop! This is not correct. This argument only shows that there exists such a bijection that fails to be continuous at one or more points. (Not being continuous means being discontinuous at one or more points.) In fact, there are $2^c$ many functions that have at least one point of continuity. For example, just take the union of any function with domain $[0,1]$ along with the restriction of $f(x) = x$ for $x > 1.$
I'll delete this answer in a few minutes, after everyone involved here will hopefully have had a chance to see my correction.
(A FEW MINUTES LATER) It was requested that maybe I keep this up for pedagogical reasons, so I guess I'll leave it. Incidentally, when I realized the error, I considered trying to use the stronger result that there are only $c$ many Borel measurable functions, but this doesn't work either. There are plenty of non-Borel functions, even non-Lebesgue measurable functions, that have lots of points of continuity. Just choose the function to be bad on $[0,1]$ and linear on another interval.
A: Here's a recipe for building such functions which seems simpler:


*

*First, partition $[a, b]$ into three nontrivial intervals: $I_0=[a, c), I_1=[c, d), I_2=[d, b]$ with $a<c<d<b$. Note that each interval has size continuum.

*Next, partition $[a, b]$ into three mutually dense, size continuum sets: $[a, b]=D_0\sqcup D_1\sqcup D_2$, where each $D_i$ has size continuum and each $D_i$ is a dense subset of $[a, b]$.

*Finally, pick bijections $f_i: D_i\rightarrow I_i$, and let $f=f_0\sqcup f_1\sqcup f_2$ be the function gotten by pasting these together. (Such bijections exist since each $D_i$ and $I_i$ has size continuum.)
Then we have:


*

*$f$ is a bijection between $[a, b]$ and $[a, b]$. This is because each $f_i$ is a bijection, and the domains and ranges of the $f_i$s partition $[a, b]$.

*$f$ is everywhere discontinuous. Fix $x\in [a, b]$ and $\epsilon>0$. We can find $y_0\in D_0, y_2\in D_2$ with $\vert y_0-x\vert, \vert y_2-x\vert<\epsilon$. But we are guaranteed to have $\vert f(y_0)-f(y_2)\vert\ge d-c$.

You might ask: how hard is it to find such a partition of an interval into mutually dense sets of size continuum? The answer, luckily, is: not very hard.
Here's one way. Suppose $[a, b]=[0, 1]$ for simplicity. Then:


*

*Let $D_0$ be the set of numbers in $[0, 1]$ whose binary expansion contains infinitely many substrings of the form "$1100$," but only finitely many of the form "$1010$".

*Let $D_1$ be the set of numbers in $[0, 1]$ whose binary expansion contains infinitely many substrings of the form "$1010$," but only finitely many of the form "$1100$".

*Finally, let $D_2$ be the set of numbers in $[0, 1]$ which are in neither $D_0$ nor $D_1$.
Clearly the $D_i$s partition $[0, 1]$, and $D_0$ and $D_1$ have size continuum and are dense. To see that $D_2$ has size continuum and is dense, note that $D_2$ contains the set of all numbers in $[0, 1]$ whose binary expansion contains infinitely many substrings of the form "$11001010$."
A: Take $A=[0,1].$ Note that $B=[0,1]\cap\mathbb{Q}$ is countable, then write $B=\{x_n\,;\,n\in\mathbb{N}\}.$ Then define $f:A\to A$ such that for $x\in A-B$, then $f(x)=x$ and let $$f(x_1)=x_2, f(x_2)=x_1,f(x_3)=x_4,f(x_4)=x_3,\text{ etc.}$$ Then $f$ will satisfy what you are looking for, because if $x_i\in B$ then you can find a sequence $(y_k)_{k\in\mathbb{N}}$ such that $\forall k\in\mathbb{N},y_k\in A-B$ and $\lim\limits_{k\to+\infty}y_k=x_i.$ Then you get $$f(x_i)=x_{i+1} \text{(or $x_{i-1}$)} \neq\lim\limits_{k\to+\infty} f(y_k)=x_i.$$ 
