Let X and Y be finite non empty sets such that $|X| = |Y|$. Show that a function $f : X \to Y$ is onto if it is one to one. Hello this is a recent question posted on my course website for bonus marks. I am not exactly an expert at proving bijection (our current topic of study) and the definitions of onto and one-to-one are giving me a bit of a headache. This is a proofs class f.y.i. 

Let $X$ and $Y$ be finite non empty sets such that $|X| = |Y|$. Show that a function $f : X \to Y$ is onto if it is one to one.

Help please?
 A: If $f : X\to Y$ is one-to-one or injective, that is, for $f(x_1) = f(x_2)$ implies $x_1 = x_2$. Without losing any generality, we assume that $\big\vert X \big\vert =  \big\vert Y \big\vert = N\in\mathbb{N}^\ast$. 
If $f$ is not onto, then there exists some $y\in Y$ such that $f(x) \neq y$ for any $x\in X$.
So (the range of $f$) the set $\big\{ f(x) : x\in X \big\}$ has at most $N - 1$ elements. Thus there are at least two elements in $X$, say $x_1$ and $x_2$  that have the same image under $f$, that is, 
$$f(x_1) = f(x_2) \quad but \quad x_1 \neq x_2 $$
which is a contradiction to the injectivity.
Q.E.D.
A: Another take in case helpful. Denote the distinct elements of $X$ by $x_1, \dots x_n$. Then ${\rm ran}\,f = \{f(x_1), \dots, f(x_n)\}$. If any $f(x_i)$ equals any $f(x_j)$, then $f$ is not one-to-one. Hence the $n$ points $f(x_1), \dots, f(x_n)$ are distinct, and we have $|{\rm ran}\,f| = n = |X|$. But $|X| = |Y|$ so $|{\rm ran}\,f| = |Y|$. Thus $0 = |Y| - |{\rm ran}\,f| = |Y \setminus {\rm ran}\,f|$, i.e., $Y \setminus {\rm ran}\,f$ is empty. In other words, ${\rm ran}\,f = Y$, $f$ is onto.
A: Suppose $|X|=|Y|=0$, the map $\varnothing \to \varnothing$ is a surjection, since the map from the empty set to the empty set is a bijection.
Suppose we have already proven the assertion for sets of size $n\ge0$, $|X|=|Y|=n+1$ and  $f: X \to Y$ is an injection. Since $X$ is clearly non-empty we choose some $x_0\in X$,  and let $y_0= f(x_0)$. Now we define  $X': = X \setminus \{x_0\}$, $Y': = Y \setminus \{y_0\}$ and $h: X' \to Y'$ such that $h(x)=f(x)$ for all $x\in X'$. Clearly $h$ is injective. Since $|X'|=|Y'|=n$ and $h$ is $1$-$1$ so by the inductive hypothesis $h$ is also onto i.e., $h$ is a bijection.  Since $f = h \cup \left\{  \langle x_0, y_0 \rangle  \right\}$, then $f$ is surjective too. 
as was to be shown.
