Is the “distance to boundary” function smooth in a neighborhood? Let $M$ be a connected Riemannian manifold with boundary. We define the “distance to boundary” function $d(p)=d(p,\partial M)$, i.e. the infimum of lengths of (piecewise) smooth paths connecting $p$ with some point in $\partial M$. Does there always exist a neighborhood $U$ of $\partial M$, so that $d$ is smooth in $U$?
This is not true if we replace $\partial M$ by an arbitrary subset $A$, e.g. consider $A=\text{point}$.
 A: Yes, at least if the boundary is compact.
Define a map $$\varphi:\partial M\times[0,\epsilon)\to M,\quad (p,t)\mapsto\exp_p(t\nu),$$where $\nu$ is the inward pointing unit normal vector field along the boundary. The differential of $\varphi$ at $(p,0)$ is nonsingular for any $p\in\partial M$. Using the inverse function theorem and a compactness argument, we deduce that for some $\epsilon'\leq\epsilon$, the map $\varphi|_{\partial M\times[0,\epsilon')}$ is a diffeomorphism. This means, in particular, that $$d(\varphi(p,t))=t,\quad(p,t)\in\partial M\times[0,\epsilon'),$$and the claim is proved.
Edit: Here is an optional compactness argument. By the inverse function theorem, we know that for $p\in\partial M$, there is a neighborhood of $(p,0)$ in $\partial M\times[0,\epsilon)$ in which $\varphi$ is a diffeomorphism. Now suppose that for any $\epsilon'>0$ the restriction $\varphi|_{\partial M\times[0,\epsilon')}$ is not injective. Then there exist two sequences, $(p_n,t_n)$ and $(q_n,s_n)$, of points in $\partial M\times[0,\epsilon),$ such that for every $n$ we have $$(p_n,t_n)\neq(q_n,s_n),\quad t_n,s_n<\frac{1}{n},\quad\varphi(p_n,t_n)=\varphi(q_n,s_n).$$By moving to a subsequence of $(p_n)$, and then to a subsequence of $(q_n)$, we may assume that both sequences converge, say, to the points $p$ and $q$, respectively. By continuity, we get $$p=\varphi(p,0)=\lim_{n\to\infty}\varphi(p_n,t_n)=\lim_{n\to\infty}\varphi(q_n,s_n)=\varphi(q,0)=q.$$ But this would mean that $\varphi$ is not injective in any neighborhood of the point $(p,0)=(q,0)$, a contradiction.
