9/14/10 1 Counting I: Choice Trees and Correspondences Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS 15-251 Fall 2010 Lecture 7 Sep 14, 2010 Carnegie Mellon University In the next few lectures we will learn some fundamental counting methods. • Addition and Product Rules • The Inclusion-Exclusion Principal • Choice Tree • Permutations and Combinations • The Binomial Theorem • The Pigeonhole Principal • Diophantine Equations • Generating Functions If I have 14 teeth on the top and 12 teeth on the bottom, how many teeth do I have in all? Addition Rule Let A and B be two disjoint finite sets Addition of Multiple Disjoint Sets: Let A1, A2, A3, …, An be disjoint, finite sets: Addition Rule (2 Possibly Overlapping Sets) Let A and B be two finite sets: |A| + |B| - |A∩B| |A∪B| =9/14/10 2 Inclusion-Exclusion If A, B, C are three finite sets, what is the size of (A ∪ B ∪ C) ? |A| + |B| + |C| - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| Inclusion-Exclusion If A1, A2, …, An are n finite sets, what is the size of (A1 ∪ A2 ∪ … ∪ An) ? ∑i |Ai| - ∑i < j |Ai ∩ Aj| + ∑i < j < k |Ai ∩ Aj ∩ Ak| … + (-1)n-1 |A1 ∩ A2 ∩ … ∩ An| A school has 100 students. 50 take French, 40 take Latin, and 20 take both. How many students take neither language? French Latin French AND Latin students: |F∩L|=20 |F∪L|= F ≡ French students L ≡ Latin students |F|=50 |L|=40 French OR Latin students: Neither language: 100 – 70 = 30 |F|+|L|-|F ∩ L| = 50 + 40 – 20 = 70 100 20 How many positive integers ≤ 70 are relatively prime to 70? A1 ≡ integers in U divisible by 2 A2 ≡ integers in U divisible by 5 A3 ≡ integers in U divisible by 7 |A1| = 35 |A2| = 14 |A3|=10 A1 A3 A2 U U = [1..70], 70 = 2x5x7 |A1 ∩ A2| = 7 |A1 ∩ A3| = 5 |A2 ∩ A3| = 2 |A1∩ A2 ∩ A3| = 1 |A1∪A2∪A3| = |A1|+|A2|+|A3| - |A1∩ A2| - |A1∩ A3| - |A2∩A3| +|A1∩ A2∩ A3| |A1 ∪ A2 ∪ A3| = |A1|+|A2|+|A3| - |A1∩ A2| - |A1∩ A3| - |A2∩ A3| + |A1∩ A2∩ A3| How many positive integers less than 70 are relatively prime to 70? |A1 ∪ A2 ∪ A3| = 35+14+10-7-5-2+1 = 46 Thus, the number of relatively prime to 70 is 70 – 46 = 24.9/14/10 3 A1 A3 A2 U The Principle of Inclusion and Exclusion Let Sk be the sum of the sizes of All k-tuple intersections of the Ai’s. S1=|A1|+|A2|+|A3| S2=|A1∩A2|+|A1∩A3|+|A2∩A3| S3=|A1∩A2∩A3| |A1 ∪ A2 ∪ A3| = S1 – S2+ S3 Partition Method To count the elements of a finite set S, partition the elements into non-overlapping subsets A1, A2, A3, …, An. S = all possible outcomes of one white die and one black die. Partition Method Each of 6 disjoint set have size 6 = 36 outcomes Partition S into 6 sets: S = all possible outcomes of one white die and one black die. Partition Method A1 = the set of outcomes where the white die is 1. A2 = the set of outcomes where the white die is 2. A3 = the set of outcomes where the white die is 3. A4 = the set of outcomes where the white die is 4. A5 = the set of outcomes where the white die is 5. A6 = the set of outcomes where the white die is 6. S = all possible outcomes where the white die and the black die have different values Partition Method Ai ≡ set of outcomes where black die says i and the white die says something else. S ≡ Set of all outcomes where the dice show different values. ⎢S⎥ = ? | S | = ∑ i = 1 6 | Ai | = ∑ i = 1 6 5 = 309/14/10 4 | S ∪ B | = # of outcomes = 36 |S| + |B| = 36 |B| = 6 |S| = 36 – 6 = 30 B ≡ set of outcomes where dice agree. S ≡ Set of all outcomes where the dice show different values. ⎢S⎥ = ? Difference Method To count the elements of a finite set S, find two sets A and B such that S and B are disjoint and S ∪ B = A then |S| = |A| - |B| S ≡ Set of all outcomes where the black die shows a smaller number than the white die. ⎢S⎥ = ? Ai ≡ set of outcomes where the black die says i and the white die says something larger. S = A1 ∪ A2 ∪ A3 ∪ A4 ∪ A5 ∪ A6 |S| = 5 + 4 + 3 + 2 + 1 + 0 = 15 It is clear by symmetry that | S | = | L |. ⎢S⎥ + ⎢L⎥ = 30 Therefore | S | = 15 S ≡ Set of all outcomes where the black die shows a smaller number than the white die. ⎢S⎥ = ? L ≡ set of all outcomes where the black die shows a larger number than the white die. “It is clear by symmetry that |S| = |L|?” S L Pinning Down the Idea of Symmetry by Exhibiting a Correspondence Put each outcome in S in correspondence with an outcome in L by swapping color of the dice. Thus: ⎢S⎥ = ⎢L⎥ Each outcome in S gets matched with exactly one outcome in L, with none left over.9/14/10 5 f is injective if and only if 'For Every There Exists f is surjective if and only if 'Let f : A → B Be a Function From a Set A to a Set B ∀x,y∈A, x ≠ y ⇒ f(x) ≠ f(y) ∀z∈B ∃x∈A f(x) = z A BLet’s Restrict Our Attention to Finite Sets ∃ injective (1-1) f : A → B ⇒ | A | ≤ | B | BA∃ surjective (onto) f : A → B ⇒ | A | ≥ | B | AB∃ bijective f : A → B ⇒ | A | = | B | AB∃ bijective f : A → B ⇒ | A | = | B | bijective f means the inverse f-1 is well-defined Correspondence Principle If two finite sets can be placed into bijection, then they have the same size It’s one of the most important mathematical ideas of all time!9/14/10 6 Each sequence corresponds to a unique number from 0 to 2n-1. Hence 2n sequences. Question: How many n-bit sequences are there? 000000 000001 000010 000011 111111 2n-1 ↔ ↔ ↔ ↔ ↔ : : 0 1 2 3 : The entire set and the empty set are subsets with all the rights and privileges pertaining thereto S = { a,b,c,d,e } has Many Subsets {a}, {a,b}, {a,d,e}, {a,b,c,d,e}, {e}, Ø, … Question: How Many Subsets Can …
View Full Document