In an exercise from a book, I am asked:
Given that $A$ and $B$ are sets, $f: A \rightarrow B$ is a function from $A$ to $B$, $R$ is a relation from $A$ to $B$, and $f$ is compatible with $R$, prove that there is a unique function, $h: A/R \rightarrow B$, such that $\forall x \in A (h([x]_R) = f(x))$
I know the function is $h = \{(X,y) \in A/R \times B: \exists x \in X(f(x) = y) \}$ (the function is given as a hint).
When I initially wrote the proof I did the following. (The 'proof' below is just to establish $h$ is a function, not that $h$ is the unique function.)
Existence: Suppose $X \in A/R$, then $\exists x \in A ([x]_R = X$. Say $[x_0]$ = X. Suppose $b = f(x_0)$. Then since $\forall x \in A (h([x]) = f(x)$, we have that $h([x_0]_R) = f(x_0) = b$. Since $f$ is a function, we know $f(x_0)$ exists. Thus $\exists b(h(X)=b)$.
Uniqueness: Suppose $y\in B$ and $h(X) = y$. Then $h([x_0])=y$. But $h([x_0] = b$ so $b=y$ $\square$
I felt like something was wrong and thinking about it a bit more I'm quite certain I have gone wrong by assuming $h$ is a function, and then proving that $h$ is a function. Basically I think I did what the accepted answer here says I shouldn't do: How do I prove that a function is well defined?.
I thought I could try to just treat $h$ as a relation, and reformulate the proof. The reason I am now quite confused however is that the notation used in the constraint $\forall x \in A (h([x]) = f(x)$ seems to implicitly say $h$ is a function. Basically I am wondering how I can formulate my proof such that I avoid assuming $h$ is a function, while using this constraint? Can I just treat the given statement as $\forall x \in A ((h([x]),f(x)) \in h)$?
Note: I tried to treat the given statement as described in the previous paragraph's last sentence. But I ended up needing to show that $(X,y) = (X,b)$ for both those elements in $h$, having already shown $(X,b) \in h$. But from here I am not sure how to proceed without treating $h$ as a function.