# Does Hom(X,Spec R) = Hom(R, O(X)) hold for algebraic stacks?

For an affine scheme $Spec R$ and a scheme $X$ we know that $Hom(X,Spec R) = Hom(R,\Gamma(X,\mathcal{O}_X))$.

Does it still hold when we replace $X$ with an algebraic stack?

My guess is yes as $Hom(-,Spec R)$ glues like a sheaf and given an algebraic stack we can consider an atlas and the hypercovering given by it (whatever it may mean).

-
It is certainly true for algebraic spaces. But does it make sense at all for algebraic stacks? A natural definition of the sheaf of regular functions is not ring-valued, but rather 2-ring-valued: $\Gamma(X)$ is the category of morphisms $X \to \mathbb{A^1}$. – Martin Brandenburg Oct 29 '11 at 22:53
Isn't that category just a set? – Yosemite Sam Oct 29 '11 at 23:04
OK, I confess my sin of sloppiness, to make everyone happy I could write $\pi_0 Hom(X,Spec R) = \pi_0 Hom(R,\mathcal{O}(X))$ (although again it's not an equality but a bijection!). But more importantly: does the result hold? – Yosemite Sam Oct 30 '11 at 0:34
I claim yes. Choose an embedding into affine space $Spec R \to \mathbb A^n$. Then a map to $Spec R$ creates uniquely a map to $\mathbb A^n$, $n$ maps to $\mathbb A^1$, that is, a map $k[x_1,..,x_n]$ to $\mathcal O(X)$. Moreover the map must land in a certain subvariety, so it must come from a specific quotient, so it's just $R$. Similarly, any map from $R$ can be extended to $k[x_1,...,x_n]$ and so blah blah blah blah. I claim, with no particular evidence, that no additional difficulties come in rings that are not finitely generated over a field. – Will Sawin Oct 30 '11 at 4:27
I think that the "category" of morphisms $X\to \mathbb{A}^1$ is literally a set, meaning that it's a category with only identity arrows: natural transformations don't do much, since $\mathbb{A}^1$ is a category fibered in sets.. – Mattia Talpo Oct 31 '11 at 14:38

Take a smooth atlas $U\to X$, and notice that sections of $\mathcal{O}_X$ (which you can see as morphisms of quasi-coherent sheaves $\mathcal{O}_X \to \mathcal{O}_X$) correspond to sections of $\mathcal{O}_U$, such that the two restrictions to $U_1:=U\times_X U$ by means of the two projections to $U$ coincide.
This is also true of morphisms out of $X$: a morphism $X\to T$ where $T$ is a scheme corresponds to a morphism $U\to T$ such that the two compositions $U_1\to U\to T$ coincide (basically because $Hom(-,Spec R)$ is a sheaf, as you said).
This reduces the question to the fact that morphisms $U\to Spec R$ such that the two compositions $U_1\to Spec R$ coincide correspond to morphisms $R\to \mathcal{O}_U(U)$ such that the two compositions $R\to \mathcal{O}_{U_1}(U_1)$ coincide.