Show that if $g \circ f = \tilde{g} \circ f$ and $f$ is surjective, then $g=\tilde{g}$. Is the same statement true if $f$ is not surjective Proof of the first part of the question :
Given $g \circ f = \tilde{g} \circ f$ and $f$ is surjective.
To prove $g=\tilde{g}$.
=> $f$ is surjective, which implies for every $y∈Y, ∃x∈X$, such that $f(x)=y$
=> $g∘f =\tilde{g}∘f⟹g∘f(x) =\tilde{g}∘f(x)⟹g(f(x))=\tilde{g}(f(x))⟹g(y)=\tilde{g}(y)$
=> from definition of "Equality of Set" since $g(y)=\tilde{g}(y)$, hence $g =\tilde{g}$.
 A: Your proof for the first part is good. The statement is no longer true if $f$ is not surjective. For example, put $f, ~g, ~\tilde{g}:\mathbb R \to \mathbb R$ by $f(x)=0$, $g(x)=x$ and $\tilde{g}(x)=x^2$. Then $g \neq \tilde{g}$ but $g \circ f$ and $ \tilde{g}\circ f$ are same because $(g \circ f)(x) = 0 = (\tilde{g}\circ f)(x)$ for all $x \in \mathbb R$.
A: It is not necessarily true. Let $I = \{1,2,3\}$ and take for example $
f,g,\tilde{g} \colon I \to I$ such that
\begin{alignat*}{3}
f(1)=1 & \quad  f(2)&&=2 \quad  f(3)&&=2 \\
g(1)=2 &\quad  g(2)&&=2 \quad  g(3)&&=3 \\
\tilde{g}(1) =2 &\quad  \tilde{g}(2)&&=2 \quad  \tilde{g}(3)&&=1.
\end{alignat*}
Then $f$ is not surjective,
\begin{align*}
g(f(1)) & = g(1) = 2,\\
g(f(2)) & = g(2) = 2, \\
g(f(3)) & = g(2) = 2,
\end{align*}
and
\begin{align*}
\tilde{g}(f(1)) & = \tilde{g}(1) = 2,\\
\tilde{g}(f(2)) & = \tilde{g}(2) = 2, \\
\tilde{g}(f(3)) & = \tilde{g}(2) = 2,
\end{align*}
so $g\circ f = \tilde{g}\circ f$, but $g \neq \tilde{g}$.
A: The other two answers haven't tackled the general case. So here it is.
In general, if $Y$ is the codomain of $f$ and there is a $y\in Y$ that is not in the image of $f$, then $g\circ f=\tilde g\circ f$ says nothing about whether $g(y)=\tilde g(y)$. Thus if $f$ is not surjective, we can never conclude $g=\tilde g$ without more information of some kind.
Your proof in the case where $f$ is surjective is fine.
Also note that there is a completely dual property for injectivity. If we have $f\circ g=f\circ \tilde g$, then in an entirely analogous way, $f$ being injective lets us conclude that $g=\tilde g$, and if $f$ is not injective we can find a similar "lack of information" as in the not-surjective case that stops us from concluding.
