Open subschemes of affine schemes are affine?

I'm reading Hartshorne, and was wondering if this was true:

Let $A$ be a ring and let $U$ be an open subset of $Spec(A)$. Let $S$ be the set of elements of $A$ not in any prime of $U$. Then $S$ is multiplicatively closed and $\mathcal{O}_A|_U \cong Spec(A[S^{-1}])$ as schemes.

It seems like you would certainly want open subsets of affine schemes to be affine, but I can't seem to find a proof in Hartshorne. Perhaps it's too "obvious" to bother proving, but here is a supposed proof:

$S$ is obviously multiplicatively closed. The map $A \rightarrow A[S^{-1}]$ induces an inclusion-preserving bijection between primes not meeting $S$ and primes of $A[S^{-1}]$. I claim that the primes in $U$ are precisely those that do not meet $S$: if $U^c = V(\mathfrak{a})$, then we show that some element of $S$ lies in $\mathfrak{a}$. If not, then each element of $\mathfrak{a}$ is not in $S$, and so $\mathfrak{a} \subset \bigcup \big\{\mathfrak{p} : \mathfrak{p} \in U\big\}.$ A result of commutative algebra (Atiyah-MacDonald Prop 1.11) then has $\mathfrak{a} \subseteq \mathfrak{p}$ for some $\mathfrak{p}$, a contradiction. Hence any prime not in $U$ contains $\mathfrak{a}$ and so meets $S$. The primes that are in $U$ do not meet $S$ by definition.

This gives a homeomorphism $\phi:U \rightarrow Spec(A[S^{-1}])$ on the level of spaces. We now build an isomorphism of schemes. Let $W$ be an open set of $A[S^{-1}]$. The correspondence of ideals gives an open set in $U$, which we will denote $V$. Suppose $F:W \rightarrow \bigsqcup_{\mathfrak{p} \in W} A[S^{-1}]_\mathfrak{p}$ is locally a fraction. Pick $\mathfrak{p} \in W$. Then let $f = \frac{a}{s} \in A[S^{-1}]$ satisfy $\mathfrak{p} \in D(f) \subseteq W$, and choose $b \in A$ such that $F(\mathfrak{q}) = \frac{b}{f} \in A[S^{-1}]_\mathfrak{q}$ for each $\mathfrak{q} \in D(f)$. Now, if $\mathfrak{p} \in D(f)$, then $\mathfrak{p}\cap A$ does not contain $a$, and conversely. So $D(f)$ is sent to the open set $D(a)$ in $A$. So if we define $G$ on $V$ by $G(\mathfrak{p}\cap A) = F(\mathfrak{p}) \in A[S^{-1}]_\mathfrak{p} \cong A_{\mathfrak{p}\cap A}$, then on $D(a)$, we have $G(\mathfrak{p}\cap A) = F(\mathfrak{p}) = \frac{b}{f} = \frac{sb}{a} \in A_{\mathfrak{p} \cap A}$. So $G$ is locally a fraction, and so this defines $\Gamma(A[S^{-1}], W) \rightarrow \Gamma(A,V)$ and so produces a morphism of schemes. On stalks, this morphism is an isomorphism, and so the morphism itself is an isomorphism of schemes.


Does this proof look correct? I'm always afraid I've missed something subtle with these things.

EDIT: I have figured out where the proof is wrong. The cited Atiyah-Macdonald proposition only holds for finite unions of prime ideals.


It turns out to be wrong in general! (it was a surprise to me too) It's true for (noetherian) curves, though.

The simplest example I know is the affine punctured plane. Let $k$ be an algebraically closed field, and let $A = \mathbb{A}^2_k$ be the affine plane over $k$: that is, $\mathop{\mathrm{Spec}} k[x,y]$.

Then if $O$ is the origin, $Z = A \setminus \{ O \} $ is not an affine scheme. However, it is a scheme, and can be written as the union of $A \setminus X$ and $A \setminus Y$, where $X$ and $Y$ are the $x-$ and $y-$ axes respectively.

The easiest way to see that it's not affine is that $\mathcal{O}(Z) \cong k[x,y]$! This can be computed by the union I described above:

  • $A \setminus X \cong \mathop{\mathrm{Spec}} k[x,y,x^{-1}]$
  • $A \setminus Y \cong \mathop{\mathrm{Spec}} k[x,y,y^{-1}]$
  • $A \setminus (X \cup Y) \cong \mathop{\mathrm{Spec}} k[x,y,x^{-1},y^{-1}]$

Therefore, $\mathcal{O}(A \setminus O) = \mathcal{O}(A \setminus (X \cap Y))$ is the pullback of the diagram

$$ \begin{matrix} & & k[x,y,x^{-1}] \\ & & \downarrow \\ k[x,y,y^{-1}] &\rightarrow& k[x,y,x^{-1},y^{-1}] \end{matrix} $$

Both arrows are inclusions, so this means we have

$$\mathcal{O}(A \setminus O) = k[x,y,y^{-1}] \cap k[x,y,x^{-1}] = k[x,y] $$