# If $f: X \to \mathrm{Spec}(R)$ is a morphism of schemes, and $U \cong \mathrm{Spec}(A)$ is an open affine of $X$, how is $A$ an $R$-algebra? [closed]

I'm reading a proof that starts:

Proof: Assume $$f$$ separated. Suppose $$(U,V)$$ is a pair as in (1). Let $$W=\operatorname{Spec}(R)$$ be an affine open {subset ?} of $$S$$ containing both $$f(U)$$ and $$f(V)$$. Write $$U=\operatorname{Spec}(A)$$ and $$V=\operatorname{Spec}(B)$$ for $$R$$-algebras $$A$$ and $$B$$.

But anyhow, I don't see how $$A$$ is an $$R$$-algebra which leads to my more general question:

If $$f: X \to \mathrm{Spec}(R)$$ is a morphism of schemes, and $$U \cong \mathrm{Spec}(A)$$ is an open affine of $$X$$, how is $$A$$ an $$R$$-algebra?

• By the universal property of $\mathrm{Spec}$, given $f$ you have that $\Gamma(X,\mathcal{O}_X)$ is an $R$-algebra. Composing with the restriction map from $X$ to $U$ you get the answer. Oct 8, 2020 at 14:20
• @Aurelio Could we have also restricted $f|_U : U \to \mathrm{Spec}(R)$ and that would have given us a map $\mathrm{Spec}(A) \to \mathrm{Spec}(R)$ which in turn gives a ring hom $R \to A$? Oct 8, 2020 at 14:50
• Yes, of course! Thar argument works too. If you write down the final $R$-action on $A$, you will see that the two approaches are basically the same. Oct 8, 2020 at 14:50
Following @KReiser's suggestion, I bundle my comments above into a proper answer. Given a morphism $$\DeclareMathOperator{Spec}{Spec}f:X\to \Spec R$$, we obtain a map on global sections $$f^\sharp\colon R\to \Gamma(X,\mathcal{O}_X)$$, hence the latter ring is an $$R$$-algebra on the nose. Moreover, by the universal property of $$\Spec$$, there is a natural bijection between $$R$$-algebra structures on $$\Gamma(X,\mathcal O_X)$$ and morphisms $$X\to \Spec R$$.
This construction localises easily. For any open subset $$U\subseteq X$$, the restriction map $$\Gamma(X,\mathcal O_X)\to\Gamma(U,\mathcal O_X)$$ presents the ring of sections over $$U$$ as an $$R$$-algebra. In particular, when $$U=\Spec A$$, this holds for $$A\simeq \Gamma(U,\mathcal O_X)$$. Equivalently, we could simply consider the restriction $$f_{\vert U}\colon U \to \Spec R$$ and apply the universal property.
This discussion shows why we often work in the category $$\mathrm{Sch}/B$$ of schemes over a fixed scheme $$B$$, also called "$$B$$-schemes": they are schemes with a given morphism $$X\to B$$, and morphisms of $$B$$-schemes preserve the map to the base.
Consider for starters $$B=\Spec R$$ affine, for example $$R=k$$ a field: we are saying that a $$B$$-scheme is covered by spectra of $$R$$-algebras, not just rings. Similarly, a map between affine $$B$$-schemes is equivalent to a map of $$R$$-algebras. Now look at $$X\to B$$, when $$B$$ is not necessarily affine. We pull back an affine cover $$\{\Spec A_i\}$$ of $$B$$ to $$X$$, and up to refining we obtain that $$X$$ is covered by algebras over different rings $$\{A_i\}$$.