Definition
Composition (Function)
Let
and be functions. Their composition is First apply
to , then apply to the result. The rightmost function is applied first, and the output of must be a valid input to . Several inner functions
Let
and . Combining the inner outputs into a tuple defines All inner functions receive the same input
; their outputs become the arguments of . This is the composition rule used for primitive-recursive functions.
Identity and Associativity
The identity function
For
Parentheses do not change the result, but the order generally does:
Injectivity and Surjectivity
For
An injective composition cannot recover distinctions lost by
Consequently, if both functions are injective, their composition is injective; if both are surjective, their composition is surjective. Conversely, injectivity of
Example
Order matters
Let
and on . Then
Only the intermediate image matters
Let
be , and let be . Then The composition is the identity on
, hence both injective and surjective. Yet is not injective, since , and is not surjective onto , since it never returns a negative integer.