Show if $A^2 = A$ then $\textrm{rank}(A) + \textrm{rank}(A - I) = n$ suppose $n \in \mathbb{N}$ and $A$ is a $n \times n$ idempotent matrix, meaning $A^2 = A$.
show that:
$$
\textrm{rank}(A) + \textrm{rank}(A - I) = n
$$

I think we should first use rank-nullity theorem:
$$
\textrm{rank}(A) + \textrm{dim}(\textrm{null}(A)) = n
$$
then show that:
$$
\textrm{dim}(\textrm{null}(A)) = \textrm{rank}(A - I)
$$
but I don't know how to show the second phrase.

It can be shown that $F^n\cong \text{im}(A)\oplus\text{im}(I-A)$ (where $F$ is the base field, and $\text{im}$ stands for image.) Then the rank property folows directly.
To show this for any $v\in F^n$, $v = A(v) + (I-A)(v)$, hence $F^n\cong \text{im}(A)+\text{im}(I-A)$. Now it's enough to show the two images have trivial interection.
If $A(x) = (I-A)y$, then apply $A$ to both sides, $A^2(x) = A(I-A)y$, $A(x) = (A-A^2)y = (A-A)y = \vec 0$.
We can also show the second phrase directly. It's enough to show that $\text{im }(I-A)=\ker A$. Indeed, if $x = (I-A)y\in\text{im }(I-A)$, then $A(x) = A(I-A)(y) = 0$, so $x\in\ker A$. If $x\in \ker A$, then $(I-A)(x) = Ix-Ax = x$, hence $x\in\text{im }(I-A)$.
