1 Chapter 2 - 2 Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess.

Slides:



Advertisements
Similar presentations
Countability. The cardinality of the set A is equal to the cardinality of a set B if there exists a bijection from A to B cardinality? bijection? injection.
Advertisements

COUNTING AND PROBABILITY
Equivalence, Order, and Inductive Proof
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
1 Chapter Equivalence, Order, and Inductive Proof.
1 Chapter Facts about Functions. 2 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly.
1 Diagonalization Fact: Many books exist. Fact: Some books contain the titles of other books within them. Fact: Some books contain their own titles within.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 10 Cardinality Uncountability of the real numbers.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Functions f( ) = A B Lecture 15: Nov 4.
1 Discrete Math CS 2800 Prof. Bart Selman Module Basic Structures: Functions and Sequences.
Pigeonhole.
Discrete Math for CS Chapter 5: Functions. Discrete Math for CS New Relation Operations: Given R, a relation on A x B, we define the inverse relation,
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements of two sets such that no element of the first set is.
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
Cardinality of Sets Section 2.5.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
1 Section 2.3 Properties of Functions Let ƒ : A  B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one):
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
1 Lecture 3 (part 3) Functions – Cardinality Reading: Epp Chp 7.6.
Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
MSU/CSE 260 Fall Functions Read Section 1.8.
1 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly one element of B. Write ƒ : A  B.
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
MAT 3749 Introduction to Analysis Section 1.3 Part I Countable Sets
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.1 and 7.2.
Mathematical Induction
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Relations, Functions, and Countability
Discrete Mathematics R. Johnsonbaugh
Section 2.2: Affine Ciphers; More Modular Arithmetic Shift ciphers use an additive key. To increase security, we can add a multiplicative parameter. –For.
COMPSCI 102 Introduction to Discrete Mathematics.
Discrete Structures Li Tak Sing ( 李德成 ) Lectures
1 Section Congruences In short, a congruence relation is an equivalence relation on the carrier of an algebra such that the operations of the algebra.
Introduction to Real Analysis Dr. Weihu Hong Clayton State University 8/27/2009.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
1 Section 4.3 Order Relations A binary relation is an partial order if it transitive and antisymmetric. If R is a partial order over the set S, we also.
Great Theoretical Ideas in Computer Science.
Lecture 4 Infinite Cardinals. Some Philosophy: What is “2”? Definition 1: 2 = 1+1. This actually needs the definition of “1” and the definition of the.
CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
CS 285- Discrete Mathematics
1 Section 4.2 Equivalence Relations A binary relation is an equivalence relation if it has the three properties reflexive, symmetric, and transitive (RST).
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Discrete Structures Li Tak Sing( 李德成 ) mt263f ppt 1.
Section 2.5. Cardinality Definition: A set that is either finite or has the same cardinality as the set of positive integers (Z + ) is called countable.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
Sequences Lecture 11. L62 Sequences Sequences are a way of ordering lists of objects. Java arrays are a type of sequence of finite size. Usually, mathematical.
1 Section 4.4 Inductive Proof What do we believe about nonempty subsets of N? Since  N, <  is well-founded, and in fact it is linear, it follows that.
1-1 Copyright © 2013, 2005, 2001 Pearson Education, Inc. Section 2.4, Slide 1 Chapter 2 Sets and Functions.
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Discrete Mathematics CS 2610
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Cardinality of Sets Section 2.5.
Lecture 7 Functions.
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Presentation transcript:

1 Chapter Facts about Functions

2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one): Distinct elements in A map to distinct elements in B. In other words, x ≠ y implies ƒ(x) ≠ ƒ(y) or, equivalently, ƒ(x) = ƒ(y) implies x = y. Example. Let ƒ : N 8 → N be defined by ƒ(x) = 2x mod 8. ƒ is not injective. e.g., ƒ(0) = ƒ(4).

3 Quiz (1 minute) Quiz (1 minute). Let ƒ : Z → N be defined by ƒ(x) = x 2. Is ƒ injective? Answer. No. e.g., ƒ(2) = ƒ(–2). Quiz (1 minute). Are any of the three functions injective? log 2, floor, ceiling. Answer. log 2 is injective, but floor and ceiling are not.

4 Surjectivity Surjective (also called onto): The range is the codomain. In other words, each b ∊ B has the form b = ƒ(a) for some a ∊ A. Example. ƒ : Z → N defined by ƒ(x) = x 2 is not surjective. E.g., 2 is not a square. Example. ƒ : Z → N defined by ƒ(x) = | x | is surjective but not injective.

5 Bijectivity Bijective (also called one-to-one and onto): Both injective and surjective. Example. Let ƒ : N → {a}* by ƒ(n) = a n. Then ƒ is a bijection. Example. The function ƒ : (0, 1) → (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. Proof: If ƒ(x) = ƒ(y), then 3x + 2 = 3y + 2, which implies that x = y. So ƒ is injective. Let y ∊ (2, 5). Does y = ƒ(x) = 3x + 2 for some x ∊ (0, 1)? Solve the equation for x to get x = (y – 2)/3. Since y ∊ (2, 5), we have y – 2 ∊ (0, 3). So x = (y – 2)/3 ∊ (0, 1). Thus ƒ(x) = y. So ƒ is surjective. Thus ƒ is bijective. Quiz (2 minutes). Let ƒ : R → R by ƒ(x) = x 3. Is ƒ bijective?

6 Inverse Inverses: If ƒ : A → B is a bijection, then there is an inverse function g : B → A defined by g(b) = a iff ƒ(a) = b. The inverse of ƒ is denoted by ƒ –1. Example. We have observed that the function ƒ : (0, 1) → (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. So ƒ –1 : (2, 5) → (0, 1) is defined by ƒ –1 (x) = (x– 2)/3.

7 Example ƒ : N 5 → N 5 defined by ƒ(x) = (4x + 1) mod 5 is a bijection (check each value). So it has an inverse. To see that it is a bijection (without listing the values) and to find a formula for the inverse, we can apply the theorem in the next slide.

8 mod and inverses Theorem (mod and inverses) Let n > 1 and ƒ : N n → N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ is bijective iff gcd(a, n) = 1. If so, then ƒ –1 (x) = (kx + c) mod n where ƒ(c) = 0 and 1 = ak + nm.

9 Example Let ƒ : N 5 → N 5 be defined by ƒ(x) = (4x + 1) mod 5. Since gcd(4, 5) = 1, the theorem says that ƒ is a bijection. We test values to find c such that ƒ(c) = 0. e.g., ƒ(1) = 0. We can use Euclid’s algorithm to verify that 1 = gcd(4, 5) and then work backwards through the equations to find that 1 = 4(–1) + 5(1). So k = –1. Thus ƒ –1 (x) = (–x + 1) mod 5. (Check it out).

10 Quiz (3 minutes) Quiz (3 minutes). Let ƒ : N 13 → N 13 be defined by ƒ(x) = (7x + 5) mod 13. Find ƒ –1 if it exists. Answer. gcd(7, 13) = 1. So ƒ is a bijection. ƒ(3) = 0 and 1 = 7(2) + 13(–1). So we can write ƒ –1 (x) = (2x + 3) mod 13.

11 Pigeon Hole Principle If m things are put into n places and m > n, then one place has two or more things. Another way to say this is that if A and B are finite sets with | A | > | B |, then there are no injections from A to B. Example. The function ƒ : N 7 → N 6 defined by ƒ(x) = x mod 6 has ƒ(0) = ƒ(6).

12 Example In Mexico City there are two people with the same number of hairs on their heads. Everyone has less than 10 million hairs on their head and the population of Mexico City is more than 10 million. So the pigeon hole principle applies.

13 Example If 11 numbers are chosen from S = {1, 2, 3, …, 19, 20}, then for two of the numbers chosen one divides the other. Proof: Each natural number x ≥ 1 has a factorization x = 2 k m for some k ≥ 0 where m is odd. So the numbers in S can be written in this form: 1 = 2 0 ·1, 2 = 2 1 ·1, 3 = 2 0 ·3, 4 = 2 2 ·1, 5 = 2 0 ·5, …, 12 = 2 2 ·3, …, 19 = 2 0 ·19, 20 = 2 2 ·5. Notice that the values of m are in the set {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, which has 10 elements. So by the pigeon hole principle two of the 11 chosen numbers, say x and y, must share the same m. i.e., x = 2 k m and y = 2 j m for k ≠ j. So either x | y or y | x. QED.

14 Quiz (2 minutes) Find 10 numbers in S that don’t divide each other. An answer: 6, 7, 8, 9, 11, 13, 15, 17, 19, 20.

15 Ciphers and the mod function (some cryptology) Let the letters from a to z be represented by 0, 1, …, 25, respectively. Now any bijection ƒ : N 26 → N 26 can act as a cipher and it’s inverse ƒ –1 can act as a decipher.

16 Examples Example (additive cipher). ƒ(x) = (x + 2) mod 26 and ƒ –1 (x) = (x + 24) mod 26. Example (multiplicative cipher). ƒ(x) = 3x mod 26 and ƒ –1 (x) = 9x mod 26. Example (affine cipher). ƒ(x) = (5x + 1) mod 26 and ƒ –1 (x) = (–5x +5) mod 26. Some ciphers keep one or more letters fixed. For example, the cipher ƒ(x) = 3x mod 26 has ƒ(0) = 0, so it sends the letter a to itself. The following theorem can be used to construct ciphers with no fixed letters.

17 Mod and Fixed Points Let n > 0 and let ƒ : N n → N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ has no fixed points iff gcd(a – 1, n) does not divide b. Example. Both the additive and affine ciphers in the preceding examples have no fixed points.

18 Hash Functions The goal is to use a key of some kind to look up information in a table, but without searching. A hash function maps a set S of keys into a finite set N n of table indexes. The table is called a hash table. Collisions occur if the function is not injective. If there are no collisions, then any key in S is mapped to the index where the information is stored without any searching.

19 Example Let S be the students in a class and let h : S → N 366 be defined by letting h(x) be the birthday of x. If two people have the same birthday, then a collision occurs.

20 Resolving Collisions by Linear Probing If a collision occurs at index k, then some key is placed in location k and the other colliding keys must be located elsewhere. Linear probing is a technique to search (probe) for an open place in the table by looking linearly at the following places, where g is a fixed gap: (k + g) mod n, (k + 2g) mod n, …, (k + (n – 1)g) mod n.

21 Example Let S = {jan, feb, mar, apr, may, jun} and let h : S → N 6 be defined by h(xyz) = p(x) mod 6, where p(x) is the position of x in the alphabet (p(a) = 1, …, p(z) = 26). We’ll place the keys from S into a hash table by first placing jan, then feb, and so on. h(jan) = p(j) mod 6 = 10 mod 6 = 4. So place jan in position 4 of the table. Continue the process to get h(feb) = 0, h(mar) = 1, h(apr) = 1 (collision with mar), h(may) = 1 (collision with mar and apr), and h(jun) = 4 (collision with jan). The table shows the result of resolving collisions by linear probing with a gap of 1. feb mar apr may jan jun

22 Quizzes Quiz (2 minutes). Resolve collisions with gap = 2. Answer: feb, mar, jun, apr, jan, may. Quiz (2 minutes). Resolve collisions with gap = 3. Answer: feb, mar, blank, blank, jan, blank. (apr, may, and jun are not placed).

23 Property If n is the table size and g is a gap, then gcd(g, n) = 1 implies that all indexes are probed with gap g. So we were lucky to fill the table when the gap was 2. If the table size is a prime number p, then any gap other than p will insure that all keys are entered in the table.

24 Section 2.4 Countability We can compare the cardinality of two sets by properties of functions. | A | = | B | means there is a bijection between A and B. | A | ≤ | B | means there is an injection from A to B. | A | < | B | means | A | ≤ | B | and | A | ≠ | B |.

25 Example Let A = {3x + 4 | x ∊ N and 0 ≤ 3x + 4 ≤ 1000}. What is | A |? Solution. Notice that 0 ≤ 3x + 4 ≤ 1000 iff – 4/3 ≤ x ≤ 996/3 iff –4/3 ≤ x ≤ 332. So we can rewrite the definition of A = {3x + 4 | x ∊ N and 0 ≤ x ≤ 332}. Now we can define a function ƒ : {0, 1, …, 332} → A by ƒ(x) = 3x + 4. Notice that ƒ is a bijection. So | A | = 333.

26 A condition A set S is countable if | S | = | N n | for some n (i.e., S is finite) OR | S | = | N |. Otherwise S is uncountable. If | S | = | N | we sometimes say that S is countably infinite. Example. Z is countable. i.e., | Z | = | N |. To prove this we need to find a bijection between Z and N. Let ƒ : N → Z be defined by ƒ(2k) = k and ƒ(2k + 1) = – (k + 1). Check that ƒ is a bijection.

27 Some Countability Results 1. S ⊂ N implies S is countable. 2. S is countable iff | S | ≤ | N |. 3. Subsets and images of countable sets are countable. 4. N × N is countable. Use Cantor’s bijection to associate (x, y) with ((x + y) 2 + 3x + y)/2. 5. If each of the sets S 0, S 1, …, S n, … is countable, then so is S 0 ∪ S 1 ∪ … ∪ S n ….

28 Example Is N × N × N countable? Let S = {(x, y, z) ∊ N 3 | x + y + z = n}. Each of sets S 0, S 1, …, S n, … is countable (actually finite). So the union S 0 ∪ S 1 ∪ … ∪ S n … is also countable. But the union is N 3, so N 3 is countable.

29 Diagonalization Technique Given a countable listing of sequences S 0, S 1, …, S n, …, where each sequence has the form S n = (a n0, a n1, …, a nn, …) where each a ni ∊ A and | A | ≥ 2. Then there is a sequence over A that is not in the listing. A sequence S not in the listing can be defined by choosing two elements x, y ∊ A and letting S = (a 0, a 1, …, a n, …) where a n = if a nn = x then y else x.

30 Example The set of languages over the alphabet {a} is uncountable. Proof: Assume, BWOC, that L 0, L 1, …, L n, …, is a countable listing of all languages over {a}. We can represent each language L n by a sequence S n over {0, 1} as follows: S n = (a n0, a n1, …, a nn, …), where a ni = if a i ∊ L n then 1 else 0. But now the Diagonlization technique applies to tell us there is a sequence not listed. So there is a language that is not listed. So the set of languages is uncountable. QED.

31 Cantor’s Result | A | < | power(A) | for any set A. Example. Power(N) is uncountable because | N | < | power(N) |. Example. The closed interval [0, 1] is uncountable. Show that | [0, 1] | = | power(N) |. We can represent each x ∊ [0, 1] as a binary string 0.b 0 b 1 b 2 …. Then associate x with the set S x = {i | b i = 1}. e.g., … is associated with the set {0, 2, 4, 6, …}. This association is a bijection between [0, 1] and power(N).

32 The End of Chapter 2 - 2