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?



Why does the (S2) property of a ring correspond to the Hartogs phenomenon?
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](https://mathoverflow.net/questions/35736/the-canonical-line-bundle-of-a-normal-variety/46663#46663)]


