Is a continuous real-valued function with smooth level sets differentiable? Suppose I have a function $g$ from some open subset $M \subset R^n$ to the reals. I seem to recall that if $g$ is a submersion then, for any $t$ in the range of $g$ the level set $g^{-1}(t)$ is  "smooth".
How about the converse: Suppose I only know that the function $g$ is continuous but $g^{-1}(t)$ is smooth for every $t$ in the range of $g$. Must $g$ be differentiable? Concretely, I have a smooth regular codimension one foliation $\mathscr{F}$ of $M$ and have constructed a continuous function $g$ such that, for each $t$ in the range of $g$, $g^{-1}(t)$ is a leaf of $\mathscr{F}$ ($g$ is a variant of the quotient map of $\mathscr{F}$). I've thought about this for a while now trying, among other things, using foliated charts but can't seem to get anywhere. My sense is it's true but I easily could be wrong, of course. I'd appreciate any pointers so I can work this problem out for myself.
Edit: Pursuant to Lee Mosher's comment, I know a few more things about the foliation $\mathscr{F}$. First, $M$ is actually $P^n$, where by $P$ I mean the strictly positive reals. Second, I know that $\mathscr{F}$ arises from a smooth plane distribution via Frobenius' Theorem (hence each leaf is a connected integral manifold which also happens to be proper). Finally, I know that every ray through the origin intersects each leaf once and only once. I still don't think that is imposing any "control" in the transverse direction, but I could be wrong.
 A: For a rock bottom counterexample take
$$g(x,y) = \begin{cases}
x & \quad\text{if $x \le 0$} \\
2x &\quad\text{if $x \ge 0$}
\end{cases}
$$
so $g^{-1}(t)$ is a vertical line for all $t$, which is as "smooth" as you can get I suppose.
But $g(x,y)$ is not differentiable at any value where $x=0$.
I'm sure you can pump this up to examples which are considerably worse behaved.
The point is that you are not imposing any control on $g$ in any direction that is "transverse" to the foliation, so its unreasonable to expect smoothness of $g$.
A: How about $g: \mathbb{R}_{>0} \to \mathbb{R}$ via:
$$
g(x) = (x-1)^{\frac{1}{3}}.
$$
Here each of your leaves are singleton which highlights the fact that the 'integrability' aspect of your assumptions aren't buying you control over the one remaining 'degree of freedom.'  The graph of $g$ is even a smooth manifold here too.
Edit: Your problem is actually partially related to a classical problem in economics.  You might be interested in this paper by Gerard Debreu which treats a similar question, but has some nice exposition/pictures.
