Scheme satisfying certain condition is affine. Exercise 3.5 Qing Liu Let $Y$ be a scheme such that the natural morphism
$$ Hom_{Schemes}(X,Y) \rightarrow Hom_{Rings}(\mathcal{O}_Y(Y),\mathcal{O}_X(X))$$
is bijective for all affine schemes $X$. Prove $Y$ is affine.
I have no idea how to prove this. Since $Y$ is scheme we can cover it by open affine subsets $Y=\bigcup_iU_i$, but I'm not sure how I can utilise the $U_i$. I know that
$$ Hom_{Schemes}(U_i,Y) \rightarrow Hom_{Rings}(\mathcal{O}_Y(Y),\mathcal{O}_Y(U_i))$$
is bijective, but that doesn't seem to help.
 A: The claim is that $Y \cong \text{Spec}\,\mathcal{O}_Y(Y)$, and by the $\text{Spec}$-$\Gamma$ adjunction we get a morphism of schemes $f:Y \to \text{Spec}\,\mathcal{O}_Y(Y)$ (which I guess is called the 'unit' of the adjunction? I'm not sure what the terminology is for contravariant functors). To show $f$ is an isomorphism, it suffices to check its effect on functors of points (recall Yoneda): for all test schemes $T$ we have a commutative diagram (of sets) $$
   Y(T) := \text{Hom}_{\text{Sch}}(T,Y) \xrightarrow{f\circ-} (\text{Spec}\,\mathcal{O}_Y(Y))(T):= \text{Hom}_{\text{Sch}}(T,\text{Spec}\,\mathcal{O}_Y(Y))\\
\cong\,\downarrow \hspace{7cm} \downarrow\,\cong\\
\text{Hom}_{\text{Ring}}(\mathcal{O}_Y(Y),\mathcal{O}_T(T)) \xrightarrow{=} \text{Hom}_{\text{Ring}}(\mathcal{O}_Y(Y),\mathcal{O}_T(T))
$$ where the downwards left arrow is bijective by your hypothesis and the downwards right arrow is bijective by the mentioned adjunction, since $\text{Spec}\,\mathcal{O}_Y(Y)$ is affine. This of course shows that $f\circ -$ is an isomorphism, regardless of $T$.
Hope this helps! :)
