Docsity

CS311H: Discrete Mathematics Functions, Slides of Discrete Mathematics

Toggle sidebar
bg1
CS311H: Discrete Mathematics
Functions
Instructor: I¸sıl Dillig
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 1/46
Functions
IAfunction ffrom a set Ato a set Bassigns each element of
Ato exactly one element of B.
IAis called domain of f, and Bis called codomain of f.
IIf fmaps element a∈Ato element b∈B, we write f(a) = b
IIf f(a) = b,bis called image of a;ais in preimage of b.
IRange of fis the set of all images of elements in A.
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 2/46
Functions Examples and Non-Examples
Is this mapping a function?
AB
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 3/46
Functions Examples and Non-Examples
Is this mapping a function?
AB
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 4/46
Functions Examples and Non-Examples
Is this mapping a function?
AB
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 5/46
Functions Examples and Non-Examples
Is this mapping a function?
AB
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 6/46
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download CS311H: Discrete Mathematics Functions and more Slides Discrete Mathematics in PDF only on Docsity!

CS311H: Discrete Mathematics

Functions

Instructor: I¸sıl Dillig

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 1/

Functions

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/

Functions Examples and Non-Examples

Is this mapping a function?

A (^) B

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 3/

Functions Examples and Non-Examples

Is this mapping a function?

A (^) B

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 4/

Functions Examples and Non-Examples

Is this mapping a function?

A (^) B

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 5/

Functions Examples and Non-Examples

Is this mapping a function?

A (^) B

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 6/

Function Terminology Examples

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/

Image of a Set

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/

One-to-One Functions

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/

More Injective Function Examples

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/

Proving Injectivity Example

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/

Proving Injectivity Example, cont.

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 12/

Inverse Functions

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/

Why are Inverse Functions Only Defined on Bijections?

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/

Why are Inverse Functions Only Defined on Bijections?

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/

Inverse Function Examples

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/

Function Composition

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/

Composition Example

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/

Another Composition Example

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/

Example

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/

Floor and Ceiling Functions

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/

Ceiling Function

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/

Useful Properties of Floor and Ceiling Functions

I I I I I

x-1 n x^ x+ (m-1)

m (n+1)

  1. For integer n and real number x , bx c = n iff n ≤ x < n + 1
  2. For integer n and real number x , dx e = m iff m − 1 < x ≤ m
  3. For any real x , x − 1 < bx c ≤ x ≤ dx e < x + 1

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 29/

Proofs about Floor/Ceiling Functions

I I I I I

x-1 n x (^) x+ (m-1)

m (n+1)

Prove that b−x c = − dx e

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 30/

Another Way to Prove Countable-ness

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/

Another Example

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/

Rational Numbers are Countable

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/

Rationals in a Table

I (^) Now imagine placing rationals in a table such that:

  1. Rationals with p = 1 go in first row, p = 2 in second row, etc.
  2. Rationals with q = 1 in 1st column, q = 2 in 2nd column,...

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 40/

Enumerating the Rationals

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/

Enumerating the Rationals, cont.

I (^) This allows us to list all rationals in a sequence:

1 1 ,^

1 ,^

2 ,^

3 ,^

2 ,^

1 ,^

1 ,^

I (^) Hence, set of rationals is countable

Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 42/

Uncountability of Real Numbers

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/

Cantor’s Diagonalization Argument

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/

Diagonalization Argument, cont

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/

Diagonalization Argument, concluded

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/