The notion of a constant morphism in a category generalises the notion of constant function.
A constant morphism in a category is a morphism with the property that if are morphisms in then . In other words, for every object , at most one morphism from to factors through .
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.
A morphism in a category is constant if, for every object , exactly one morphism from to factors through . Assuming that has a terminal object, is constant iff it factors through this terminal object.
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. More generally, if is a morphism in a category , then the two definitions are equivalent if is inhabited for every . 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.
Using the two-point set, it is simple to show that the constant morphisms in Set are precisely the constant functions.