TITLE: Continuous $f\colon [0,1]\to \mathbb{R}$ all of whose nonempty fibers are countably infinite?
QUESTION [22 upvotes]: I have been told it is possible to construct a continuous function $f\colon [0,1]\to \mathbb{R}$ such that $f^{-1}(x)$ is either empty or has cardinality $\aleph_0$ for every $x\in \mathbb{R}$. I've thought about this for a while but can't seem to cook up an example. Does anyone know such a construction?

REPLY [2 votes]: I'll define a convergent sequence of functions $f_n: [0,1] \to [0,1]$, which will be piecewise linear, starting with $f_0(x)=x$.  For each $k \in \{0, 1, \ldots, 2^n - 1\}$ a  particular segment of the graph of $f_n$, call it $L_k$, will go from $y = k/2^n$ to $y = (k+1)/2^n$.  For $f_{n+1}$ we replace each $L_k$ by a "zigzag" with the same starting and ending points, first going from $y=k/2^n$ to $(k+1/2)/2^n$, then back down to $k/2^n$, up to $(k+1/2)/2^n$ and then $(k+1)/2^n$, down to $(k+1/2)/2^n$ and up to $(k+1)/2^n$.  The distinguished segments of the graph of $f_{n+1}$ corresponding to the intervals $[k/2^n, (k+1/2)/2^n]$ and $[(k+1/2)/2^n, (k+1)/2^n]$ are the rightmost segments of this zigzag with $y$ in those intervals.  For example, here is the graph of $f_2$, with the four distinguished segments in red:

Then $f_n$ converges uniformly to a continuous function $f$ which has the desired properties.