Discrete Mathematics : Functions

Contents

One-to-one functions

What is the difference between the two marriage functions?

One-to-one function
  • Every female is a wife of at most one male
  • One-to-one function
Not one-to-one
  • There is a female who is a wife of at least two males
  • Not a one-to-one function

Definition

Template

Prove that a function $f$ is one-to-one.

Proof: Direct proof.

Prove that a function $f$ is not one-to-one.

Proof: Counterexample.

Example 1

Define $f:\mathbb{R} \rightarrow \mathbb{R}$ by $f(x) = 4x - 1$ for all $x \in \mathbb{R}$. Is $f$ one-to-one? Prove or give a counterexample.

Proof:
Direct proof. \begin{align*} & \text{Suppose } f(x_1) = f(x_2). \\ & \implies 4x_1 - 1 = 4x_2 - 1 \quad & \text{(Defn. of } f\text{)} \\ & \implies 4x_1 = 4x_2 \quad & \text{(Add 1 on both sides)} \\ & \implies x_1 = x_2 \quad & \text{(Divide by 4)} \\ \end{align*} Hence, $f$ is one-to-one.

Example 2

Define $g:\mathbb{Z} \rightarrow \mathbb{Z}$ by $g(n) = n^2$ for all $n \in \mathbb{Z}$. Is $g$ one-to-one? Prove or give a counterexample.

Proof (Invalid):
Direct proof. \begin{align*} & \text{Suppose } g(n_1) = g(n_2). \\ & \implies n_1^2 = n_2^2 \quad & \text{(Defn. of } g\text{)} \\ & \implies n_1 = n_2 \quad & \text{(Taking square root)} \\ \end{align*} Hence, $g$ is one-to-one.

Incorrect! What's wrong?

Proof:
Counterexample.

Onto functions

What is the difference between the two marriage functions?

Onto function
  • Every female is a wife
  • Onto function
Not onto
  • There is a female who is not a wife
  • Not an onto function

Definition

Template

Prove that a function $f$ is onto.

Proof
Direct proof.

Prove that a function $f$ is not onto.

Proof:
Counterexample.

Example 1

Define $f:\mathbb{R} \rightarrow \mathbb{R}$ by $f(x) = 4x - 1$ for all $x \in \mathbb{R}$. Is $f$ onto? Prove or give a counterexample.

Proof:
Direct proof. \begin{align*} & \text{Let } y \in \mathbb{R}. \text{ Set } x = \frac{y+1}{4}. \text{ Then:} \\ & f\!\left(\frac{y+1}{4}\right) = 4 \cdot \frac{y+1}{4} - 1 = y \quad & \text{(Defn. of } f\text{, then simplify)} \end{align*} Hence, $f$ is onto.

Example 2

Define $g:\mathbb{Z} \rightarrow \mathbb{Z}$ by $g(n) = 4n - 1$ for all $n \in \mathbb{Z}$. Is $g$ onto? Prove or give a counterexample.

Proof (Invalid):
Direct proof. \begin{align*} & \text{Let } m \in \mathbb{Z}. \text{ Set } n = \frac{m+1}{4}. \text{ Then:} \\ & g\!\left(\frac{m+1}{4}\right) = 4 \cdot \frac{m+1}{4} - 1 = m \quad & \text{(Defn. of } g\text{, then simplify)} \end{align*} Hence, $g$ is onto.

Incorrect! What's wrong?

Proof:
Counterexample.

One-to-one correspondences

What is the difference between the three marriage functions?

One-to-one, not onto
  • Every female is a wife of at most one male
  • One-to-one
  • Not onto
Onto, not one-to-one
  • Every female is a wife
  • Onto
  • Not one-to-one
Bijection
  • Every female is a wife of exactly one male
  • One-to-one
  • Onto

A one-to-one correspondence (or bijection) from $X$ to $Y$ is a function $F: X \rightarrow Y$ that is both one-to-one and onto.

Example 1

Subset of $\{a,b,c,d\}$4-tuple of $\{0,1\}$
$\{\ \}$$\to$$(0,0,0,0)$
$\{a\}$$\to$$(1,0,0,0)$
$\{b\}$$\to$$(0,1,0,0)$
$\{c\}$$\to$$(0,0,1,0)$
$\{d\}$$\to$$(0,0,0,1)$
$\{a,b\}$$\to$$(1,1,0,0)$
$\{a,c\}$$\to$$(1,0,1,0)$
$\{a,d\}$$\to$$(1,0,0,1)$
$\{b,c\}$$\to$$(0,1,1,0)$
$\{b,d\}$$\to$$(0,1,0,1)$
$\{c,d\}$$\to$$(0,0,1,1)$
$\{a,b,c\}$$\to$$(1,1,1,0)$
$\{a,b,d\}$$\to$$(1,1,0,1)$
$\{a,c,d\}$$\to$$(1,0,1,1)$
$\{b,c,d\}$$\to$$(0,1,1,1)$
$\{a,b,c,d\}$$\to$$(1,1,1,1)$

Example 2

Define $F:\mathbb{R}{\times}\mathbb{R} \rightarrow \mathbb{R}{\times}\mathbb{R}$ by $F(x, y) = (x + y,\; x - y)$. Is $F$ a one-to-one correspondence? Prove or give a counterexample.

Proof:
To show $F$ is a one-to-one correspondence, we show:

  1. $F$ is one-to-one.
    Suppose $F(x_1,y_1) = F(x_2,y_2)$. \begin{align*} & \implies (x_1{+}y_1,\; x_1{-}y_1) = (x_2{+}y_2,\; x_2{-}y_2) \quad & \text{(Defn. of } F\text{)} \\ & \implies x_1{+}y_1 = x_2{+}y_2 \text{ and } x_1{-}y_1 = x_2{-}y_2 \quad & \text{(Equality of ordered pairs)} \\ & \implies x_1 = x_2 \text{ and } y_1 = y_2 \quad & \text{(Solving the two equations)} \\ & \implies (x_1, y_1) = (x_2, y_2) \quad & \text{(Equality of ordered pairs)} \\ \end{align*} Hence, $F$ is one-to-one.
  2. $F$ is onto.
    Let $(u,v) \in \mathbb{R}{\times}\mathbb{R}$. Set $r = \frac{u+v}{2}$ and $s = \frac{u-v}{2}$. Then: $$F(r,s) = \left(\frac{u+v}{2}+\frac{u-v}{2},\;\frac{u+v}{2}-\frac{u-v}{2}\right) = (u,v).$$ Hence, $F$ is onto.

Inverse functions

What is the difference between the two marriage functions?

Function F: Male to Female
  • Input: male. Output: female.
  • $F$
Inverse F⁻¹: Female to Male
  • Input: female. Output: male.
  • $F^{-1}$

Definition

Example 1

Subset of $\{a,b,c,d\}$4-tuple of $\{0,1\}$
$\{\ \}$$\leftarrow$$(0,0,0,0)$
$\{a\}$$\leftarrow$$(1,0,0,0)$
$\{b\}$$\leftarrow$$(0,1,0,0)$
$\{c\}$$\leftarrow$$(0,0,1,0)$
$\{d\}$$\leftarrow$$(0,0,0,1)$
$\{a,b\}$$\leftarrow$$(1,1,0,0)$
$\{a,c\}$$\leftarrow$$(1,0,1,0)$
$\{a,d\}$$\leftarrow$$(1,0,0,1)$
$\{b,c\}$$\leftarrow$$(0,1,1,0)$
$\{b,d\}$$\leftarrow$$(0,1,0,1)$
$\{c,d\}$$\leftarrow$$(0,0,1,1)$
$\{a,b,c\}$$\leftarrow$$(1,1,1,0)$
$\{a,b,d\}$$\leftarrow$$(1,1,0,1)$
$\{a,c,d\}$$\leftarrow$$(1,0,1,1)$
$\{b,c,d\}$$\leftarrow$$(0,1,1,1)$
$\{a,b,c,d\}$$\leftarrow$$(1,1,1,1)$

Example 2

Define $f:\mathbb{R} \rightarrow \mathbb{R}$ by $f(x) = 4x - 1$. Find its inverse function.

Proof:
For any $y \in \mathbb{R}$, find $x$ such that $f(x) = y$: \begin{align*} & 4x - 1 = y \quad & \text{(Defn. of } f\text{)} \\ & \implies x = \frac{y+1}{4} \quad & \text{(Simplify)} \\ \end{align*} Hence, $f^{-1}(y) = \dfrac{y+1}{4}$.

Example 3

If $F: X \rightarrow Y$ is a one-to-one correspondence, then $F^{-1}: Y \rightarrow X$ is also a one-to-one correspondence.

Proof:

Composition of functions

Function composition as a pipeline

Definition

Let $f : X \rightarrow Y$ and $g: Y \rightarrow Z$ where the range of $f$ is a subset of the domain of $g$. Then the composition $g \circ f : X \rightarrow Z$ is defined by:
$(g \circ f)(x) = g(f(x)) \text{ for all } x \in X.$
Read: “$g$ circle $f$”; $g(f(x))$ is “$g$ of $f$ of $x$.”

Example 1

Let $f(n) = n+1$ (successor) and $g(n) = n^2$ (squaring), both $\mathbb{Z} \to \mathbb{Z}$. Find $g \circ f$, $f \circ g$. Is $g \circ f = f \circ g$?

Solution:

Example 2

Draw the arrow diagram for $g \circ f$. What is the range of $g \circ f$?
Arrow diagram for f and g

Solution:

Arrow diagram for g∘f

Example 3

Find $f \circ I_X$ and $I_Y \circ f$.
Function f with identity functions

Solution:
$f \circ I_X = f$.

Diagram showing f∘IX

$I_Y \circ f = f$.

Diagram showing IY∘f

If $f: X \to Y$, $I_X$ is the identity on $X$, and $I_Y$ is the identity on $Y$, then $f \circ I_X = f$ and $I_Y \circ f = f$.

Proof:

Example 4

Find $f^{-1} \circ f$ and $f \circ f^{-1}$.

Function f: X to Y
Inverse function f⁻¹: Y to X

Solution:
$f^{-1} \circ f = I_X$:

$f \circ f^{-1} = I_Y$:

If $f : X \rightarrow Y$ is one-to-one and onto with inverse $f^{-1}: Y \rightarrow X$, then $f^{-1} \circ f = I_X$ and $f \circ f^{-1} = I_Y$.

Proof:

Example 5

f one-to-one, g one-to-one
$f$ is one-to-one and $g$ is one-to-one
g∘f is one-to-one
$g \circ f$ is one-to-one

If $f : X \rightarrow Y$ and $g: Y \rightarrow Z$ are both one-to-one, prove $g \circ f$ is one-to-one.

Proof:
Direct proof. \begin{align*} & \text{Suppose } (g \circ f)(x_1) = (g \circ f)(x_2). \\ & \implies g(f(x_1)) = g(f(x_2)) && \text{(Defn. of composition)} \\ & \implies f(x_1) = f(x_2) && \text{(}g \text{ is one-to-one)} \\ & \implies x_1 = x_2 && \text{(}f \text{ is one-to-one)} \\ \end{align*} Hence, $g \circ f$ is one-to-one.

Example 6

f onto, g onto
$f$ is onto and $g$ is onto
g∘f is onto
$g \circ f$ is onto

If $f : X \rightarrow Y$ and $g: Y \rightarrow Z$ are both onto, prove $g \circ f$ is onto.

Proof (Core idea):

Step 1: z in Z
show $g \circ f$ is onto
Step 2: y in Y maps to z
$g$ is onto
Step 3: x in X maps to y
$f$ is onto

Proof:

Direct proof.

Infinite sets

Comparing set sizes

Consider you are in a room with no access to Internet or people or electronic gadgets. There is a bag of finite number of apples and a bag of finite number of mangoes. How can you find out which bag has more number of fruits? Assume that you have only 1 bit of memory, i.e., you can only store two states and hence you cannot count numbers.

Solution:

Comparing set sizes using one-to-one correspondences

3 elephants mapped to 3 flowers

3 elephants mapped to 4 flowers, one unmapped

3 elephants mapped to numbers 1, 2, 3

Enumeration of integers: 0, 1, −1, 2, −2, …

Suppose you have two bags each with an infinite number of objects. How can you find out which bag has more number of objects? As an example, one bag has all Java computer programs and another bag has all irrational numbers.

Cardinality

$A$ and $B$ have the same cardinality if and only if $A$ has the same cardinality as $B$ or $B$ has the same cardinality as $A$.

Properties: For all sets $A$, $B$, $C$:

$|\mathbb{Z}| = |\mathbb{Z}^{\text{even}}|$

failed approach to show Z and Zeven do not have the same size

correct approach to show Z and Zeven have the same size

Prove that $|\mathbb{Z}| = |\mathbb{Z}^{\text{even}}|$.

Proof

Take-home lesson

An infinite set and its proper subset can have the same size!

surprise

Countable sets

$\mathbb{N}$$A$
$1$$\to$“First” element of $A$
$2$$\to$“Second” element of $A$
$3$$\to$“Third” element of $A$
$4$$\to$“Fourth” element of $A$
$5$$\to$“Fifth” element of $A$
$\vdots$$\vdots$

$\mathbb{Z}$ is countable

Prove that $\mathbb{Z}$ is countable.

Solution

Enumeration of integers: 0, 1, −1, 2, −2, …

$\mathbb{N}$$\mathbb{Z}$
$1$$\to$$0$
$2$$\to$$1$
$3$$\to$$-1$
$4$$\to$$2$
$5$$\to$$-2$
$\vdots$$\vdots$
$n$$\to$$f(n)$
$\vdots$$\vdots$

$Q^{+}$ is countable

$\mathbb{N}$$\mathbb{Q}^{+}$
$\vdots$
$1$$\to$$\dfrac{1}{1}$
$\vdots$
$2$$\to$$\dfrac{2}{1}$
$\vdots$
$3$$\to$$\dfrac{3}{1}$
$\vdots$$\vdots$

Prove that $\mathbb{Q}^{+}$ is countable.

Solution

Enumeration of positive rationals

$\mathbb{N}$$\mathbb{Q}^{+}$
$1$$\to$$1/1$
$2$$\to$$1/2$
$3$$\to$$2/1$
$4$$\to$$3/1$
$5$$\to$$1/3$
$6$$\to$$1/4$
$7$$\to$$2/3$
$8$$\to$$3/2$
$9$$\to$$4/1$
$10$$\to$$5/1$
$\vdots$$\vdots$

$[0, 1]$ is uncountable

Prove that $[0,1]$ is uncountable.

Solution

Take-home lesson

There are different types of $\infty$!

surprise

More theorems

$\mathbb{R}$ and $[0, 1]$ have the same size

Prove that $|\mathbb{R}| = |{[0,1]}|$.

Solution

Projection of circle onto number line

We show $F$ is a one-to-one correspondence:

Set of bit strings is countable

Prove that the set of all bit strings $\mathbb{B}$ is countable.

Solution

Set of computer programs is countable

Prove that the set $\mathbb{P}$ of all programs in a given language is countable.

Solution

Set of all functions $\mathbb{N} \to \{0, 1\}$ is uncountable

Prove that the set $\mathbb{L}$ of all functions $\mathbb{N} \to \{0, 1\}$ is uncountable.

Solution

Take-home lesson

There is an infinite sequence of larger and larger infinities!

surprise