Prove that $f = g$, given that $f \circ h = g \circ h$ Let $A$, $B$, $C$ be sets, and let $f, g, h$ be functions such that:
$$
h: A \rightarrow B\\
f: B \rightarrow C\\
g: B \rightarrow C
$$
Given that $f \circ h = g \circ h$, prove or disprove that $f=g$ if:
1. $h$ is surjective
2. $h$ is injective
How do I use/incorporate the fact that $h$ is surjective/injective in order to prove that $f=g$?
My attempt at proving (1):
Let $h$ be surjective, therefore for every $b\in B$, there exists $a \in A$ such that $h(a) = b$. Therefore, $f \circ h$ and $g \circ h$ are defined for every $a \in A$.
And given that $f \circ h = g \circ h$, it is true that for every $a \in A \implies f \circ h (a) = g \circ (a)$. Therefore $f = g$.
Edit: My attempt at proving (2):
Let $h$ be injective and not surjective. Therefore there exists $b_1 \in B$ such that for all $a \in A$ $f(a) \neq b_1$.
We will define $f$ such that: $f(b_1) = c_1$, and we will define $g$ such that: $g(b_1) = c_2$.
Therefore $f \neq g$.
 A: Your proof is okay - it certainly gets the right idea, but it's not quite correctly written. Your first sentence is a good idea:

Since $h$ is surjective, for every $b\in B$ there exists an $a\in A$ such that $h(a)=b$.

You then write "therefore $f\circ h$ and $g\circ h$ are defined for every $a\in A$" - but that's not relevant, because these are all (total) functions, so whether or not an expression is defined for every $a\in A$ doesn't depend at all on surjectivity and, indeed, in this context, is assumed by the notation that $f\circ h$ and $g\circ h$ are maps $A\rightarrow C$. You also get the right idea that two functions are equal if and only if all of their evaluations are equal - but you don't apply this to the pair $(f,g)$ of functions.
It's somewhat better to start by thinking about your goal: you want to show $f=g$ which is the same as saying that $f(b)=g(b)$ for all $b\in B$. This is almost always a good starting point if you wish to show functions are equal. It makes it clear how this statement fits together with $h$ being surjective: that lets us pick some $a$ so that $h(a)=b$. Then you can just write

Let $b\in B$ be arbitrary. Note that there exists some $a\in A$ such that $h(a)=b$. Therefore $f(b)=f(h(a))=g(h(a))=g(b)$ where the middle equality follows from the assumption that $f\circ h = g\circ h$. Since $b$ was arbitrary, $f = g$.

It seems like you had the idea of this in mind, but your proof didn't accurately convey it. Note how our path is very explicit here: we showed $f=g$ by showing that $f(b)=g(b)$ for every $b\in B$, which we did via a little algebra involving the substitution $b=h(a)$.
For injectivity, you might just consider why this proof fails - essentially, what you show in the proof is that $f\circ h = g\circ h$ implies that $f$ and $g$ are equal on the image of $h$ - but what if that image isn't all of $B$? What happens if you make the values of $f$ and $g$ disagree off of the image of $h$? (Then, you can distill this into a simple counterexample; you might consider even using the case where $A$ is empty if you're comfortable with that edge case).
It's perhaps worth noting that if $h$ is injective, then $h\circ f=h\circ g$ does imply $f=g$ where $h:B\rightarrow C$ and $f,g:A\rightarrow B$. The proof is very similar in character to the one I show earlier, but you end up doing it in reverse - it's useful to start with noting, for all $a\in A$ that
$$h(f(a))=h(g(a))$$
and then using injectivity of $h$ on that to immediately conclude that $f(a)=g(a)$.
You might also consider what happens if $h\circ f = h\circ g$ for $h$ not injective - where does this go wrong and how can you make a counterexample for it?
A: f and g are mappings with the same domains and codomains. Therefore they are equal iff for all $x$  in $ B$ $f(x)=g(x)$.
Draw a diagram with h as a surjective mapping and realise that the previous equality holds because for any element of $B$ we can always find an element of $A$ that maps to it via $ h $. Use a similiar diagram to find a counterexample in case that $h$ is injective.  
