Hartshorne Lemma II 8.9. I am trying to understand the proof of Hartshorne's Lemma II 8.9:

Let $A$ be a noetherian local integral domain, with residue field $k$
  and quotient field $K$. If $M$ is a finitely generated A-module and
  if $\dim_k M \otimes_A k = \dim_K M \otimes_A K = r$, then $M$ is free of rank $r$.

The proof goes: 

1- $\dim_k M \otimes_A k = r$ so Nakayama's lemma tells us that $M$ can be generated by $r$ elements.

I can see it's a consequence of Nakayama's lemma for local rings but I couldn't find a clear proof of this.

2- From the surjective map $\varphi : A^r \to M \to0$ and $R=\ker \varphi,  $ we get an exact sequence $0\to R\otimes K\to K^r\to M\otimes K\to 0$

How is that done?

3- Since $\dim_K M \otimes_A K = r$, we have $R \otimes K =0$

Why is that?

4- $R$ is torsion-free, so $R=0$

Why is $R$ is torsion-free and why it implies $R=0$
Thank you for your help!

*

*Consider the submodule $M_0$ generated by the lifting of a basis of $M\otimes_A k$ in $M$. Tensoring the exact sequence
$$0\longrightarrow M_0 \longrightarrow M \longrightarrow M/M_0 \longrightarrow 0$$ with $k$, you obtain that $\;M/M_0\otimes_Ak=0$, so Nakayama ensures that $M/M_0=0$.

*It results from tensoring the exact sequence $\;0 \longrightarrow R\longrightarrow A^r \longrightarrow M\longrightarrow 0$ with the flat $A$-module $K$.

*The map $ A^r\otimes_AK\simeq K^r \longrightarrow M\otimes_AK$becomes an isomorphism by hypothesis.

*$R$ is a submodule of the free $A$-module $A^r$ and $A$ is a domain, so free modules are  torsion-free.

