
Functions 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 . I If f maps element a A to element b B, we write f (a) = b Instructor: I¸sıl Dillig ∈ ∈ 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 1/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 2/46 Functions Examples and Non-Examples Functions Examples and Non-Examples Is this mapping a function? Is this mapping a function? A B A B Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 3/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 4/46 Functions Examples and Non-Examples Functions Examples and Non-Examples Is this mapping a function? Is this mapping a function? A B A B Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 5/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 6/46 1 Function Terminology Examples Image of a Set I We can extend the definition of image to a set A B a I Suppose f is a function from A to B and S is a subset of A d b e c I The image of S under f includes exactly those elements of B f that are images of elements of S: 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? I What is the preimage of e? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 7/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 8/46 One-to-One Functions More Injective Function Examples 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 : I Is this function injective? x, y. (f (x) = f (y) x = y) ∀ → A B a I One-to-one functions never assign different elements in the d b e domain to the same element in the codomain: c f g x, y. (x = y f (x) = f (y)) ∀ 6 → 6 2 I Consider the function f (x) = x from set of integers to set of I A one-to-one function also called injection or injective function integers. Is this injective? I Is this function one-to-one? I What about if the domain of f is the set of non-negative integers? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 9/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 10/46 Proving Injectivity Example Proving Injectivity Example, cont. I Consider the function f from Z to Z defined as: 3x + 1 if x 0 f (x) = ≥ 3x + 2 if x < 0 − I Prove that f is injective. I We need to show that if x = y, then f (x) = f (y) 6 6 I What proof technique do we need to use? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 11/46 Instructor: I¸sı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 ∀ ∈ ∃ ∈ I Note: x A. φ is shorthand for x.(x A φ), and ∃ ∈ ∃ ∈ ∧ x A. φ is shorthand for x.(x A φ) ∀ ∈ ∀ ∈ → I Onto functions also called surjective functions or surjections I For onto functions, range and codomain are the same I Is this function onto? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 13/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 14/46 Examples of Onto Functions Bijective Functions I Function that is both onto and one-to-one called bijection I Is this function onto? A B a I Bijection also called one-to-one correspondenced or invertible function b e A B c f g I Example of bijection: A B a 2 d I Consider the function f (x) = x from the set of integers to b e the set of integers. Is f surjective? c f Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 15/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 16/46 Bijection Example Bijection Example, cont. 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) = b ∀ ∈ 6 I Need to prove I is both one-to-one and onto. I Since I (a) = a, this means a A. a = b ∀ ∈ 6 I One-to-one: We need to show x, y. (x = y I (x) = I (y)) ∀ 6 → 6 I But since b is itself in A, this would imply b = b, yielding a 6 I Suppose x = y. contradiction. 6 I Since I (x) = x and I (y) = y, and x = y, I (x) = I (y) I Since I is both onto and one-to-one, it is a bijection. 6 6 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 17/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 18/46 3 Inverse Functions Why are Inverse Functions Only Defined on Bijections? I Every bijection from set A to set B also has an inverse function A B a I Suppose f is not injective, i.e., assigns distinct elements to 1 d I The inverse of bijectionb f , written f − , is the function that the same element. assigns to b B a unique element a Aesuch that f (a) = b ∈ c ∈ A B f f a b f -1 I Then, the inverse is not a function because it assigns the I Observe: Inverse functions are only defined for bijections, not same element to distinct elements arbitrary functions! I This is why bijections are also called invertible functions Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 19/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 20/46 Why are Inverse Functions Only Defined on Bijections? Inverse Function Examples I Suppose f is not surjective, i.e., range and codomain are not the same A B a 2 I Let f be the function from Z to Z such thatd f (x) = x . Is f b e invertible? c f g I Let g be the function from Z to Z such that g(x) = x + 1. Is g invertible? 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/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 22/46 Function Composition Composition Example 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: ◦ I Let f and g be function from Z to Z such that f (x) = 2x + 3 (f g)(x) = f (g(x)) ◦ and g(x) = 3x + 2 I What is f g? A B g f C ◦ a g(a) f(g(a)) f g Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 23/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 24/46 4 Another Composition Example Example 1 I Prove that f f = I where I is the identity function. − ◦ 1 I Since I (x) = x, need to show (f f )(x) = x − ◦ 1 1 I First, (f − f )(x) = f − (f (x)) ◦ I Prove that if f and g are injective, then f g is also injective. ◦ I Let f (x) be y 1 1 I Then, f − (f (x)) = f − (y) 1 I By definition of inverse, f − (y) = x iff f (x) = y 1 1 I Thus, f − (f (x)) = f − (y) = x Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 25/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 26/46 Floor and Ceiling Functions Ceiling Function I Two important functions in discrete math are floor and ceiling I The ceiling of a real number x, written x , is the smallest d e functions, both from R to Z integer greater than or equal to x. I The floor of a real number x, written x , is the largest b c integer less than or equal to x. Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 27/46 Instructor: I¸sı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 x-1 n x m x+1 (m-1) (n+1) Prove that x = x b− c − d e 1. For integer n and real number x, x = n iff n x < n + 1 b c ≤ 2. For integer n and real number x, x = m iff m 1 < x m d e − ≤ 3. For any real x, x 1 < x x x < x + 1 − b c ≤ ≤ d e Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 29/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 30/46 5 Another Example More Examples Prove that 2x = x + x + 1 b c b c 2 I Observe: Any real number x can be written as n + where n = x and 0 < 1 b c ≤ Prove that x + k = x + k where k is an integer I To prove desired property, do proof by cases b c b c 1 I Case 1: 0 < ≤ 2 1 I Case 2: < 1 2 ≤ I First prove property for first case, then second case Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 31/46 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Functions 32/46 Revisiting Sets Cardinality of Infinite Sets I Sets with infinite cardinality are classified into two classes: I Earlier we talked about sets and cardinality of sets 1.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-