Prove that $f: \{0, \dots , n \} \mapsto \{0, \dots , n \}$ is surjective $\iff$ is injective
I have written a solution to this problem but I am not sure whether it's correct and formally satisfactory.
- injective $\Rightarrow$ surjective
Assume that this function is not surjective. Then, there is $y \in img(f)$ such that there is no $x \in dom(f)$ such that $f(x) =y$. And so, there are $x_1, x_2 \in dom(f)$ such that $f(x_1) = f(x_2)$ But $f$ is injective - contradiction.
2.surjective $\Rightarrow$ injective
Assume that $f$ is not injective. Then, there are $x_1, x_2 \in dom(f)$ such that $f(x_1) = f(x_2)$ This implies that there is a $y \in img(f)$ such that there is no$x \in dom(f) $ satisfying $f(x) = y$. However,$f$ is injective. Contradiction.
What do you think of my proof, is it valid?