Hom-functor preserves pullbacks I am trying to prove that the hom-functor $\mathrm{Hom}(A,-)$ preserves pullbacks.
I stuck at showing uniqueness. Could you please give me some hints?
 A: Consider some pullback $X \times_S Y$ in a category. In order to show that $\hom(A,-)$ preserves it, we have to show that the natural map
$$\hom(A,X \times_S Y) \to \hom(A,X) \times_{\hom(A,S)} \hom(A,Y)$$
is an isomorphism. By construction of pullbacks in $\mathsf{Set}$, the right hand side is simply the set of pairs of maps $A \to X$ and $A \to Y$ such that the diagram
$$\begin{array}{c} A & \rightarrow & X \\ \downarrow && \downarrow \\ Y & \rightarrow & S \end{array}$$
is commutative. Hence, the map is bijective by definition of a pullback!
A: Let's assume you're working in $_R \text{Mod}$. In this case $\text{Hom}(X, \square)$ is a functor from $_R \text{Mod} \to \text{Ab}$. Prove this if you don't have it at your disposal.
Define $T := \text{Hom}(X, \square)$ where $X$ is an $R$-module.
Lemma: Let $f : B \to A$ and $g : C \to A$ be a diagram in $_R \text{Mod}$. It's pullback exists and a concrete construction is $(D, \alpha, \beta)$ where $D = \{(b, c) \in B \oplus C : fb = gc \}$, $\alpha : D \to C$ is defined by $(b, c) \mapsto c$ and $\beta : D \to B$ is defined by $(b, c) \mapsto b$.
Proof: Exercise.
Now let $f : B \to A$ and $g : C \to A$ be a diagram in $_R \text{Mod}$. By the lemma above, it's pullback exists and we can call it $(D, \alpha, \beta)$ defined as above. We want to show that $T(D)$ is a pullback in $\text{Ab}$ of $Tf : TB \to TA$ and $Tg : TC \to TA$. Since $\text{Ab} = _\mathbb Z \text{Mod}$, we also know a concrete construction of the pullback of $Tf, Tg$: call it $D' = \{(b', c') \in TB \oplus TC : (Tf)b' = (Tg)c'\}$.
We'll now use the universal property of the pullback: observe that $T\alpha : TD \to TC$ and $T\beta : TD \to TB$ are such that $Tf \circ T\beta = T(f \circ \beta) = T(g \circ \alpha) = Tg \circ T\alpha$ (as by construction of $D$ as the pullback of $f, g$ we have $f \circ \beta = g \circ \alpha$). Thus by definition of pullback, there exists a unique morphism $\theta : TD \to D'$ such that $\beta' \circ \theta = T\beta$ and $\alpha' \circ \theta = \alpha$.
Let's define $\psi : TD \to D'$ by taking $\big(h : X \to D \big) \in TD = \text{Hom}(X, D)$ and mapping it to $(\beta \circ h, \alpha \circ h) \in TB \oplus TC$. Is this well-defined? i.e., is $(\beta \circ h, \alpha \circ h)$ actually in $D'$? Well, it suffices to show that $(Tf)(\beta \circ h) = (Tg)(\alpha \circ h)$. Observe that $$T(f)(\beta \circ h) = f_*(\beta \circ h) = f \circ \beta \circ h = g \circ \alpha \circ h = g_* (\alpha \circ h) = (Tg) (\alpha \circ h)$$ as desired. (again, here we use that $f \circ \beta = g \circ \alpha$). Notice that if we have $h \in TD$, then $$\beta' \circ \psi (h) = \beta' (\beta \circ h, \alpha \circ h) = \beta \circ h = \beta_* (h) = (T\beta)(h)$$ which means $\beta' \circ \psi = T\beta$, and similarly $\alpha ' \circ \psi = T\alpha$.
We can conclude, by uniqueness of $\theta$ from the universal mapping property, that $\theta = \psi$. Now, it suffices to show that $\psi$ is an isomorphism.
$\theta$ is injective: Suppose that $\theta(h) = (0, 0)$. This means that $\alpha \circ h = 0$ and $\beta \circ h = 0$. Pick $x \in X$ and say $h(x) = (c, d) \in D$. Observe that $\alpha \circ h(x) = c = 0$ and $\beta \circ h(x) = b = 0$. Conclude that $h(x) = (0, 0)$. By arbitrariness of $x$, conclude that $h = 0$ and hence $\theta$ is injective.
$\theta$ is surjective: Pick $(b', c') \in D'$ which means $b' \in \text{Hom}(X, B)$ and $c' \in \text{Hom}(X, C)$ with the property that $f \circ b' = g \circ c'$. Now we use the universal mapping property of the pulback of $f, g$ that there exists a unique morphism $h : X \to D$ such that $\beta \circ h = b'$ and $\alpha \circ h = d'$. It is immediate that $\theta(h) = (\alpha \circ h, \beta \circ h) = (b', c')$ and hence $\theta$ is surjective.
Conclude that $\theta$ is an isomorphism and thus $\text{Hom}(X, \square)$ preserves pullbacks.
If your $\text{Hom}$ functor wasn't necessarily from $_R \text{Mod}$ to $\text{Ab}$, this approach might still be salvageable.
