Show that, if $f:A\to B$ is a function, with $A$ and $B$ being finite sets, and $|A|=|B|$, then $f$ is one to one iff $f$ is onto. I'm a little stuck with this proof. Not sure where to go. I was thinking that I could first assume that $f$ is one to one and prove that it's onto, and then assume it's onto and prove that it's one to one... but I'm not sure what to do with the knowledge that $|A|=|B|=m\in\mathbb{Z}\geq 0$.
I've tried to start by defining what it means for $f$ to be one-to-one, and going from there...
\begin{align*}
f\text{ is one-to-one}&\Longrightarrow f=\{(a,b)\in A\times B\mid b=f(a)\wedge f^{-1}(b)=a\}\\
&\Longrightarrow \dots\\
&\Longrightarrow \text{$f$ is onto}
\end{align*}
but not sure where to go from there... I have a feeling that my definition is too presumptuous to begin with, since I'm trying to show that $f$ is onto... not assume that it is.
 A: If $f$ is not one-to-one, then there are distinct $a_1, a_2 \in A$ such that $f(a_1) = f(a_2) \in B$.  As a result,
$$ \left| f(A) \right| < |A|.$$
So there must be some $b \in B$ with no preimage.  Hence, $f$ is not onto.
For the converse, just run the arguments in reverse.
A: If $f$ is not injective, then there exist $a_1\neq a_2$ such that $f(a_1)=f(a_2)$. So $f(A)=f(A\setminus\{a_2\})$, hence $|f(A)|=|f(A\setminus\{a_2\})|\leq |A\setminus \{a_2\}|=|A|-1<|A|$. Conversely, if $f$ is injective, then it is a bijection onto its range so $|f(A)|=|A|$. Hence:
$$
f\;\mbox{injective}\quad\iff\quad |f(A)|=|A|.
$$
Now easier, since $f(A)\subseteq B$:
$$
f\;\mbox{surjective}\quad\iff\quad f(A)=B\quad\iff\quad |f(A)|=|B|.
$$
Since $|A|=|B|$, you get:
$$
f\;\mbox{injective}\quad\iff\quad f\;\mbox{surjective}\quad\iff\quad f\;\mbox{bijective}.
$$
That's a sort of nonlinear rank-nullity theorem...
A: If $|f(A)| < m$, then by the pigeon hole principle there must exist $a_1,a_2 \in A$ with $a_1 \neq a_2$ such that $f(a_1) = f(a_2)$, ie, $f$ is not injective. 
If $f$ is not injective, then there must exist $a_1,a_2 \in A$ with $a_1 \neq a_2$ such that $f(a_1) = f(a_2)$. Then $|f(A)| \le |f(\{a_1,a_2\})| + |f(A \setminus \{a_1,a_2\})| = 1 +m-2 = m-1 < m$.
Hence $f$ is injective iff $|f(A)| = m$.
Furthermore, $f(A) = B$ iff $|f(A)| = |B|$, hence $f$ is surjective iff $|f(A)| = m$.
The result follows.
