Proof (preimage theorem for manifold with boundary)

Let $x\in f\inv(y)$. If $x\not\in \op{int}(X)$ (which is a manifold without boundary), the preimage theorem for manifolds without boundary shows $x$ has a neighbourhood in $f\inv(y)$ diffeomorphic to $\R^{m - n}$, where $\dim X = m$ and $\dim Y = n$. So it remains to consider $x\in f\inv(y) \cap \partial X$. Working in a local chart near $x$ and $y$, WLOG assume $X = \mathbb{H}^m$ and $Y = \R^n$.

Since $f$ is smooth at $x$, by definition there exists a smooth function $F: V\to \R^n$ where $V$ is an open neighbourhood of $x$ in $\R^m$ and $F|_{V \cap \mathbb{H}^m} = f|_V$. $y$ is a regular value of $f$, so $\d F_x = \d f_x$ is surjective. By shrinking $V$, we can assume $\d F_z$ is surjective for all $z\in V$, so $y$ is also a regular value of $F$.

By the preimage theorem, $F\inv(y)\subseteq V$ is a manifold of dimension $m-n$. Moreover $$ \begin{align*} f\inv(y) \cap V = F\inv(y) \cap \mathbb{H}^m = π|_{F\inv(y)}\inv([0,\infty)) \end{align*} $$ where $π: \R^m \to \R: (x_1, \ldots, x_m) \mapsto x_m$ is the projection map onto the last component. From our previous result about superlevel sets, it suffices to show $0$ is a regular value of $π|_{F\inv(y)}$, since then we can conclude $$\dim f\inv(y) = \dim (f\inv(y) \cap V) = \dim F\inv(y) = n - m$$ and $$\partial(f\inv(y) \cap V) = π\inv|_{F\inv(y)}(0) = F\inv(y) \cap \partial\mathbb{H}^m = f\inv(y) \cap \partial \mathbb{H}^m.$$

To show $0$ is a regular value of $π|_{F\inv(y)}$, let $z \in π|_{F\inv(y)}\inv(0) = F\inv(y) \cap \partial \mathbb{H}^m$, and we need to check $\d(π|_{F\inv(y)})_z = (\d π_z)|_{T_z F\inv(y)}$ is surjective. As $\d π_z = π: \R^m \to \R$, this is equivalent to showing $$ \begin{align*} T_z F\inv(y) \not \subseteq \ker \d π_z = T_z \partial\mathbb{H}^m. \end{align*} $$ The preimage theorem tells us $T_z F\inv(y) = \ker \d F_z = \ker \d f_z$, and our hypothesis that $y$ is a regular value of $f|_{\partial \mathbb{H}^m}: \partial \mathbb{H}^m \to \R^n$ implies $(\d f|_{\partial \mathbb{H}^m})_z = (\d f_z)|_{T_z \partial\mathbb{H}^m}$ is surjective. Therefore $\ker \d f_z \not \subseteq T_z \partial \mathbb{H}^m$.