Construct $f$ such that $\partial X=f^{-1}(0)$ 
Given a (smooth) manifold $X$ with boundary, show that there is a smooth map $f:X \to \mathbb R$ with $0$ as a regular value and $\partial X=f^{-1}(0)$.

I haven't been able to make any progress. Hints are welcome.
 A: Well, smooth manifolds with boundary admit partitions of unity, so what if you assigned a nonnegative real valued function to every element of a partition of unity and then added them up?
Then you essentially only have to define such a function $f$ on whatever space your manifolds with boundary are modeled on (by this I mean what the codomain of a chart is defined to be). And I think you should find that considerably less difficult. :)
Elaboration on the hint: First suppose that we can solve your problem when $X = \mathbb{H}^k$ (i.e. by finding such a nonnegative $f:X \to \mathbb{R}$)---then I claim we are done. Why? Because if $\{ g_i \}$ is a partition of unity of $X$ (necessarily with each $g_i$ nonzero on the interior of some chart $\psi_i : U_i \to \mathbb{H}^k$), then we can multiply each $g_i$ by the pullback $f \circ \psi_i$ of the solution $f$ to each chart domain $U_i$. We are then allowed to take the sum $\widehat{f} = \sum_i g_i \cdot (f \circ \psi_i)$, and this sum vanishes at a point $x \in X$ exactly if each $g_i  \cdot (f \circ \psi_i)$ vanishes there (since we chose $f$ to be nonnegative).
So now assume that $\widehat{f}(x) = \sum_i g_i(x) \cdot (f \circ \psi_i)(x) = 0$. By the definition of a partition of unity there must be some $i$ for which $g_i(x)$ is nonzero, and we still must have $g_i(x) \cdot (f \circ \psi_i)(x) = 0$, so the only possibility is $f(\psi_i(x)) = 0$. But now by the definition of $f$ we must have that $\psi_i(x)$ lies on the boundary of $\mathbb{H}^k$, and since $\psi_i$ is a diffeomorphism $x$ must lie in the boundary $\partial X$. Conversely if $x \in \partial X$ then each pullback $f \circ \psi_i$ is zero at $x$, so each product $g_i \cdot (f \circ \psi_i)$ is also zero there, and thus $\widehat{f}(x) = 0$.
It only remains to solve your problem on $\mathbb{H}^k$ with a nonnegative $f : \mathbb{H}^k \to \mathbb{R}$. How about you just let $f$ be the product of all of the coordinate projections?
