Sets: Categorical Viewpoint
1. Set-functions. Let \(X\) and \(Y\) be sets. If \(f\) is a function from \(X\) to \(Y\), we draw
2. Composition of functions. Let \(f\colon X\to Y\) and \(g\colon Y\to Z\) be given. If \(g \circ f\colon X\to Z\) is the composite of \(f\) and \(g\), we may draw diagrams such as
and say that the diagrams commute. Generally, saying that a diagram commutes means that whenever two directed paths share the same source and target, the composition of the functions along both paths yields the same result. It is evident from the definition of composition that composition is associative. That is, if \(f\colon X\to Y, g\colon Y\to Z\), and \(h\colon Z\to W\) are functions, then \(h\circ(g\circ f) = (h\circ g)\circ f\); the diagram
commutes. The identity function is very special with respect to compositions. For any function \(f\colon X\to Y\), the diagrams
commute.
3. Surjectivity and injectivity. Let \(f\colon X\to Y\) be a function. A function \(g\colon Y\to X\) is called a left-inverse of \(f\) if \(g\circ f = \mathrm{id}_X\); the following diagram commutes:
A function \(h\colon Y\to X\) is called a right-inverse of \(f\) if \(f\circ h = \mathrm{id}_Y\); the following diagram commutes:
If a function from \(Y\) to \(X\) is both a left-inverse and right-inverse of \(f\), then it is called the inverse of \(f\).
Proposition 1. Let \(X\ne \varnothing\), and let \(f\colon X\to Y\) be a function.
- The function \(f\) is injective if and only if it has a left-inverse.
- The function \(f\) is surjective if and only if it has a right-inverse.
4. Cartesian product.