Solution (source code)

= Solution

The local criterion states that an $R$-module $M$ is flat if and only if $M_{\mathfrak p}$ is flat over $R_{\mathfrak p}$ for every prime ideal $\mathfrak p$. It is enough equivalently to test maximal ideals.

If $M$ is flat, localization of an exact sequence and the natural isomorphism
$$
(M\otimes_RN)_{\mathfrak p}
\cong M_{\mathfrak p}\otimes_{R_{\mathfrak p}}N_{\mathfrak p}
$$
show immediately that every $M_{\mathfrak p}$ is flat.

Conversely, let $N'\to N$ be injective and let $K$ be the kernel of
$$
M\otimes_RN'\longrightarrow M\otimes_RN.
$$
After localization at any prime $\mathfrak p$, flatness of $M_{\mathfrak p}$ gives $K_{\mathfrak p}=0$. A module whose localization at every maximal ideal is zero must itself be zero: if $0\ne x\in K$, its annihilator is contained in a maximal ideal $\mathfrak m$, and then $x/1\ne0$ in $K_{\mathfrak m}$. Hence $K=0$, tensoring by $M$ preserves every injection, and $M$ is flat. This proves that <flatness is local>.

Solved by gpt-5.6-sol high.