Exactness of sequences of modules is a local property, isn't it?

It’s well known, that passing to modules of fractions is exact, i.e. if $M'\xrightarrow{f} M\xrightarrow{g} M''$ is an exact sequence of $A$-modules ($A$ being a commutative ring with unity), then for every multiplicative subset $S\subset A$, the induced sequence $S^{-1}M'\to S^{-1}M\to S^{-1}M''$ is exact.

But none of the books on commutative algebra I know treats whether for $M'\to M\to M''$ to be exact it suffices that $M'_\mathfrak{p}\to M_\mathfrak{p} \to M''_\mathfrak{p}$ is exact for each prime ideal $\mathfrak{p}\subset A$. So I was looking for a proof, even if I didn’t expected it to be true (at least without some finiteness assumptions), and surprisingly it seems to work. But it’s too easy to be right, though I can’t find the error — so where am I mistaken? These are my thought:

Let $M'_\mathfrak{p}\to M_\mathfrak{p} \to M''_\mathfrak{p}$ be exact for each prime ideal $\mathfrak{p}\subset A$ (one could take maximal ideals as well). Then (only for the case this wasn’t assumed anyway) we have $\operatorname{im}(f)\subset \ker(g)$, since for each prime $\mathfrak{p}\subset A$ we have $0=g_\mathfrak{p}\circ f_\mathfrak{p}(x) = (g\circ f)_\mathfrak{p}(x) = g\circ f (x)$ in $M''_\mathfrak{p}$ for all $x\in M'$, hence there exists $s\in A\setminus\mathfrak{p}$ such that $s\; (g\circ f(x))=0$. But with a standard argument (take $\mathfrak{p}\supset\operatorname{ann}(g\circ f(x))$ to produce a contradiction to the contrary) we get $g\circ f(x) = 0$ and $\operatorname{im}(f)\subset \ker(g)$.

Now we know, that the inclusion map $i\colon\operatorname{im}(f)\hookrightarrow \ker(g)$ is defined. But for each prime $\mathfrak{p}\subset A$ we assumed $i_\mathfrak{p}\colon \operatorname{im}(f_\mathfrak{p})\to\ker(g_\mathfrak{p})$ to be bijective and this is a local property, so $i\colon\operatorname{im}(f)\to \ker(g)$ is too and finally $\operatorname{im}(f)=\ker(g)$. Of cause this requires that localization commutes with $\ker$ and $\operatorname{im}$, but I’m sure this is true.

I’m getting more and more convinced it’s right the more often I look at it but still, something bothers me. Any Suggestions or even counter examples?

Solutions Collecting From Web of "Exactness of sequences of modules is a local property, isn't it?"

Yes, exactness is indeed local, and localisation commutes with $\ker$ and $\operatorname{im}$ (since localisation is exact). In fact, exactness is so local that you just need to check it at the maximal ideals. Here is a sketch:

  1. $M = 0$ if and only if $M_\mathfrak{m} = 0$ for all maximal ideals $\mathfrak{m}$.

  2. A homomorphism $M \to N$ is a monomorphism/epimorphism/isomorphism if and only if $M_\mathfrak{m} \to N_\mathfrak{m}$ is a monomorphism/epimorphism/isomorphism for all maximal ideals $\mathfrak{m}$. [Use (1).]

  3. Suppose we have a sequence of modules and homomorphisms:
    $$0 \longrightarrow M'' \longrightarrow M \longrightarrow M' \longrightarrow 0$$
    Suppose also that this sequence is exact after localising at $\mathfrak{m}$, for all maximal ideals $\mathfrak{m}$. Then, by (1), the sequence is a chain complex, and by (2), the sequence is exact at $M''$ and $M'$. Since we have a chain complex, there is an induced homomorphism $\ker (M \to M') \to \operatorname{coker} (M'' \to M)$; but this is an isomorphism after localising at each $\mathfrak{m}$, so the homomorphism is already an isomorphism, and thus the sequence is exact at $M$ as well.

as this is about one of the only things I can comment on I thought I’d write an answer! Hopefully it will be of help to someone. It essentially the same as what has been written but a bit more condensed.

$(1)$ $M = 0$ if and only if $M_\mathfrak{m} = 0$ for all maximal ideals $\mathfrak{m}$

Keep notation and hypothesis of the orginal post i.e. we are considering a sequence $E$: $M’\xrightarrow{f} M\xrightarrow{g} M”$ that is exact when localized at every maximal ideal.

Since $((g\circ f)M’)_{\mathfrak{m}}=(g_\mathfrak{m}\circ f_\mathfrak{m})M_{\mathfrak{m}}’=0$, we have by $(1)$ that $E$ is a complex, and hence, the quotient module ker($g$)/im($f$) is well-defined. Whence, (ker($g$)/im($f))_\mathfrak{m}=$ker($g_{\mathfrak{m}}$)/im($f_{\mathfrak{m}})=0$, and the result follows.