Gradient of Sobolev function on level sets I have been told by my teacher that, if $f$ is Sobolev (i.e. $W^{1,p}$ for some $p$) on an open set $\Omega$, which, for the proof what I'm asking is needed for, may well be assumed bounded, then its gradient is a.e. zero on each of its level sets, i.e. $\nabla f|_{\{f=k\}}=0$ a.e. for all $k$. I am trying to prove it.
For the moment, I have thought that, calling $A_k=\{f=k\}$, if $A_k$ contains any ball, then the gradient is zero there. This is because I know that, for a.e. line in that ball, $f$ will be absolutely continuous on that line, and since it is constant, its derivative will have to be a.e. zero on a.e. segment, and letting the segment length go to zero I can finally say the derivative at the endpoint is zero.
But what about non-interior points? I don't think I can say much about the gradient there. So I would have to prove that, if I take $A_k$ and remove all the balls it contains, I am left with a zero measure set.
So how do I go about this? Or maybe I am missing something and I can, in fact, say something about the gradient in at least some of those left-out points?
"Edit"
Naturally the ball discussion is overkill: $f$ is constant on that ball, so it is smooth therein, hence weak derivatives are classical, and we know classical derivatives of constants are zero.
 A: I know a proof which proceeds by proving Stampacchia's lemma in two different ways. I do not know if there is a more direct proof.
Therefore, we need a smoothing of the $\max(\cdot,0)$-function:
$$\varphi_\varepsilon(t) = \begin{cases}0 & \text{if } t \le 0, \\ \frac{t^2}{2\,\varepsilon} & \text{if } 0 < t \le \varepsilon, \\ t - \frac\varepsilon2 & \text{if } \varepsilon < t.\end{cases}$$
(I hope I got the constants right.)
Then, you consider $g_\varepsilon := \varphi_\varepsilon \circ f$ and show that $g_\varepsilon \to \max(f,0)$ in $W^{1,p}(\Omega)$. This shows
$$\nabla (\max(f,0))(x) = \begin{cases} 0 & \text{if } f(x) \le 0, \\ \nabla f(x) & \text{if } f(x) > 0.\end{cases}$$
Here, it is essential that $\varphi_\varepsilon'(0) = 0$.
Now, you perform the same calculation with the translates $\psi_\varepsilon(t) := \varphi_\varepsilon(t + \varepsilon)$. Since $\psi_\varepsilon'(0) = 1$, you end up with
$$\nabla (\max(f,0))(x) = \begin{cases} 0 & \text{if } f(x) < 0, \\ \nabla f(x) & \text{if } f(x) \ge 0.\end{cases}$$
This shows that $\nabla f = 0$ a.e. on the set $\{f = 0\}$.
A: Browsing through Measure Theory and Fine Properties of Functions, by L.C. Evans and F Gariepy, I just found a proof of $\nabla f=0$ a.e. on $\{f=0\}$, and I went, "Oh right. So easy. How dumb I was". I mean, knowing Stampacchia for positive and negative part, one just needs to observe:
$$\nabla f=\nabla f^+-\nabla f^-,$$
and those two are indeed zero where $f=0$. As for $\{f=c\}$, that will be $\{f-c=0\}$, and then:
$$\nabla f=\nabla(f-c+c)=\nabla(f-c)+\nabla c=\nabla(f-c)=\nabla(f-c)^+-\nabla(f-c)^-,$$
which by the above will be $0-0$ where $f-c=0$, or $f=c$.
