This is essentially an exercise in Sze-Tsen Hu's "Introduction to Homological Algebra", page 143.
Let $R$ be a PID and consider two $R$-modules $X$ and $Y$. Let $S$ denote the subset of the Cartesian product $$W=X\times Y\times Z$$ consisting of all elements $(x,y,r)\in W$ such that $rx=0$ in $X$ and $ry=0$ in $Y$. Let $F(S)$ denote the free $R$ module generated by the set $S$ and let $M$ denote the smallest submodule of $F(S)$ containing all elements of the forms:$$(x+x',y,r)-(x,y,r)-(x',y,r),$$ $$(x,y+y'r)-(x,y,r)-(x,y',r),$$ $$(x,y,sr)-s.(x,y,r),$$ $$(x,y,sr)-s.(x,y,r),$$ whenever every triple in parenthesis is an element in $S$. Prove$$\text{Tor}(X,Y)\simeq F(S)/M$$ Then deduce that $\text{Tor}(X,Y)=0$ if $X$ or $Y$ is torsion free.
My attempt: Consider the short exact sequence $$0\rightarrow \text{ker}\phi \rightarrow F(X) \rightarrow X\rightarrow 0$$ where $F(X)\rightarrow X$ is given by $\phi$, the linear map from $F(X)$ to $X$ sending $x$ to $x$, and $\text{ker}\phi \rightarrow F(X)$ is given by inclusion, say $\iota$. Note that $\text{ker}\phi$ is also free since we are working with modules over a PID. Taking tensor products with $Y$ gives $$0\rightarrow \text{ker}\phi\otimes Y \rightarrow F(X)\otimes Y \rightarrow X\otimes Y\rightarrow 0$$ and we only need to compute $\text{ker}(\iota \otimes \text{id})$, so assume that $\sum m_j \otimes y_j \in \text{ker}(\iota \otimes \text{id})$ where $j \in J$ for some finite index set $J$ and $m_j \in \text{ker}(\phi), y_j \in Y$ for each $j$.
Since $m_j \in \text{ker}(\phi)$, when written in the form $m_j=\sum r_{ij} .x_i$ (here, $I$ is also some finite index set which does not depend on $j$, and the dot indicates that the scalar multiplication if formal) we must have $0=\sum r_{ij} x_i$, in $X$, for each $i$.
Now the fact that $\sum m_j \otimes y_j \in \text{ker}(\iota \otimes \text{id})$ is equivalnet to $$0=\sum _{j \in J} \left( \sum _{i \in I} r_{ij}.x_i \otimes y_j \right)=\sum _{i \in I} \left( \sum _{j \in J} (r_{ij}.x_i) \otimes y_j \right)=\sum _{i \in I} \left( x_i \otimes \sum _{j \in J} r_{ij}y_j \right)$$ in $F(X) \otimes Y$, but considering the canonical isomorphisms $$F(X) \otimes Y \simeq \left( \bigoplus_{x \in X} R.x \right) \otimes Y \simeq \bigoplus_{x \in X} (R.x \otimes Y) \simeq \bigoplus _{x \in X} Y ,$$ shows that this happens iff $$0=\sum _{j \in J} r_{ij}y_j$$ for each $i \in I$, so considering the case when $\vert I \vert=\vert J \vert=1$ shows that $\text{ker}(\iota \otimes \text{id})$ contains elements in $F(X)$ of the form $(r.x \otimes y)$ for every $(x,y,r) \in S$, and this correspondence from $S$ to $\text{ker}(\iota \otimes \text{id})$ gives a linear map from $F(S)$ to $\text{ker}(\iota \otimes \text{id})$, whose kernel clearly contains $M$, so we actually have a linear map from $F(X)/M$ to $\text{ker}(\iota \otimes \text{id})$, say $\psi$.
Now the only obstacle left is to show that $\psi$ is an isomorphism, and this is the part I'm stuck. I'm sure that this is the right way to solve this problem, but I can't make any more progress showing that $\psi$ is an isomorphism. I tried to show that $\psi$ is both injective and surjective, but failed. I tried to construct the inverse of $\psi$, but failed. The major problem was showing the surjectivity of $\psi$. Once the surjectivity have been established, the inverse of $\psi$ can be constructed... hopefully.
Any advice on proving this point would be a great help :D. Any other approaches on this exercise are also welcome.
PS1. Originally the exercise asks for the case $R=\mathbb{Z}$, but the next exercise asks for a generalization of this to PIDs, so in overall it's the same.
PS2. Can this result be used to prove the fact that for modules over a PID, "torsion-free" imples "flat"? So that two concepts "finitely generated and flat" and "free of finite rank" are equivalent?