Thus, is a constant morphism if the function given by composition with is a constant function for every object .
Another definition that is sometimes used is the following.
If has a terminal object, then is constant iff it factors through this terminal object.
If does not have a terminal object, then we can reformulate this by saying that the image of under the Yoneda embedding, , factors through the terminal presheaf?. In elementary terms, this means that we can choose for each object a morphism such that (1) and (2) the are natural in , i.e. for any we have .
This second definition implies the first, but they are not equivalent in general. In the category of sets, the first implies the second if the set is inhabited, or if the set is empty set and the set is inhabited. (By excluded middle, is either inhabited or empty, so it suffices to assume that is inhabited with no assumption about .)
More generally, if is a morphism in a category , then the two definitions are equivalent if is inhabited for every , since we can then define for some (hence any) . If has a terminal object , then this is equivalent to the existence of a global section .
See the forum for further discussion of this.
The identity morphism on an object satisfies definition 1 if and only if is subterminal; it satisfies definition 2 iff is terminal. In particular, the identity function on the empty set satisfies definition 1 but not definition 2.
Using the two-point set, it is simple to show that the constant morphisms in Set are precisely the constant functions.