a problem on composition of functions Let $f \colon A \to A$ be a function such that $f \circ f=f$.  If $f$ is one-to-one then prove that $f$ is also onto. 
I know in my head that the func. $f$ is $f(x)=x$, but I can't develop a proof for the above statement.
 A: What I like about this problem is that it places no restriction on the carinality  $A$; its conclusion binds for some very large sets indeed.
Suppose $f$ is not surjective, and let
$B = f(A) \tag 1$
be the image of $A$ under $f$; since
$f \circ f = f, \tag 2$
it is clear that every element of $B$ is fixed under $f$, for
$b \in B \Longrightarrow \exists c \in A, \; b = f(c) \Longrightarrow f(b) = f(f(c)) = f(c) = b; \tag 3$
furthermore, for $c \in A$,
$f(c) = c \Longrightarrow c \in B; \tag 4$
thus $B$ is precisely the set of fixed points of $f$.
We have assumed $f$ not surjective; then by the above we have
$B \subsetneq A, \tag 5$
which implies
$\exists a \in A \setminus B; \tag 6$
if
$b = f(a) \in B, \tag 7$
then
$f(b) = f(f(a)) = f(a) = b; \tag 8$
we note 
$B \ni b \ne a \in A \setminus B, \tag 9$
which contradicts the given hypothesis that $f$ is an injective map.  Thus $f$ is in fact surjective.
A: We know
$f\circ f=f$ so $f([f(x)]) =f (x)$.
Comparing both sides, which shows $[f (x)] = x$ (since $f$ is one-to-one)
so for all $x$ in codomain of $f$ there is an $x$ in domain such that $f(x) = x$ .. so it is onto.. yay...
i see someone downvoted the question
if you feel its a dumb question please know I'm still in school learning relations and functions ! :)
A: Let $x \in A$. Let $y=f(x).$ Then $f(y) = f(f(x)) = (f \circ f) (x) = f(x)$ $\implies y=x,$ if $f$ was assumed to be injective. So if $f$ was injective then $f(x)=x,$ for all $x \in A.$ So $f$ is the identity map on $A.$ But then $f$ is clearly surjective, as claimed.
QED
