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.
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\}$.