TITLE: Can we stay invertible while approximating linear maps in Sobolev spaces?
QUESTION [5 upvotes]: Let $\Omega \subseteq \mathbb{R}^n$ be an open bounded domain with a smooth boundary. Fix $1<p<n$.
Let $A \in W^{1,p}(\Omega;\text{End}(\mathbb{R}^n)) \cap C(\Omega;\text{End}(\mathbb{R}^n))$ with $\det A > 0$ a.e.

Do there exist $u_n \in C^{\infty}\big(\Omega,\text{GL}(\mathbb{R}^n)\big)$ such that $u_n \to A$ in $W^{1,p}_{loc}$?
I am also interested in a weaker  result: Are there $u_n \in C^{\infty}\big(\Omega,\text{End}( \mathbb{R}^n)\big)$, such that $u_n(x) \in \text{GL}(\mathbb{R}^n)$ a.e. and
$u_n \to  A$ in $W^{1,p}_{loc}$?

I don't really need the $u_n$ to be defined on all $\Omega$. It suffices that for every arbitrarily small ball in $\Omega$, there would be a neighbourhood where such a sequence $u_n$ would be defined.
The problem is that it is not always true that $A_x \in \text{GL}( \mathbb{R}^n)$ for every $x \in \Omega$. The rank can fall on a subset of measure zero.
If we knew $A(x) \in \text{GL}(\mathbb{R}^n)$  everywhere then the answer would be positive. This follows from the facts that "being invertible" is an open condition, and that continuous Sobolev maps can be approximated uniformly by smooth maps over compact subsets.

In more detail, let $K \subseteq \Omega$ be compact. Since we assumed $A \in C\big(\Omega, \text{GL}(\mathbb{R}^n) \big)$, the map $\psi:x \to A_x$, considered as a map $K \to \text{GL}( \mathbb{R}^n)$, is continuous. Thus $\psi(K) $ is compact and $\text{dist}\big(\psi(K),\partial \text{GL}(\mathbb{R}^n)\big)>0$.
Now consider each component of $\psi(x)=A_x \in \text{End}(\mathbb{R}^n) $. We can approximate  each component of $\psi$ using mollification on an open subset of $\Omega$ containing $K$. Since each component is a continuous function, the mollifications converge uniformly on $K$. This implies that from a certain point in the mollified sequence, $\text{dist}(u_n,A)<\text{dist}\big(\psi(K),\partial \text{GL}(\mathbb{R}^n)\big)$, so the $u_n$ are invertible.

REPLY [4 votes]: I will recycle the answer I've been writing into some words of explanation on Alex Gavrilov's example, which is more simple and elegant. We can focus on the first column $p_n$ of an approximating sequence $u_n:=[p_n,q_n]$ of $A(x,y):=\begin{bmatrix}x&-y\\y&x\end{bmatrix}$. If $p_n\in C^0\cap W^{1,1}_{loc}(\mathbb{R}^2,\mathbb{R}^2)$ converges in $W^{1,1}_{loc}(\mathbb{R}^2,\mathbb{R}^2)$, then for at least one $r_0>0$ (actually, for a.e. $r>0$) the sequence restricted to the boundary, $p_{n|\partial B(0,r_0)}$ is in $W^{1,1}(\partial B(0,r_0))$ and converges there, therefore also uniformly. Then for some $n_0$, $$\|p_{n_0|\partial B(0,r_0)}-{\operatorname{id}_{\partial B(0,r_0)}}\|_{\infty,\partial B(0,r_0) }<r_0$$  that implies that $ p_{n_0|B(0,r_0)} $ has degree $1$ and $p_n(x,y)$ vanishes in some $(x_0,y_0)\in B(0,r_0)$, so that $u_{n_0}(x_0,y_0)$ is not invertible. 
For the weaker version, it is sufficient to approximate $A$ in $W^{1,p}_{loc}$ with a sequence of  polynomial maps $u_n$, since the polynomial $\det(u_n)$ is automatically non-vanishing a.e. as soon as it is not identically zero (which of course is eventually true,  since $\det(u_n(x_0))\to\det(A(x_0))>0$ holds at some point $x_0)$ )