TITLE: Justification of the term "invertible sheaf"
QUESTION [12 upvotes]: Let $X$ be a locally ringed space (or a scheme) and $M,N$ two $\mathcal{O}_X$-modules such that $M \otimes N \cong \mathcal{O}_X$. Does it follow that $M$ is invertible in the usual sense, namely that $M$ is locally free of rank $1$?
It is true if $M$ is locally of finite type (which is, of course, also necessary). 
Proof: Let $x \in X$. Then $M_x \otimes N_x \cong \mathcal{O}_{X,x}$. Now tensor with the residue field of $\mathcal{O}_{X,x}$ and use linear algebra to conclude that $M_x / \mathfrak{m}_x M_x$ is $1$-dimensional. Since $M_x$ is of finite type over $\mathcal{O}_{X,x}$, Nakayama shows that $M_x$ is generated by just one element. Since $M$ is of finite type in a neighborhood of $x$, it follows that the generator at $x$ is also a generator in a neighborhood of $x$. Also $N$ has one generator, and their tensor product is a generator of $M \otimes N \cong \mathcal{O}_X$, which must be free. Thus also the generators of $M$ and $N$ are free.
But I don't know what happens in the general case. Here are some intermediate questions:

Does it follow that $M$ is flat?
Is the resulting morphism $M \to Hom(N,\mathcal{O}_X)$ an isomorphism?
Is the claim true for $X$ a point, i.e. a local ring?
Is the claim true if $X$ is an affine scheme and $M,N$ are quasi-coherent? (Thus in the question, replace $\mathcal{O}_X$ by a usual ring.)

REPLY [12 votes]: Yes, for quasi-coherent sheaves on a scheme it is true that if $M \otimes N \cong \mathcal{O}_X$, then 
$M$ is locally free of rank one. It is enough to prove the 
REDUCTION  Let $M,N$ be $A$- modules such that $M \otimes_A N\cong A$. Then $M$ is projective of finite type.
Proof : We are given an isomorphism $f:M \otimes_A N\cong A$ . Say $\; f( \Sigma m_i\otimes n_i)= 1$ (FINITE index set!). The composition of the isomorphisms
$g_M:M \to M\otimes (N\otimes M):m\mapsto \Sigma m\otimes (n_i\otimes m_i)$
$assoc: M\otimes (N\otimes M) \to (M\otimes N) \otimes M:
m\otimes (n \otimes m') \mapsto (m\otimes n)\otimes m'$ 
$f_M:(M\otimes N) \otimes M \to M: (m\otimes n) \otimes m_1\mapsto f (m \otimes n).m_1 $
is the isomorphism $j:M\to M: m\mapsto \Sigma  f(m\otimes n_i).m_i$
By introducing the linear forms $\nu_i:M\to A: m\mapsto f(m\otimes n_i)$ we see that we have an isomorphism
$j:M\to M: m\mapsto \Sigma \nu _i(m).m_i$ and we deduce that for all $m\in M$ we can write  $m=\Sigma \nu _i(m).j^{-1}(m_i)$.
It is well known that the existence of such a dual basis $(j^{-1 }m_i, \nu_i)$ proves that $M$ is a finitely generated projective module.