Prove that $\operatorname{rank}(B) = \operatorname{rank}(AB) + \operatorname{dim}\left(N(A) \cap C(B)\right)$. I am studying for midterm exam, and solving many problems on the textbook. I want to prove the following statement, but I failed to prove it. Please someone help me how to prove the following statement.

If $A$ is an $n\times m$ matrix and $B$ is an $m \times n$ matrix with $m\le n$, then $$\operatorname{rank}(B) = \operatorname{rank}(AB) + \operatorname{dim}\left(N(A) \cap C(B)\right),$$
  where $N$ and $C$ is space of null and column.

I cannot find how to start.... so there is nothing of what I have done. I just draw many images and tried many examples with real numbers.... However, I cannot find any method to prove it.
 A: Hint: Recall that the rank of a matrix is the dimension of its column space. So you're looking for a basis for $C(B)$ with $\operatorname{rank}(AB) + \operatorname{dim}(N(A)\cap C(B))$ elements.
Now $N(A)\cap C(B)$ is a subspace of $C(B)$, so it's natural to start by selecting a basis for it. Then you need to find $\operatorname{rank}(AB)$ additional vectors to extend that with so you get a basis for all of $C(B)$.
A basis for $C(AB)$ has exactly the right number of elements, but they live in the wrong space. But each of the $C(AB)$ basis vectors is -- by definition -- $ABv_i$ for some vector $v_i$, and if you take $Bv_i$ for those vectors, you get the right number of vectors in $C(B)$.
Now all you need to prove is that the basis for $N(A)\cap C(B)$, together with the $Bv_i$s, form a basis for $C(B)$.
A: I consider $A$ and $B$ as linear maps. Denote by $A|_{C(B)}$ the restriction of the linear map $A$ to the subspace $C(B)$. Then $\operatorname{Im}(A|_{C(B)}) = A(C(B)) = \operatorname{Im}(AB)$. Hence, $\operatorname{rank}(AB) = \operatorname{rank}(A|_{C(B)})$. By the rank-nullity theorem, applied to $A|_{C(B)}$, we get
\begin{align*}
\operatorname{rank}(B)
&= \dim C(B) = \operatorname{rank}(A|_{C(B)}) + \dim N(A|_{C(B)})\\
&= \operatorname{rank}(AB) + \dim(N(A)\cap C(B)).
\end{align*}
