1 / 32

Chapter 2 - 2

Chapter 2 - 2. Facts about Functions. 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.

Télécharger la présentation

Chapter 2 - 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. • 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 ƒ : N8→ 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) = x2. Is ƒ injective? • Answer. No. e.g., ƒ(2) = ƒ(–2). • Quiz (1 minute). Are any of the three functions injective? log2, floor, ceiling. • Answer. log2 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) = x2 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) = an. 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) = x3. 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 • ƒ : N5→ N5 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 ƒ : Nn→ Nn 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 ƒ : N5→ N5 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 ƒ : N13→ N13 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 ƒ : N7→ N6 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 = 2km for some k ≥ 0 where m is odd. So the numbers in S can be written in this form: 1 = 20·1, 2 = 21·1, 3 = 20·3, 4 = 22·1, 5 = 20·5, …, 12 = 22·3, …, 19 = 20 ·19, 20 = 22·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 = 2km and y = 2jm 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 ƒ : N26→ N26 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 ƒ : Nn→ Nn 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 Nn 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 → N366 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 → N6 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. 0 1 2 3 4 5

  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 | = | Nn| 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 S0, S1, …, Sn, … is countable, then so is S0∪ S1∪ … ∪ Sn … .

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

  29. Diagonalization Technique • Given a countable listing of sequences S0, S1, …, Sn, …, where each sequence has the form Sn = (an0, an1, …, ann, …) where each ani∊ 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 = (a0, a1, …, an, …) where an = if ann = x then y else x.

  30. Example • The set of languages over the alphabet {a} is uncountable. • Proof: Assume, BWOC, that L0, L1, …, Ln, …, is a countable listing of all languages over {a}. We can represent each language Ln by a sequence Sn over {0, 1} as follows: Sn = (an0, an1, …, ann, …), where ani = if ai∊ Ln 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.b0b1b2… . Then associate x with the set Sx = {i | bi = 1}. e.g., 0.10101010… 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

More Related