TITLE: Increasing $g$ where $g' = 0$ a.e. but $g$ not constant on any open interval?
QUESTION [6 upvotes]: As the question title suggests, does there exist an increasing function $g$ such that $g' = 0$ almost everywhere  but $g$ isn't constant on any open interval?

REPLY [2 votes]: Yes, Let $\phi(x)$ be Cantor-Lebesgue function for $[0,1]$ and continue it to a function on $\mathbb{R}$ by fixing it $1$ for $x>1$ and $0$ for $x<0$. Let $O_n = (a_n,b_n)$ be an enumeration of all open intervals in $\mathbb{R}$ such that the end-points are of rational value.
Define $ \phi_n(x) = \phi(\frac{x-a_n}{b_n-a_n}) $ and define$$ g(x) = \sum_{n=1}^\infty \frac{1}{2^n}\phi_n(x)$$
Now, for us to differentiate $g$ we need to recall Fubini's theorem (which you can verify, holds).
then we have $g'(x)= \sum_{n=1}^\infty \frac{1}{2^n}\phi_n(x)' = 0 \quad (\text{a.e})$
$g$ is stricly increasing since if $x>y$ then $\phi_n(x) \geq \phi_n(y)$ for all $n$. Moreover, there must exist some rational $y<r<x$ and hence for atleast one $\phi_k(x)$ we have $\phi_k(x)>\phi_k(y)=0$.
A stricly increasing function is not constant on any open interval.