It is obvious that there is a parallel between the definition of structure sheaf of $\operatorname{Spec}(A)$
versus the sheafification of a pre-sheaf.


The definition of the sheaf $\mathscr F^+$ associated to pre-sheaf $\mathscr F$ is (Hartshorne p.64):



> 
> For any open set $U$, let $\mathscr F^+ (U)$ be the set of functions $s$ from $U$ to the union of stalks $\mathscr F\_P$ of $\mathscr F$ over points $P$ of $U$ such that:
> 
> 
> 1. For each $P$ in $U$, $s(P)$ is in $\mathscr F\_p$.
> 2. For each $P$ in $U$, there is a neighborhood $V$ of $P$ , contained in $U$, and an element $t$ in $\mathscr F(V)$, such that for all $Q$ in $V$, the germ $t\_Q$ of $t$ at $Q$ is equal to $s(Q)$.
> 
> 
> 


While, in (Hartshorne p.70), the definition of the sheaf of rings $\mathscr O$ on $\operatorname{Spec}(A)$ is:



> 
> For any open set $U$ of $\operatorname{Spec}(A)$, let $\mathscr O(U)$ be the set of functions $s$ from $U$ to the union of localizations $A\_\mathscr{p}$ of $A$ at $\mathscr{p}$ such that:
> 
> 
> For each $\mathscr{p}$ in $U$, there is a neighborhood $V$ of $\mathscr{p}$, contained in $U$, and elements $a,f$ of $A$, such that for each $\mathscr{q}$ in $V$, $f$ not in $\mathscr{q}$, and $s(\mathscr{q}) = a/f$ .
> 
> 
> 


So, is there a naturally occurring pre-sheaf on $\operatorname{Spec}(A)$ (which in general is not a sheaf) that exists for any ring $A$ such that its sheafification gives exactly the structure sheaf $\mathscr O$ of $\operatorname{Spec}(A)$?



Affine scheme on spec(A) of a ring A as the sheafification of a pre-sheave on spec(A)?
For any open subset $U\subseteq\mathrm{Spec}(A)$ let $S\_U=A\setminus\bigcup\_{\mathfrak p\in U}\mathfrak p$ and $\mathscr O'(U)=A[S\_U^{-1}]$. It is obviously a presheaf.


Claim: For open subsets of the form $U=\mathrm{Spec}(A\_f)$ with $f\in A$ we have $\mathscr O'(U)=A\_f$. (This shows that the associated sheaf of $\mathscr O'$ is indeed $\mathscr O\_{\mathrm{Spec}(A)}$.)


Proof: Assume there is an $s\in S\_U$ which does not divide $f^n$ for any $n$. The ideal $(s)$ does not meet the multiplicative set $S\_f=\{1,f,f^2,\dots\}$, so it is contained in an ideal $\mathfrak q$ which is maximal with respect to this property, but it is well-known that such an ideal $\mathfrak q$ is prime. By construction, $s\in\mathfrak q\in U$, contradicting $s\in S\_U$.


Applying the usual associated sheaf construction to $\mathscr O'$ seems to be what Hartshorne does when he defines $\mathscr O\_{\mathrm{Spec}(A)}$.


