This is from Guillemin and Pollack chapter 2.
Theorem: If $X$ is any compact manifold with boundary, then there exists no smooth map $g:X\to \partial X$ with $\partial g:\partial X\to \partial X$ the identity.
The proof proceeds by contradiction: Suppose such a $g$ exists and let $z\in \partial X$ be a regular value. They claim this follows by Sard's theorem, but I don't see why? Couldn't the boundary have measure zero (it could even be empty)?
My second question: They also claim that the codimension of $g^{-1}(z)$ in $X$ is equal to the codimension of $z\in \partial X$, and so is $\dim X-1$, but why is this true?
The point 1) is an application of the generalization of Sard's theorem proved page $62$ : for any smooth map $f : X \to Y$, $X$ being a manifold possibly with boundary, then almost every point is a regular value of both $f$ and $f_{|\partial X}$.
For the second point, this is also an application of the theorem concerning transversality page $60$.