Prove that $\operatorname{rank}A=\operatorname{rank}B$ if $A$ and $B$ are idempotent matrices and $I - (A+B)$ is invertible I've got a very interesting problem and wondering if my idea for the solution is right and complete. Please, take a look.
Problem
Given two matrices $A$ and $B$ such that $A^2=A$ and $B^2=B$. Prove that $\operatorname{rank}A=\operatorname{rank}B$ if the matrix $I - (A+B)$ is invertible.
Solution
$A^2=A$
$B^2=B$
Let's subtract the second equation from the first one.
$A^2 - B^2 = A - B$
$(A - B)(A+B) = A - B$
$(A - B)(A+B) - (A-B)= 0$
$(A - B)((A+B) - I))= 0$
$(A - B)(I - (A+B))= 0$
Since $(I - (A+B))$ is invertible, let's multiply the above equation by $(I - (A+B))^{-1}$ from the right.
$(A - B)(I - (A+B))(I - (A+B))^{-1}= 0$
$A - B = 0$
Hence, $A = B$ which means that $rankA = rankB$.
 A: As the comments explain, your current approach is wrong.
For one correct approach, try a proof by contrapositive. Suppose $A$ and $B$ do not have the same rank.  It follows that we have either
$$
\dim \ker (A) + \dim \operatorname{im}(B) > n
$$
or
$$
\dim \ker (B) + \dim \operatorname{im}(A) > n
$$
where $\ker(A)$ denotes the kernel (nullspace) of $A$ and $\operatorname{im}(A)$ denotes the image (column space) of $A$.
If the first condition holds, then $\ker(A) \cap \operatorname{im}(B)$ contains a non-zero vector $x$.  This vector $x$ satisfies $Ax = 0$ and $Bx = x$.  It follows that
$$
(I - (A + B))x = x - Ax - Bx = x - 0 - x = 0.
$$
That is, $I - (A + B)$ has a non-trivial kernel.  Thus, $I - (A + B)$ is not invertible.
If the second condition holds, we similarly conclude that $I - (A + B)$ has a non-trivial kernel and so cannot be invertible.
So, we have proven the desired result: if $I - (A + B)$ is invertible, then $A$ and $B$ must have the same rank. 

A slicker approach is as follows: note that
$$
(I - (A + B))A = A - A^2 - BA = -BA\\
B(I - (A + B)) = B - BA - B^2 = -BA
$$
That is, we have
$$
(I - (A + B))A = B(I - (A + B)).
$$
If $(I - (A + B))$ is invertible, then multiply both sides by $(I - (A + B))$ from the left to conclude that
$$
A = (I - (A + B))^{-1}B(I - (A + B)).
$$
Since $A$ and $B$ are similar, we conclude that they have the same rank.
A: Recall that if $P$ is a projection matrix (matrix such that $P^2 = P$), it holds $\operatorname{rank} P = \operatorname{Tr} P$.
Notice that $A$ is a projection so  $I-A$ is also a projection. It follows
$$\operatorname{rank}(I-A) = \operatorname{Tr}(I-A) = n-\operatorname{Tr} A = n-\operatorname{rank} A$$
Now since rank is subadditive, we have
$$n = \operatorname{rank}(I-(A+B)) \le \operatorname{rank}(I-A) +  \operatorname{rank}(-B) = n-\operatorname{rank} A + \operatorname{rank}B$$
so $\operatorname{rank} A \le \operatorname{rank}B$.
By symmetry it follows $\operatorname{rank} B \le \operatorname{rank}A$ so we have equality.
