Right adjoint of forgetful functor from slice category $\mathbf{C}/X$ to $\mathbf{C}$

If $$U : \mathbf{C}/X \to \mathbf{C}$$ is the forgetful functor and $$\mathbf{C}$$ has binary products then I want to find the right adjoint of $$U$$.

Here is what I have so far:

I will define $$F : \mathbf{C} \to \mathbf{C}/X$$ by $$F(C) = \pi_1 : X \times C \to X$$ and I want to show that $$F$$ is the right adjoint of $$U$$.

I know that a characterization of $$F$$ being right adjoint to $$U$$ is that for any $$f : C \to X$$ in $$\mathbf{C}/X$$ and any $$C^\prime$$ in $$\mathbf{C}$$ there is an isomorphism $$\phi : \text{Hom}_\mathbf{C}(U(f : C \to X),C^\prime) \to \text{Hom}_{\mathbf{C}/X}(f : C \to X, F(C^\prime))$$ that is natural in both $$f : C \to X$$ and $$C^\prime$$. In this case $$\phi$$ is equivalent to $$\phi : \text{Hom}_\mathbf{C}(C,C^\prime) \to \text{Hom}_{\mathbf{C}/X}(f : C \to X, \pi_1 : X \times C^\prime)$$.

For any $$g \in \text{Hom}_\mathbf{C}(C,C^\prime)$$ there is a unique $$\langle f,g \rangle : C \to X \times C^\prime$$ such $$\pi_1 \circ \langle f,g \rangle = f$$ and $$\pi_2 \circ \langle f,g \rangle = g$$ by the UMP for products. Define $$\phi(g) = \langle f,g \rangle$$. Then $$\phi$$ is surjective since for each $$h \in \text{Hom}_{\mathbf{C}/X}(f : C \to X, \pi_1 : X \times C^\prime)$$ we have that $$\pi_2 \circ h : C \to C^\prime$$ is in $$\text{Hom}_\mathbf{C}(C,C^\prime)$$ and is mapped to $$h$$ by $$\phi$$. Also, $$\phi$$ is injective since $$\phi(g) = \phi(h)$$ implies that $$\langle f,g \rangle = \langle f,h \rangle$$ and it follows that $$g = \pi_2 \circ \langle f,g \rangle = \pi_2 \circ \langle f,h \rangle = h$$. Therefore, $$\phi$$ is an isomorphism.

I now need to show that $$\phi$$ is natural in $$f : C \to X$$ and $$C^\prime$$. I am not sure what this means. I know what a natural isomorphism is, but not what it means for an isomorphism to be natural in an object. What conditions must hold for $$\phi$$ to be natural in $$f$$ and $$C^\prime$$? Any help is much appreciated.

The idea is not being natural in an object but on an input. So when you fix an input of $$\phi : \text{Hom}_\mathbf{C}(U(f : C \to X),C^\prime) \to \text{Hom}_{\mathbf{C}/X}(f : C \to X, F(C^\prime))$$ what you get is a natural. In other words, the map $$\phi_1 : \text{Hom}_\mathbf{C}(U(f : C \to X),-) \to \text{Hom}_{\mathbf{C}/X}(f : C \to X, F(-))$$ is natural (whenever you have a morphism $$C'\to C''$$ you get the usual commutative diagram between $$\phi_1(C')$$ and $$\phi_2(C'')$$). And similarly on the second input, i.e. the map $$\phi_2 : \text{Hom}_\mathbf{C}(U(-),C') \to \text{Hom}_{\mathbf{C}/X}(-, F(C'))$$ is natural.
Indeed you can do both inputs at once if you consider $$\text{Hom}$$ to be a functor from the product category (also called bifunctor) so that a morphism between $$(f:C\to X, C')\to (f'':C''\to X, C''')$$ is just a pair of morphisms, each component corresponding to a component of these pairs. This way you get that $$\phi : \text{Hom}_\mathbf{C}(U(-),-) \to \text{Hom}_{\mathbf{C}/X}(-, F(-))$$ is natural.
• I'm not sure I follow sorry. I think what you are saying is that for naturality in $f$, we require that the following diagram commutes diagram. But, what would the arrows between the Hom sets be? Commented May 12, 2021 at 10:15
• The usual ones. If $f:C'\to C''$ is an arrow, then you have an arrow $\hom(C,f):\hom(C,C')\to \hom(C,C'')$ given by $g\mapsto f\circ g$. Similarly if you fix the second argument but reversing the composition. If you don't fix any of them, as I said, it is just one of these maps for each component.