I'm trying to prove that rank is invariant under similarity. My approach is as follows: suppose I have some matrix $B=P^{-1} AP$. I can simplify this to $PB = AP$. Using the identity
$$rank(AB) \le \min(rank(A), rank(B))$$
we conclude the two following properties:
$$rank(AP) \le \min(rank(A), q)$$
and
$$rank(PB) \le \min(rank(B), q)$$
$AP$ and $PB$ are equivalent, thus we have
$$rank(AP) = rank(PB) \le \min(rank(A),rank(B), q)$$
and we conclude that $rank(A) = rank(B)$.
Is this correct? If not, why? How do we prove that rank is invariant under similarity?