# Given a smooth function $f:M\to [a,b]$, $f^{-1}(a)$ and $f^{-1}(b)$ are (immersed) submanifolds

Suppose that $(M,g)$ is a compact Riemannian manifold and $f:M\to [a,b]$ a smooth function such that $\|\nabla f\|$ is constant along each level set.

Assume that $\forall c,d \in [a,b]$ and $\forall p \in f^{-1}(c)$ and $\forall q \in f^{-1}(d)$, $$d(p,f^{-1}(d))=d(f^{-1}(c),q).$$ Also we know that $a$ and $b$ are the only critical values and each of the level sets $f^{-1}(a)$ and $f^{-1}(b)$ has dimension less than $n-1$, where $n=\dim M$. Here $\nabla f$ is the gradient of $f$, that is defined as $df_p(v)=g(\nabla f, v)$, $\forall v \in T_pM$.

Is that possible to show that $f^{-1}(a)$ and $f^{-1}(b)$ are (immersed) submanifolds of $M$, with these hypothesis?

One can also prove that each level set $f^{-1}(c)$, where $c\in (a,b)$, is am embedded submanifold of dimension $n-1$.

Also $\forall q \in f^{-1}(a)$ there exists a geodesic that minimizes the distance from $q$ to $f^{-1}(c)$ and this geodesic is orthogonal to each level set $f^{-1}(c)$ and eventually meets $f^{-1}(b)$. One has the same results about $\forall q \in f^{-1}(b)$.

Start with the following planar convex curve $C$ (which can be made to be $C^\infty$-smooth):
Make sure that this curve is symmetric with respect to the reflection in the (vertical) y-axis. Let $h: C\to {\mathbb R}$ be the $y$-coordinate function (the "height function"). Let $a, b$ be the minimal and maximal values of $h$ respectively. Then $h^{-1}(a), h^{-1}(b)$ are not submanifolds (they are submanifolds with boundary though). Equip $C$ with the Riemannian metric obtained as the pull-back of the standard flat metric $dx^2 + dy^2$ on ${\mathbb R}^2$. It is easy to check that this example satisfies all the requirements of the question except the dimension requirement: $h^{-1}(a), h^{-1}(b)$ are 1-dimensional while $dim(C)=1$.
I suspect that by taking a product of $C$ with another manifold one can get an example satisfy the requirement $dim(f^{-1}(a))< dim(M)-1$, $dim(f^{-1}(b))< dim(M)-1$ as well.