




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Instructor: I¸sıl Dillig
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 1/
I (^) A function f from a set A to a set B assigns each element of A to exactly one element of B.
I (^) A is called domain of f , and B is called codomain of f.
I (^) If f maps element a ∈ A to element b ∈ B, we write f (a) = b
I (^) If f (a) = b, b is called image of a; a is in preimage of b.
I (^) Range of f is the set of all images of elements in A.
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 2/
Is this mapping a function?
A (^) B
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 3/
Is this mapping a function?
A (^) B
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 4/
Is this mapping a function?
A (^) B
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 5/
Is this mapping a function?
A (^) B
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 6/
A (^) B a b c
d e f
I (^) What is the range of this function?
I (^) What is the image of c?
I (^) What is the preimage of e?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 7/
I (^) We can extend the definition of image to a set
I (^) Suppose f is a function from A to B and S is a subset of A
I (^) The image of S under f includes exactly those elements of B that are images of elements of S :
f (S ) = {t | ∃s ∈ S. t = f (s)}
I (^) What is the image of {b, c}? A (^) B a b c
d e f
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 8/
I (^) A function f is called one-to-one if and only if f (x ) = f (y) implies x = y for every x , y in the domain of f : ∀x , y. (f (x ) = f (y) → x = y)
I (^) One-to-one functions never assign different elements in the domain to the same element in the codomain: ∀x , y. (x 6 = y → f (x ) 6 = f (y))
I (^) A one-to-one function also called injection or injective function
I (^) Is this function one-to-one? A (^) B a b c
d e f Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 9/
I (^) Is this function injective?
A (^) B a b c
d e f g
I (^) Consider the function f (x ) = x 2 from set of integers to set of integers. Is this injective?
I (^) What about if the domain of f is the set of non-negative integers?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 10/
I (^) Consider the function f from Z to Z defined as:
f (x ) =
3 x + 1 if x ≥ 0 − 3 x + 2 if x < 0
I (^) Prove that f is injective.
I (^) We need to show that if x 6 = y, then f (x ) 6 = f (y)
I (^) What proof technique do we need to use?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 11/
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 12/
I (^) Every bijection from set A to set B also has an inverse function
I (^) The inverse of bijection f , written f −^1 , is the function that assigns to b ∈ B a unique element a ∈ A such that f (a) = b A (^) B a (^) b
f
f -
I (^) Observe: Inverse functions are only defined for bijections, not arbitrary functions!
I (^) This is why bijections are also called invertible functions
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 19/
I Suppose f is not injective, i.e., assigns distinct elements to the same element. A (^) B a b c
d e f
I (^) Then, the inverse is not a function because it assigns the same element to distinct elements
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 20/
I (^) Suppose f is not surjective, i.e., range and codomain are not the same A (^) B a b c
d e f g
I (^) Then, the inverse is not a function because it does not assign some element in B to any element in A
I (^) Hence, inverse functions only defined for bijections!
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 21/
I (^) Let f be the function from Z to Z such that f (x ) = x 2. Is f invertible?
I (^) Let g be the function from Z to Z such that g(x ) = x + 1. Is g invertible?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 22/
I (^) Let g be a function from A to B, and f from B to C.
I (^) The composition of f and g, written f ◦ g, is defined by:
(f ◦ g)(x ) = f (g(x ))
A (^) B a g(a)
g f C
f(g(a))
f g
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 23/
I (^) Let f and g be function from Z to Z such that f (x ) = 2x + 3 and g(x ) = 3x + 2
I (^) What is f ◦ g?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 24/
I (^) Prove that f −^1 ◦ f = I where I is the identity function.
I (^) Since I (x ) = x , need to show (f −^1 ◦ f )(x ) = x
I (^) First, (f −^1 ◦ f )(x ) = f −^1 (f (x ))
I (^) Let f (x ) be y
I (^) Then, f −^1 (f (x )) = f −^1 (y)
I By definition of inverse, f −^1 (y) = x iff f (x ) = y
I (^) Thus, f −^1 (f (x )) = f −^1 (y) = x
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 25/
I (^) Prove that if f and g are injective, then f ◦ g is also injective.
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 26/
I (^) Two important functions in discrete math are floor and ceiling functions, both from R to Z
I (^) The floor of a real number x , written bx c, is the largest integer less than or equal to x.
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 27/
I (^) The ceiling of a real number x , written dx e, is the smallest integer greater than or equal to x.
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 28/
x-1 n x^ x+ (m-1)
m (n+1)
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 29/
x-1 n x (^) x+ (m-1)
m (n+1)
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 30/
I One way to show a set A is countably infinite is to give bijection between Z+^ and A
I (^) Another way is by showing members of A can be written as a sequence (a 1 , a 2 , a 3 ,.. .)
I (^) Since such a sequence is a bijective function from Z+^ to A, writing A as a sequence a 1 , a 2 , a 3 ,... establishes one-to-one correspondence
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 37/
Prove that the set of all integers is countable
I (^) We can list all integers in a sequence, alternating positive and negative integers:
an = 0, 1 , − 1 , 2 , − 2 , 3 , − 3 ,...
I (^) Observe that this sequence defines the bijective function:
f (n) =
n/ 2 if n even −(n − 1)/ 2 if n odd
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 38/
I (^) Not too surprising Z and odd Z+^ are countably infinite
I (^) More surprising: Set of rationals is also countably infinite!
I (^) We’ll prove that the set of positive rational numbers is countable by showing how to enumerate them in a sequence
I (^) Recall: Every positive rational number can be written as the quotient p/q of two positive integers p, q
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 39/
I (^) Now imagine placing rationals in a table such that:
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 40/
I (^) How to enumerate entries in this table without missing any?
I (^) Trick: First list those with p + q = 2, then p + q = 3,...
I (^) Traverse table diagonally from left-to-right, in the order shown by arrows
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 41/
I (^) This allows us to list all rationals in a sequence:
1 1 ,^
I (^) Hence, set of rationals is countable
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 42/
I (^) Prime example of uncountably infinite sets is real numbers
I (^) The fact that R is uncountably infinite was proven by George Cantor using the famous Cantor’s diagonalization argument
I (^) Reminiscient of Russell’s paradox
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 43/
I (^) For contradiction, assume the set of reals was countable
I (^) Since any subset of a countable set is also countable, this would imply the set of reals between 0 and 1 is also countable
I (^) Now, if reals between 0 and 1 are countable, we can list them in the following way:
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 44/
I (^) Now, we’ll create a new real number R and show that it is not equal to any of the Ri ’s in this sequence:
I (^) Let R = 0.a 1 a 2 a 3... such that:
ai =
4 dii 6 = 4 5 dii = 4
I (^) Clearly, this new number R differs from each number Ri in the table in at least one digit (its i’th digit) Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 45/
I (^) Since R is not in the table, this is not a complete enumeration of all reals between 0 and 1
I (^) Hence, the set of real between 0 and 1 is not countable
I (^) Since the superset of any uncountable set is also uncountable, set of reals is uncountably infinite
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 46/