Lecture 18 : One-to-One and Onto Functions.

In this lecture, we will consider properties of functions:

  • Functions that are One-to-One, Onto and Correspondences.

    • Proving that a given function is one-to-one/onto.

  • Comparing cardinalities of sets using functions.

One-to-One/Onto Functions

Here are the definitions:

  • f is one-to-one (injective) if f maps every element of A to a unique element in B. In other words no element of B are mapped to by two or more elements of A.

    • (forall a,b in A) f(a) = f(b) Rightarrow a = b .

  • f is onto (surjective)if every element of B is mapped to by some element of A. In other words, nothing is left out.

    • (forall b in B) (exists a in A) f(a) = b.

  • f is one-to-one onto (bijective) if it is both one-to-one and onto. In this case the map f is also called a one-to-one correspondence.

Example-1

Classify the following functions f_j: mathbb{N} rightarrow mathbb{N} between natural numbers as one-to-one and onto.

f_j One-to-One? Onto?
f_1(n) = n^2 Yes No
f_2(n) = n+3 Yes No
f_3(n) = lfloor sqrt{n} rfloor No Yes
f_4(n) = left{begin{array}{l} n-1, mbox{odd} n  n+1, mbox{even} n  end{array} right.. Yes Yes

It helps to visualize the mapping for each function to understand the answers.

Reasons
  • f_1 is not onto because it does not have any element n such that f_1(n)=3, for instance.

  • f_2 is not onto because no element n such that f_2(n) = 0, for instance.

  • f_3 is not one-to-one since f_3(2) = f_3(1) =1 .

Example-2

Prove that the function f(n) = n^2 is one-to-one.

Proof: We wish to prove that whenever f(m) = f(n) then m=n. Let us assume that f(m) = f(n) for two numbers m,n in mathbb{N}. Therefore, m^2 = n^2. Which means that m = pm n. Splitting cases on n, we have

  • For n not= 0, -n notin mathbb{N}, therefore m = n for this case.

  • For n = 0, we have m = n =0. Therefore, it follows that m = n for both cases.

Example-3

Prove that the function f(n) = lfloor sqrt{n} rfloor is onto.

Proof

Given any m in mathbb{N}, we observe that n = m^2 in mathbb{N} is such that f(n) = m. Therefore, all m in mathbb{N} are mapped onto.

Claim-1 The composition of any two one-to-one functions is itself one-to-one.

Proof

Let f: A rightarrow B and g: B rightarrow C be both one-to-one. We wish to tshow that g circ f is also one-to-one.

  • Assume that g circ f (a) = g circ f (b) for two elements a,b in A.

  • Therefore g(f(a)) = g(f(b)).

  • Since g is itself one-to-one, it follows that f(a) = f(b).

  • Since f is one to one and f(a) = f(b) it follows that a = b.

  • Therefore g(f(a)) = g(f(b)) can happen only if a = b.

The reasoning above shows that gcirc f is one-to-one.

Claim-2 The composition of any two onto functions is itself onto.

Proof

Let f: A rightarrow B and g: B rightarrow C be onto functions. We will prove that g circ f is also onto.

  • Let c in C be any element.

  • Since g is onto, we know that there exists b in B such that g(b) = c.

  • Likewise, since f is onto, there exists a in A such that f(a) =b.

  • Combining, f(g(a)) = c.

  • Thus, gcirc f is onto.

Comparing Cardinalities of Sets

Let A and B be two finite sets such that there is a function f: A rightarrow B. We claim the following theorems:

  • If f is one to one then |A| leq |B|.

  • If f is onto then |A| geq |B|.

  • If f is both one-to-one and onto then |A| = |B|.

The observations above are all simply pigeon-hole principle in disguise.

Theorem Let A,B be two finite sets so that |A| > |B|. Any function from A to B cannot be one-to-one.

Proof

Let f: A rightarrow B be any function. Think of the elements of B as the holes and elements of A as the pigeons. There are more pigeons than holes. Therefore two pigeons have to share (here map on to) the same hole.

QED.

We now prove the following claim over finite sets A.

Claim Let A be a finite set. Prove that every one-to-one function f: A rightarrow A is also onto.

Proof

We will prove by contradiction.

  • Let f be a one-to-one function as above but not onto.

  • Therefore, exists a in A such that for every b in A, f(b) not= a.

  • Therefore, f can be written as a one-to-one function from A rightarrow A - {a} (since nothing maps on to a in A).

  • Similarly, we repeat this process to remove all elements from the co-domain that are not mapped to by f to obtain a new co-domain A'.

  • f is now a one-to-one and onto function from A to A'.

  • However, |A'| < |A|. Therefore by pigeon-hole principle f cannot be one-to-one.

The last statement directly contradicts our assumption that f is one-to-one. QED.

Infinite Sets

We now note that the claim above breaks down for infinite sets.

Let us take mathbb{N}, the set of all natural numbers.

  • f: mathbb{N} rightarrow mathbb{N} defined by f(n) = 2n+1 is one-to-one.

  • However, f is not onto.

Hilbert's Hotel

Consider a hotel with infinitely many rooms and all rooms are full.

  • An important guest arrives at the hotel and needs a place to stay. How does the manager accommodate the new guests even if all rooms are full?

  • Each one of the infinitely many guests invites his/her friend to come and stay, leading to infinitely many more guests. How does the manager accommodate these infinitely many guests?

One-to-One Correspondences of Infinite Set

There is a one to one correspondence between the set of all natural numbers mathbb{N} and the set of all odd numbers O.

Take f(n) = 2 n +1, where f: mathbb{N} rightarrow O. We note that f is a one-to-one function and is onto.

Can we say that |mathbb{N}| = |O|? Yes, in a sense they are both infinite!! So we can say infty = infty!! Therefore we conclude that

  1. There are “as many” even numbers as there are odd numbers?

  2. There are “as many” positive integers as there are integers? (How can a set have the same cardinality as a subset of itself? :-)

  3. There are “as many” prime numbers as there are natural numbers?

Note that “as many” is in quotes since these sets are infinite sets.

Infinite Sets

There are many ways to talk about infinite sets. We will use the following “definition”:

A set A is infinite if and only if there is a proper subset B subset A and a one-to-one onto (correspondence) f: A rightarrow B.

Here are some examples of infinite sets:

  • Natural numbers mathbb{N}: The odd numbers O subset mathbb{N}. We just proved a one-to-one correspondence between natural numbers and odd numbers.

  • Integers mathbb{Z} are an infinite set. The correspondence f(n) = left{ begin{array}{l} 2 |n| +1, mbox{if} n < 0  2 n, mbox{if} n geq 0 end{array}right..

  • Rational numbers mathbb{Q}: We will prove a one-to-one correspondence between rationals and integers mathbb{Z} next class.