Can we perturb a map $\mathbb{R}^n \to \mathbb{R}^n$ to have high rank? Let $\mathbb{D}^n$ be the closed $n$-dimensional unit ball, and let $f:\mathbb{D}^n \to \mathbb{R}^n$ be smooth.
Suppose that $df$ is invertible outside a set of Hausdorff dimension $\le n-1$, and that $\text{rank}(df) \ge n-1 $ on $\partial \mathbb{D}^n$. 

Question: Do there exist $f_n \in C^{\infty}(\mathbb{D}^n, \mathbb{R}^n)$ such that $f_n \to f$ in $W^{1,2}(\mathbb{D}^n, \mathbb{R}^n)$ and $\text{rank}(df_n) \ge n-1 $ everywhere on the interior $ \text{Int}(\mathbb{D}^n) $? 

Easier question:
My intuition is that the set of points where the rank is less than $n-1$ should be very small (generically). Indeed, it is the set where all the $n-1$-minors of $df$ vanish; these are $n^2$ (independent?) equations. Thus, I expect that typically, the Hausdorff dimension of this set would be zero. Can we prove that?
That is, can we find $f_n \in C^{\infty}(\mathbb{D}^n, \mathbb{R}^n)$ such that $f_n \to f$ in $W^{1,2}(\mathbb{D}^n, \mathbb{R}^n)$ and $\dim_{\mathcal H}(\{ p \, | \, \text{rank}(df_n)_p < n-1  \})=0$? 
Edit 2:
As commented by Dap, the algebraic set of matrices of rank $\le n-2$ has codimension 4. So, for $n \ge 5$ we shouldn't expect to get dimension $0$ just by generic modifications and dimension arguments. However, we may get dimension $0$ for dimension $n=4$. (Can this be formalized?)
 A: This is not a complete answer, it requires some literature search. But I believe still that the answer to this question is negative and the proper setting of this question is within singularity theory and things like stable singularities. 
Namely, if you go to the book 
Singularity Theory I. Author(s): V. I. Arnold, V. V. Goryunov, O. V. Lyashko, V. A. Vasil’ev (auth.) Series: Encyclopedia of Mathematical Sciences 6
and look on page 160, there is a theorem, attributed to Porteuos (Porteous, I.R.: The second-order decomposition of $\Sigma^2$ Topology 11, 325-334 (1972).), 
Theorem. A generic map $f: N^n\to P^n$ can be written, in suitable coordinates in a neighborhood of an elliptic [resp. hyperbolic] singular point 0 as
$$y_1=x_1,\ldots, y_{n-2}=x_{n-2}, \, y_{n-1}=x_{n-1}x_n,\,y_n=x_{n-1}^2-x_n^2+x_{n-3}x_{n-1}+x_{n-2}x_n$$
[resp $y_n=x_{n-1}^2+x_n^2+...$] 
This formula makes sense starting from $n=4$. Note that the rank of the map at $(0,\ldots, 0)$ is $n-2$. So I interpret this theorem that the map $\mathbb R^4\to \mathbb R^4$ given by the above formula can not be perturbed in such a way so to get rid of a point where the rank of the differential equals $2$. This result is about small smooth perturbations, but I doubt that involving the functional space $W^{1,2}$ will make any difference.
ADDED:  Easier question.
Concerning the second part of the question, it should follow from the result called "Strong tranversality Theorem" in the book of Arnol'd, Varchenko, Gussein-Zade, page 38 "Singularities of differentiable maps, volume 1"
Theorem.(Thom) Let $M^n$ be a closed manifold and $C$ a closed submanifold of the space of jets $J^k(M,N)$. Then the set of maps $f:M\to N$ whose $k$-jet extensions are transversal to $C$ is an open everywhere dense set in the set of all smooth maps from $M$ to $N$.
In the case under consideration it is enough to consider $1$-jets, since we are only interested in the condition on the rank of the differential. Now this theorem will give you codimension 4, as was noticed in the comments.
A: I believe the answer is positive.
First step: reduce to the case that $\mathrm{rank}(df_x)\geq n-1$ except on a finite union of submanifolds of dimension at most $n-4.$
Proof: For $r=0,\dots,n-2,$ let $M_r\subset \mathbb R^{n\times n}$ be the set of matrices of rank exactly $r.$ Each of these is a smooth manifold of dimension at most $n^2-4.$ For each such $r,$ consider the map $\phi_r:\mathrm{int}(\mathbb D^n)\times M_r\to\mathbb R^{n\times n}$ defined by $\phi_r(x,M)=M-df_x.$ A preimage $\phi_r^{-1}(\{N\})$ consists of pairs $(x,df_x+N)$ where $x$ is such that $df_x+N$ has rank $r$ i.e. such that $x\mapsto f(x)+Nx$ has a derivative of rank $r.$
By the preimage theorem, if $N$ is regular for $\phi_r$ then this preimage is a manifold of codimension at least $4.$ Since this preimage is actually a graph of the smooth function $x\mapsto df_x+N,$ projecting away the second component doesn't affect the codimension. A similar argument can be applied to the boundary of $\mathbb D^n.$ By Sard's theorem, almost all $N$ are regular values for all these maps. Take a small such $N$ so that $x\mapsto f(x)+Nx$ is approximately $f.$ $\square$
Actually it will be useful to also require $\mathrm{rank}(df_0)\geq n-1,$ which is easy enough because it holds for almost all $N$ - just pick $N$ outside $(\bigcup_r M_r)-df_0.$
Second step: given $\epsilon>0,$ we can construct a diffeo $\phi$ from $\mathrm{int}(\mathbb D^n)$ to a subset of the points $x$ with $\mathrm{rank}(df_x)\geq n-1,$ such that $\max_x|d\phi_x|= O(1/\epsilon),$ and the set where $\phi(x)\neq x$ has measure $O(\epsilon^3).$ The implicit constants here are allowed to depend on $f.$
Proof: Let $E$ denote the exceptional set $\{x\in\mathrm{int}(\mathbb D^n)\mid \mathrm{rank}(df_x)<n-1\}.$ The idea is to push $E$ away from the origin in a radial direction, out of the disc.
Let $\epsilon>0.$ Define $$R_0=\min_{x\in E}|x|.$$ Define $E'$ to be the set of points $v\in S^{n-1}$ such that $\lambda v\in E$ for some $0\leq \lambda < 1$ - the radial projection of $E$ to the boundary of the disc.
I will argue that the $\epsilon$-neighborhood of $E'$ in $S^{n-1}$ (the set of points at distance at most $\epsilon$ from $E'$) has $(n-1)$-dimensional volume at most $O(\epsilon^3).$
 The homeomorphism $\phi:(v,r)\mapsto rv$ from $S^{n-1}\times (R_0/2,1)$ to $\{x\in D^n\mid |x|\in(R_0/2,1)\}$ is a diffeo. So the preimage of the the at-most-$(n-4)$-dimensional manifold $E$ still has Minkowski dimension $n-4.$
It can therefore be covered by a set of $N(\epsilon)$ balls $B((v_i,r_i),\epsilon)$ such that $N(\epsilon) \epsilon^{n-4}=O(1).$ The projected balls $B(v_i,\epsilon)\subset S^{n-1}$ cover $E'$ and still satisfy $N(\epsilon) \epsilon^{n-4}=O(1).$ This means the $(n-1)$-dimensional volume is at most $O(1)N(\epsilon) \epsilon^{n-1}=O(\epsilon^3).$
Doubling the radii gives a set $\bigcup_i B(v_i,2\epsilon)$ still of $(n-1)$-dimensional volume $O(\epsilon^3),$ and containing the $\epsilon$-neighborhood of $E'.$
We will need a function $h:S^{n-1}\to[R_0/4,2]$ such that:


*

*$h$ is smooth

*$h\leq R_0/2$ on $E'$

*$h\geq 1$ except on the $\epsilon$-neighborhood of $E'$

*$h$ has Lipschitz constant $O(1/\epsilon)$
To construct such a function, first define $g(v)=R_0/4$ for $v\in E',$ and $g(v)=2$ for $v$ not in the $\epsilon$-neighborhood of $E'.$
Note that $g$ has Lipschitz constant at most $2/\epsilon.$
By the Kirszbraun theorem, $g$ extends to a function $S^{n-1}\to [R_0/4,2]$ with the same Lipschitz constant.
However $g$ may not be smooth. To deal with this, we can think of $S^{n-1}$ as the symmetric space $SO(n)/SO(n-1),$ so $g$ is a function on $SO(n)$ invariant under the right action of $SO(n-1)$ (specifically, $SO(n-1)$ is the stabilizer of $(1,0,0,\dots,0),$ and a rotation $\rho\in SO(n)$ corresponds to the point $\rho\cdot (1,0,0,\dots,0)\in S^{n-1}$). Convolve by left multiplication by a smooth mollifier $SO(n)\to\mathbb R$ supported on a small ball around the identity. The resulting function is still invariant under the right $SO(n-1)$ action, so corresponds to a function $h:S^{n-1}\to [R_0/4,2].$ This function $h$ will be smooth (basically by the implicit function theorem). It is a convex combination of rotated versions of $g,$ where each rotation moves points by no more than $R_0\epsilon/8$ say. This ensures conditions (2.) and (3.), and also (4.) because the set of functions with Lipschitz constant $\leq 2/\epsilon$ is convex.
Let $\psi:\mathbb R\to\mathbb R$ be a smooth function with $\psi(x)=x$ for $x\leq 0,$ and $\psi(x)<R_0/2$ and $0<\psi'(x)\leq 1$ everywhere.
Define $\phi:\mathrm{int}(\mathbb D^n)\to \mathrm{int}(\mathbb D^n)$ by $\phi(0)=0$ and $$\phi(rv)=(\psi(r-h(v))+h(v))v$$ for unit vectors $v$ and real $0<r<1.$
Then $\phi(rv)=rv$ if $r\leq h(v),$ in particular for $r\leq R_0/4$ or $h(v)\geq 1.$
So $\phi(x)=x$ in a neighborhood of zero, which ensures $\phi$ is smooth at zero. And $\phi(rv)=rv$ for all $0<r<1$ and $v\not\in E'$; since $E'$ has $(n-1)$-dimensional measure $O(\epsilon^3),$ the set of $x$ of the form $rv$ with $v\not\in E'$ has $n$-dimensional measure $O(\epsilon^3).$ (The probability that a uniformly chosen $x\in D^n$ satisfies $x/|x|\in E'$ is the same as the probability that a uniformly chosen $v\in S^{n-1}$ lies in $E'.$)
The Lipschitz constant of $\phi$ can be bounded by bounding the derivatives of $\phi$ along a path through $(r,v)$ with $r>R_0/4$ and $|\dot r|,|\dot v|\leq 1.$
Writing $h=h(v)$ and $\psi=\psi(r-h),$ the chain rule gives $|\dot h|=O(1/\epsilon)$ and hence $|\dot\psi|=O(1/\epsilon).$
So $$\frac{d}{dt} \phi(rv) = (\dot\psi+\dot h)v + (\psi+h)\dot v = O(1/\epsilon)$$
which means $\max_x|d\phi_x|=O(1/\epsilon).$ $\square$
The integral of $|d(f\circ \phi)-df|^2$ is at most the maximum value of the integrand, $O(1/\epsilon^2),$ multiplied by the volume of the set where the integrand can be non-zero, $O(\epsilon^3),$ giving $O(\epsilon)$ overall. The integral of $|(f\circ \phi)-f|^2$ is even better: $O(\epsilon^3).$ So $\|f-f\circ \phi\|^2_{W^{1,2}}=O(\epsilon).$ And the rank of $f\circ \phi$ will be $\geq n-1$ everywhere.
