Prove: If $(g \circ f)$ is bijective, is $f$ bijective? I need to prove or disprove for a discrete mathematics assignment the following statement:
$(g \circ f)$ is bijective $\rightarrow$ $f$ is bijective, $f: X \rightarrow Y$ $\hspace{.5cm} g:Y\rightarrow Z$
All of the domains and codomains here are supposed to be the real numbers.
I'm having a hard time understanding how to prove things about functions, which we just got into.
I assume that I need to break this into two cases, those cases being to prove or disprove:

*

*$(g \circ f)$ is injective $\rightarrow$ $f$ is injective


*$(g \circ f)$ is surjective $\rightarrow$ $f$ is surjective
I've been playing around with drawing different circle diagrams for $X$, $Y$ and $Z$. For $f(x)$, I drew diagrams where $|X|$ < $|Y|$, where $|X|$ = $|Y|$, and where $|X|$ > $|Y|$, and for $g(f(x))$, I did the same for $Y$ and $Z$.
It appears to me that when $(g \circ f)$ is surjective, $f$ is not necessarily surjective, because you could draw the functions out like this:

This makes sense to me as a counterexample, but I'm not sure if that's right.
Next, as for $f$ being injective when $(g \circ f)$ is injective, I found a proof (see problem 3.3.7 part a at the top of the first page) that explained that this is true, but I didn't really understand the explanation. Also, when I drew it out myself trying to find an example for which it would be false, I found this:

And it seems to me to show that when $(g \circ f)$ is injective, $f$ is not necessarily injective, but that contradicts the proof that I found online.
The only two possibilities are that the proof I found was wrong, or that I'm drawing these functions and sets incorrectly and breaking some rule(s) that I'm unaware of.
Any insight into what I'm doing wrong with my drawings, my logic, or into how to go about correctly solving this problem would be hugely appreciated. Thank you all.
 A: Neither diagram works properly.  For the first, $g \circ f$ is not surjective as the middle element of $Z$ is not the image of any element of $X$.  This can be patched up by deleting the middle element of $Z$ and sending the middle element of $Y$ to one of the other two elements of $Z$.  For the second, $g \circ f$ is not injective as $x_1$ and $x_2$ map to the same element.  It is true that if $g \circ f$ is injective then $f$ must be.  If $f$ maps two elements to the same element of $Y$, $g \circ f$ must necessarily map them both to the same element of $Z$.
A: Suppose $f:X \rightarrow Y$, $g: Y \rightarrow Z$.
If $(g \circ f)$ is bijective the only things we can conclude are 


*

*$g$ is surjective. For suppose $z \in Z$ is arbitrary. Then as $(g \circ f)$ is bijective, so surjective, there exists an $x \in X$ with $(g \circ f)(x) =z$.
But the latter means by definition that $g(f(x)) = z$, so take $y=f(x) \in Y$, then $g(y) = z$. So any $z \in Z$ is an image of $g$, so $g$ is surjective.

*$f$ is injective. Suppose that $f$ is not injective. This means that there are different $x_1, x_2 \in X$ with $f(x_1) = f(x_2)$. But then 
$$(g\circ f)(x_1) = g(f(x_1))  =g(f(x_2)) = (g \circ f)(x_2)$$
Which shows that $g\circ f$ is not injective ,so not bijective, contradiction. So $f$ is injective. 
The conditions 1,2 are necessary for $g \circ f$ to be bijective but not sufficient:
If $f$ is the identity on $X= Y = \{1,2,3\}$ and $g$ is the constant map to $Z = \{0\}$, then $g$ is surjective, $f$ is injective but $g \circ f$ is not bijective.
And if we take $X =Z = \{0,1\}, Y = \{0,1,2\}$, $f$ the identity ($f(0) = 0, f(1) =1$, and $g(0) = 0, g(1) = 1, g(2) = 1$,then $f$ is no bijection while $g \circ f$ is. 
A: Your first diagram doesn't have $g\circ f$ surjective, so it's not bijective a fortiori. In the second diagram, $g\circ f$ is not injective.

Keep it simple, at least at first. If things don't work, you can always go for bigger examples.
Let $f\colon\{0\}\to\{1,2\}$ be defined by $f(0)=1$; let $g\colon\{1,2\}\to\{3\}$ be the unique map.
Then $g\circ f\colon\{0\}\to\{3\}$ is obviously bijective.
Thus there's no way you can prove that $g\circ f$ surjective implies $f$ surjective. (It is true that, if $g\circ f$ is surjective, then $g$ is surjective, though.)
The same maps prove that $g\circ f$ injective doesn't imply $g$ is injective.
