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 non-zero case !?



locally isomorphic modules
Here is an explicit counterexample:


Let $R^3$ be euclidean 3-space and $S^2$ the 2-sphere, embedded in $R^3$ as usual. Let $A$ be the ring of all real-valued 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 real-valued 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$.


