How do equivalence classes and functions relate?
We can associate to each element of a set its equivalence class under an equivalence relation. Let $X$ denote a set and $R$ an equivalence relation. We call the function $f: X \to X/R$ defined by $f(x) = x/R$ the canonical map from $X$ to $X/R$.
Conversely, if $f$ is an arbitrary function from $X$ onto $Y$, we can naturally define an equivalence relation $R$ in $X$ so that for $a, b \in X$, $a\,R\,b \iff f(a) = f(b)$ $f$ was onto, so for each $y \in Y$, there exists an $x \in X$ with $f(x) = y$. Now let $g: Y \to X/R$ be defined by $g(y) = x/R$. The values of $g$ are the subset $X$ which are mapped to the same value under $f$. Moreover, the function $g$ is one-to-one.