If $g \circ f$ is one-to-one, is $g$ one-to-one?

Let $f:X\to Y, g:Y \to Z$ be functions. I'm trying to prove that if $g \circ f$ is 1-1, then is $g$ 1-1?

Well the definition of a one-to-one (injective) function is that if $f:X \to Y$ is a function such that each $x \in X$ is related to a different $y \in Y$. I'm not sure what do do about the $g \circ f$ or how to show that that makes $g$ 1-1

What happens if $X=Z=\{1\},$ $Y=\{1,2\}$ and $f:X\to Y$ is defined by $f(1)=1$ and $g:Y\to Z$ is defined by $g(1)=g(2)=1$ ?
This is not true, suppose $f,g:\mathbb{R}\rightarrow \mathbb{R}$, such that $f(x)=e^x$ and $g(x)=x^2$. So $g(f(x))=e^{2x}$ and therefore is $1-1$, but g is not $1-1$.
• $g\circ f$ is not one-to-one, because $(g\circ f)(1)=(g\circ f)(0)$ but $1\neq 0.$ – Balloon Nov 23 '15 at 22:05
• Beware that now $g\circ f$ is injective but not surjective : indeed, as $e^{2x}>0,$ it won't exists $x\in\mathbb{R}$ such as $e^{2x}=-1$ (for example). Actually $g\circ f:\mathbb{R}\to\mathbb{R}^{+*}$ would be one-to-one. – Balloon Nov 23 '15 at 22:18
If $X \stackrel{f}\to Y \stackrel{g} \to Z$ with $g\circ f$ 1-1 then g may not be 1-1: other answers have given counterexamples. However, if $f$ is surjective then $g$ must be 1-1: if $y_1,y_2\in Y$ with $y_1\ne y_2$, then $y_i = f(x_i)$ for some $x_i\in X, i = 1,2$. We must have $x_1\ne x_2$, so $g(f(x_1))\ne g(f(x_2))$ — that is, $g(y_1)\ne g(y_2$.