Formal definition of function composition.

89 Views Asked by At

This is something that is bothering me for a while now.

Suppose we have two functions

$$f: A \to B$$ $$g: B \to C$$

Then the composition is defined by $g\circ f : A \to C: a \mapsto g(f(a))$ and one can write this in a nice commutative diagram.

However, all we actually need is that $f(A) \subseteq B$, so we can define function composition for functions

$$f: A\to B$$ $$g: C \to D$$

where $f(A) \subseteq C$.

The problem is then that we don't really get commutative diagrams, but rather must restrict one of the functions domains/codomains to make things work, or compose with an inclusion map or something like that.

Which definition is preferred?