Maximal linearly independent subsets in module over a domain has the same number of elements. 
Let $M$ be an $R$-module and $R$ be an integral domain. Then I want to know if any two maximal linearly independent sets have the same number of elements or not.

Actually I am reading Modules over PID from Dummit and Foote, where they define rank of an $R$-module to be the maximum number of linearly independent elements in $M.$ Is it well defined ?
 A: As explained (a bit differently) here and here, the trick is to show that a maximal $R-$linearly independent subset $\{m_i\}_{i \in I}$ of $M$ gives a $K-$basis $\{\frac{m_i}{1}\}_{i \in I}$ of $M_{(0)} = (R \backslash\{0\})^{-1}M$, the localization of $M$ away from $(0)$, which is a $K-$vector space. Then the result follows from the fact that the cardinality of a basis of a vector space does not depend on the choice of the basis.
First of all, notice that there is always a (possibly infinite) maximal $R-$linearly independent subset of $M$, by Zorn's lemma. Let $\{m_i\}_{i \in I}$ be such a set. Then $\{\frac{m_i}{1}\}_{i \in I}$ is linearly independent in $M_{(0)}$, because if it were not, we'd get an equation of linear dependence, and by clearing denominators and multiplying by a non-zero element of $R$, this would give an equation of linear dependence of the $m_i$ over $R$, contradiction. On the other hand, if $\{\frac{m_i}{1}\}_{i \in I}$ is not maximal, we can add some other fraction, say $\frac{m}{s}$, so that they stay linearly independent. But considering the element $m \in M$ together with the $m_i$, we get an equation of linear dependence, and (multiplying by $s$ the coefficient of $m$) the same coefficients give an equation of linear dependence of the $\{\frac{m_i}{1}\}_{i \in I}$ and $\frac{m}{s}$, contradiction. Hence $\{\frac{m_i}{1}\}_{i \in I}$ is a basis of $M_{(0)}$, as desired.
The key fact, in some sense, is that $\frac{m}{1}$ is zero if and only if $m$ is torsion, and that torsion elements are never part of a linearly independent set.
