Max dimension of a subspace of singular $n\times n$ matrices

I am sure the answer to this is (kind of) well known. I’ve searched the web and the site for a proof and found nothing, and if this is a duplicate, I’m sorry.

The following question was given in a contest I took part. I had an approach but it didn’t solve the problem.

Consider $V$ a linear subspace of the real vector space $\mathcal{M}_n(\Bbb{R})$ ($n\times n$ real entries matrices) such that $V$ contains only singular matrices (i.e matrices with determinant equal to $0$). What is the maximal dimension of $V$?

A quick guess would be $n^2-n$ since if we consider $W$ the set of $n\times n$ real matrices with last line equal to $0$ then this space has dimension $n^2-n$ and it is a linear space of singular matrices.

Now the only thing there is to prove is that if $V$ is a subspace of $\mathcal{M}_n(\Bbb{R})$ of dimension $k > n^2-n$ then $V$ contains a non-singular matrix. The official proof was unsatisfactory for me, because it was a combinatorial one, and seemed to have few things in common with linear algebra. I was hoping for a pure linear algebra proof.

My approach was to search for a permutation matrix in $V$, but I used some ‘false theorem’ in between, which I am ashamed to post here.

Solutions Collecting From Web of "Max dimension of a subspace of singular $n\times n$ matrices"

We can show more generally that if $\mathcal M$ is a linear subspace of $\mathcal M_n(\mathbb R)$ such that all its element have a rank less than or equal to $p$, where $1\leq p<n$, then the dimension of $\mathcal M$ is less than or equal to $np$. To see that, consider the subspace $\mathcal E:=\left\{\begin{pmatrix}0&B\\^tB&A\end{pmatrix}, A\in\mathcal M_{n-p}(\mathbb R),B\in\mathcal M_{p,n-p}(\mathbb R) \right\}$. Its dimension is $p(n-p)+(n-p)^2=(n-p)(p+n-p)=n(n-p)$. Let $\mathcal M$ a linear subspace of $\mathcal M_n(\mathbb R)$ such that $\displaystyle\max_{M\in\mathcal M}\operatorname{rank}(M)=p$. We can assume that this space contains the matrix $J:=\begin{pmatrix}I_p&0\\0&0\end{pmatrix}\in\mathcal M_n(\mathbb R)$. Indeed, if $M_0\in\mathcal M$ is such that $\operatorname{rank}M_0=p$, we can find $P,Q\in\mathcal M_n(\mathbb R)$ invertible matrices such that $J=PM_0Q$, and the map $\varphi\colon \mathcal M\to\varphi(\mathcal M)$ defined by $\varphi(M)=PMQ$ is an isomorphism.

If we take $M\in\mathcal M\cap \mathcal E$, then we can show, considering $M+\lambda J\in\mathcal M$, that $M=0$. Therefore, since
$$\dim (\mathcal M+\mathcal E)=\dim(\mathcal M)+\dim(\mathcal E)\leq \dim(\mathcal M_n(\mathbb R))=n^2, $$
we have
$$\dim (\mathcal M)\leq n^2-n(n-p)=np.$$