Hartogs Theorem says every function whose undefined locus is of codim 2 can be extend to the whole domain. I saw people saying this corresponds to the (S2) property of a ring. But I can't see why this is true. Can anybody explain this or give a heuristic argument?

2$\begingroup$ It would probably be useful to give a definition of the (S2) property. $\endgroup$ – Peter Samuelson Nov 11 '10 at 7:46

1$\begingroup$ @Shawn: I do. Just didn't log in for several days. $\endgroup$ – Yuhao Huang Nov 13 '10 at 6:15

2$\begingroup$ (i) If F is a coherent sheaf on a scheme X and Z ⊂ X is a closed subset, then local sections of F extend uniquely across Z if and only if F has depth ≥ 2 along Z , [Groth, LNM 41, Prop. 1.11, pp. 1112, Thm. 3.8, p. 44. (ii) If X is an irreducible noetherian Cohen Macaulay scheme, and Z ⊂ X a closed subset, then O(X) has depth ≥ k along Z if and only if every irreducible component of Z has codimension ≥ k in X [Harts, p. 184]. $\endgroup$ – roy smith Nov 4 '11 at 20:40
Let $\mathscr F$ be a coherent sheaf on a noetherian scheme $X$ and assume that ${\rm supp}\mathscr F=X$. Let $Z\subset X$ be a subscheme of codimension at least $2$ and $U=X\setminus Z$. Let $\iota:U\hookrightarrow X$ denote the natural embedding and assume that $\mathcal F_x$ is $S_2$ for every $x\in Z$. Now the $S_2$ assumption implies that $$ \mathscr H^0_Z(X,\mathscr F)= \mathscr H^1_Z(X,\mathscr F)=0 $$ and the Hartogs type extension is equivalent to $$ \iota_*\iota^*\mathscr F\simeq \mathscr F. $$ Finally one has the exact sequence $$ \mathscr H^0_Z(X,\mathscr F) \to \mathscr F\to \iota_*\iota^*\mathscr F \to \mathscr H^1_Z(X,\mathscr F).$$
[See also this MO answer]

$\begingroup$ The last term in your last equation should be $H^1$, right? $\endgroup$ – David E Speyer Nov 8 '10 at 20:21

$\begingroup$ @David: yes, of course. The pitfalls of copypaste... :) $\endgroup$ – Sándor Kovács Nov 8 '10 at 20:26

$\begingroup$ Sandor, is it really true that $H^1_Z(X, F) = 0$ by the S2 hypothesis? When Hartshorne proved this kind of thing, the argument is MUCH more involved. If $Z$ is a point, then you are right, but if $Z$ is not a point, I don't think you get the vanishing you claim. $\endgroup$ – Karl Schwede Nov 9 '10 at 19:20

$\begingroup$ Also, here is one of the places where which definition of $S_2$ one uses may matter, if I am not mistaken. $\endgroup$ – Hailong Dao Nov 9 '10 at 20:26

3$\begingroup$ Karl, I included an argument for this vanishing as a separate answer (it needs more space then a few comments). Also, I want to also comment on your saying "When Hartshorne proved this kind of thing, the argument is MUCH more involved".  I agree. I did not claim this was easy or obvious. Since the question seemed to ask for a heuristic argument, I didn't bother explaining the details. $\endgroup$ – Sándor Kovács Nov 10 '10 at 23:02
This is an answer to a question of Karl in the comments to my first answer to this question.
[EDIT: The following is a minimally simplified version of Proposition 3.3 of HasettKovács04.]
Theorem. Let $X$ be a noetherian scheme, $r\in\mathbb N$, $Z\subseteq X$ a subscheme such that ${\rm codim}_XZ\geq r$, and $\mathscr F$ a coherent $\mathscr O_X$module such that ${\rm supp}\,\mathscr F=X$ and $\mathscr F_x$ is $S_r$ for every $x\in Z$. Then $$ \mathscr H^i_Z(X,\mathscr F)=0\quad\text{for $i=0,\ldots,r1$}. $$
Proof. Let $x\in Z$ and notice that we have the following equality of functors: $$ H^0_x = H^0_x\circ \mathscr H^0_Z $$ which induces a Grothendieck spectral sequence $$ E^{p,q}_2= H^p_x \circ \mathscr H^q_Z \Rightarrow H^{p+q}_x. $$ Now prove the statement using induction on $i$.
Suppose $\exists\,\sigma\in\mathscr H^0_Z(X,\mathcal F)$, $\sigma\neq 0$. Let $x\in Z$ be the general point of an irreducible component of ${\rm supp}\,\sigma$. Then $H^0_x(X, \mathscr H^0_Z(X,\mathscr F))\neq 0$ and hence $H^0_x(X,\mathscr F)\neq 0$. But this contradicts the assumption that $\mathscr F_x$ is $S_r$.
Now suppose that we already know that $$ \mathcal H^i_Z(X,\mathscr F)=0\quad\text{for $i=0,\ldots,k1$} $$ for some $k<r$ and assume that $\mathscr H^k_Z(X,\mathscr F)\neq 0$. By the same argument as above we find a point such that $E^{0,k}_2=H^0_x(X,\mathscr H^k_Z(X,\mathscr F))\neq 0$. Since it is an $E^{0,k}$ term there are no differentials (including later pages of the spectral sequence) mapping to this term and all subsequent differentials mapping from this term map to something of the form $E^{p,q}$ with $0\leq q\leq k1$. However those latter kind are zero by the inductive hypothesis. Therefore this implies that then $H^k_x(X,\mathscr F)\neq 0$ which is again a contradiction to the assumption that $\mathscr F_x$ is $S_r$. Q.E.D.
See also this MO answer
Here's a somewhat more elementary argument that (S2) implies the Hartogs condition. More precisely, I will show that if $X$ is an (S2) noetherian scheme, then any rational function defined outside a closed subset of codimension two can be extended to the whole domain. (This extension is unique by definition of a rational function.)
Assume, by way of contradiction, that $X$ is an (S2) noetherian scheme and $f$ is a rational function on $X$ that is defined outside a closed set of codimension at least two, but cannot be extended to the whole domain. Let $\mathscr{I}$ be the ideal of denominators of $f$; in other words, over an open affine $\operatorname{Spec} A$, $$I = \{g \in A \mid g f \in A\}.$$ This is welldefined as a sheaf since the ideal of denominators is preserved under flat pullback (and in particular, localization); see this mathoverflow question.
If $g \in A$ is a nonzerodivisor, then $g \in I$ if and only if $f = a / g$ for some $a \in A$, hence the name "ideal of denominators." One can check that the closed subscheme $Z \subset X$ corresponding to $\mathscr{I}$ is, settheoretically, the "indeterminacy locus of $f$": the smallest closed subset such that $f$ is defined over $X \smallsetminus Z$. By hypothesis, $f$ can be defined outside a closed subset of codimension two, so $\operatorname{codim} Z \geq 2$. Equivalently, whenever $W$ is an irreducible component of $Z$, then the local ring $\mathscr{O}_{X,W}$ has dimension at least two. Since $X$ is assumed to be (S2), every maximal regular sequence in $\mathscr{O}_{X,W}$ has length at least two.
Since $W$ is an irreducible component of the subscheme corresponding to $\mathscr{I}$, it follows that the radical of $\mathscr{I}_W \subset \mathscr{O}_{X,W}$ is precisely the maximal ideal $\mathfrak{p}$. (Algebraically, $\mathfrak{p}$ is a minimal prime over $I$, and corresponds to the generic point of $W$.) Let $g,h \in \mathfrak{p}$ form a regular sequence (which exists since $X$ is (S2)). Replacing $g$ and $h$ by appropriate powers, we may assume that they are both contained in $\mathscr{I}_W$. By definition of regular sequence, $g$ is a nonzerodivisor. Since $h,g$ is a also a regular sequence, $h$ is a nonzerodivisor. Thus, $g$ and $h$, being nonzerodivisors that lie in the ideal of denominators, are in fact denominators of $f$: there exist $a, b \in \mathscr{O}_X,W$ such that $$\frac{a}{g} = \frac{b}{h} = f$$ $$ah = bg.$$ Since $g,h$ is a regular sequence, $h$ is a nonzerodivisor mod $g$. When we mod out by $g$, the equation above becomes $ah \equiv 0$, which would imply $a \equiv 0 \pmod{g}$. In other words, $a \in (g)$. But since $f = a/g$, this would imply that $f \in \mathscr{O}_{X,W}$, a contradiction since $f$ cannot be extended over $W$.

2$\begingroup$ Charles, nice proof. Since you get the contradiction from extending $f$ to $W$ and you don't seem to use the contradictory assumption elsewhere, you could even make it a positive statement (avoid the contradictory setup). $\endgroup$ – Sándor Kovács Feb 17 '12 at 5:40

2$\begingroup$ Sándor: Thanks. Morally, I agree with your suggestion, but as the proof is currently written, the definition of $W$ as an irreducible component of the indeterminacy locus requires that $f$ have a nonempty indeterminacy locus. Thus, the proof has the form (more or less) "let's assume that $f$ cannot be extended, and use this assumption to extend $f$." I find such setups vaguely displeasing, so if you can see a way around this, I'd love to hear it. $\endgroup$ – Charles Staats Feb 17 '12 at 19:22
See
MR1291023 (95k:14008), Hartshorne, "Generalized divisors on Gorenstein schemes"
Proposition 1.11.