How to write a rigorous proof for this statement? 
Prove that for finite set $X$, the function $f:X \to X$ is surjective if and only if it is injective

I have the idea of proof in my mind but find it difficult to translate it into mathematical language.
If $f$ is surjective then every element of $X$ will be hit, but the source and the target are exactly the same, hence it must be that every element in the source hit another element in the target, and no two elements in the source that hit the same target. Hence I prove $f$ is injective. In the same way I can prove the reverse statement.
How can I translate this into rigorous mathematical language?

You can do this by induction over the size of $X$ Or rather prove something stronger: If $f:Y\rightarrow Z$ is a function between sets of equal size, then $f$ is injective if and only if $f$ is surjective
Base: $|Y|=|Z|= 1$ (or possibly $0$ but that is completely trivial), then every function is both surjective and injective.
Induction assumption:
If $f:Y\rightarrow Z$ is a function on a sets $Y$ and $Z$ of size $n$ then $f$ is surjective if and only if $f$ is injective.
Induction step:
Assume $f:X\rightarrow W$ where $|X|=|W|=n+1$. 
Assume $f$ is injective. Choose an element $a\in X$. The function $g:(X-\{a\})\rightarrow (W-\{f(a)\})$ such that $g(b)=f(b)$ for each $b\in X-\{a\}$ is then also an injective function between two sets of size $n$, and thus by induction assumption $g$ is surjective. However then each element in $W-\{f(a)\}$ is mapped to by something in $X-\{a\}$ and thus $f$ is surjective.
Assume $f$ is surjective. Choose an element $c\in W$ and assume that $f(a)=b$ for some $a\in X$. Again the function $g:(X-\{a\})\rightarrow (W-\{f(a)\})$ such that $g(b)=f(b)$ for each $b\in X-\{a\}$ is then also a surjective function between two sets of size $n$, thus the induction assumption implies that $g$ is injective. As $f(a)$ is not in the range of $g$, this implies that $f$ is injective.
This concludes the induction.
