# effective Cartier divisor is trivial

Given a schema $X/k$ with $H^0(X,\mathcal{O}_X^\times) = k^\times$ and an effective Cartier divisor $D \geq 0$ such that $\mathcal{O}(D) = O_X$, why is necessarily $D = 0$?

I tried to apply the long exact cohomology sequence to $1 \to \mathcal{O}_X^\times \to \mathcal{M}_X^\times \to \mathcal{M}_X^\times/\mathcal{O}_X^\times \to 1$, but without success.

-

Since $\mathcal O_X=\mathcal O_X(0)=\mathcal O_X(D)$, we deduce $D=D-0=\operatorname{div}(f)$ for some rational function $f\in \operatorname{Rat}(X)$. But since $\operatorname{div}(f)=D$ is effective, $f$ is locally regular: there is an open covering $(U_i)$ of $X$ such that on $U_i$ our $f$ is represented by $f_i\in \mathcal O_X(U_i)$. So actually $f$ is regular everywhere i.e. $f\in H^0(X,\mathcal O_X)$.
Since $\frac 1 f \mathcal O_X=\mathcal O_X(D)=\mathcal O_X$ it follows that the inverse $\frac 1f\in Rat(X)$ of $f$ is also regular, in other words $f\in H^0(X,\mathcal O_X^\times)$. By the definition of cartier divisors this means that$D=0$.

Edit
Cantlog attracted my attention to the fact that the implication (which I had stupidly used in a preceding version of the answer)) $H^0(X, \mathcal O_X^{\star})=k^{\star} \implies H^0(X, \mathcal O_X)=k$ is false, as shown by the counterexample $X=\mathrm{Spec} (k[T])$.
He also notices that actually you don't need the hypothesis $H^0(X, \mathcal O_X^{\star})=k^{\star}$ at all!
Many thanks to Cantlog for his great comments.

-

Edited version. This is true without hypothesis on $H^0(X, \mathcal O_X^{\star})$ and without assuming $D\ge 0$.

As in Georges's excellent answer, $D$ is defined by an invertible rational function $f$ on $X$. The condition $f^{-1}\mathcal O_X=\mathcal O_X(D)=\mathcal O_X$ then implies that $f$ is regular and invertible in $\mathcal O_X$. So $D=0$ by definition.

One more edit (sorry). This indeed is an interesting question that we could put in a different perspective. Let $X$ be a noetherian scheme. It is known that the canonical map from the group of Cartier divisors modulo linear equivalence to the Picard group of $X$ is injective (this is what you can prove with your exact sequence $1\to \mathcal O_X^{\star}\to \mathcal M_X^{\star}\to ...$). But there is a more primitive map from the group of Cartier divisors to the group of sub-invertible sheaves of $\mathcal M_X$ defined by $D\mapsto \mathcal O_X(D)$. What is noticed above is that this map is also injective.

-
Dear Cantlog: a thousand thanks for your penetrating comments. I have modified my answer and upvoted your answer. It would be a pity that you delete such a brilliant answer, much better than mine. – Georges Elencwajg Aug 25 '13 at 12:01
Dear @GeorgesElencwajg: thanks for your kind encouraging words ! I will leave the answer as it does not use the hypothesis $D\ge 0$. – Cantlog Aug 25 '13 at 15:48
Dear Cantlog, your second edit is extremely interesting too. The key point seems to be that $\mathcal O_X=\mathcal O_X(D)$ really means equality as subsheaves of $\mathcal M_X$, and not merely abstract isomorphism of $\mathcal O_X$-modules, which certainly wouldn't imply $D=0$ as attested by the divisor $D=div(f)$ of an arbitrary rational function $f$. – Georges Elencwajg Aug 25 '13 at 18:33