Existence of Function Taking Every Value Uncountably Many Times I am stuck on the following problem coming from a plane geometry theorem I'm working on.  This is a generalization of that problem which might actually prove easier to handle.  All the techniques that I have tried have failed, and it wasn't in Counterexamples in Analysis, which is the only collection of results on this sort of thing I'm familiar with.  Here, by a function $f$ we mean any function, not necessarily continuous or measurable.
Is it possible to find a subset $A \subset \mathbb{R}$ and a function $f: A \rightarrow [0,1]$ such that $f$ takes every value uncountably many times, $f^{-1}(x)$ is totally disconnected for every $x \in [0,1]$ (equivalently, $f$ is not constant on any interval), and satisfying the following local monotonicity condition:
If $a_n \rightarrow a$ are points of $A$ and $a_n \leq a$, then $\limsup f(a_n) \leq f(a)$, and
if $a_n \rightarrow a$ are points of $A$ and $a \leq a_n$, then $f(a) \leq \liminf f(a_n)$?
Thanks!
 A: How about this "modified Cantor function":
Let $A=[0,\frac23]$. To compute $f(x)$, write $x$ as a decimal fraction, and follow these rules:


*

*If $x$ can be written with only even digits, convert each of its digits to a binary digit by mapping $0, 4, 8$ to binary $0$ and $2, 6$ to binary $1$.

*Otherwise, let $x_1$ and $x_2$ be the numbers closest to $x$ on each side that do consist of only eve digits and interpolate linearly between $f(x_1)$ and $f(x_2)$. Since $x_1$ will end in repeating $8$s and $x_2$ will end in repeating $0$s, both map to repeating binary $0$s, so $f(x_1)\ne f(x_2)$ and this linear interpolation will not make $f$ constant on an interval.
This function is continuous so certainly satisfies your "monotonicity" criterion, and hits every number in $[0,1]$ continuum many times.
(If you don't require $A$ to be an interval, you could also just let it consist of the Cantor set of numbers that can be written with even digits, and skip the linear interpolation).
A: Take any space filling curve, i.e., any continuous surjective function $g : [0, 1] \to [0, 1] \times [0, 1]$ and arrange for $g$ to be non-constant on any open interval (either by adjusting an arbitrary space filling $g$ to shrink any open interval where it is constant to a point or by picking a specific $g$ like the Peano curve that doesn't suffer from this problem). Then define $f(x) = \pi_1(g(x))$, where $\pi_1 : [0, 1]\times[0, 1]\to [0, 1]$ is projection onto the first factor of the product ($\pi_1(x, y) = x)$. Then $f : [0, 1] \to [0, 1]$ is continuous and so certainly meets your monotonicity conditions and for any $x \in [0, 1]$, $f^{-1}(x)$ comprises the set $\{y : [0, 1] \mid g(y) \in \{x\} \times [0, 1]\}$, which is uncountable because $g$ is surjective and $\{x\} \times [0, 1]$ is uncountable.
