TITLE: Schemes (as in algebraic geometry) and first-order logic.
QUESTION [7 upvotes]: Affine schemes are simply the Zariski spectra of commutative rings, and commutative rings occurs as models of a first-order theory.  
I would guess that general schemes do not naturally correspond to the models of any first-order theory and would like to know of any theorems that formalize this.  
I would also like to know of interesting first-order theories that do capture more general schemes than merely the affine ones.  
Even more interesting to me: first order theories that approximate/generalize scheme theory by allowing unintended models.  For example, variables in the theory might range over partial sections of the structure sheaf, one relation might indicate when one section extends another, and another when two sections have the same domain.  One would then formulate addition and multiplication as relations (with the various sections all required to have the same domain.)  As above, I would guess that "locally affine" resists a first-order formulation in this language.  Still one can consider the first-order theory of the models that have the form of schemes, then ask about systems of axioms for such a theory and what the non-scheme models look like.

REPLY [2 votes]: One kind of answer is as follows.  A commutative ring $R$ is local iff for all $a\in R$, either $a$ is invertible or $1-a$ is invertible.  The logical form of this statement is obviously much simpler than the usual definition in terms of maximal ideals, so one can easily interpret it in a wide range of categories.  The pair (sheaves on spec($R$), structure sheaf) is in some sense the free locally-ringed topos generated by the ringed topos (sets,$R$).  If I remember correctly, this is explained in more detail in Johnstone's book on Stone Spaces.  (He probably talks about it in his topos theory books as well.)  More generally, the structure sheaf on a scheme is always a local ring object in the sense just discussed.  Concretely, this means that for any section $a$ of the structure sheaf over an open set $U$ we can write $U=V\cup W$ with $V$ and $W$ open, such that $a|_V$ and $(1-a)|_W$ are invertible.