1. Assume that there are the invertible matrices X,Y,Z∈Mn(R) such that AX+YB=AZB. Then rank(A)=rank(AX)=rank((AZ−Y)B)≤rank(B). Similarly, rank(B)≤rank(A). Therefore, rank(A)=rank(B).
2. Assume rank(A)=rank(B)=r. Then there are the invertible matrices T,U,V,W∈Mn(R) such that
TAU=(IrOn−r,rOr,n−rOn−r)=VBW.
Thus A(UW−1)=(T−1V)B. We can choose λ∈R such that det(B−λ(UW−1))=0 and det(A+λ(T−1V))=0. Define the invertible matrices X=B−λ(UW−1) and Y=A+λ(T−1V). We obtain
AX+YB=2AB−λA(UW−1)+λ(T−1V)B=AZB,
where Z=2In.