Math236 Discrete Maths with Applications P. Ittmann UKZN, Pietermaritzburg Semester 1, 2012 Ittmann (UKZN PMB) Math236 2012 1 / 43
The Multiplication Principle Theorem Let S be a set of k-tuples (s 1, s 2,..., s k ) of objects in which: the rst object s 1 comes from a set of size n 1 for each choice of s 1 there are n 2 choices for object s 2 for each choice of s 2 there are n 3 choices for object s 3 for each choice of s 3 there are n 4 choices for object s 4 and, in general, for each choice of s i, 1 i k 1, there are n i+1 choices for object s i+1 Then the number of k-tuples in the set S is n 1 n 2 n k Ittmann (UKZN PMB) Math236 2012 2 / 43
The Multiplication Principle (cont.) How many 4-digit odd numbers are there? We consider each number abcd as the 4-tuple (a, b, c, d) Such a number is odd if and only if the last digit, d, is in the set {1, 3, 5, 7, 9} There are no other restrictions on the digits Thus: n 1 = 9 (since the rst digit cannot be 0), n 2 = n 3 = 10, and n 4 = 5 It follows that the number of 4-digit odd numbers is 9 10 10 5 = 4500 Ittmann (UKZN PMB) Math236 2012 3 / 43
Basic counting principles How many odd numbers less than 10,000 are there? We use the Addition Principle together with the Multiplication Principle For i {1, 2, 3, 4}, let N i be the set of all i-digit odd numbers So, N 1 = {1, 3, 5, 7, 9}, N 2 = {11, 13, 15, 17, 19, 21,..., 99} and so on Notice that {N 1, N 2, N 3, N 4 } is a pairwise disjoint collection of sets Ittmann (UKZN PMB) Math236 2012 4 / 43
Basic counting principles (cont.) By the Addition Principle, the number of odd numbers less than 10,000 is N 1 + N 2 + N 3 + N 4 Using the Multiplication Principle as we did in the previous example We see that N 1 = 5, N 2 = 45, N 3 = 450 and N 4 = 4500 Thus the answer is 4500 + 450 + 45 + 5 = 5000 Ittmann (UKZN PMB) Math236 2012 5 / 43
Basic counting principles (cont.) How many k-tuples can be chosen from a set of n elements if repetition is allowed? We seek the number of k-tuples (s 1, s 2,..., s k ) in which each s i from a xed set of n elements and in which it's possible that s i comes = s j For each position in the k-tuple, we can choose any one of n dierent elements Hence, by the Multiplication Principle, there are such k-tuples n n n }{{} = n k k terms Ittmann (UKZN PMB) Math236 2012 6 / 43
The Power Set Denition If S is a set, then we let 2 S called the power set of S denote the set of all subsets of S, sometimes If S = {a, b, c}, then 2 S = {, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}} Ittmann (UKZN PMB) Math236 2012 7 / 43
The Power Set (cont.) The Multiplication Principle enables us to prove a formula for the number of subsets of a set Theorem If S is a nite set, then 2 S = 2 S Ittmann (UKZN PMB) Math236 2012 8 / 43
The Power Set (cont.) Proof. Let S = {x 1, x 2,..., x S } With each subset A S do the following: Associate an S -tuple (a 1, a 2,..., a S ) with A Where for i {1, 2,..., S } we set { 0 if x i A a i = 1 if x i A. Clearly, each subset corresponds to exactly one S -tuple and each S -tuple corresponds to one subset Ittmann (UKZN PMB) Math236 2012 9 / 43
The Power Set (cont.) Proof. It follows that the number of subsets is equal to the number of such S -tuples Note each position in the S -tuple is chosen from a set {0, 1} of size 2 Thus we are asking the question How many S -tuples can be chosen from a set of 2 elements? From the second to last example, the answer is 2 S Ittmann (UKZN PMB) Math236 2012 10 / 43
The Power Set (cont.) Let S = {a, b, c} and let x 1 = a, x 2 = b, and x 3 = c The subset {a, c} corresponds to the 3-tuple (1, 0, 1) The subset {b} corresponds to the 3-tuple (0, 1, 0) According to previous theorem, the number of subsets of S is 2 S = 2 S = 2 3 = 8 This can be veried by counting the subsets Ittmann (UKZN PMB) Math236 2012 11 / 43
The Pigeonhole Principle The Pigeonhole Principle We study a principle referred to as the Pigeonhole Principle Theorem If n + 1 objects are placed into n boxes, then at least one box contains at least two objects Ittmann (UKZN PMB) Math236 2012 12 / 43
The Pigeonhole Principle The Pigeonhole Principle (cont.) Proof. Suppose this is not the case Then, each box contains at most one object This implies that the number of objects is at most n This is a contradiction If we choose 13 people, then there are two who have their birthday in the same month Ittmann (UKZN PMB) Math236 2012 13 / 43
The Pigeonhole Principle The Pigeonhole Principle (cont.) Suppose we have n married couples How many of the 2n people must be selected to guarantee that we have chosen at least one married couple? Construct n boxes, each corresponding to one married couple Each time we choose someone, place them into the box corresponding to the couple they are a member of The Pigeonhole Principle says that once we've chosen n + 1 people, at least one box must contain 2 people That is, we've chosen a married couple Ittmann (UKZN PMB) Math236 2012 14 / 43
The Pigeonhole Principle The Pigeonhole Principle (cont.) We choose 101 of the integers 1, 2,..., 200 We claim that among the integers chosen, there are two having the property that one is divisible by the other Each integer in {1, 2,..., 200} can be written in the form n2 k, where n is an odd number between 1 and 199 Ittmann (UKZN PMB) Math236 2012 15 / 43
The Pigeonhole Principle The Pigeonhole Principle (cont.) There are 100 odd integers in {1, 2,..., 200} So if we choose 101 numbers, by the Pigeonhole Principle, two of the numbers we've chosen must have the same odd n That is, two of the numbers we've chosen are of the form n2 k 1 n2 k 2 and We assume without loss of generality that k 1 k 2 The number n2 k 2 divides the number n2 k 1, as desired Ittmann (UKZN PMB) Math236 2012 16 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle We now give a stronger form of the Pigeonhole Principle Theorem Let n 1, n 2,..., n k be positive integers Let n 1 + n 2 + + n k k + 1 objects are placed into k boxes Then there is an integer i {1, 2,..., k} such that the i th box contains at least n i objects Ittmann (UKZN PMB) Math236 2012 17 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) Proof. Assume, to the contrary, that this is not the case Then for each i {1, 2,..., k}, the ith box contains at most n i 1 objects Thus the total number of objects is at most (n 1 1) + (n 2 1) + + (n k 1) = n 1 + n 2 + + n k k This is a contradiction Ittmann (UKZN PMB) Math236 2012 18 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) A basket of fruit is to be made up from apples, bananas, litchis, and mangos How many pieces of fruit must we place in the basket to be guaranteed that there are at least three apples or at least two bananas or at least ten litchis or at least ve mangos? From the Strong Pigeonhole Principle, the answer is 3 + 2 + 10 + 5 4 + 1 = 17 Ittmann (UKZN PMB) Math236 2012 19 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) Suppose that we choose n 2 + 1 integers from the integers 1, 2,..., n Think of this in the following way: We pick n 2 + 1 integers Each integer is put into a box marked from 1 to n depending on its value Ittmann (UKZN PMB) Math236 2012 20 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) Note that n 2 + 1 = (n + 1) + (n + 1) + + (n + 1) n + 1 }{{} n terms The Strong Pigeonhole Principle guarantees that at least one box contains at least n + 1 objects That is, at least one of the integers 1, 2,..., n is chosen at least n + 1 times Ittmann (UKZN PMB) Math236 2012 21 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) Let a 1, a 2,..., a k be a sequence of real numbers Recall that a subsequence of a 1, a 2,..., a k a i1, a i2,..., a it, where is of the form 1 i 1 < i 2 < < i t k The sequence a 1, a 2,..., a k is increasing if a 1 a 2 a k and decreasing if a 1 a 2 a t Ittmann (UKZN PMB) Math236 2012 22 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) Consider the sequence 8, 1, 3, 5, 9, 2, 6, 4, 7 Then 1, 5, 2, 7 is a subsequence, but 1, 2, 3, 4 is not Note that 1, 3, 5, 9 is an increasing subsequence, and 8, 5, 2 is a decreasing subsequence Ittmann (UKZN PMB) Math236 2012 23 / 43
The Pigeonhole Principle The Strong Pigeonhole Principle (cont.) The Strong Pigeonhole Principle enables us to prove the following interesting result, rst established by Erdös and Szekeres Theorem Every sequence a 1, a 2,..., a n 2 +1 of n2 + 1 real numbers contains an increasing subsequence of length n + 1 or a decreasing subsequence of length n + 1 Ittmann (UKZN PMB) Math236 2012 24 / 43
One-to-one functions and permutations One-to-one functions As mentioned before, a function is a relation in which each element of the domain is related to exactly one element of the range Let f be a function with the additional property that no two elements of its domain are related to the same element of its range That is, x y implies that f (x) f (y) We call f a one-to-one function, or an injection Ittmann (UKZN PMB) Math236 2012 25 / 43
One-to-one functions and permutations One-to-one functions (cont.) If f is one-to-one, then the relation is also a function f 1 = {(b, a) : (a, b) f } Conversely, if f is not one-to-one, then f 1 is not a function If f is an injection, then f 1 is called the inverse function of f Ittmann (UKZN PMB) Math236 2012 26 / 43
One-to-one functions and permutations One-to-one functions (cont.) Let f 1 = {(1, a), (2, c), (3, b)} and f 2 = {(1, a), (2, b), (3, b)} Both f 1 and f 2 are functions The function f 1 is an injection, while f 2 is not This follows since the element b of the range of f 2 is related to both 2 and 3 The inverse of f 1 is f 1 1 = {(a, 1), (c, 2), (b, 3))} Ittmann (UKZN PMB) Math236 2012 27 / 43
One-to-one functions and permutations One-to-one functions (cont.) The relation f 3 = {(x, x 2 ) : x R} is a function However, both (2, 4) and ( 2, 4) are members of f 3, so f 3 is not one-to-one The relation f 4 = {(x, 5x + 6) : x R} is a one-to-one function Its inverse is the function f 1 4 = {(x, (x 6)/5 : x R} The relation f 5 = {(x, tan(π(x 1/2))) : x (0, 1)} is a one-to-one function Its inverse is the function f 1 5 = {(x, (1/π) arctan x + 1/2) : x (, )} Ittmann (UKZN PMB) Math236 2012 28 / 43
One-to-one functions and permutations Permutations Let S be a nite nonempty set A permutation of S is a one-to-one function whose domain and range are both S Let S = {1, 2, 3} One permutation of S is the function f with f (1) = 1, f (2) = 3, and f (3) = 2 This permutation can be denoted in the following manner ( ) 1 2 3 f = 1 3 2 Ittmann (UKZN PMB) Math236 2012 29 / 43
One-to-one functions and permutations Permutations (cont.) The top row of the matrix is read as the domain and the bottom row as the range Thus, in general, this notation has this form ( ) 1 2 3 f = f (1) f (2) f (3) Ittmann (UKZN PMB) Math236 2012 30 / 43
One-to-one functions and permutations Permutations (cont.) There are six permutations of a set of three elements. The six permutations of {1, 2, 3} are: ( 1 2 3 f 1 = 1 2 3 ( 1 2 3 f 4 = 1 3 2 ) ) ( 1 2 3 f 2 = 2 3 1 ( 1 2 3 f 5 = 3 2 1 ) ) ( 1 2 3 f 3 = 3 1 2 ( 1 2 3 f 6 = 2 1 3 ) ) Ittmann (UKZN PMB) Math236 2012 31 / 43
One-to-one functions and permutations Permutations (cont.) Written this way, it's easy to nd the inverse of a permutation To do so, 1 Interchange the top and bottom rows of the matrix 2 (If necessary) re-order by the elements in the (new) rst row Ittmann (UKZN PMB) Math236 2012 32 / 43
One-to-one functions and permutations Permutations (cont.) The inverse of f 2 = ( 1 2 ) 3 2 3 1 is ( ) 2 3 1 1 2 3 After resorting the top row into ascending order, becomes the permutation ( ) 1 2 1 = f 3 3 1 2 In other words, f 1 2 = f 3 Ittmann (UKZN PMB) Math236 2012 33 / 43
One-to-one functions and permutations Permutations (cont.) Similarly f 1 1 = f 1 f 1 3 = f 2 f 1 4 = f 4 f 1 5 = f 5 f 1 6 = f 6 Ittmann (UKZN PMB) Math236 2012 34 / 43
One-to-one functions and permutations Permutations (cont.) If f = f 1, as is the case with f 1, f 4, f 5, and f 6, then f is called an involution Another way of writing permutations is as follows For the permutation ( ) 1 2 3 4 2 4 1 3 we only write the bottom row, (2413) Thus, we could write f 1 = (123), f 6 = (213), etc. Ittmann (UKZN PMB) Math236 2012 35 / 43
Counting permutations Counting permutations We now attempt to count permutations and similar mathematical objects How many permutations of the set S = {a, b, c} are there? As mentioned in the last example, we can think of each permutation on S as a 3-tuple (f (a), f (b), f (c)) The question then becomes: How many such 3-tuples are there? Ittmann (UKZN PMB) Math236 2012 36 / 43
Counting permutations Counting permutations (cont.) The value f (a) may be any of three things: a, b, and c Once we've assigned a value to f (a), we must assign one to f (b) Since f is one-to-one, f (b) cannot have the same value as f (a) This means that there are only two possibilities for f (b) Ittmann (UKZN PMB) Math236 2012 37 / 43
Counting permutations Counting permutations (cont.) Lastly, once we've chosen f (b), we must specify f (c), which can be neither f (a) nor f (b) It follows that, whatever the values of f (a) and f (b), there's only one possible value for f (c) From the Multiplication Principle, the total number of such 3-tuples is 3 2 1 = 6 Ittmann (UKZN PMB) Math236 2012 38 / 43
Counting permutations Counting permutations (cont.) Recall that n factorial is the function with rule 0! = 1 and, for n 1, n! = n (n 1) (n 2) 3 2 1 So, 0! = 1 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 This gives us a compact way to write certain expressions down Ittmann (UKZN PMB) Math236 2012 39 / 43
Counting permutations Counting permutations (cont.) An n-set is a set containing n elements How many permutations of an n-set are there? Suppose that the elements of the n-set are x 1, x 2,..., x n As in the previous example, we can consider each permutation to be an n-tuple (f (x 1 ), f (x 2 ),..., f (x n )) As before, we have n choices for f (x 1 ) Once we've chosen f (x 1 ), there are (n 1) possible choices for f (x 2 ) Ittmann (UKZN PMB) Math236 2012 40 / 43
Counting permutations Counting permutations (cont.) Once we've chosen f (x 2 ), there are (n 2) possible choices for f (x 3 ), and so on So we see that the number of permutations of an n-set is n(n 1)(n 2) 2 1 = n! Ittmann (UKZN PMB) Math236 2012 41 / 43
Counting permutations Counting permutations (cont.) There are 6! = 720 permutations of the set {a, b, c, d, e, f } How many k-tuples can be chosen from an n-set if repetition of elements is not allowed? If repetition of elements is allowed, we already know the answer to this question is n k Suppose then that repetition is not allowed We may choose any of n elements for the rst position in the k-tuple Once we've done that, we may choose any element for the second position except the one we chose for the rst Ittmann (UKZN PMB) Math236 2012 42 / 43
Counting permutations Counting permutations (cont.) So for each choice for the rst position, there are n 1 choices for the second position Once we've chosen the second position, there are (n 2) possibilities for the third position, and so on When we reach the kth position, there are n k + 1 possibilities From the Multiplication Principle, the number of such k-tuples is thus n(n 1)(n 2) (n k + 2)(n k + 1) Ittmann (UKZN PMB) Math236 2012 43 / 43