[Math] Cardinality of the Domain vs Codomain in Surjective (non-injective) & Injective (non-surjective) functions

elementary-set-theoryfunctions

I'm a student in college just beginning to study the basics of set theory. In studying about Surjective & Injective functions & how they map their domain to their codomain, it came to my mind a question that I really wanted to confirm:

1) Is it possible to build a "surjective non-injective" function that has a domain with the same number of elements as the codomain?

2) Is it possible to build an "injective non-surjective" function that has a domain with the same number of elements as the codomain?

The context of these questions are:

  • Both the domain & the codomain of the function must have a finite number of elements. They are both finite sets.
  • Both the domain & the codomain of the function must not be an empty set. It has to have at least one element.
  • The function must not be a partial function. It has to take all the elements in the domain.
  • The function must not be a multi-value function. So for one element in the domain, the function can only output one value in the codomain.
  • The function must be only injective or surjective, but cannot be both (bijective) and cannot be non of those (general function).
  • I'm not expecting complex answers that explain using axioms, morphisms, complex notations, etc, which I cannot understand as of yet, since I'm just "beginning" to study the basics of set theory.
  • I already tried building such "function" but never really succeeded. It always has to have a different number of elements between the domain & the codomain in order to be surjective only or injective only. So this post is really just to "make sure" that it's true that building such function is never really possible for finite sets (I already know it's a different story in the case of infinite sets). Unless… umm I am missing something.
  • As I'm typing this post, I already read all the questions in the "similar questions" and in the "Questions that may already have your answer" panel. I did found some questions that are similar, but not actually detailed enough, requiring specific conditions & using specific context such as those that I'm posting here. I'm still posting this since those are not satisfying enough of a question & answer for me, so not quite what I'm looking for. Hope I don't get marked as duplicate.
    • Lastly, since no human is perfect. Just let me know in the comment if there is something in the question that still needs to be cleared out or not in accordance to the rules of this forum. Hope I'm being clear enough.

Regards,

Best Answer

If $f$ is a function $A\to A$ where $A$ is a finite set, then $f$ is injective if and only it it is surjective. It is not possible for such an $f$ to be injective without being surjective or vice versa.

This can be proved by induction on the number of elements in $A$, but the details are slightly tedious. This property carries over to a function $f:A\to B$ where $A$ and $B$ have the same number of elements -- because "the same number of elements" means that there is a bijection $g:A\to B$, and then $f$ is injective/surjective exactly when $g^{-1}\circ f$ is, and $g^{-1}\circ f$ goes from $A$ to $A$ itself.


On the other hand, if $A$ is infinite, then it is possible for a function to be injective without being surjective, or vice versa. Some simple examples for $\mathbb N\to\mathbb N$ is $$ g(n) = n+7 \\ h(n) = \begin{cases} n & \text{if }n\le 42 \\ n-1 & \text{otherwise} \end{cases}$$ where $g$ is injective but not surjective, and $h$ is surjective but not injective.

(Strictly speaking this property of infinite sets is only guaranteed if the axiom of choice holds, but that is a techincal complication that you probably don't want to worry about at this level).

Related Question