Q:

$R(AB)=R(A)$ iff rank$(AB)$=rank$(A)$, $N(AB)=N(B)$ iff rank$(AB)$=rank$(B)$

$A$ and $B$ are two square matrices then show that $R(AB) = R(A)$ iff $\mathrm{rank} (AB) = \mathrm{rank} (A)$, and $N(AB) = N(B)$ iff $\mathrm{rank} (AB) = \mathrm{rank} (B)$. 

Here is my attempt:
Clearly $R(A)\supset R(AB)$, now can we say that these two subspaces are identical iff they have the same dimension?
also i know $N(AB)\supset N(B)$ but i am not finding a way to prove converse part.
Thanks for giving me time.

A:

Note that $R(AB)\subseteq R(A)$ always holds: if $x$ is any vector, then $AB(x) = A(Bx)\in R(A)$.
Thus, if $\mathrm{rank}(AB)=\mathrm{rank}(A)$, then that means that $\dim(R(AB))=\dim(R(A))$; since $R(AB)\subseteq R(A)$, equality of dimensions suffices to conclude that $R(AB)=R(A)$, because we are in finite dimension. Conversely, if $R(AB)=R(A)$, then they necessarily have the same dimension, hence the ranks of $AB$ and of $A$ must be equal. 
(Yes: if $V$ is finite dimensional, and $W\leq V$, then $W=V$ if and only if $\dim(W)=\dim(V)$: if $\dim(W)=\dim(V)$, then take a basis for $W$; then this already has the right number of elements to be a basis for $V$, and since it is linearly independent, it spans $V$; since it also spans $W$, we have $V=W$. Conversely, if $V=W$, then $\dim(V)=\dim(W)$. This does not work if $\dim(V)$ is infinite, and also does not work if you don't know that $W$ is contained in $V$; but if you have both conditions, it does.)
Similarly, $N(B)\subseteq N(AB)$, since $Bx=0$ implies $ABx=0$. Thus:
$$\begin{align*}
N(B)=N(AB) &\iff \dim(N(B))=\dim(N(AB))\\
&\iff \mathrm{null}(B)=\mathrm{null}(AB)\\
&\iff n-\mathrm{null}(B) = n-\mathrm{null}(AB)\\
&\iff \mathrm{rank}(B) = \mathrm{rank}(AB)
\end{align*}$$
with the last equivalence by the Rank-Nullity Theorem.

