A locally ringed space is a topological space equipped with a sheaf of commutative rings whose stalk at every point is a local ring. A morphism of locally ringed spaces consists of a continuous map and a morphism of sheaves of rings , with every induced stalk map a local homomorphism: the inverse image of the target maximal ideal is the source maximal ideal. Here is the direct image sheaf, with sections on .
Let be a ring homomorphism. Define the map between the spectra of rings by
The inverse image is a prime ideal, and . Thus is a continuous map, because the principal open subsets form a basis. On these principal open subsets, define the structure sheaf map using the localizations
These maps commute with restrictions and consequently give a morphism of sheaves. At , putting , the stalk map is . An element belongs to its inverse image of exactly when , so this is a local homomorphism. We have constructed a morphism of locally ringed spaces.
Conversely, take a morphism of locally ringed spaces . Its map on global sections gives a ring homomorphism
Locality of the stalk map implies, for every ,
Hence the point map must be . On , its structure sheaf map must send to and the inverse of to the inverse of . Thus it is precisely the localization map constructed above. Agreement on this basis proves agreement of the morphisms of sheaves. In particular, the inducing ring homomorphism exists and is unique.
If is surjective, write . The correspondence between prime ideals of and prime ideals of containing identifies homeomorphically with the closed subset : the principal open subsets correspond on both sides. Moreover, the stalk maps are the surjections , so is surjective.
For the converse, it is important not to assume that global sections preserve an arbitrary surjection of sheaves. Here the affine module-sheaf equivalence supplies the extra information: on every ,
Thus is the quasi-coherent sheaf associated with the -module , and the cokernel sheaf of is associated with the module , since localization of a module is exact. Surjectivity of the morphism of sheaves gives for every prime ideal . This implies : if , its proper annihilator lies in a maximal ideal , and then in . Therefore is surjective. We have proved the closed immersion criterion for affine schemes: