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!
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).