Professional Documents
Culture Documents
CS311H: Discrete Mathematics I A function f from a set A to a set B assigns each element of
A to exactly one element of B .
Functions I A is called domain of f , and B is called codomain of f .
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 1/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 2/46
A A
B B
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 3/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 4/46
A A
B B
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 5/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 6/46
1
Function Terminology Examples Image of a Set
f (S ) = {t | ∃s ∈ S . t = f (s)}
I What is the range of this function?
I What is the image of {b, c}?
I What is the image of c? A B
a
d
I What is the preimage of e? b
e
c
f
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 7/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 8/46
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 9/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 10/46
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 11/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 12/46
2
Proving Injectivity Example, cont. Onto Functions
I A function f from A to B is called onto iff for every element
y ∈ B , there is an element x ∈ A such that f (x ) = y:
∀y ∈ B .∃x ∈ A. f (x ) = y
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 13/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 14/46
A B
a
d
I Consider the function f (x ) = x2
from the set of integers to b e
the set of integers. Is f surjective? c f
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 15/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 16/46
I The identity function I on a set A is the function that assigns I Now, prove I is onto, i.e., for every b, there exists some a
every element of A to itself, i.e., ∀x ∈ A. I (x ) = x such that f (a) = b
I Prove that the identity function is a bijection. I For contradiction, suppose there is some b such that
∀a ∈ A. I (a) 6= b
I Need to prove I is both one-to-one and onto.
I Since I (a) = a, this means ∀a ∈ A. a 6= b
I One-to-one: We need to show ∀x , y. (x 6= y → I (x ) 6= I (y))
I But since b is itself in A, this would imply b 6= b, yielding a
I Suppose x 6= y. contradiction.
I Since I (x ) = x and I (y) = y, and x 6= y, I (x ) 6= I (y) I Since I is both onto and one-to-one, it is a bijection.
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 17/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 18/46
3
Inverse Functions Why are Inverse Functions Only Defined on Bijections?
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 19/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 20/46
Why are Inverse Functions Only Defined on Bijections? Inverse Function Examples
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 21/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 22/46
I What is f ◦ g?
A B C
g f
a
g(a) f(g(a))
f g
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 23/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 24/46
4
Another Composition Example Example
I First, (f −1 ◦ f )(x ) = f −1 (f (x ))
I Prove that if f and g are injective, then f ◦ g is also injective.
I Let f (x ) be y
I Then, f −1 (f (x )) = f −1 (y)
I Thus, f −1 (f (x )) = f −1 (y) = x
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 25/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 26/46
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 27/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 28/46
Useful Properties of Floor and Ceiling Functions Proofs about Floor/Ceiling Functions
I I I I I
I I I I I x-1 n x m x+1
x-1 n x m x+1 (m-1) (n+1)
(m-1) (n+1)
Prove that b−x c = − dx e
1. For integer n and real number x , bx c = n iff n ≤ x < n + 1
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 29/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 30/46
5
Another Example More Examples
Prove that b2x c = bx c + x + 12
I I I I I I Observe: Any real number x can be written as n + where
x-1 n x m x+1
(m-1) (n+1) n = bx c and 0 ≤ < 1
I 1
Case 1: 0 ≤ < 2
I 1
Case 2: 2 ≤<1
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 31/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 32/46
I Earlier we talked about sets and cardinality of sets 1. Countably infinite sets (e.g., natural numbers)
I Recall: Cardinality of a set is number of elements in that set 2. Uncountably infinite sets (e.g., real numbers)
I This definition makes sense for sets with finitely many I A set A is called countably infinite if there is a bijection
element, but more involved for infinite sets between A and the set of positive integers.
I Agenda: Revisit the notion of cardinality for infinite sets I A set A is called countable if it is either finite or countably
infinite
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 33/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 34/46
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 35/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 36/46
6
Another Way to Prove Countable-ness Another Example
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 37/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 38/46
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 39/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 40/46
I How to enumerate entries in this table without missing any? I This allows us to list all rationals in a sequence:
I Trick: First list those with p + q = 2, then p + q = 3, . . . 1 2 1 1 2 3 4 3
, , , , , , , ,...
1 1 2 3 2 1 1 2
I Traverse table diagonally from left-to-right, in the order shown
I Hence, set of rationals is countable
by arrows
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 41/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 42/46
7
Uncountability of Real Numbers Cantor’s Diagonalization Argument
I The fact that R is uncountably infinite was proven by George I Now, if reals between 0 and 1 are countable, we can list them
Cantor using the famous Cantor’s diagonalization argument in the following way:
Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 43/46 Instructor: Işıl Dillig, CS311H: Discrete Mathematics Functions 44/46