Continuous and almost everywhere continuously differentiable with bounded gradient implies Lipschitz? Let $f:\mathbb{R}^n\to \mathbb{R}$ be continuous and bounded. Let the gradient of $f$ be continuous almost everywhere and let it be uniformly bounded wherever it is defined, i.e. $\|\nabla f(x)\|\le M$ for any $x\in\mathbb{R}^n$, where $M$ is a positive constant. Can we say that $f$ is globally Lipschitz continuous?
If so, where can we find a formal proof?
If not, can we provide a counterexample? (I.e., a function $f:\mathbb{R}^n\to \mathbb{R}$ that is continuous and bounded, has uniformly bounded gradient but is not Lipschitz.)
Remark.
This question has been answered (positively) for $n=1$ in If $f$ is continuous and piecewise $C^1$ and $f'$ is bounded a.e., is $f$ Lipschitz?.
Remark.
This question has been answered (positively) for $f$ continuously differentiable in A continuously differentiable map is locally Lipschitz. However, from the answer given there, I seem to understand that continuity of the derivatives can be relaxed to boundedness of the derivatives. If this is actually the case, then my question is also answered (positively) in that post. But judging from the following remark, I may be missing something.
Remark
This paper http://www.sciencedirect.com/science/article/pii/S0024379512002741
seems to prove that there DO exist counterexamples (i.e. functions that are continuous, have uniformly bounded derivatives but are NOT Lipschitz). However, I must confess I do not understand their proof.
 A: As stated, the answer to your question is no. The Cantor function is a common counterexample when the derivative is required to exist only almost everywhere. It is continuous, has zero derivative a.e., in particular in an open set of full measure, but it is not Lipschitz continuous, nor absolutely continuous. You can make an analogous example in the cube $\mathbb{R}^n$ considering the Cantor function of the first variable.
If instead you take a function $f\in L^1_{loc}(\mathbb{R}^n)$ and require its gradient to exist in the distributional sense and to be represented by a function in $L^\infty$, then you are by definition stating that $f$ belongs to the Sobolev space $W^{1,\infty}(\mathbb{R}^n)$, which can be proven to coincide with the space of Lipschitz functions, see for example this question. This still holds if you replace $\mathbb{R}^n$ with a convex set $\Omega$ (there are some weaker conditions on $\Omega$ under which it works, but it doesn't work with arbitrary domains). Note that you don't need to assume a priori that $f$ is continuous, nor that the gradient is continuous almost everywhere.
A: Yes. The given assumptions imply that $f$ is locally absolutely continuous, that is, it is the integral of each of its derivatives (which are defined only at almost all points): 
$$\tag{*}
f(x_1, \ldots x_j+h \ldots x_n) - f(x_1 \ldots x_n) = \int_0^h \frac{\partial f}{\partial x_j}(x_1 \ldots x_j + y \ldots x_n)\ dy, \qquad j=1\ldots n.$$
You can therefore use the mean value theorem as you would normally do for smooth functions. 
Proving (*) is a bit annoying for me (I tend to gladly assume that those things are true without bothering to prove them), and is connected to a fine property of functions known as ACL property (see the book on Sobolev spaces by Giovanni Leoni - related). 
If you know something about weak or distributional derivatives, then you might be happy to know that they satisfy property (*) (modulo almost-everywhere-related technicalities). Your assumptions give that the almost-everywhere-defined classical derivatives of $f$ are indeed weak derivatives, and so (*) is satisfied. The space of functions that satisfy your assumptions is (contained into) a space usually known as $W^{1, \infty}_{\rm loc}(\mathbb{R}^n)$.
EDIT You are right that my post is way too imprecise. For a rigorous proof using approximation by mollifying, see e.g. Evans's book on PDEs, second edition, Theorem 4 chapter 5 (Characterization of $W^{1,\infty}$ functions), pag. 294.
