Function $F$ is surjective if and only if $F$ is $1-1$ While I was working on proofs of functions, the following claim occurred to me that I think it is correct but I could not prove it. Please note that the claim may not be correct since it is just my hypothesis. So my hypothesis is:

Let $A$ be a finite set and $F$, a function $F:A\rightarrow A$.
  $F$ is surjective if and only if $F$ is injective. 

Here is how I tried to prove it:


*

*$\rightarrow$ Let $X$, $Y$, $Z$ and assume $F(X)=F(Y)$. We need to show that $X=Y$ to prove that $F$ is $1-1$. $F(X)$ and $F(Y)\in A$ and $F$ is surjective then $\text{Img}(F)=A$. $A$ is a finite set then $\text{Img}(F)$ is a finite set.


how can I continue the proof? 


*

*$\leftarrow$ We need to show that $A=\text{Img}(F)$ to show that $F$ is surjective but we know that $\text{Img}(F)\subseteq A$ so we need to show $A\subseteq \text{Img}(F)$. Let $x\in A$. We need to show $x\in\text{Img}(F)$.
$A=\text{Dom}(F)$ and $x\in\text{Dom}(F)$ and $F$ is function so there exists $y$ such that $F(x)=y$.


And here also I got stuck. Any ideas how to continue the proof if it is right..
I know that I did not use that $A$ is a finite set and $F$ is injective in one way because I do not see where I can use in my proof.
 A: In general, one has the following

Proposition: If $A$ and $B$ are two finite sets with the same number of elements, and $f:A\to B$, then the following conditions are equivalent:

*

*$f$ is injective


*$f$ is surjective


*$f$ is bijective

To prove this, we need the following

Lemma: Let $f:A\to B$ be a function. Then
a) If $f$ is injective and $B$ is finite, then $A$ is also finite and $|A|\le|B|$
b) If $f$ is surjective and $A$ is finite, then $B$ is finite and $|B|\le|A|$

Proof of the Lemma:
a) Since $f:A\to B$ is injective, $f:A\to \text{im}(f)$ is bijective, and its image set $\text{im}(f)$ is a subset of the finite set $B$, therefore it is finite, and $|A|=|\text{im}(f)|\le|B|$
b) Let $n=|A|$ and let $g:A\to n$ be a bijective function. We would like to define an injective function from $B$ to $n$ and apply a) . Since $f:A\to B$ is surjective, for each $b\in B$ there is at leat one $a\in A$ so that $f(a)=b$, and although there might be more than one element $a$ in $A$ like that, the images via $g$ of those $a$ are natural numbers less than $n$, so we can choose the smallest of them, that is we choose $k$ the smallest natural number from those natural numbers $i$ that verify $i<n$ and $g(a)=i$. We define the function $h:B\to n$ like:
$$h(b)=\text{the smallest}\;k<n\;\text{such that}\;f(g^{-1}(k))=b$$
The function $h$ is injective: if $b,b'\in B$ are so that $h(b)=h(b')=k$, then $b=f(g^{-1}(k))=b'$. From a) , for the injective function $h:B\to n$ with $n\in\mathbb{N}$ - thus $n$ is finite - we can conclude that $B$ is finite and $|B|\le n=A$
Proof of he proposition
$a)\implies b)$: Suppose that $f:A\to B$ is injective, but not surjective: $\text{im}(f)\subset B$. Let $b\in B\text{\im}(f)$. Then $f:A\to B \text{ \ }\{b\}$ and $B \text{ \ }\{b\}$ is a subset of the finite set $B$, so it is a finite set and from a) of the previous lemma, $|B|=|A|\le |B \text{ \ }\{b\}|<|B|$, which is a contradiction.
$b)\implies c)$: We only have to prove that $f$ is injective. Suppose that $f$ is surjective but not injective. Then there exist $a,a'\in A$ so that $a\not=a'$ and $f(a)=f(a')$. The restriction $f\restriction (A \text{ \ }\{a\}):A\to B$ is also surjective. From b) of the previous lemma, $|B|\le |A \text{ \ }\{a\}|<|A|=|B|$, which is a contradiction.
$c)\implies a)$ There is nothing to prove.
A: I use the idea of a partition of the domain of F ( that is, of the set A) in classes of elements having the same image. I call P this partition. I want to show that the cardinal of this partition defines a maximum for the cardinal of the codomain of F. And without injectivity, this maximum is necessarily less than the cardinal of A. Which makes surjectivity impossible. 

Rk. I use Card(S) to denote : the cardinal number of the set S. 
First part : If F is surjective, then F is 1-1. 
What is to be proved is equivalent ( by contraposition) to :
if F is not 1-1, then F is not surjective. 
(1) since F is a function from A to A, F is surjective iff Card ( Codomain) = Card (A). 
(2) Define an equivalence relation on the set A by the following formula  : the element x has same image under F as the element y 
This equivalence relation partitions A into a collection of sets. Call  P this collection . Card(P) is the number of classes of A-elements ( pre-images) such that all elements in each class  have the same image ( under F) . 
(3) Card (P) = Card A iff  F is injective ( it means that injectivity guarantees that there is one and only one element in each cell of the partition). 
But if F in not injective ( not 1-1) , Card(P) is less than Card A ( there is at least a cell of the partition that contains 2 elements  of the domain, that is, 2 elements of A) 
(4) Now Card ( Codomain) is, in any case, at most as great as Card (P) ( the number of images under F cannot be greater that the number of classes of preimages having the same image). 
So we have : 


*

*By (4) Card (Codomain) is less or equal than Card (P) 

*By (3) If F is not injective Card (P) is less than Card(A) 

*Therefore : if F is not injective, Card ( Codomain) is less than Card(A) 

*But , by (1) if Card ( Codomain) is not equal to Card (A) then F is not surjective. 

*Therefore, if F is not injective, F is not surjective. 

*Therefore ( by contraposition) if F is surjective, F is injective. 
Second part of the prooF: If F is 1-1, then F is surjective. 
(1) we said earlier that Card(P ) is a maximum for Card ( Codomain). We can add that it is also a minimum. Suppose that the number of images is less that the number of cells of equivalent preimages. That would imply that there is at least an image corresponding to 2 different cells. But this leads to a contradiction : if 2 cells are diffferent, their elements cannot have the same image under F ( being given that cells are determined by the equuivalence relation " having the same image under f) 
(2) Since we have both Card (Codomain) is at most as great as Card(P) and Card( Codomain) is at least as great as P, we must conclude that 
                 Cardinal(Codomain)=Card (P)

(3) But, if ( by hypothesis) F is 1-1, it means that card (P) = card (A) 
( as we said in part 1 of the proof). 
(3) So Card (Codomain) = Card (A) 
(4) Since F is from A to A, the codomain is a subset of A. Since the only subset of A having the same cardinal as A is A itself, we have 
                              Codomain of F = A 

which means that F  ( from A to A) is surjective. 
(5) Conclusion : If F (from A to A)  is injective, then it is also surjective. 
