Let $\sim$ be some equivalence relation on $X$. Is there some function with domain $X$ such that $f(x)=f(y)$ exactly when $x\sim y$? 
1. Suppose that $X$ is a set.
a) Let $f$ be some function with domain $X$ (and codomain anything you like), and say that $x \sim y$ means $f(x)=f(y)$. Is $\sim$ an equivalence relation? If it is, then prove it; if not then give a counterexample.
b) Let $\sim$ be some equivalence relation on $X$. Is there some function with domain $X$ such that $f(x)=f(y)$ exactly when $x\sim y$? If there is, then prove it; if not then give a counterexample.

I proved part a, but I don't really understand part b. Wouldn't this be true for any function that exists? Why would someone ask me this question? I think I missed something. Because it seems this is always true.  If $x$ is related to $y$, then we immediately know $f(x) = f(y)$, so of course this would be true for any function. If $x$ is not related to $y$ , then we know for sure $f(x) \neq f(y)$ since if it was the case them, $x$ would be related to $y$ . What am I missing?

The ~ and f for part b are not necessarily the same as part a. The question is asking that for any ~, even if it's not the same as part  a, there exists such an f.
