Let $X$ be an n-dimensional manifold with boundary and let $x \in \partial X$. Show that there exists a smooth non-negative function $f$ on some open neighborhood $U$ of $x$, such that $f(z)=0$ iff $z \in \partial U$, with $0$ be the regular value of $f$.
Could someone help me in solving this problem? thank you.
I'll denote the manifold by $M$. I assume you want to take $x$ as a boundary point (?).
Denote by $n$ the interior unit normal along the boundary (on a neighbourhood of some point, if you want to do this locally)
If you know that the exponentional map $$\partial M \times [0,\varepsilon ): (x,t)\mapsto \exp_x(t n(x))$$ is a diffeormorphism onto a neighbourhood of $\partial M$ in $M$ (for sufficiently small $\varepsilon >0$, if $\partial M$ is compact) then you know that (on that neighbourhood) $$f(\exp_x(t n(x))) := t$$ is well defined. It has the properties you asked for.
If $\partial M$ is not compact you need to modify this a bit or do this locally.
If you do not know about the exponential map you may work in local coordinates (which will result in a local result, which you could patch together to a global one using a partition of unity):
Consider a chart $$\varphi:\mathbb{R}^{n-1}\times [0,\infty) \rightarrow M$$ at the boundary and define $$h(x, t) = t$$ on $\mathbb{R}^{n-1}\times [0,\infty)$ and let $f(p) = h(\varphi^{-1}(p))$