Let $M$ and $N$ be $R$ modules ($R$ commutative with identity). Is it true that if for every prime ideal $P$, $M_P \cong N_P$ (as $R_P$ modules) then $M \cong N$ ? Clearly the question is true if $M$ or $N$ is zero. But what about the nonzero case !?

9$\begingroup$ The module $M$ of sections of a nontrivial line bundle on an affine variety $X=\operatorname{Spec} R$ satisfies $R_{\mathfrak{P}}\cong M_{\mathfrak{P}}$ for any prime ideal $\mathfrak{P}\subset R$, but $R\ncong M$. $\endgroup$ – Fernando Muro Dec 27 '12 at 10:22

3$\begingroup$ Metathread here: tea.mathoverflow.net/discussion/1500/locallyisomorphicmodules $\endgroup$ – Steven Landsburg Dec 27 '12 at 13:32

3$\begingroup$ I think the simplest explicit example is ring $k[x,y]/(x^2y^31)$. The ideal $(x1,y)$ is not principal, so as a module it is not isomorphic to the trivial module. But at every point other than $x=1,y=0$, that ideal is trivial, so isomorphic to the trivial module, and at $x=1,y=0$, that ideal is the maximal ideal of a a PID, thus isomorphic to the trivial module. $\endgroup$ – Will Sawin Dec 27 '12 at 21:16

4$\begingroup$ The question got 11 up votes. The accepted answer to 10 up votes. Clearly there's both people who find the question and the answer interesting. What is the benefit of closing such a question? Voting to reopen. $\endgroup$ – André Henriques Jan 15 '13 at 16:29

2$\begingroup$ This question is I think very poor. A special case of it is "are all projective modules free?" and the answer even to that special case is "go to any commutative algebra class, or read any book on commutative algebra, and get to the point where projective modules are defined, and then read the next two lines, where it is pointed out that there exist projective modules that aren't free". I learnt this in an undergraduate manifolds class. Just because there are 10 people out there that don't know this, doesn't make it a good question...does it?? $\endgroup$ – user30035 Jan 15 '13 at 21:46
Here is an explicit counterexample:
Let $R^3$ be euclidean 3space and $S^2$ the 2sphere, embedded in $R^3$ as usual. Let $A$ be the ring of all realvalued continuous functions on $S^2$. Let $T$ be the $A$module of all $R^3$valued continuous functions on $S^2$ (so that $T\approx A^3$ is a free $A$module). Let $M\subset T$ consist of all those functions $f$ such that $f(x).x=0$ for all $x$ (where "dot" denotes the usual inner product in $R^3$). Let $M'\subset T$ be the submodule generated by the identity function.
Observation 1: $M\oplus M'=T$. Thus, for any prime $P\subset A$, we have $M_P\oplus M'_P\approx T_P$. But over a local ring, any direct summand of a free module is free. Therefore $M_P$ is free.
Observation 2: $M$ can't be free. If it were, it would have a basis consisting of two triples $(f_1,f_2,f_3)$ and $(g_1,g_2,g_3)$ (the entries $f_i$ and $g_i$ being realvalued functions). This basis, together with the basis consisting of the single element $(x,y,z)$ for $M'$, would form a basis for $T$. It would follow that the matrix $$\pmatrix{f_1&f_2&f_3\cr g_1&g_2&g_3\cr x&y&z\cr}$$ has unit determinant; in particular the determinant is a function on $S^2$ with no zeros.
But it is a fact from topology that if $f(x).x=0$ for all $x$, then there is some $x$ such that $f(x)=(f_1(x),f_2(x),f_3(x))=(0,0,0)$. Thus the determinant of the displayed matrix has a zero at $x$. This contradiction shows that $M$ is not free.
Now let $N$ be a free $A$module of rank 2. Observation 1 shows that $M_P\approx N_P$ for all primes $P$; Observation 2 shows that $M$ is not isomorphic to $N$.
No in general, per Fernando's comment. Yes if you have a single map $M\rightarrow N$ that localizes to isomorphisms at every prime $P$ (compute the kernel and cokernel and use your observation about zeromodules).

1$\begingroup$ yes, this is a wellknown exercise in algebraic text books for example see AtiyahMacDonald's book. $\endgroup$ – user30230 Dec 27 '12 at 18:34