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.
 A: Since $A(A-I) = 0$, the eigenvalues of $A$ are $0,1$, and the matrix is diagonalizable. The rank of $A$ is the number of non-zero eigenvalues, which is the multiplicity of the eigenvalue $1$. Similarly, the rank of $A-I$ is the number of eigenvalues different from $1$, which is the multiplicity of the eigenvalue $0$. The sum of these multiplicities must be $n$.
A: 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)$.
A: If $v\in Range(I-A)$, $v=(I-A)w$, then $Av=A(I-A)w=0$ so $Range(I-A)\subseteq Null(A)$. Conversely if $v\in Null(A), Av=0$ then $(I-A)v=v$ and $v\in Range(I-A)$. Thus $Range(I-A)=Null(A)$. Hence $$rank(I-A)=dim(Range(I-A))=dim(Null(A))=nul(A).$$
