Questions about the definition of a Category

Yes, it may happen that $\operatorname{Hom}_C(X,Y)$ is the empty class.

No, that does not invalidate the part about composition. If $\operatorname{Hom}_C(X,Y)=\emptyset$, then it is vacuously true that for every $f\in \operatorname{Hom}_C(X,Y)$ and $g\in \operatorname{Hom}_C(Y,Z)$, we have a composite morphism $g\circ f$.


An example is the category of fields and field homomorphisms: If two fields have different characteristic, there is no morphism between them.


The axioms just state that there is a mapping

$$ Hom(X,Y) \times Hom(Y,Z) \to Hom(X,Z) $$

but this does not imply that $Hom(X,Y),Hom(Y,Z)$ and $Hom(X,Z)$ are non empty.

Indeed, if any of $Hom(X,Y),Hom(Y,Z)$ are empty, then the domain of the wanted mapping is empty, so we can take the mapping to be the empty set. Indeed, the empty set is a mapping $\emptyset \to A$ for any class $A$. (It is also unique, since no other such mappings exist.)

For a simple counterexample, take the $\bf Set$ category made of sets and functions, and observe that $Hom(\{42\},\emptyset)$ is empty, otherwise we could take a morphism/function $f:\{42\}\to\emptyset$ and have $f(42)\in\emptyset$.

Discrete (poset) categories also provide counterexamples. Take $\{0,1\}$ as objects, and only the two identity morphisms $id_0,id_1$. This makes a category, even if $Hom(0,1)=Hom(1,0)=\emptyset$.

At most, the composition axiom implies that, if $Hom(X,Y),Hom(Y,Z)$ are both non empty, then $Hom(X,Z)$ is also non empty. This is because we can take two morphisms $f\in Hom(X,Y),g \in Hom(Y,Z)$ and compose them as $g\circ f \in Hom(X,Z)$.

$Hom(W,W)$ is always nonempty because of the identity morphism.