TITLE: A problem regarding the rank of a matrix
QUESTION [7 upvotes]: $\mathbf {The \ Problem \ is}:$ If $A$ and $B$ be two $n\times n$ square matrix such that $A^2=A$ and $B^2=B,$ then show that $r(A-B)=r(A-AB)+r(AB-B)$ where $r(A)$ denotes rank of the square matrix $A.$
$\mathbf {My \ approach} :$ Actually I have tried that, from the two equations, $A(A-B)=(A-AB)$ and $(A-B)B=(AB-B)$, we have $r(A-AB)+r(AB-B) \leq r(A)+r(B)$ and again $A(AB-B)=0$ and $(A-AB)B=0$, then $r(A)+r(AB-B)\leq n$ and $r(B)+(A-AB)B\leq n$, but I can't draw any further conclusion to show that 
$r(A-AB)+r(AB-B) \leq r(A-B)$ .
And the other side is obvious by the rank-inequality $r(P+Q)\leq r(P)+r(Q).$ 
A small hint is warmly appreciated .

REPLY [2 votes]: Let $F$ be the underlying field, $V=F^n,\,A'=I-A$ and $B'=I-B$. Then $A'$ and $B'$ are also projectors and $AA'=A'A=BB'=B'B=0$. We have two observations:

$r(AB')+r(A'B)=r(AB'-A'B)$:


Since $AB'V\cap A'BV\subseteq AV\cap A'V=0$, we have $AB'V\cap A'BV=0$. Hence
\begin{aligned}
r(AB')+r(A'B)&=\dim(AB'V)+\dim(A'BV)\\
&=\dim(AB'V)+\dim(A'BV)-\dim(AB'V\cap A'BV)\\
&=\dim(AB'V+A'BV).
\end{aligned}
For any $x,y\in V$, we have $AB'x+A'By=(AB'-A'B)(B'x-By)$. Hence $AB'V+A'BV\subseteq (AB'-A'B)V$ and
$$
\dim(AB'V+A'BV)
\le\dim\left((AB'-A'B)V\right)
=r(AB'-A'B)
\le r(AB')+r(A'B).
$$

$r(AB'-A'B)=r(A-B)$: by rank-nullity thm, it suffices to show that $\ker(AB'-A'B)=\ker(A-B)$:


Suppose $(AB'-A'B)x=0$. Left-multiply both sides by $A$, we get $AB'x=0$. Subtract this equation from the previous one, we obtain $A'Bx=0$ too. Now $AB'x=0$ and $A'Bx=0$ imply that $Ax=ABx$ and $Bx=ABx$ respectively. Hence $(A-B)x=0$.
Conversely, suppose $(A-B)x=0$. Then $Ax=Bx$ and $A'x=B'x$. Hence $(AB'-A'B)x=AB'x-A'Bx=AA'x-A'Ax=0$.


The result now follows from 1 and 2.