Prove $ g \circ f = f \circ f $ and f is surjective $ \Rightarrow f = g $ I want to prove $ g \circ f = f \circ f  $ and f is surjective $ \Rightarrow f = g $. $ f,g: A \to A$.
Here is what I tried to do:
Assume $ f \ne g $ ans therefote, because $ Domain(f) = Domain(g) $ and $ Range(f) = Range(g) $, then thete exists $ x \in A $ such that $ f(x) \ne g(x) $.
$ f $ is surjective and therefore, there exists $ m \in A $ such that $ f(m) = g(x) $. Hence, $ g(f(m)) = f(f(m)) $, which means $ g(g(x)) = f(g(x)) $.
But K don't know what I should do from here.
 A: It is nice and direct to make use of the hint in the comment of @lulu.

But let me add the following theorem:
$$\text{ a function }f:X\to Y\text{ is surjective iff a function }s:Y\to X\text{ exists with: }f\circ s=\mathsf{id}_Y$$
The surjectivity of $f:X\to Y$ makes it possible to construct such a function $s:Y\to X$  by choosing (AC is needed here) for every $y\in Y$ an element $s(y)$ in the non-empty set $f^{-1}(\{y\})$.
If conversely $f\circ s=\mathsf{id}_Y$ and $y\in Y$ then $f(s(y))=y$, showing surjectivity.

In your case we can make use of this and find:$$f=f\circ\mathsf{id}_A=f\circ (f\circ s)=(f\circ f)\circ s=(g\circ f)\circ s=g\circ(f\circ s)=g\circ\mathsf{id}_A=g$$
A: In general we have a map $f:A\to B$ is surjective if and only if for any maps $g,h:B\to C$, $g\circ f=h\circ f$ implies $g=h$. In fact, suppose $f$ is surjective, and $g\circ f=h\circ f$. If $g\neq h$, then there exists $b\in B$ such that $g(b)\neq h(b)$, since $f$ is surjective there exists $a\in A$ such that $f(a)=b$, so $g(f(a))=h(f(a))$ wich means that $g(b)= h(b)$, contradiction. Conversely, assume that for any maps $g,h:B\to C$, $g\circ f=h\circ f$ implies $g=h$. Suppose $f$ is not surjective then there exists $b_{0}\in B$ such that for any $a\in A$, $f(a)\neq b_0$. Define the map $g:B\to B$ to be the constant map at $b_{0}$ and the map $h:B\to B$ by $h(f(a))=b_{0}$ for any $a\in A$ and $h(b)=b_{1}\neq b_{0}$ for any $b\notin f(A)$. Then it is clear that $g\circ f=h\circ f$ wich implies that $g=h$, Contradiction.
