If R is a commutative ring (with unit) then we have an affine scheme Spec(R) which is an object of the category of ringed topological spaces. Is there any way of characterising this object relative to the category of ringed topological spaces? The underlying space of an affine scheme is compact and the structure sheaf is a ring, but these statements hardly go any way towards characterising an affine scheme. I am not looking for an answer that is necessarily strictly tied to the structure of the category of ringed topological spaces  just something that is topological and/or about the algebraic structure of the structure sheaf.
A nonanswer is: 'An affine scheme is a ringed topological space of the form SpecR for some cummutative ring R.'
Thanks for any pointers, Christopher

3$\begingroup$ In terms of pure point set topology, there is a complete characterisation of spectral spaces. $\endgroup$– Zhen LinFeb 23, 2012 at 12:56

1$\begingroup$ An affine scheme is a ringed topos arising as a pullback of topoi, namely as the pullback of a morphism from the topos of sets to the classifying topos of rings along the forgetful morphism from the classifying topos of local rings to the topos of rings  see this answer for more details: mathoverflow.net/questions/8204/… $\endgroup$– Peter ArndtFeb 23, 2012 at 21:51

1$\begingroup$ @Peter Arndt, I thought through what you said. Viewing rings as geoemtric morphisms, I can't see how every affine scheme can be a pullback of toposes as described. The morphism being pulled back is a subtopos morphism from one classifying topos(that of local rings) to another (that of rings). It's pullback will be a subtopos of Set, and these correspond [I think] to sublocales of 1 and not to coherent locales in general, which they must for the caracterization to work. I am sure you are right, but perhaps you can see my difficult in agreeing the characterisation? $\endgroup$– Christopher TownsendFeb 28, 2012 at 9:01

$\begingroup$ @ChristopherTownsend, that claim of Peter is discussed on the nForum, with no clear consensus. One thing to note is that the "pullback square" in question only commutes up to a noninvertible natural transformation. $\endgroup$– Ingo BlechschmidtSep 24, 2015 at 20:37
5 Answers
An affine scheme can be characterized in the category of locally ringed spaces (one needs the "locally" if I remember correctly). A l.r.s. $X$ is an affine scheme i.f.f. $Hom(Y,X)$ functorially equals $Hom(\Gamma(X,\mathcal{O}_X),\Gamma(Y,\mathcal{O}_Y))$, for $Y$ a l.r.s.
In other words, the affine scheme construction is the construction of a right adjoint to $\Gamma: ( l.r.s. ) \to ( rings )^{op}$.

4$\begingroup$ This fact also gives (what I think is) a nice characterization of affineness among all locally ringed spaces. If $Y$ is a locally ringed space, taking $X=\mathrm{Spec}(\mathscr{O}_Y(Y))$ in Sasha's answer shows there is a unique morphism $f:Y→\mathrm{Spec}(\mathscr{O}Y(Y))$ inducing the identity on global sections, and $Y$ is an affine scheme (in the sense that it is isomorphic to the spectrum of some ring via some isomorphism) if and only if this canonical $f$ is an isomorphism. $\endgroup$ Feb 23, 2012 at 13:29

2$\begingroup$ This is wellknown (EGA I, 1.6.3). Sometimes this is also taken as the definition of an affine scheme (DemazureGabriel). $\endgroup$ Feb 23, 2012 at 14:17

1$\begingroup$ I wish it were always taken as the definition of an affine scheme. $\endgroup$ Feb 23, 2012 at 15:36
Look at Eisenbud and Harris, The Geometry of Schemes, page 21.
The conditions for a ringed space $(X,\mathcal{O})$ to be isomorphic to $Spec(R)$, where $R=\mathcal{O}(X)$, are:
1) For each $f\in R$, let $U_f\subset X$ be the set of $x$ such that $f$ maps to a unit in the stalk $\mathcal{O}_x$. Then $\mathcal{O}(U_f)=R[f^{1}]$.
2) The stalks $\mathcal{O}_x$ are local rings.
3) The natural map $X\to \left Spec(R)\right$ that takes $x$ to the preimage in $R$ of the maximal ideal in $\mathcal{O}_x$ is a homeomorphism.

1$\begingroup$ do you happen to know whether a similar criterion of affineness exists for algebraic spaces? $\endgroup$ Feb 23, 2012 at 10:38

$\begingroup$ @Yosemite: No, I'm afraid I don't. Perhaps someone else who does will come along and comment. $\endgroup$ Feb 23, 2012 at 14:33

$\begingroup$ Sadly there is no proof in the book you mentioned, but I would love to understand why this is exactly what is needed for X to be affine. $\endgroup$ Nov 16, 2014 at 18:40
The characterizations mentioned so far are purely formal. There is a nontrivial cohomological characterization by Serre of affine schemes within quasicompact quasiseparated schemes $X$ (see EGA II, 5.2). Namely, $X$ is affine iff $\Gamma : \mathrm{Qcoh}(X) \to \mathrm{Ab}$ is exact (i.e. $\mathcal{O}_X$ is a projective object in $\mathrm{Qcoh}(X)$) iff all cohomology groups $H^i(X,F)$ vanish, where $F$ is a quasicoherent sheaf on $X$ and $i>0$. Actually it suffices to take $i=1$ and $F$ a finite type ideal of $\mathcal{O}_X$.

5$\begingroup$ Unless I misunderstood, the asker was looking for a characterization of affine schemes among ringed spaces, not among schemes. $\endgroup$ Dec 11, 2012 at 1:23
Maybe you will be interested in the thesis of Mel Hochster. He characterizes the image of Spec in Top. The article based on it is called Prime Ideal Structures in Commutative Rings and appeared in the Transactions of the AMS in 1969.
There is a purely categorytheoretical way to describe affine schemes. Consider an arbitrary scheme $X$. For any ring $R$ we can consider a set of $R$points of $X$, that is $X(R)=\mathrm{Hom}_{Schm}\left( \mathrm{Spec}\;R,X \right)$. This is a functor $X: Ring \to Set$. For an affine $X=\mathrm{Spec}\;A$ it equals to $X(R)= \mathrm{Hom}_{Ring}\left( A, R \right)$. Affine schemes are exactly such representable functors $Ring\to Set$.
There's also a concrete theorem, describing affine schemes. If $X$ is a scheme and $\mathcal{J}$ is a nilpotent quasicoherent sheaf of ideals of $\mathcal{O}_X$, then $X$ is affine iff the closed subscheme $V(\mathcal{J})$ of $X$ is affine. (see Gabriel, Demazure, p.80).

1$\begingroup$ Aren't you more or less describing affine schemes as the opposite of the category of commutative rings? I don't see how ringed spaces really enter into this description. $\endgroup$ Feb 24, 2012 at 1:14

1$\begingroup$ @Anton: although I agree that locally ringed spaces are evil, I think the OP was asking a different question. (by the way, another great place to learn about the functorofpoints POV is the master course on stacks to be found on Toen's webpage) $\endgroup$ Feb 24, 2012 at 1:24

$\begingroup$ @Qiaochu Yuan, I didn't really describe what a scheme is, I just pointed the direction. There is Zariskitype Grothendieck topology on the category of affine schemes and the corresponding sheaves are schemes. This allows to associate a topological space to any scheme. The structure sheaf appears as a sheaf of morphisms from an open subset to the affine line (affine scheme represented by $\mathbb{Z}[T]$). So description of affine schemes as representable functors is meaningful, although possibly (like any representability) too difficult to check in practice without more concrete theorems. $\endgroup$ Feb 26, 2012 at 17:20

$\begingroup$ @Yosemite Sam, thank you for the pointer! My answer is more or less a reformulation of @Sasha 's one. It's just a step forward: you don't need to check his equality for all l.r.s. $Y$, it suffices to check only affine ones, because all (pre)sheaves are colimits of representables. And then it becomes exactly the representability condition for $X$. $\endgroup$ Feb 26, 2012 at 17:28