hcju/stacksqa huggingface dataset:
Observe that if $A$ is Nagata, then so is $B$ (Algebra, Lemma \ref{algebra-lemma-nagata-localize} and Proposition \ref{algebra-proposition-nagata-universally-japanese}). Thus the lemma follows on combining Proposition \ref{proposition-epp-essentially-finite-type} and Lemma \ref{lemma-separable-solution-separable-solution}.
Assume (1). Consider the module $N = \Hom_R(M, R)$ and the evaluation map $M \otimes_R N = M \otimes_R \Hom_R(M, R) \to R$. If $f \in R$ such that $M_f \cong R_f$, then the evaluation map becomes an isomorphism after localization at $f$ (details omitted). Thus we see the evaluation map is an isomorphism by Algebra, Lemma \ref{algebra-lemma-cover}. Thus (1) $\Rightarrow$ (3). \medskip\noindent Assume (3). Then the functor $K \mapsto K \otimes_R N$ is a quasi-inverse to the functor $K \mapsto K \otimes_R M$. Thus (3) $\Rightarrow$ (2). Conversely, if (2) holds, then $K \mapsto K \otimes_R M$ is essentially surjective and we see that (3) holds. \medskip\noindent Assume the equivalent conditions (2) and (3) hold. Denote $\psi : M \otimes_R N \to R$ the isomorphism from (3). Choose an element $\xi = \sum_{i = 1, \ldots, n} x_i \otimes y_i$ such that $\psi(\xi) = 1$. Consider the isomorphisms $$ M \to M \otimes_R M \otimes_R N \to M $$ where the first arrow sends $x$ to $\sum x_i \otimes x \otimes y_i$ and the second arrow sends $x \otimes x' \otimes y$ to $\psi(x' \otimes y)x$. We conclude that $x \mapsto \sum \psi(x \otimes y_i)x_i$ is an automorphism of $M$. This automorphism factors as $$ M \to R^{\oplus n} \to M $$ where the first arrow is given by $x \mapsto (\psi(x \otimes y_1), \ldots, \psi(x \otimes y_n))$ and the second arrow by $(a_1, \ldots, a_n) \mapsto \sum a_i x_i$. In this way we conclude that $M$ is a direct summand of a finite free $R$-module. This means that $M$ is finite locally free (Algebra, Lemma \ref{algebra-lemma-finite-projective}). Since the same is true for $N$ by symmetry and since $M \otimes_R N \cong R$, we see that $M$ and $N$ both have to have rank $1$.
Let $L$ be an invertible $R$-module. By Lemma \ref{lemma-invertible} we see that $L$ is a finite locally free $R$-module. In particular $L$ is torsion free and finite over $R$. Pick a nonzero element $\varphi \in \Hom_R(L, R)$ of the dual invertible module. Then $I = \varphi(L) \subset R$ is an ideal which is an invertible module. Pick a nonzero $f \in I$ and let $$ f = u p_1^{e_1} \ldots p_r^{e_r} $$ be the factorization into prime elements with $p_i$ pairwise distinct. Since $L$ is finite locally free there exist $a_i \in R$, $a_i \not \in (p_i)$ such that $I_{a_i} = (g_i)$ for some $g_i \in R_{a_i}$. Then $p_i$ is still a prime element of the UFD $R_{a_i}$ and we can write $g_i = p_i^{c_i} g'_i$ for some $g'_i \in R_{a_i}$ not divisible by $p_i$. Since $f \in I_{a_i}$ we see that $e_i \geq c_i$. We claim that $I$ is generated by $h = p_1^{c_1} \ldots p_r^{c_r}$ which finishes the proof. \medskip\noindent To prove the claim it suffices to show that $I_a$ is generated by $h$ for any $a \in R$ such that $I_a$ is a principal ideal (Algebra, Lemma \ref{algebra-lemma-cover}). Say $I_a = (g)$. Let $J \subset \{1, \ldots, r\}$ be the set of $i$ such that $p_i$ is a nonunit (and hence a prime element) in $R_a$. Because $f \in I_a = (g)$ we find the prime factorization $g = v \prod_{i \in J} p_j^{b_j}$ with $v$ a unit and $b_j \leq e_j$. For each $j \in J$ we have $I_{aa_j} = g R_{aa_j} = g_j R_{aa_j}$, in other words $g$ and $g_j$ map to associates in $R_{aa_j}$. By uniqueness of factorization this implies that $b_j = c_j$ and the proof is complete.
Let $K$ be a perfect object of $D(R)$. By definition we can represent $K$ by a finite complex $M^\bullet$ of finite projective $R$-modules. We define $c$ by setting $$ c(K) = \sum (-1)^n[M^n] $$ in $K_0(R)$. Of course we have to show that this is well defined, but once it is well defined, then (1) and (3) are immediate. For the moment we view the map $c$ as defined on complexes of finite projective $R$-modules. \medskip\noindent Suppose that $L^\bullet \to M^\bullet$ is a surjective map of finite complexes of finite projective $R$-modules. Let $K^\bullet$ be the kernel. Then we obtain short exact sequences of $R$-modules $$ 0 \to K^n \to L^n \to M^n \to 0 $$ which are split because $M^n$ is projective. Hence $K^\bullet$ is also a finite complex of finite projective $R$-modules and $c(L^\bullet) = c(K^\bullet) + c(M^\bullet)$ in $K_0(R)$. \medskip\noindent Suppose given finite complex $M^\bullet$ of finite projective $R$-modules which is acyclic. Say $M^n = 0$ for $n \not \in [a, b]$. Then we can break $M^\bullet$ into short exact sequences $$ \begin{matrix} 0 \to M^a \to M^{a + 1} \to N^{a + 1} \to 0, \\ 0 \to N^{a + 1} \to M^{a + 2} \to N^{a + 3} \to 0, \\ \ldots \\ 0 \to N^{b - 3} \to M^{b - 2} \to N^{b - 2} \to 0, \\ 0 \to N^{b - 2} \to M^{b - 1} \to M^b \to 0 \end{matrix} $$ Arguing by descending induction we see that $N^{b - 2}, \ldots, N^{a + 1}$ are finite projective $R$-modules, the sequences are split exact, and $$ c(M^\bullet) = \sum (-1)[M^n] = \sum (-1)^n([N^{n - 1}] + [N^n]) = 0 $$ Thus our construction gives zero on acyclic complexes. \medskip\noindent It follows formally from the results of the preceding two paragraphs that $c$ is well defined and satisfies (2). Namely, suppose the finite complexes $M^\bullet$ and $L^\bullet$ of finite projective $R$-modules represent the same object of $D(R)$. Then we can represent the isomorphism by a map $f : M^\bullet \to L^\bullet$ of complexes, see Derived Categories, Lemma \ref{derived-lemma-morphisms-from-projective-complex}. We obtain a short exact sequence of complexes $$ 0 \to L^\bullet \to C(f)^\bullet \to K^\bullet[1] \to 0 $$ see Derived Categories, Definition \ref{derived-definition-cone}. Since $f$ is a quasi-isomorphism, the cone $C(f)^\bullet$ is acyclic (this follows for example from the discussion in Derived Categories, Section \ref{derived-section-canonical-delta-functor}). Hence $$ 0 = c(C(f)^\bullet) = c(L^\bullet) + c(K^\bullet[1]) = c(L^\bullet) - c(K^\bullet) $$ as desired. We omit the proof of (2) which is similar.
It follows from the definition of $K_0(D_{perf}(R))$ (Derived Categories, Definition \ref{derived-definition-K-zero}) that $c$ induces a homomorphism $K_0(D_{perf}(R)) \to K_0(R)$. \medskip\noindent Given a finite projective module $M$ over $R$ let us denote $M[0]$ the perfect complex over $R$ which has $M$ sitting in degree $0$ and zero in other degrees. Given a short exact sequence $0 \to M \to M' \to M'' \to 0$ of finite projective modules we obtain a distinguished triangle $M[0] \to M'[0] \to M''[0] \to M[1]$, see Derived Categories, Section \ref{derived-section-canonical-delta-functor}. This shows that we obtain a map $K_0(R) \to K_0(D_{perf}(R))$ by sending $[M]$ to $[M[0]]$ with apologies for the horrendous notation. \medskip\noindent It is clear that $K_0(R) \to K_0(D_{perf}(R)) \to K_0(R)$ is the identity. On the other hand, if $M^\bullet$ is a bounded complex of finite projective $R$-modules, then the the existence of the distinguished triangles of ``stupid truncations'' (see Homology, Section \ref{homology-section-truncations}) $$ \sigma_{\geq n}M^\bullet \to \sigma_{\geq n - 1}M^\bullet \to M^{n - 1}[-n + 1] \to (\sigma_{\geq n}M^\bullet)[1] $$ and induction show that $$ [M^\bullet] = \sum (-1)^i[M^i[0]] $$ in $K_0(D_{perf}(R))$ (with again apologies for the notation). Hence the map $K_0(R) \to K_0(D_{perf}(R))$ is surjective which finishes the proof.
Let $L$ be an invertible $R_f$-module. In particular $L$ is a finite $R_f$-module. There exists a finite $R$-module $M$ such that $M_f \cong L$, see Algebra, Lemma \ref{algebra-lemma-construct-fp-module}. By Algebra, Proposition \ref{algebra-proposition-regular-finite-gl-dim} we see that $M$ has a finite free resolution $F_\bullet$ over $R$. It follows that $L$ is quasi-isomorphic to a finite complex of {\it free} $R_f$-modules. Hence by Lemma \ref{lemma-perfect-to-K-group} we see that $[L] = n[R_f]$ in $K_0(R)$ for some $n \in \mathbf{Z}$. Applying the map of Lemma \ref{lemma-det} we see that $L$ is trivial.
Recall that a regular local ring is a domain, see Algebra, Lemma \ref{algebra-lemma-regular-domain}. We will prove the unique factorization property by induction on the dimension of the regular local ring $R$. If $\dim(R) = 0$, then $R$ is a field and in particular a UFD. Assume $\dim(R) > 0$. Let $x \in \mathfrak m$, $x \not \in \mathfrak m^2$. Then $R/(x)$ is regular by Algebra, Lemma \ref{algebra-lemma-regular-ring-CM}, hence a domain by Algebra, Lemma \ref{algebra-lemma-regular-domain}, hence $x$ is a prime element. Let $\mathfrak p \subset R$ be a height $1$ prime. We have to show that $\mathfrak p$ is principal, see Algebra, Lemma \ref{algebra-lemma-characterize-UFD-height-1}. We may assume $x \not \in \mathfrak p$, since if $x \in \mathfrak p$, then $\mathfrak p = (x)$ and we are done. For every nonmaximal prime $\mathfrak q \subset R$ the local ring $R_\mathfrak q$ is a regular local ring, see Algebra, Lemma \ref{algebra-lemma-localization-of-regular-local-is-regular}. By induction we see that $\mathfrak pR_\mathfrak q$ is principal. In particular, the $R_x$-module $\mathfrak p_x = \mathfrak pR_x \subset R_x$ is a finitely presented $R_x$-module whose localization at any prime is free of rank $1$.  By Algebra, Lemma \ref{algebra-lemma-finite-projective} we see that $\mathfrak p_x$ is an invertible $R_x$-module. By Lemma \ref{lemma-regular-local-Pic-zero} we see that $\mathfrak p_x = (y)$ for some $y \in R_x$. We can write $y = x^e f$ for some $f \in \mathfrak p$ and $e \in \mathbf{Z}$. Factor $f = a_1 \ldots a_r$ into irreducible elements of $R$ (Algebra, Lemma \ref{algebra-lemma-factorization-exists}). Since $\mathfrak p$ is prime, we see that $a_i \in \mathfrak p$ for some $i$. Since $\mathfrak p_x = (y)$ is prime and $a_i | y$ in $R_x$, it follows that $\mathfrak p_x$ is generated by $a_i$ in $R_x$, i.e., the image of $a_i$ in $R_x$ is prime. As $x$ is a prime element, we find that $a_i$ is prime in $R$ by Algebra, Lemma \ref{algebra-lemma-invert-prime-elements}. Since $(a_i) \subset \mathfrak p$ and $\mathfrak p$ has height $1$ we conclude that $(a_i) = \mathfrak p$ as desired.
Let $L$ be an invertible $A \otimes_R K$-module. In particular $L$ is a finite module. There exists a finite $A$-module $M$ such that $M \otimes_R K \cong L$, see Algebra, Lemma \ref{algebra-lemma-construct-fp-module}. We may assume $M$ is torsion free as an $R$-module. Thus $M$ is flat as an $R$-module (Lemma \ref{lemma-valuation-ring-torsion-free-flat}). From Lemma \ref{lemma-flat-finite-type-valuation-ring-finite-presentation} we deduce that $M$ is of finite presentation as an $A$-module and $A$ is essentially of finite presentation as an $R$-algebra. By Lemma \ref{lemma-structure-relatively-perfect} we see that $M$ is perfect relative to $R$, in particular $M$ is pseudo-coherent as an $A$-module. By Lemma \ref{lemma-perfect-over-regular-local-ring} we see that $M$ is perfect, hence $M$ has a finite free resolution $F_\bullet$ over $A$. It follows that $L$ is quasi-isomorphic to a finite complex of {\it free} $A \otimes_R K$-modules. Hence by Lemma \ref{lemma-perfect-to-K-group} we see that $[L] = n[A \otimes_R K]$ in $K_0(A \otimes_R K)$ for some $n \in \mathbf{Z}$. Applying the map of Lemma \ref{lemma-det} we see that $L$ is trivial.
Write $M^i = \Ker(a^i)$. Thus we have a map of short exact sequences $$ \xymatrix{ 0 \ar[r] & M^{-1} \ar[r] \ar[d]_{d_M} & K^{-1} \ar[r] \ar[d]_{d_K} & L^{-1} \ar[r] \ar[d]_{d_L} & 0 \\ 0 \ar[r] & M^0 \ar[r] & K^0 \ar[r] & L^0 \ar[r] & 0 } $$ By Lemma \ref{lemma-det-ses-functorial} we know that $\det(d_K)$ corresponds to $\det(d_M) \otimes \det(d_L)$ as maps. Unwinding the definitions this gives the required equality.
The local rings of $A$ and $B$ at height $1$ primes are discrete valuation rings (Algebra, Lemma \ref{algebra-lemma-characterize-dvr}). Thus the assumption makes sense (via Definition \ref{definition-extension-discrete-valuation-rings}). Let $\mathfrak p_1, \ldots, \mathfrak p_r$ be the primes of $A$ minimal over $f$. These have height $1$ by Algebra, Lemma \ref{algebra-lemma-minimal-over-1}. For each $i$ let $\mathfrak q_{i, j} \subset B$, $j = 1, \ldots, r_i$ be the height $1$ primes of $B$ lying over $\mathfrak p_i$. Say we number them so that  $A_{\mathfrak p_i} \to B_{\mathfrak q_{i, 1}}$ is weakly unramified. Since $f$ maps to an $n$th power times a unit in $B_{\mathfrak q_{i, 1}}$ we see that the valuation $v_i$ of $f$ in $A_{\mathfrak p_i}$ is divisible by $n$. Consider the exact sequence $$ 0 \to I \to A \to \prod\nolimits_{i = 1, \ldots, r} A_{\mathfrak p_i}/\mathfrak p_i^{v_i/n}A_{\mathfrak p_i} $$ Applying the exact functor $- \otimes_A B$ we obtain $$ 0 \to I \otimes_A B \to B \to \prod\nolimits_{i = 1, \ldots, r} \prod\nolimits_{j = 1, \ldots, r_i} B_{\mathfrak q_{i, j}}/\mathfrak q_{i, j}^{e_{i, j}v_i/n}A_{\mathfrak p_i} $$ where $e_{i, j}$ is the ramification index of  $A_{\mathfrak p_i} \to B_{\mathfrak q_{i, j}}$. It follows that $I \otimes_A B$ is the set of elements $h'$ of $B$ which have valuation $\geq e_{i, j}v_i/n$ at $\mathfrak q_{i, j}$. Since $f = wh^n$ in $B$ we see that $h$ has valuation $e_{i, j}v_i/n$ at $\mathfrak q_{i, j}$. Thus $h'/h \in B$ by Algebra, Lemma \ref{algebra-lemma-normal-domain-intersection-localizations-height-1}. It follows that $I \otimes_A B$ is a free $B$-module of rank $1$. Therefore $I$ is a free $A$-module of rank $1$, see Algebra, Lemma \ref{algebra-lemma-finite-projective-descends}. Let $g \in I$ be a generator. Then we see that $g$ and $h$ differ by a unit in $B$. Working backwards we conclude that the valuation of $g$ in $A_{\mathfrak p_i}$ is $v_i/n$. Hence $g^n$ and $f$ differ by a unit in $A$ (by Algebra, Lemma \ref{algebra-lemma-normal-domain-intersection-localizations-height-1}) as desired.
The ring $A$ has weak dimension $\leq 1$ by Lemma \ref{lemma-weak-dimension-at-most-1}. Then $B$ has weak dimension $\leq 1$ by Lemmas \ref{lemma-weak-dimension-goes-up} and \ref{lemma-when-weakly-etale}. hence the local ring $B_\mathfrak m$ is a valuation ring by Lemma \ref{lemma-weak-dimension-at-most-1}. Since the extension $A \subset B_\mathfrak m$ induces a finite extension of fraction fields, we see that the $\Gamma_A$ has finite index in the value group of $B_{\mathfrak m}$. Thus for every $h \in B_\mathfrak m$ there exists an $n > 0$, an element $f \in A$, and a unit $w \in B_\mathfrak m$ such that $f = w h^n$ in $B_\mathfrak m$. We will show that this implies $f = ug^n$ for some $g \in A$ and unit $u \in A$; this will show that the value groups of $A$ and $B_\mathfrak m$ agree, as claimed in the lemma. \medskip\noindent Write $A = \colim A_i$ as the colimit of its local subrings which are essentially of finite type over $\mathbf{Z}$. Since $A$ is a normal domain (Algebra, Lemma \ref{algebra-lemma-valuation-ring-normal}), we may assume that each $A_i$ is normal (here we use that taking normalizations the local rings remain essentially of finite type over $\mathbf{Z}$ by Algebra, Proposition \ref{algebra-proposition-ubiquity-nagata}). For some $i$ we can find an \'etale extension $A_i \to B_i$ such that $B = A \otimes_{A_i} B_i$, see Algebra, Lemma \ref{algebra-lemma-etale}. Let $\mathfrak m_i$ be the intersection of $B_i$ with $\mathfrak m$. Then we may apply Lemma \ref{lemma-extension-normal-domains-and-roots} to the ring map $A_i \to (B_i)_{\mathfrak m_i}$ to conclude. The hypotheses of the lemma are satisfied because: \begin{enumerate} \item $A_i$ and $(B_i)_{\mathfrak m_i}$ are Noetherian as they are essentially of finite type over $\mathbf{Z}$, \item $A_i \to (B_i)_{\mathfrak m_i}$ is flat as $A_i \to B_i$ is \'etale, \item $B_i$ is normal as $A_i \to B_i$ is \'etale, see Algebra, Lemma \ref{algebra-lemma-normal-goes-up}, \item for every height $1$ prime of $A_i$ there exists a height $1$ prime of $(B_i)_{\mathfrak m_i}$ lying over it by Algebra, Lemma \ref{algebra-lemma-finite-in-codim-1} and the fact that $\Spec((B_i)_{\mathfrak m_i}) \to \Spec(A_i)$ is surjective, \item the induced extensions $(A_i)_\mathfrak p \to (B_i)_\mathfrak q$ are unramified for every prime $\mathfrak q$ lying over a prime $\mathfrak p$ as $A_i \to B_i$ is \'etale. \end{enumerate} This concludes the proof of the lemma.
Write $A^h = \colim (B_i)_{\mathfrak q_i}$ where $A \to B_i$ is \'etale and $\mathfrak q_i \subset B_i$ is a prime ideal lying over $\mathfrak m_A$, see Algebra, Lemma \ref{algebra-lemma-henselization-different}. Then Lemma \ref{lemma-etale-extension-valuation-ring} tells us that $(B_i)_{\mathfrak q_i}$ is a valuation ring and that the induced map $$ (A \setminus \{0\})/A^* \longrightarrow ((B_i)_{\mathfrak q_i} \setminus \{0\}) / (B_i)_{\mathfrak q_i}^* $$ is bijective. By Algebra, Lemma \ref{algebra-lemma-colimit-valuation-rings} we conclude that $A^h$ is a valuation ring. It also follows that $(A \setminus \{0\})/A^* \to (A^h \setminus \{0\})/(A^h)^*$ is bijective. This proves the lemma for the inclusion $A \subset A^h$. To prove it for $A \subset A^{sh}$ we can use exactly the same argument except we replace Algebra, Lemma \ref{algebra-lemma-henselization-different} by Algebra, Lemma \ref{algebra-lemma-strict-henselization-different}. Since $A^{sh} = (A^h)^{sh}$ we see that this also proves the assertions of the lemma for the inclusion $A^h \subset A^{sh}$.
Assume (2) and let $a, b \in R$. Then $(a, b) = (c)$. If $c = 0$, then $a = b = 0$ and $a$ divides $b$. Assume $c \not = 0$. Write $c = ua + vb$ and $a = wc$ and $b = zc$. Then $c(1 - uw - vz) = 0$. Since $R$ is local, this implies that $1 - uw - vz \in \mathfrak m$. Hence either $w$ or $z$ is a unit, so either $a$ divides $b$ or $b$ divides $a$. Thus (2) implies (1). \medskip\noindent Assume (1). If $R$ has two maximal ideals $\mathfrak m_i$ we can choose $a \in \mathfrak m_1$ with $a \not \in \mathfrak m_2$ and $b \in \mathfrak m_2$ with $b \not \in \mathfrak m_1$. Then $a$ does not divide $b$ and $b$ does not divide $a$. Hence $R$ has a unique maximal ideal and is local. It follows easily from condition (1) and induction that every finitely generated ideal is principal. Thus (1) implies (2). \medskip\noindent It is straightforward to prove that (1) and (3) are equivalent. The final statement is Algebra, Lemma \ref{algebra-lemma-valuation-ring-x-or-x-inverse}.
Let $M$ be a finitely presented $R$-module. We will use all the equivalent properties of $R$ from Lemma \ref{lemma-generalized-valuation-ring} without further mention. Denote $\mathfrak m \subset R$ the maximal ideal and $\kappa = R/\mathfrak m$ the residue field. Let $I \subset R$ be the annihilator of $M$. Choose a basis $y_1, \ldots, y_n$ of the finite dimensional $\kappa$-vector space $M/\mathfrak m M$. We will argue by induction on $n$. \medskip\noindent By Nakayama's lemma any collection of elements $x_1, \ldots, x_n \in M$ lifting the elements $y_1, \ldots, y_n$ in $M/\mathfrak m M$ generate $M$, see Algebra, Lemma \ref{algebra-lemma-NAK}. This immediately proves the base case $n = 0$ of the induction. \medskip\noindent We claim there exists an index $i$ such that for any choice of $x_i \in M$ mapping to $y_i$ the annihilator of $x_i$ is $I$. Namely, if not, then we can choose $x_1, \ldots, x_n$ such that $I_i = \text{Ann}(x_i) \not = I$ for all $i$. But as $I \subset I_i$ for all $i$, ideals being totally ordered implies $I_i$ is strictly bigger than $I$ for $i = 1, \ldots, n$, and by total ordering once more we would see that $\text{Ann}(M) = I_1 \cap \ldots \cap I_n$ is bigger than $I$ which is a contradiction. After renumbering we may assume that $y_1$ has the property: for any $x_1 \in M$ lifting $y_1$ the annihilator of $x_1$ is $I$. \medskip\noindent We set $A = Rx_1 \subset M$. Consider the exact sequence $0 \to A \to M \to M/A \to 0$. Since $A$ is finite, we see that $M/A$ is a finitely presented $R$-module (Algebra, Lemma \ref{algebra-lemma-extension}) with fewer generators. Hence $M/A \cong \bigoplus_{j = 1, \ldots, m} R/f_jR$ by induction. On the other hand, we claim that $A \to M$ satisfies the property: if $f \in R$, then $fA = A \cap fM$. The inclusion $fA \subset A \cap fM$ is trivial. Conversely, if $x \in A \cap fM$, then $x = gx_1 = f y$ for some $g \in R$ and $y \in M$. If $f$ divides $g$, then $x \in fA$ as desired. If not, then we can write $f = hg$ for some $h \in \mathfrak m$. The element $x'_1 = x_1 - hy$ has annihilator $I$ by the previous paragraph. Thus $g \in I$ and we see that $x = 0$ as desired. The claim and Lemma \ref{lemma-characterize-PD-modules} imply the sequence $0 \to A \to M \to M/A \to 0$ is split and we find $M \cong A \oplus \bigoplus_{j = 1, \ldots, m} R/f_jR$. Then $A = R/I$ is finitely presented (as a summand of $M$) and hence $I$ is finitely generated, hence principal. This finishes the proof.
Let $M$ be a finitely presented $R$-module. We first show that $M$ is a summand of a direct sum of modules of the form $R/fR$ and at the end we argue the direct sum can be taken to be finite. Let $$ 0 \to A \to B \to C \to 0 $$ be a short exact sequence of $R$-modules such that $fA = A \cap fB$ for all $f \in R$. By Lemma \ref{lemma-characterize-PD-modules} we have to show that $\Hom_R(M, B) \to \Hom_R(M, C)$ is surjective. It suffices to prove this after localization at maximal ideals $\mathfrak m$, see Algebra, Lemma \ref{algebra-lemma-characterize-zero-local}. Note that the localized sequences $0 \to A_\mathfrak m \to B_\mathfrak m \to C_\mathfrak m \to 0$ satisfy the condition that $fA_\mathfrak m = A_\mathfrak m \cap fB_\mathfrak m$ for all $f \in R_\mathfrak m$ (because we can write $f = uf'$ with $u \in R_\mathfrak m$ a unit and $f' \in R$ and because localization is exact). Since $M$ is finitely presented, we see that $$ \Hom_R(M, B)_\mathfrak m = \Hom_{R_\mathfrak m}(M_\mathfrak m, B_\mathfrak m) \quad\text{and}\quad \Hom_R(M, C)_\mathfrak m = \Hom_{R_\mathfrak m}(M_\mathfrak m, C_\mathfrak m) $$ by Algebra, Lemma \ref{algebra-lemma-hom-from-finitely-presented}. The module $M_\mathfrak m$ is a finitely presented $R_\mathfrak m$-module. By Lemma \ref{lemma-generalized-valuation-ring-modules} we see that $M_\mathfrak m$ is a direct sum of modules of the form $R_\mathfrak m/fR_\mathfrak m$. Thus we conclude by Lemma \ref{lemma-characterize-PD-modules} that the map on localizations is surjective. \medskip\noindent At this point we know that $M$ is a summand of $\bigoplus_{i \in I} R/f_i R$. Consider the map $M \to \bigoplus_{i \in I} R/f_i R$. Since $M$ is a finite $R$-module, the image is contained in $\bigoplus_{i \in I'} R/f_i R$ for some finite subset $I' \subset I$. This finishes the proof.
Proof of (1). Let $M \subset F$ be a finite submodule of a free module $F$. Since $M$ is finite, we may assume $F$ is a finite free module (details omitted). Say $F = R^{\oplus n}$. We argue by induction on $n$. If $n = 1$, then $M$ is a finitely generated ideal, hence principal by our assumption that $R$ is B\'ezout. If $n > 1$, then we consider the image $I$ of $M$ under the projection $R^{\oplus n} \to R$ onto the last summand. If $I = (0)$, then $M \subset R^{\oplus n - 1}$ and we are done by induction. If $I \not = 0$, then $I = (f) \cong R$. Hence $M \cong R \oplus \Ker(M \to I)$ and we are done by induction as well. \medskip\noindent Let $M$ be a finitely presented $R$-module. Since the localizations of $R$ are maximal ideals are valuation rings (Lemma \ref{lemma-localize-bezout}) we may apply Lemma \ref{lemma-warfield}. Thus $M$ is a summand of a module of the form $R^{\oplus r} \oplus \bigoplus_{i = 1, \ldots, n} R/f_iR$ with $f_i \not = 0$. Since taking the torsion submodule is a functor we see that $M_{tors}$ is a summand of the module $\bigoplus_{i = 1, \ldots, n} R/f_iR$ and $M/M_{tors}$ is a summand of $R^{\oplus r}$. By the first part of the proof we see that $M/M_{tors}$ is finite free. Hence $M \cong M_{tors} \oplus M/M_{tors}$ as desired.