Resources on function factoring From time to time I come across statements like (not verbatim) "...function $f$ can be decomposed into surjection $g$ followed by injection $h$..." or "...by canonical decomposition..." or something to that effect. My question is if there's one (nice) place (books, websites) that has a collection of main elementary theorems and definitions about this topic? My own exposure to set theoretic functions is just the elementary stuff that usually precedes elementary real analysis books.  I am guessing this is a bit more advanced (naive) set theory. And/or category theory. Either way, I only want familiarity with a few theorems related to the topic of decomposing a function into a bunch of injections, surjections and isomorphisms just to get the gist of what it is about. Thanks.
 A: This particular issue is not particularly advanced. If you have a function $f: X  \to Y$ you start by partitioning the domain $X$ as a union of the subsets on which $f$ is constant. Let $Z$ be the set of those subsets. Then there is a natural surjection  $\pi: X \to Z$ that maps each $x \in X$ to the block it's in. Then there's a natural injection $g: Z \to Y$ that maps each block to the common value of $f$ on that block. Then $f = g \circ \pi$.
This general scheme is discussed under labels like "equivalence relation" and "partition". You can read about it at wikipedia: https://en.wikipedia.org/wiki/Equivalence_relation#Equivalence_class,_quotient_set,_partition.
For example, let $$X = \{a,b,c,d\},$$
$$Y = \{r,s,t\}$$
and suppose 
$$f(a) = f(b) = f(c) = r,$$
$$
f(d) = s.
$$
This function is neither injective nor surjective.
Then let
$$
Z = \{\{a,b,c\}, \{d\}\}.
$$
Finally
$$\pi(a) = \pi(b) = \pi(c) = \{a,b,c\},$$
$$\pi(d) = =\{d\}
$$
and
$$
g(\{a,b,c\}) = r,$$
$$
g(\{d\}) = s.$$
Clearly $\pi$ is surjective, $g$ is injective and they compose to give $f$.
