Abstracting our abstractions: "limits of cones", universal properties

The last article, Abstracting some categorical definitions, saw the same kind of construction repeated over and over: given some diagram, we'd ask for an object with morphisms to or from that diagram (demanding that the diagram commute) -- such an object would be a "candidate" for our construction, and we'd then ask for the "maximum" or "minimum" among such constructions.

That this notion appears so frequently makes sense. It's really a generalisation of the notions of initial and final topologies, and comes from the notion that an object is defined by its morphisms to or from other objects, and that we're interested in constructions that are unique up to isomorphism.

So consider some diagram in $\mathcal{C}$. As we will later see, this is formally a "functor" (morphism between categories) from an indexing category $\mathcal{I}$ to $\mathcal{C}$ -- denote it as $X:\mathcal{I}\to\mathcal{C}$.
We define a cone to $\mathcal{C}$ as an object $M$ together with morphisms $m_i:M\to X_i$ such that it commutes with the existing diagram (formally, such that for every morphism $f:i\to j$ in $\mathcal{I}$, we have $F(f)\circ m_i=m_j$).
Now this necessarily represents an object with "more information than each $X_i$" -- so we're interested in the "infimum" of these cones, the one with the least information, the one to which there exists a morphism from any other cone. The limsup of cones, if you will:
We define the limit $(L,\ell_i)$ of the diagram to be a cone such that for any cone $(M,m_i)$ to the diagram, $\exists!\ u:M\to L$ such that the diagram commutes, i.e. $m_i=\ell_i\circ u$ forall $i$.
 The above diagram commutes, and the purple morphism is unique.
And the dual notion is also observed, a liminf:
We define a co-cone from $\mathcal{C}$ as an object $\overline{M}$ together with morphisms $\overline{m}_i:X_i\to \overline{M}$ such that it commutes with the existing diagram (formally, such that for every morphism $f:i\to j$ in $\mathcal{I}$, we have $\overline{m}_j\circ F(f)=\overline{m}_i$).
We define the co-limit $(\overline{L},\overline{\ell}_i)$ of the diagram to be a cone such that for any cone $(\overline{M},\overline{m}_i)$ to the diagram, $\exists!\ u:\overline{L}\to \overline{M}$ such that the diagram commutes, i.e. $\overline{m}_i=u\circ\overline{\ell}_i$ forall $i$.
 The below diagram commutes, and the purple morphism is unique.
Alternatively, the limit and colimit may be characterised as the final object in the category of cones and the initial object in the category of co-cones respectively (check that this makes sense).

Examples:
Diagrams captioned by their limits.

(empty diagram)
Limit: final object
Co-limit: initial object

(discrete diagram)
Limit: product
Co-limit: co-product

This answers the difficult cases of the empty product (it's just the final object) and the power (use the constant functor).
(parallel diagram)
Limit: equaliser
Co-limit: co-equaliser

Exercises: Do some examples to convince yourself of the following ideas:
• Even if there are a bunch of morphisms in the diagram, the limit of the diagram talks fundamentally about the product of the "starting" objects of the diagram (think of: $X\rightarrow Y\leftarrow Z$, etc.).
• If your original diagram has non-commuting features, the limit of the diagram talks about equalisers of these features (think of: parallel diagram, reverse-parallel diagram $\leftrightharpoons$, other cycles, a diagram with non-trivial automorphisms).
• Adding commuting stuff doesn't change the limit (i.e. the limit of $X\to Y\to Z$ is the same if you add another morphism $X\to Z$).

Universal objects and comma categories

You may have noticed that images and coimages cannot be written as limits and colimits (do you see why?). We made a fairly specific specialisation when defining limits/colimits that doesn't really have to do with our "limsup/liminf" intuition -- we insisted we had morphisms either from or to the diagram, whereas we could in general have a more complicated property.

In general, instead of dealing with the category of cones, we could deal with some other category (called the comma category) and discuss its initial and final objects instead.

The key insight regarding this generalisation is as follows: one can see the limit as a construction in the category $\mathcal{C}^{\mathcal{I}}$ of diagrams in $\mathcal{C}$ of a certain shape $\mathcal{I}$. The limit object (which is an object in $\mathcal{C}$) can be "upgraded" to that category as the constant diagram (an element of $\mathcal{C}^{\mathcal{I}}$ that maps every node in the diagram shape to the same object in $\mathcal{I}$) (this "upgrading" is called the diagonal functor $\Delta: \mathcal{C}\to\mathcal{C}^\mathcal{I}:=\lambda M.\ (\lambda i.\ M)$) with a morphism to the object of $\mathcal{C}^\mathcal{I}$ we're actually taking the limit of.

So more generally, we can consider some category other than $\mathcal{C}^\mathcal{I}$, and a more general functor than $\Delta$, in order to formalise a more general notion of being a limiting object. We make the following definition:
We define the final morphism from a functor $F:\mathcal{C}\to\mathcal{D}$ to an object $D\in\mathcal{D}$ as a morphism $\ell:F(L)\to D$ such that for any morphism $m:F(M)\to D$, there $\exists!\ u: M\to L$ such that the diagram commutes, i.e. $m=\ell\circ F(u)$.
You may observe that $F$ generalised $\Delta$, $\mathcal{D}$ is the generalisation of the "category of diagrams", and the final morphism generalises the limit (with $L$ being the limit "object" in $\mathcal{C}$). Analogously we define, generalising the colimit:
We define the initial morphism to a functor $F:\mathcal{C}\to\mathcal{D}$ from an object $D\in\mathcal{D}$ as a morphism $\overline{\ell}:D\to F(\overline{L})$ such that for any morphism $\overline{m}:D\to F(\overline{M})$, there $\exists!\ u: \overline{L}\to \overline{M}$ such that the diagram commutes, i.e. $\overline{m}=F(u)\circ\overline{\ell}$.
These terms "final morphism" and "initial morphism" are not to be confused with the morphisms to and from an initial object or a final object, that we defined previously. Typically, these terms are used in neither context -- one simply says "universal morphism" to/from $D$ from/to $F$; and in the previous context, one simply says morphisms to a final object/from an initial object.

In general, these morphisms are referred to as universal morphisms or universal objects.

(By the way: the term "universal property" is just used to refer to the property of being initial or terminal or whatever.)

This notion can easily be restated as follows: given an object $D\in\mathcal{D}$ and a functor $F:\mathcal{C}\to\mathcal{D}$, one can construct the following:
The comma category $[F\to D]$ is a category whose objects are the morphisms $m:F(M)\to D$, and whose morphisms from $m_1\to m_2$ are given by morphisms $u:M_1\to M_2$ such that the diagram commutes, i.e. such that $m_1=m_2 \circ F(u)$.
The cocomma category $[D\to F]$ is a category whose objects are the morphisms $m:D\to F(M)$ and whose morphisms from $m_1\to m_2$ are given by morphisms $u:M_1\to M_2$ such that the diagram commutes, i.e. such that $m_2=F(u)\circ m_1$
Then a final morphism is the final object in the comma category, and an initial morphism is the initial morphism is the initial object in the cocomma category. If $\mathcal{D}=\mathcal{C}^{\mathcal{I}}$ (i.e. is a diagram category) and $F$ is the diagonal functor, then the comma category is the category of cones, and the cocomma category is the category of cocones.

One might dislike the asymmetry between $F$ and $D$ and decide to go a step further, generalising $D$ to another functor. So given two functors $F:\mathcal{A}\to\mathcal{D}$ and $G:\mathcal{B}\to\mathcal{D}$, we can construct:
The comma category $[F\to G]$ is a category whose objects are the morphisms $m:F(M)\to G(N)$ and whose morphisms from $m_1\to m_2$ are given by morphisms $u:M_1\to M_2,\ v: N_1\to N_2$ such that the following diagram commutes:
The previous definition of comma and cocomma categories then occur when $\mathcal{B}$ and $\mathcal{A}$ respectively are replaced by a singleton (and $D$ is the only object in their image in $\mathcal{D}$).

Examples: free group, image