Prove that if $f(f(x)) = x-1$ then $f$ is bijective I have this statement: 

Let $f: \mathbb{R} \to \mathbb{R},$  and $f(f(x)) = x-1$ prove that $f$ is bijective

My attempt was:
$(1)$ Use the fact that if a composite function $gof$ is bijective then $f$ is bijective. In this case, if $fof$ is bijective, then $f$ is bijective.
First, prove $fof$ is injective. To prove: $f(f(x_1)) = f(f(x_2)) \to x_1 = x_2$
$x_1 -1 = x_2 - 1 \to x_1 = x_2$ and proved.
Second, prove $fof$ is surjective. Using the fact that the codomain of $gof$ is equal to the codomain of $g$, then in this case,  the codomain of $f$ is $\mathbb{R}$ and therefore the codomain of $fof$ is $\mathbb{R}$ and noting that the range of $x -1$ is the same, we can conclude that $fof$ is surjective.
And using $(1)$, i proved that $f$ is bijective.
My teacher told me that my development was wrong and i dont know why. Thanks in advance.
 A: Statement $(1)$ is not necessarily true. If $g\circ f$ is bijective, $f$ is injective but may not be surjective – consider $f:\mathbb R\to \mathbb R,f(x)=e^x$ and $g:\mathbb R\to\mathbb R,g(x)=\ln x$.
But it is also true that if $g\circ f$ is bijective then $g$ is surjective, which allows you to rescue your proof.
A: You are over-thinking the question.Suppose $f(a)=f(b).$ Then $f(f(a))=f(f(b)).$ Thus $a-1 =b-1$ and hence $a=b.$ So $f$ is injective. Let $\alpha \in \mathbb R.$ Then $$f(f(\alpha+1))=(\alpha +1)-1=\alpha.$$
So $f$ is surjective.
A: Hint:
Perhaps your teacher meant that what you say in (1) is false...Try to prove the following:
a) If the composition  $\;f\circ g\;$ is injective, then $\;g\;$ is injective
b) If the composition $\;f\circ g\;$ is surjective then $\;f\;$ is surjective
With the above you must prove at once what you want, which is way more general than the example you have.
A: 1) Injective: 
Let $y= f(a)=f(b)$, then 
$a-1= f(f(a))=f(f(b))=b-1$, $a=b;$
2) Surjective:
Let $y \in \mathbb{R}.$
$f(f(x))=x-1.$
Set $x=y+1$, then $f(f(y+1))=y;$
For $a =: f(y+1):$
$f(a)=y$, and we are done.
