Suppose $f: A\rightarrow B,g:B\rightarrow C, h:B\rightarrow C$. Pro that If $f$ is onto $B$ and $g\circ f$= $h\circ f$, then $g=h$ Suppose that $f: A\rightarrow B,g:B\rightarrow C, h:B\rightarrow C$.
Prove that If $f$ is onto $B$ and  $g\circ f$= $h\circ f$, then $g=h$
Could anyone please give some guideline on how to solve this proof. Thanks
 A: Here is my attempt and logic on how I would solve this problem. Please bear with me since I'm just giving an educated guess on how to solve it. Thanks.
Based on the definition of 
$g\circ f$: $(x,z)\in A\times C$| $\exists y \in B$ s.t $f(x)=y$ and $g(y)=z$
I can gather that there must be elements $(y,z)\in g$ which also should be in $h$.
Then my proof would start like this:
Let $(y,z) \in g$
Since $f$ is onto $B$, then $\exists x \in A $ s.t $(x,y) \in f$
Now there must be $(x,z) \in g\circ f$
Since $g\circ f$ = $h\circ f$
then $(x,z) \in h\circ f$
So, $ \exists w \in B$ s.t $(x,w) \in f$ and  $(z,w) \in h$
Then $f(x)=y$ and $f(x)=w$
So $y=w$
Therefore $h(y)=z$ , so $(y,z) \in h$
A: Note that given $g,h$ with the same domain $B$, then $g=h$ if and only if $g(b)=h(b)$ for every $b\in B$.
Now consider any $b\in B$, by surjectivity of $f$ there is some $a\in A$ such that $f(a)=b$. Therefore $g(b)=(g\circ f)(a)=(h\circ f)(a)=h(b)$. This is true for an arbitrary $b$, and therefore for all of them.

As a nice exercise, I leave you to find a counterexample for when $f$ is not surjective.
