TITLE: Can we take images of equivalence relations?
QUESTION [8 upvotes]: Given a function $f : X \rightarrow Y$, it is well-known that we can take the image under $f$ of any subset $A \subseteq X$, and we can take the preimage under $f$ of any subset $A \subseteq Y$. This is fundamental.
A little less well-known is that we can take the preimage under $f$ of an equivalence relation $\cong$ on $Y$. In particular, we define $f^{-1}(\cong)$ to be the unique equivalence relation $\sim$ on $X$ such that the following holds.
$$x \sim x' \iff f(x) \cong f(x')$$
It is easy to verify that this is indeed an equivalence relation.
Question. If $f : X \rightarrow Y$ is an arbitrary function (so that, in particular, we're not assuming that $f$ is surjective), is it the case that to every equivalence relation $\sim$ on $X$, there is a naturally corresponding equivalence relation $f(\sim)$ on $Y$?
Basically, I can see at least two possible ways of doing this. In one approach, every two elements in $Y \setminus f(X)$ is equivalent; in the other, no two distinct elements in $Y \setminus f(X)$ are equivalent.
But how do we know which is the "correct" definition?

REPLY [4 votes]: One way to think about this question is in terms of the fact equivalence relations are precisely obtained as kernels of maps between sets:
If $X \to S$ is a funcion, then defining $x \sim x'$ iff $f(x) = f(x')$ gives an equivalence relation on $X$, which we might call the kernel of $f$.  Conversely,
if $\sim$ is an equivalence relation on $X$, then it is obtained as the kernel of the canonical morphism $X \to X/\sim$ (the quotient of $X$ by $\sim$, or if you prefer, the set of equiv. classes of $\sim$).
Now suppose given $X \to Y$, and an equiv. rel'n $\sim$ on $Y$ arising as the kernel
of $Y \to S$, then we have the composite $X \to Y \to S$, and its kernel is precisely the pull-back (what you call the preimage, but I would prefer to say pull-back, as in Dori Bejleri's answer) of $\sim$.
Now suppose instead that we have $f:X \to Y$, and a map $X \to S$ defining 
an equiv. rel'n $\sim$ on $X$.  If the map $X \to S$ factors through $f$, then we get
an induced map $Y \to S$, and it would be natural to call the kernel of this map  the push-forward of $\sim$ under $f$. 
Of course, in general this facorization won't be possible, but we can ask
if there is some sort of minimal modification of $S$ (or, better, of $X \to S$),
such that such a factorization is possible.
In other words, we are looking for a canonical set $S'$ equipped with $S \to S'$ and $Y \to S'$, such that the composites $X\to S \to S'$ and $X \to Y \to S'$ coincide.  Such an $S'$ exists; it is the coproduct of $S$ and $Y$ over $X$ in the
category of sets.  Concretely, it is the quotient of the disjoint union $S \cup Y$ by the equivalence relation in which we identify $s \in S$ and $y \in Y$
if they arise as the image of the same element $x \in X$.
The natural map $Y \to S'$ determines an equiv. rel'n in $Y$ (its kernel),
and this is the pushforward of $\sim$ to $Y$.
(You can check that this coincides with the constructions given in the other two answers.  I thought it might be interesting to see a slightly different perspective.)