# Is the complement of a codimension 2 subvariety of an affine variety affine

Can we show $k[X,Y,Z,W]/(XY-ZW)-\{(0,1,0,0)\}$ is not affine?

I tried to examine the proof of $\mathbb{A}^2-{0}$, and found the UFD property of $k[X,Y]$ is missing here.

(And I guess the complement of a codimension 2 subvariety of an affine variety not affine. Generally, how can we judge if a variety is not affine?)

To answer your concrete question directly, we look at the closed subscheme $V=(X=Z=0)$ in $\operatorname{Spec}k[X,Y,Z,W]/(XY-ZW)-\{(0,1,0,0)\}$, then $V$ is isomorphic to $\operatorname{Spec}k[Y,W]-\{(1,0)\}$ which is isomorphic to $\mathbb{A}_k^2-0$, so $V$ is not an affine scheme. But any closed subscheme of an affine scheme is affine, so $\operatorname{Spec}k[X,Y,Z,W]/(XY-ZW)-\{(0,1,0,0)\}$ is not affine.

For your guess, I think it is correct when the affine variety is normal.

Proposition: For any noetherian, integral, normal affine scheme $X=\operatorname{Spec}A$, and any nonempty closed subscheme $Z$ of $X$ with codimension at least $2$, $X-Z$ is not an affine scheme.

Proof: If $X-Z$ is affine, then $i:X-Z\rightarrow X$ is a morphism of affine schemes, hence $i$ is totally determined by $i^\#:\Gamma(X, \mathcal{O}_{X})\rightarrow \Gamma(X-Z, \mathcal{O}_{X-Z})=\Gamma(X-Z, \mathcal{O}_{X})$. Since $X$ is integral, $i^\#$ is injective.

Moreover, since $Z$ does not contain any codimension $1$ point of $X$, so for any $f\in \Gamma(X-Z, \mathcal{O}_{X})$, $f$ is regular at all codimension $1$ points. Hence by the algebraic Hartog theorem, $f$ is regular on $X$ because $A$ is integrally closed. As a result, $i^\#$ is surjective.

In sum, $i^\#$ is both injective and surjective, so it is actually an isomorphism. Therefore $i$ is an isomorphism, which means $Z$ is empty and we get a contradiction! QED

(Will this proposition fail when $X$ is not normal?)

• Dear Yuchen, See my answer for the general case. Regards, Oct 25, 2013 at 3:27

It is general fact that if $X$ is a variety and $U$ is an affine open subset, then the complement of $U$ has codim'n $1$ in $X$ (if it is non-empty). Hence, if $Z\subset X$ is closed of codim'n $\geq 2$ and non-empty, then $X \setminus Z$ won't be affine.

For the proof: replace $X$ by its normalization, and $U$ by its preimage in $X$. Then the codim'n of the complement of $U$ doesn't change, and so we reduce to the normal case. Intersecting $U$ with the members of an open affine cover of $X$, we reduce to the case when $X$ is affine. (I am assuming that $X$ is separated, so that the intersection of two open affines is open affine.) Then Yuchen Liu's argument applies.