Null spaces and invertible matrix 
If $A$ and $B$ are $n×n$ matrices, show that they have the same null
  space if and only if $A = UB$ for some invertible matrix $U$.

I started the question by saying $Ax = 0$ for some vector $x$ in $\text {null}(A)$. Now I'm lost.
Could someone please help me out with this question? Thank you very much. 
 A: First, note that $A=UB$ for an invertible $U$ means that $A$ and $B$ are row equivalent. This means that $A$ can be obtained from $B$ with elementary row operations.
Next, recall that the orthogonal complement of the null space $\operatorname{Null}(M)$ of any matrix $M$ is the row space $\operatorname{Row}(M)$. Succinctly, this relation is written as $\operatorname{Row}(M)=\operatorname{Null}(M)^\perp$.
Now, in our situation, we have two same-sized matrices $A$ and $B$ satisfying $\operatorname{Null}(A)=\operatorname{Null}(B)$. Taking orthogonal complements gives $\operatorname{Null}(A)^\perp=\operatorname{Null}(B)^\perp$ which reduces to $\operatorname{Row}(A)=\operatorname{Row}(B)$.
Finally, the equation $\operatorname{Row}(A)=\operatorname{Row}(B)$ tells us that $\operatorname{rref}(A)=\operatorname{rref}(B)$. This means that there are elementary matrices $\{E_1,\dotsc,E_r\}$ and $\{F_1,\dotsc,F_s\}$ satisfying the equations 
$$
E_r\dotsb E_1A = F_s\dotsb F_1 B = \operatorname{rref}(A)
$$
Inverting each elementary matrix $E_i$ and solving for $A$ gives
$$
A=E_1^{-1}\dotsb E_r^{-1}F_s\dotsb F_1B
$$
Putting $U=E_1^{-1}\dotsb E_r^{-1}F_s\dotsb F_1$ gives our desired equation $A=UB$.
A: I will give a proof not based on properties of matrix reduction (such as that every matrix has a unique row reduced echelon form) as I consider these rather hard to prove formally. I will however assume known that every family of linearly independent vectors can be extended to a basis of the whole space. Also given any basis $[b_1,\ldots,b_n]$ of $F^n$ (where $F$ is the field of scalars one is working with), and any family $[w_1,\ldots,w_n]$ of vectors, there is a linear map that sends each $b_i$ to $w_i$, namely the one sending an arbitrary vector written as $\lambda_1b_1+\cdots+\lambda_nb_n$ to $\lambda_1w_1+\cdots+\lambda_nw_n$.
Take a basis $[v_1,\ldots,v_k]$ of $\def\null{\operatorname{null}}\null(A)$ and extend it to a basis $[v_1,\ldots,v_n]$ of $F^n$. Then the vectors $Av_{k+1},\ldots,Av_n$ are linearly independent, since a relation $0=\lambda_{k+1}Av_{k+1}+\cdots+\lambda_nAv_n$ implies via $A(\lambda_{k+1}v_{k+1}+\cdots+\lambda_nv_n)=0$ that $\lambda_{k+1}v_{k+1}+\cdots+\lambda_nv_n\in\null(A)=\operatorname{span}(v_1,\ldots,v_k)$, which forces $\lambda_{k+1}=\cdots=\lambda_n=0$ since $[v_1,\ldots,v_n]$ is a basis. Similarly $Bv_{k+1},\ldots,Bv_n$ are linearly independent, since $\null(B)=\null(A)$. Now extend each of these linearly independent families to a basis of $F^n$, calling them respectively $\def\B{\mathcal B}\B_A$ and $\B_B$. Now let $f:F^n\to F^n$ be a linear map sending each vector of the basis $\B_B$ to the corresponding vector of the basis $\B_A$, and let $U$ be the matrix of$~f$ (with respect to the standard basis). We have in particular $(UB)v_i=U(Bv_i)=f(Bv_i)=Av_i$ for $i=k+1,\ldots,n$. But one also has $(UB)v_i=U(Bv_i)=Av_i$ for $i=1,\ldots,k$ since both side are zero. Then matrices $UB$ and $A$, giving the same results when applied to all vectors of the basis $[v_1,\ldots,v_n]$, must be equal matrices.
It remains to show that the matrix $U$ is invertible; this is so because the map $f$ is, its inverse being the linear map that sends each vector of the basis $\B_A$ to the corresponding vector of the basis $\B_B$.
The opposite implication is clear, since $UBx=0\iff Bx=U^{-1}UBx=0$. 
