$\operatorname{Spec} A$ as a colimit I was reading the lecture notes on algebraic geometry and came across with the following definition:
Let $A$ be a commutative ring with unit, then $\operatorname{Spec} A$ is defined as the collection of all ring homomorphism $A\rightarrow K$, where $K$ is some field, and where we identify two maps $f:A\rightarrow K$ and $f':A\rightarrow K'$ if there exists a field homomorphism $\alpha:K\rightarrow K'$ such that $f'=\alpha \circ f$.
And then the author went on: this is a rather categorical definition, and in fact we could rephrase it as $$\operatorname{Spec} A=\operatorname*{colim}_{K\in \mathfrak{Field}} \operatorname{Hom}_{\mathfrak{Ring}}(A,K).$$
where $\mathfrak{Field}$ is the category of fields and $\mathfrak{Ring}$ is the category of rings.
I am trying to prove this but not sure if I am on the right track: Let $\mathfrak{C}$ be the subcategory of the coslice category of $\mathfrak{Ring}$ over $A$ where the objects are $f:A\rightarrow K$ and the morphisms are $\alpha: f\rightarrow f'$ such that $f'=\alpha \circ f$. But then I don't see how to proceed from there. Is there any literature about this definition of spectrum of a ring rather than the usual definition as the set of all prime ideals of $A$? Thank you.
 A: I'd like to briefly mention a slight set theoretic issue. The category of $\mathbf{Fields}$ is not small, so strictly speaking this colimit could "diverge" and no longer yield a set as an answer. In fact, the definition you gave in the second paragraph is a bit sketchy as well. The collection of all maps $A \longrightarrow K$ for all fields is definitely not a set, so modding out by an equivalence relation is not strictly in set theory. I won't dwell on these issues much, as they can be rectified (as below), and are beyond the scope of this question and of my understanding. But suffice it so say that this is a reason to use the usual definition of $\operatorname{Spec}$ as prime ideals.
I'll show this by directly proving that $\operatorname{Spec} A$ as you have it defined in the second paragraph satisfies the universal property of the below colimit. What is that universal property? Well it means that any cocone out of the indexing diagram is a map out of the colimit. More formally, let's fix some set $X$. Then a cocone from the indexing diagram to $X$ is a collection of commutative diagrams

for all maps $i: K \longrightarrow L$ of fields. To say that $\operatorname{Spec} A$ is a colimit of this diagram means that for any such cocone $(X, \{f_K\}_{K \in \mathbf{Fields}})$, we have the following commutative diagram, again for every such map $i: K \longrightarrow L$:

We can see therefore that it is, strictly speaking, incorrect to say that $\operatorname{Spec} A$ is the colimit of this diagram. Instead, we need to say that the cocone $(\operatorname{Spec} A, \{\alpha_K\}_{K \in \mathbf{Fields}})$ is  the colimit. In other words, that this cocone is initial among all cocones. In particular, we need our maps $\alpha_K: \operatorname{Hom}(A, K) \longrightarrow \operatorname{Spec} A$ for all fields $K$. Well per your second paragraph, the elements of $\operatorname{Spec} A$ are define as equivalence classes of such maps. So we take $\alpha_K(f) = [f]$, where the brackets denote the equivalence class of $f: A \longrightarrow K$ viewed in $\operatorname{Spec} A$.
Now we have to check that this is actually a cocone, i.e. that for $i: K \longrightarrow L$ that $\alpha_L \circ h_i = \alpha_K$. Indeed, take some $f: A \longrightarrow K$. The right hand side is $\alpha_K(f) = [f]$ as above. The left hand side is $\alpha_L(i \circ f) = [i \circ f] = [f]$ by the very definition of the equivalence relation you gave! I hope now that you can sort of see what @AlexKruckman in the comments meant. The construction you gave in the second paragraph fits the colimit like a glove, and that is precisely because it is the standard construction of a colimit of sets.
EDIT: For this next paragraph, see the comments for a discussion of an error. I assumed $f \sim i \circ f$ was the equivalence relation, but it merely generates it. The proof I wrote below can be adapted to this correct equivalence relation but I'll leave it as is. The key ideas remain the same.
Anyways, we now have two tasks. Construct a map $F: \operatorname{Spec} A \longrightarrow X$ that fits in the diagram and proving that it is unique. We need, of course, for any $f \in \operatorname{Hom}(A, K)$ to have $f_K(f) = F(\alpha_K(f))$. So we'll do the naive thing and literally define $F([f]) = \alpha_K(f)$, given a representative $f:A \longrightarrow K$. But why is this well defined? It comes down again to commutativity - this time of the cocone with vertex $X$. Indeed, suppose $[f] = [f']$ where $f \in \operatorname{Hom}(A, K)$ and $f' \in \operatorname{Hom}(A, L)$. Then by definition, there is a map $i: K \longrightarrow L$ such that $i \circ f = f'$. In other words, $h_i(f) = f'$. Now, recall that we assumed the outer triangle commuted, i.e. $f_L \circ h_i = f_K$. Hence, $f_L(h_i(f)) = f_K(f)$ so $f_L(f') = f_K(f)$. And by my definition, $F([f]) = f_K(f)$ and $F([f']) = f_L(f') = f_K(f)$. Thus, $F([f]) = F([f'])$ whenever $[f] = [f']$ and we have well definition. Furthermore, we need to show that $F$ actually commutes in the diagram. This again fits like a glove. $F(\alpha_K(f)) = F([f]) = f_K(f)$, so $F \circ \alpha_K = f_K$ for all fields $K$.
So far we have found that given any cocone to $X$, we have a map from the cocone of $\operatorname{Spec} A$ to the cocone of $X$. All we nee to do now is show uniqueness. Indeed, suppose we had some other $G: \operatorname{Spec} A \longrightarrow X$ that fits into that commutative diagram. Then $G \circ \alpha_K = f_K$ so $f_K(f) = G(\alpha_K(f)) = G([f])$. This is exactly how $F$ was defined, so $F = G$. Once again, this all came to us for free. The hard work was done in the definition you gave.
Now, let's return to the classical definition of $\operatorname{Spec} A$ as the collection of prime ideals. As @WhatsUp pointed out in the comments, the relation between the two is that every prime ideal $\mathfrak p$ of $A$ gives us a map $A \longrightarrow A/\mathfrak p \longrightarrow \operatorname{Frac}(A/\mathfrak p)$, meaning the quotient field of the domain $A/\mathfrak p$. This is often called the residue field of $\mathfrak p$ and is denoted $k(\mathfrak p)$. On the other hand, every map $f: A \longrightarrow K$, $K$ a field, will have $\ker(f)$ a prime ideal by the first isomorphism theorem. These very closely related. $\ker(A \longrightarrow k(\mathfrak p)) = \mathfrak p$ and given $f: A \longrightarrow K$, $k(\ker(f))$ has an embedding into $K$ via extending the inclusion $A/\ker(f) \longrightarrow K$ to the field of fractions. So in particular, this gives us inverse bijections between your $\operatorname{Spec} A$ and the usual prime spectrum. We take $\mathfrak p \mapsto [A \longrightarrow k(\mathfrak p)]$ and $[f] \mapsto \ker(f)$. This is well defined because a map between fields in necessarily an injection and therefore does not affect the kernel. In other words, we can restrict the index diagram from ranging over the entire category of $\mathbf{Fields}$ to ranging over the full subcategory whose objects are the residue fields $k(\mathfrak p)$. This also resolves the set theoretic issue. The colimit over this restricted diagram is the same as the colimit ranging over the entire large category. Since the restricted diagram is small, the set theoretic issues can go away. This idea of restricting to a subdiagram is related to the general notion of a final functor. I think that the subset of the category of open sets of a space consisting of basic open set is another such example, but to be completely honest I'm not too familiar with final functors so please take what I'm saying with a grain of salt.
