How to exactly write down a proof formally (or how to bring the things I know together)? I've always had trouble with this: I know everything I need to know but I can't connect everything I know in the way it's being wanted from me.
This is what I have to do:

Prove for $f : M → N$ the following statement.$f$ is surjective if and only if the following is true: If $g, h: N → L$ are any functions with $g ∘ f = h ∘ f$, then $g = h$ applies.

The thing is, I am pretty sure I know what they want from me, but I have no idea how to show it. This is what I know:

$f: x ∈ M → f(x) ∈ N$$g: f(x) ∈ N → g(f(x)) ∈ L$  $h: f(x) ∈ N → h(f(x))∈L$  and of course:  $f$  is surjective when: $∀y ∈ N ∃ x ∈ M : f(x) = y$

Pretty simple, but I don't know if it is necesary to write this down. I continue:

$f$ is surjective if: $g ∘ f = h ∘ f $$⇔ g(f(x)) = h(f(x))$$⇔g(y) = h(y)$ would this be enough prove about that $g = h$ part?

I'm not even sure if this is going to the right direction, because I'm afraid I don't even know if I know what I am doing.
I'm open to every kind of help, because this is something I want to apply to all the proves of this kind.
 A: Since this is an "if and only if" kind of proof, slow down and try to write down both implications one at a time. Try to understand every step. For example:
Let's show that $f$ surjective implies the other thing. Assume that $g \circ f = h \circ f$. This means that for any element $m \in M$, $g(f(m)) = h(f(m))$. We need to show that for any element $n \in N$, we have $g(n) = h(n)$. But $f$ is surjective, so any $n$ has a preimage $m$: $$\exists m: n = f(m)$$ Thus we in fact have $g(n) = g(f(m)) = h(f(m)) = h(n)$, as required!
Can you try to do the other direction?
Here's what you have to do: assume that $g \circ f = h \circ f \implies g = h$. Now, take any element $n \in N$, and show that there exists a $m \in M$ such that $f(m) = n$.
Edit: This last part is perhaps the less straightforward of the two, so let's see if I can be a little more helpful. Assume on the contrary that $f$ is not surjective. Thus, there exists $n_0 \in N$ that possesses no preimage. Now, take $L = \{a,b\}$, any two-element set. Set $g(n) = a$, and
$$ h(n) = \begin{cases}a & n \neq n_0 \\ b & n = n_0 \end{cases}$$
Now can you find a contradiction?
A: You have to prove:
$$(f\mbox{ surjective})\Leftrightarrow(\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h)$$
Which actually means:
$$\left\{\begin{array}{cc}(f\mbox{ surjective})\Rightarrow(\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h) && (1) \\ (\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h) \Rightarrow (f\mbox{ surjective}) && (2)\end{array}\right.$$
What you wrote is actually already the proof of $(1)$ so you only need to prove $(2)$ now.
If you don't know how to put the pieces together, you should first write on a piece of paper the first line of the proof (what you start from), skip some lines and then write what you want to get to. In your case:
$$\begin{array}{cc}\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h \\ \Rightarrow\cdots \\ \Rightarrow\cdots \\ \Rightarrow\cdots\\ \Rightarrow f\mbox{ surjective}\end{array}$$
Now what you have to do is obviously try and fill in the $\cdots$.
To do this, try and write what the first line tells you and also try to write what the last line can come from.
Example:
$$\begin{array}{cc}\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h \\ \Rightarrow\forall y\in N,\space g(y)=h(y) \\ \Rightarrow\cdots \\ \Rightarrow\cdots \\ \Rightarrow\forall y\in N,\space\exists x\in M\mbox{ s.t. }f(x) = y \\ \Rightarrow f\mbox{ surjective}\end{array}$$
By doing this, eventually you'll narrow down the gap between the start and the end of your proof and it'll be easier for you !
Now use this to prove $(2)$ and tell us if you still have problems doing so ;)
Hints:

*

*If you have something like for example $\forall (g,h)\in L^N\mbox{ s.t. }g\circ f=h\circ f,\space g=h$ in your first line you might want to write it this way:


Let $(g,h)\in L^N$ be two functions such that $g\circ f=h\circ f$
$$\begin{array}{cc}\Rightarrow g=h \\ \Rightarrow\cdots \\ \Rightarrow\cdots\end{array}$$

Or you could even skip the first line as such:

Let $(g,h)\in L^N$ be two functions such that $g\circ f=h\circ f$
$$\begin{array}{cc}\Rightarrow\cdots \\ \Rightarrow\cdots\end{array}$$

The idea is just to transform $\forall\cdots$ in something like "Let ... be" or "Denote ...". And to replace $\exists x\mbox{ s.t.} P$ by writing an explicit $x$ which will verify the property $P$. This way it's easier to write down your proofs, you have less to worry about.
