Understanding Hom functions

I am very new to category theory. Started learning about this Hom sets/functions. I read $\operatorname{Hom}(S,T)$ as set of all functions from $S$ to $T$ but somehow this is a overloaded definition where $\operatorname{Hom}(S,T)$ is a function if $T$ is a function. I don't get that.

More over how is $\operatorname{Hom}(S,f)(g) = f \circ g$? How $f$ is injective if $\operatorname{Hom}(S,f)$ is injective?

I tried googling but it seems way too complicated.


Solution 1:

$\operatorname{Hom}(S,-)$ is more accurately a functor from some category (say, to simplify matters, Sets) to Sets. This means that it's both a "function" that takes a set and gives you back a set, and also a "function" that takes a morphism of sets (a function) and gives you back a morphism of sets. In this case, the functor $\operatorname{Hom}(S,-)$ takes a set $T$ and gives you back the set $\operatorname{Hom}(S,T)$ of functions between $S$ and $T$, and it takes a function $f:T\rightarrow U$ and gives you back a function $\operatorname{Hom}(S,f)=f\circ -:\operatorname{Hom}(S,T)\rightarrow \operatorname{Hom}(S,U)$.

To answer a comment below, you can be more visual by drawing the following commutative triangle:

$$ \begin{array}{cccc} & S & & \\ g& \downarrow & \searrow \\ & T & \xrightarrow{f} & U\\ \end{array} $$

Here the mapping $\operatorname{Hom}(S,f)$ takes as input the vertical arrow $g:S \to T$ and "pushes it forward" to the diagonal arrow to its right, which is just the composition $f \circ g$.

To answer your second question, $\operatorname{Hom}(S,f)$ being injective means that for any pair of mappings $g,g':S\rightarrow T$, we have that $f\circ g = f \circ g' \implies g = g'$. In other words, it means that $f$ is left-cancellative, which means exactly that $f$ is injective (in the category of sets).

Note that a dual construction gives you a functor $\operatorname{Hom}(-,T)$, which is contravariant. This means that this functor reverses arrows: if you feed it a function $f:S\rightarrow U$, it gives you back a function $-\circ f:\operatorname{Hom}(U,T)\rightarrow \operatorname{Hom}(S,T)$.