Let have an affine open neighbourhood , and let . Evaluation gives with kernel . If first sheaf cohomology of every coherent ideal sheaf vanishes, a global section of can be chosen with . Then is a principal open subset of an affine variety and is affine.
If for every coherent ideal sheaf, projection to the last coordinate makes any coherent an extension of a coherent submodule of by an ideal sheaf. The long exact sequence in sheaf cohomology proves the assertion by mathematical induction on .
For , the assertion is the assumed vanishing for coherent ideal sheaves. For , project onto the last component. Its image is a coherent ideal sheaf, and its kernel is a coherent sheaf contained in . Here images and kernels are coherent because a variety is Noetherian. The short exact sequence
gives an exact segment in the long exact sequence in sheaf cohomology. The outer terms vanish by mathematical induction and the hypothesis, so the middle term vanishes. This is ideal-sheaf vanishing for a coherent submodule of a trivial bundle.
Let be the coherent ideal sheaf of , and let be the ideal sheaf of a closed point. Because , the stalk is . Evaluation at therefore gives a surjective morphism of sheaves to the skyscraper sheaf at . Its kernel is again a coherent ideal sheaf. From
and , the long exact sequence in sheaf cohomology shows that is onto. Choose mapping to . It vanishes on and satisfies . Hence , and inside the affine variety it is the principal open subset defined by . A principal open of an affine variety is affine. This gives affine principal neighbourhoods from ideal-sheaf vanishing.
For the projective-space complement, assume and choose two distinct closed points . Take the ideal sheaf of two closed points on . The codimension-two extension of regular functions on a normal variety gives
One can see this directly: on every standard affine chart of , a rational function written in lowest terms cannot have a nonconstant denominator, because an irreducible polynomial factor of the denominator would define a pole along a codimension-one hypersurface, and such a hypersurface is not removed by . The extended function is constant because every global regular function on projective space is constant. Now the short exact sequence
sends diagonally into on global sections. Its cokernel is , and the long exact sequence in sheaf cohomology injects that cokernel into . Thus
The assumption is necessary: is already affine and has no such example.