**Proof.**
To prove this lemma we may assume $X$ is the spectrum of a Noetherian ring $A$. Say $x \in X$ corresponds to $\mathfrak p \subset A$.

Proof of (1). It is clear that $\mathcal{S}_ x$ is contained in the set of nonzerodivisors of $\mathcal{O}_{X, x} = A_\mathfrak p$. For the converse, let $f, g \in A$, $g \not\in \mathfrak p$ and assume $f/g$ is a nonzerodivisor in $A_{\mathfrak p}$. Let $I = \{ a \in A \mid af = 0\} $. Then we see that $I_{\mathfrak p} = 0$ by exactness of localization. Since $A$ is Noetherian we see that $I$ is finitely generated and hence that $g'I = 0$ for some $g' \in A$, $g' \not\in \mathfrak p$. Hence $f$ is a nonzerodivisor in $A_{g'}$, i.e., in a Zariski open neighbourhood of $\mathfrak p$. Thus $f/g$ is an element of $\mathcal{S}_ x$.

Proof of (2). Let $f \in \Gamma (X, \mathcal{K}_ X)$ be a meromorphic function. Set $I = \{ a \in A \mid af \in A\} $. Fix a prime $\mathfrak p \subset A$ corresponding to the point $x \in X$. By (1) we can write the image of $f$ in the stalk at $\mathfrak p$ as $a/b$, $a, b \in A_{\mathfrak p}$ with $b \in A_{\mathfrak p}$ not a zerodivisor. Write $b = c/d$ with $c, d \in A$, $d \not\in \mathfrak p$. Then $ad - cf$ is a section of $\mathcal{K}_ X$ which vanishes in an open neighbourhood of $x$. Say it vanishes on $D(e)$ with $e \in A$, $e \not\in \mathfrak p$. Then $e^ n(ad - cf) = 0$ for some $n \gg 0$ by Lemma 31.24.1. Thus $e^ nc \in I$ and $e^ nc$ maps to a nonzerodivisor in $A_{\mathfrak p}$. Let $\text{Ass}(A) = \{ \mathfrak q_1, \ldots , \mathfrak q_ t\} $ be the associated primes of $A$. By looking at $IA_{\mathfrak q_ i}$ and using Algebra, Lemma 10.63.15 the above says that $I \not\subset \mathfrak q_ i$ for each $i$. By Algebra, Lemma 10.15.2 there exists an element $z \in I$, $z \not\in \bigcup \mathfrak q_ i$. By Algebra, Lemma 10.63.9 we see that $z$ is not a zerodivisor on $A$. Hence $f = (zf)/z$ is an element of the total ring of fractions of $A$. This proves (2).
$\square$

## Comments (4)

Comment #109 by Tim on

Comment #111 by Johan on

Comment #8868 by Branislav Sobot on

Comment #9218 by Stacks project on

There are also: