Can a Lipschitz continuous function be linear almost everywhere but not linear everywhere?
(:sorry for ambiguity) The almost everywhere here is defined as:
Let $f:\mathbb R^k\to\mathbb R$. $\nabla f(x)=v$ almost surely where $v$ is a constant.
That is $\nexists$ open set $U\subseteq dom(x)$ s.t. $\nabla f(x)\neq v \ \forall x\in U.$
My intuition is "no" but I don't know how to prove it. It is not a homework.
Let $S\subset [0,1]$ such that $S$ is closed and nowhere dense in $\Bbb R$ and such that the Lebesgue measure $m( S)$ is positive. (E.g. $S$ can be a "fat Cantor set".) Let $f(x)=x$ for $x<0$ and let $f(x)=\int_0^x(1-\chi_S(t))dt$ for $x\geq 0.$ So for $x\geq 0$ we have $f(x)=m([0,x] \setminus S).$