Suppose A and B are finite sets with |A| = |B| and that f: A $\displaystyle \longrightarrow $B is a function. Prove: f is one-to-one iff f is onto.

Proof that f is onto: Suppose f is injective and f is not onto. Since |A| = |B| every $\displaystyle a_{i}\in A$ can be paired with exactly one $\displaystyle b_{i}\in B$. Now since f is injective, if $\displaystyle f(a_{i})=f(a_{j})=b_{i}$, then $\displaystyle a_{i}=a_{j}$. If f is not onto then there is a $\displaystyle b_{i}\in B$ for which there is no $\displaystyle a_{i}\in A$ such that $\displaystyle f(a_{i})=b_{i}$. But this is a contradiction since this would mean that at least two unequal $\displaystyle a_{i},a_{j}\in A$ would map to the same $\displaystyle b_{i}\in B$. Therefore f must be onto if f is injective.

Proof that f is injective: Suppose f is onto and f is not injective. Then there exists $\displaystyle a_{i},a_{j}\in A$ and $\displaystyle b_{i}\in B$ such that $\displaystyle f(a_{i})=f(a_{j})=b_{i}where a_{i}\neq a_{j}$. Now again |A| = |B| means that every $\displaystyle a_{i}$ can be paired with exactly one $\displaystyle b_{i}$. If there exists an $\displaystyle a_{i}\neq a_{j}$ such that $\displaystyle f(a_{i})=f(a_{j})=b_{i}$ and $\displaystyle i\neq j$ then there must exist a $\displaystyle b_{j}$ for which there is no $\displaystyle a_{j}$ such that $\displaystyle f(a_{j})=b_{j}$ which is a contradiction. This means that f is injective if f is onto. QED

Would someone be kind enough to critique this proof? Thanks.