Let $X$ be a normal complex affine algebraic variety. Suppose that $Y$ is an open subvariety of $X$, and that the codimension of $X\setminus Y$ in $X$ is at least $2$. One version of the Hartogs Theorem is that the restriction map $\mathbb{C}[X]\rightarrow\mathbb{C}[Y]$ is surjective. I am curious about whether there is a version of the Hartogs Theorem for extending sections of canonical bundles. Specifically, if $\alpha$ is a global section of the canonical bundle on $Y$, does there exist a global section $\beta$ of the canonical bundle on $X$ such that $\beta\vert_Y=\alpha$? I would appreciate any and all references and suggestions.

$\begingroup$ What is an example of an open subvariety Y of X whose codimension is at least 2? $\endgroup$ – Robert Garbary May 20 '13 at 15:44

$\begingroup$ oops sorry i misread. $\endgroup$ – Robert Garbary May 20 '13 at 15:44

1$\begingroup$ Hartogs' theorem is always misattributed: the one in the OP is Riemann's extension theorem (extension through analytic subsets of codimension $\geq 2$). Hartogs' is about extending through compact subsets. $\endgroup$ – Qfwfq May 20 '13 at 16:49

$\begingroup$ (continued) See: Fritzsche, Grauert, From holomorphic functions to complex manifolds, Theorem 6.12. $\endgroup$ – Qfwfq May 20 '13 at 16:55
I think the property you want is that the canonical sheaf $\omega_X$ is S2. Note that on a normal affine variety, $\omega_X$ is not necessarily a line bundle (it is if $X$ is a complete intersection though).
For simplicity, let's assume $X \subseteq A^{n}$ is of dimension $d$. Then $$ \omega_X = Ext^{nd}(O_X, O_{A^{n}}) $$ is a S2 sheaf. This implies that it satisfies Hartog's theorem. Not all sheaves do! For example, the ideal sheaf of a maximal ideal obviously does not (assuming $\dim X \geq 2$).
For a reference which discusses the S2 condition and relation to Hartog's phenomenon, see for example
Hartshorne, Generalized divisors on Gorenstein schemes.
I think Sándor Kovács has also written several good answers explaining this connection on mathoverflow.
A proof of the S2ness of $\omega_X$ for varieties can be found in KollárMori, Birational geometry of algebraic varieties. Another proof can be found in Hartshorne's Generalized divisors and biliaison.

$\begingroup$ It's also relevant that $\omega_X _Y = \omega_Y$, which follows from the definitions and is more or less (?) equivalent to the statement that open embeddings are smooth morphisms. $\endgroup$ – Charles Staats May 20 '13 at 16:22

$\begingroup$ I really appreciate this answer! I am curious, however, about whether the cotangent sheaves of $X$ and $Y$ might also satisfy this Hartogs extension property. Do you happen to know if this is the case? $\endgroup$ – Peter Crooks May 20 '13 at 17:18

$\begingroup$ @Charles sure, it's definitely implied by that. I think it's more basic though to see that dualizing complexes/sheaves commute with localization (at least depending on your definition). $\endgroup$ – Karl Schwede May 20 '13 at 17:45

$\begingroup$ @PDC I don't think that's true in general (let me know if you need an example, I can probably cook one up). Sometimes people take the reflexification/S2ification of these sheaves though, and then study those properties. You might see the paper of Manuel Blickle Cartier isomorphism for toric varieties or the paper of Greb, Kebekus, Kovács Extension theorems for differential forms and BogomolovSommese vanishing on log canonical varieties. (and the followup with the additional author Peternell Differential Forms on Log Canonical Spaces.) $\endgroup$ – Karl Schwede May 20 '13 at 17:48

1$\begingroup$ @PDC Ah, but any affine variety already can be embedded in a projective variety. Additionally $S2$ is a local condition. This should let you reduce the affine case to the projective case. The reference in the paper of Hartshorne is Lemma 1.3, note $S1$ is always satisfied on any integral scheme. $\endgroup$ – Karl Schwede May 20 '13 at 22:53