Prove that the natural map $\alpha : \text{Hom}(X,\text{Spec} A) \rightarrow \text{Hom}(A,\Gamma(X,\mathcal{O}_X))$ is an isomorphism

EDIT: I want to add that the relevant parts of EGA to compare are [EGAI, Thm. 1.7.3], which is the analogue of [Hartshorne, II, Prop. 2.3(c)], and [EGAI, Prop. 2.2.4], which is the analogue of your exercise. This proof is similar to the other answer.

[EGAInew, Prop. 1.6.3] is what I am paraphrasing below. It is also [EGAII, Err$_\mathrm{I}$, Prop. 1.8.1], with attribution to Tate.


I won't write down all of the details, but here is another way to approach the problem, which I think is easier, since it avoids the issue with trying to cover $X$ by open affines and glueing morphisms together. We use that the category of schemes is a full subcategory of the category of locally ringed spaces. It suffices to show \begin{align*} \alpha\colon \operatorname{Hom}_\mathsf{LRS}(X,\operatorname{Spec} A) &\longrightarrow \operatorname{Hom}_\mathsf{Ring}(A,\Gamma(X,\mathcal{O}_X))\\ (f,f^\#) &\longmapsto f^\#(\operatorname{Spec} A) \end{align*} is bijective. We construct an inverse map $$ \rho\colon \operatorname{Hom}_\mathsf{Ring}(A,\Gamma(X,\mathcal{O}_X)) \longrightarrow \operatorname{Hom}_\mathsf{LRS}(X,\operatorname{Spec} A) $$ as follows. Let $\varphi\colon A \to \Gamma(X,\mathcal{O}_X)$ be given. Define $$ f \colon X \to \operatorname{Spec} A, \quad x \mapsto \{s \in A \mid \varphi(s)_x \in \mathfrak{m}_x\} $$ where $\varphi(s)_x$ is the image of $\varphi(s)$ in the stalk $\mathcal{O}_{x,X}$ and $\mathfrak{m}_x \subseteq \mathcal{O}_{x,X}$ is the maximal ideal of $\mathcal{O}_{x,X}$. Note the set on the right is a prime ideal. The map $f$ is continuous since $f^{-1}(D(r)) = \{x \in X \mid \varphi(r)_x \notin \mathfrak{m}_x\} = D(\varphi(r))$. We define the map $f^\#$ of structure sheaves; since $D(r)$ form a basis of $\operatorname{Spec} A$, we construct the morphism on each $D(r)$ and then glue. We define $f^\#(D(r))$ to be the top arrow in the diagram $$ \require{AMScd} \begin{CD} A_r @>f^\#(D(r))>\exists!> \mathcal{O}_X(f^{-1}(D(r)))\\ @AAA @AAA\\ A @>\varphi>> \mathcal{O}_X(X) \end{CD} $$ induced by the the universal property of localization [Atiyah-Macdonald, Prop. 3.1], where the hypotheses for the universal property hold since $\varphi(r)$ is invertible in $\mathcal{O}_X(f^{-1}(D(r)))$ by definition of $f$. The morphisms on each $D(r)$ glue together since the maps $f^\#(D(r))$ were constructed uniquely by the universal property above, hence on any intersection $D(rs)$ they must match.

To show $\alpha$ and $\rho$ are inverse to each other, note $\alpha \circ \rho = \mathrm{id}$ is clear by letting $r = 1$ in the diagram above. This implies $\alpha$ is surjective, so it remains to show $\alpha$ is injective. Let $\varphi\colon A \to \Gamma(X,\mathcal{O}_X)$, and let $(f,f^\#)$ such that $\alpha(f,f^\#) = \varphi$. Then, we have the diagram $$ \begin{CD} A_{f(x)} @>f^\#_x>> \mathcal{O}_{x,X}\\ @AAA @AAA\\ A @>\varphi>> \mathcal{O}_X(X) \end{CD} $$ by taking the direct limit over all open sets $D(r)$ containing a point $x$. Since the map $f_x^\#$ is local, we have $(f_x^\#)^{-1}(\mathfrak{m}_x) = \mathfrak{m}_{f(x)}$, hence $f(x) = \{s \in A \mid \varphi(s)_x \in \mathfrak{m}_x\}$ as desired by using the commutativity of the diagram. The uniqueness of $f^\#$ also follows from this diagram since if $(g,g^\#)$ is any other map $X \to \operatorname{Spec}A$ such that $\alpha(g,g^\#) = \varphi$, then $f^\#_x = g^\#_x$ for all $x$, hence they must be the same morphism.


Let $g\in\hom_{ring}(A,\Gamma(X,\mathcal{O}_X)$

Cover $X$ by affine open subsets $\{U_i=Spec(A_i)\}_{i\in I}$.

Now, the inclusion $U_i\hookrightarrow X$ gives us a map from global section of $U_i$ to global section of $X$ (i.e., $\rho^{X}_{Spec(A_i)}:\Gamma(X,\mathcal{O}_X)\rightarrow A_i$)

We take the composite map $A\hookrightarrow\Gamma(X,\mathcal{O}_X)\hookrightarrow A_i$

This gives rise to a map from $f_i:U_i=Spec(A_i)\rightarrow Spec(A)$ for each $i\in I$ (Note, $f_i$ is nothing but the Spec map of the composition of $g$ with the restriction map $\rho^{X}_{U_i}$, i.e., $f_i=Spec(\rho^{X}_{U_i}\circ g)$)

Notation: If $h:A\rightarrow B$ be a ring homomorphism, then the corresponding scheme morphism is denoted by $Spec(h):Spec(B)\rightarrow Spec(A)$

Now, we use that fact- If $X$ and $Y$ are two schemes, then giving a morphism from $X$ to $Y$ is equivalent to giving an open cover $\{U_i\}_{i\in I}$ of X, together with morphism $f_i:U_i\rightarrow Y$, where $U_i$ has the induced open subscheme structure, such that the restrictions of $f_i$ and $f_j$ to $U_i\cap U_j$ are the same, for each $i,j\in I$

Therefore, we need to check: $$ f_i|_{U_i\cap U_j}=f_j|_{U_i\cap U_j} $$ We need to cover $U_i\cap U_j$, again by affine open subsets (Otherwise, we cannot use the functoriality of $Spec$) Cover $U_i\cap U_j$ by $\{V_{ijk}=Spec(B_{ijk})\}_{k\in I}$

Enough to show,

$f_i|_{V_{ijk}}=f_j|_{V_{ijk}}$

We have inclusion of open sets, $V_{ijk}\hookrightarrow U_i\cap U_j\hookrightarrow U_i \hookrightarrow X$ and $V_{ijk}\hookrightarrow U_i\cap U_j\hookrightarrow U_j\hookrightarrow X$

Observe that,

$f_i|_{V_{ijk}}=Spec(\rho^{U_i}_{V_{ijk}}\circ\rho^{X}_{U_i}\circ g)$

and

$f_j|_{V_{ijk}}=Spec(\rho^{U_j}_{V_{ijk}}\circ\rho^{X}_{U_j}\circ g)$

and both are equal to $Spec(\rho^{X}_{V_{ijk}}\circ g)=f_i|_{V_{ijk}}=f_j|_{V_{ijk}}$

Therefore, we conclude that $f_i$ and $f_j$ agrees on the intersection and glues in order to give rise to a morphism from $X\rightarrow Spec(A).$