Principle of Inclusion-Exclusion Notes

Similar documents
CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

Chapter 1. Probability

MA 524 Midterm Solutions October 16, 2018

Reading 14 : Counting

8.2 Union, Intersection, and Complement of Events; Odds

Dyck paths, standard Young tableaux, and pattern avoiding permutations

Chapter 2. Permutations and Combinations

Math236 Discrete Maths with Applications

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

ECE313 Summer Problem Set 4. Reading: RVs, mean, variance, and coniditional probability

Chapter 1. Probability

MAT 243 Final Exam SOLUTIONS, FORM A

With Question/Answer Animations. Chapter 6

It is important that you show your work. The total value of this test is 220 points.

Chapter 3 PRINCIPLE OF INCLUSION AND EXCLUSION

Compound Probability. Set Theory. Basic Definitions

CIS 2033 Lecture 6, Spring 2017

Elementary Combinatorics

Counting in Algorithms

6.1 Basics of counting

Topics to be covered

Counting and Probability Math 2320

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability (solutions)

Theory of Probability - Brett Bernstein

CSCI 2200 Foundations of Computer Science (FoCS) Solutions for Homework 7

Intermediate Math Circles November 1, 2017 Probability I

and problem sheet 7

The probability set-up

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability

Introduction to probability

Week 1: Probability models and counting

Introductory Probability

4.1 Sample Spaces and Events

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

Solution: This is sampling without repetition and order matters. Therefore

Permutation Groups. Definition and Notation

2. Nine points are distributed around a circle in such a way that when all ( )

CSE 21 Mathematics for Algorithm and System Analysis

The probability set-up

Counting integral solutions

Jong C. Park Computer Science Division, KAIST

Restricted Permutations Related to Fibonacci Numbers and k-generalized Fibonacci Numbers

Combinatorics and Intuitive Probability

7.1 Experiments, Sample Spaces, and Events

STAT Statistics I Midterm Exam One. Good Luck!

In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors?

Sets. Definition A set is an unordered collection of objects called elements or members of the set.

PROOFS OF SOME BINOMIAL IDENTITIES USING THE METHOD OF LAST SQUARES

Multiple Choice Questions for Review

Counting. Chapter 6. With Question/Answer Animations

Permutation Groups. Every permutation can be written as a product of disjoint cycles. This factorization is unique up to the order of the factors.

COUNTING AND PROBABILITY

Mathematics Competition Practice Session 6. Hagerstown Community College: STEM Club November 20, :00 pm - 1:00 pm STC-170

Non-overlapping permutation patterns

Staircase Rook Polynomials and Cayley s Game of Mousetrap

Week 3 Classical Probability, Part I

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

Solutions to Problem Set 7

March 5, What is the area (in square units) of the region in the first quadrant defined by 18 x + y 20?

Chapter 7. Intro to Counting

Math 166: Topics in Contemporary Mathematics II

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Combinatorics. PIE and Binomial Coefficients. Misha Lavrov. ARML Practice 10/20/2013

CSC/MATA67 Tutorial, Week 12

Section Introduction to Sets

CSE 312: Foundations of Computing II Quiz Section #2: Combinations, Counting Tricks (solutions)

Slide 1 Math 1520, Lecture 13

Solutions to Exercises Chapter 6: Latin squares and SDRs

Probability. The MEnTe Program Math Enrichment through Technology. Title V East Los Angeles College

NON-OVERLAPPING PERMUTATION PATTERNS. To Doron Zeilberger, for his Sixtieth Birthday

CISC-102 Fall 2017 Week 8

16 Alternating Groups

BRITISH COLUMBIA SECONDARY SCHOOL MATHEMATICS CONTEST, 2006 Senior Preliminary Round Problems & Solutions

Combinatorics: The Fine Art of Counting

DISCRETE STRUCTURES COUNTING

Sample Spaces, Events, Probability

Math 3338: Probability (Fall 2006)

ON SPLITTING UP PILES OF STONES

Chapter 1. The alternating groups. 1.1 Introduction. 1.2 Permutations

3 The multiplication rule/miscellaneous counting problems

Week 6: Advance applications of the PIE. 17 and 19 of October, 2018

European Journal of Combinatorics. Staircase rook polynomials and Cayley s game of Mousetrap

n! = n(n 1)(n 2) 3 2 1

Permutations. = f 1 f = I A

Corners in Tree Like Tableaux

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Frustration solitaire

Probability. Engr. Jeffrey T. Dellosa.

Enumeration of Two Particular Sets of Minimal Permutations

Mat 344F challenge set #2 Solutions

Class 8 - Sets (Lecture Notes)

An interesting class of problems of a computational nature ask for the standard residue of a power of a number, e.g.,

SET THEORY AND VENN DIAGRAMS

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Sec.on Summary. The Product Rule The Sum Rule The Subtraction Rule (Principle of Inclusion- Exclusion)

Math 475, Problem Set #3: Solutions

Symmetric Permutations Avoiding Two Patterns

Section II.9. Orbits, Cycles, and the Alternating Groups

Discrete Mathematics with Applications MATH236

What is counting? (how many ways of doing things) how many possible ways to choose 4 people from 10?

Transcription:

Principle of Inclusion-Exclusion Notes The Principle of Inclusion-Exclusion (often abbreviated PIE is the following general formula used for finding the cardinality of a union of finite sets. Theorem 0.1. Suppose A 1, A 2,..., A n are finite sets. Then A 1 A 2 A n = ( 1 J 1 A. (1 nonempty J {1,...,n} J In words, to count the number of elements in a finite union of finite sets, first sum the individual cardinalities of these sets, then subtract the cardinalities for each possible intersection of two of these sets, then add back the cardinalities for each possible intersection of three of these sets, the subtract the cardinalities for each possible intersection of four of these sets, and so on in alternating sign until you reach the last term ( 1 n A 1 A 2 A n. So, for instance, A 1 A 2 = A 1 + A 2 A 1 A 2, A 1 A 2 A = A 1 + A 2 + A A 1 A 2 A 1 A A 2 A + A 1 A 2 A, A 1 A 2 A A 4 = A 1 + A 2 + A + A 4 A 1 A 2 A 1 A A 1 A 4 A 2 A A 2 A 4 A A 4 + A 1 A 2 A + A 1 A 2 A 4 + A 1 A A 4 + A 2 A A 4 A 1 A 2 A A 4, etc. There is a nifty, purely combinatorial proof of PIE that uses the fact that for any nonempty finite set, the number of even subsets and the number of odd subsets it has are the same. While this can also be proven combinatorially, the quickest proof uses the binomial theorem. 1

Lemma 0.2. For any integer n > 0, k 0 ( n = ( n. 2k 2k + 1 k 0 Proof. Due to the binomial theorem, ( n ( n 0 = (1 1 n = (1 n ( 1 = ( 1 = =0 =0 k 0 The conclusion now follows. ( n ( n. 2k 2k + 1 k 0 Proof of Theorem 0.1. Let x be an arbitrary element of A 1 A 2 A n, and suppose that x is contained in exactly k of the A i. Then (1 counts x a total of k ( k ( 1 1 =1 times. Yet, based on the proof of Lemma 0.2, k ( k k ( [ k ( k k ( 1 1 = ( 1 = ( 1 =1 =1 =0 ( ] k = (0 1 = 1. 0 Therefore each element of A 1 A 2 A n is counted exactly once by formula (1, thus validating that formula. 1 Elementary Examples Example 1.1. How many integers between 1 and 900 are divisible by 2 or? Solution. Let A be the set of integers between 1 and 900 that are divisible by 2, and let B be the set of integers between 1 and 900 divisible by. Note that A B is the set of integers between 1 and 900 that are divisible by 6. Hence, the number of integers between 1 and 900 that are divisible by 2 or is given by A B = A + B A B = (900 2+(900 (900 6 = 40+00 10 = 600. 2

Example 1.2. At an art academy, there are 4 students taking ceramics, 7 students taking painting, and 29 students taking sculpture. There are 10 students in both ceramics and painting, in both painting and sculpture, in both ceramics and sculpture, and 2 taking all three courses. How many students are taking at least one course at the art academy? Solution. Let C, P, and S denote the sets of students taking ceramics, painting, and sculpture, respectively. We want to calculate C P S. We apply PIE: C P S = C + P + S C P C S P S + C P S = 4 + 7 + 29 10 + 2 = 111. Example 1.. Of 2 people who save paper or bottles (or both for recycling, 0 save paper and 14 save bottles. How many save both? How many save only paper? How many save only bottles? Solution. Let A be the set of people who save paper and let B be the set of people who save bottles. We are given that A B = 2, A = 0, and B = 14. Hence, the number of people that save both is given by A B = A + B A B = 0 + 14 2 = 12. The set of people who save only paper is A\B, the number of which is given by A\B = A A B = 0 12 = 18. Similarly, the number of people who save only bottles is B\A = B A B = 14 12 = 2. Notice that these answers make sense. Certainly, if 2 people altogether recycle paper and bottles but only 0 save paper, the remaining 2 must recycle bottles exclusively. The same logic applies to the 18 people who only save paper.

2 Intermediate Examples Example 2.1. How many integers between 1 and 600 are divisible by none of,, or 7? Solution. Let A be the set of all integers between 1 and 600 divisible by, B the set of all integers between 1 and 600 divisible by, and C the set of all integers between 1 and 600 divisible by 7. By the PIE, the total is 600 A B C = 600 A B C + A B + A C + B C A B C Now A = 600 = 2100, B = 600 = 1260, and C = 600 7 = 900. Note that any number in A B is divisible by both and, which happens precisely when that number is divisible by 1. Similarly, numbers in A C are precisely the numbers divisible by 21, and numbers in B C are precisely the numbers divisible by. Hence A B = 600 1 = 420, A C = 600 21 = 00, and B C = 600 = 180. Lastly, numbers in A B C are divisible by,, and 7, which occurs precisely when the number is divisible by 10. Hence A B C = 600 10 = 60. The final answer is thus 600-2100 - 1260-900 + 420 + 00 + 180-60 = 2880. Example 2.2. How many integers from 1 to 1,000,000 inclusive either perfect squares or perfect cubes? Solution. Let A be the set of perfect squares between 1 and 1,000,000 and let B be the set of perfect cubes between 1 and 1,000,000. By PIE, A B = A + B A B. We have A = 1,000,000 = 1000 and B = 1,000,000 = 100. Lastly, a number is in A B when it is both a perfect square and a perfect cube, which occurs precisely when that number is a perfect sixth power. So A B = 6 1,000,000 = 10. The final answer is thus 1000 + 100-10 = 1090. 4

Example 2.. How many five-card hands from a standard deck of cards contain at least one card in each suit? Solution. First note that there are ( 2 possible hands. Thus the answer will be ( 2 minus the number of five-card hands for which at least one suit is absent. Let C, D, H, and S be the sets of five-card hands containing no clubs, diamonds, hearts, and spades, respectively. Easily enough ( 9 C = D = H = S =. Note that that each possible intersection of 2 (or sets are also equinumerous. Specifically, the number of five-card hands omitting two particular suits is, and the number of five-card hands omitting three particular suits is ( 4 ( 26 2 ( 4 ( 1. Finally C D H S = since a hand cannot omit all of the suits! By PIE, the final answer is thus ( 2 C D H S = ( 2 Advanced Examples ( ( 4 9 1 + ( ( 4 26 2 ( 4 ( 1 Example.1. How many solutions of the equation x 1 + x 2 + x + x 4 = 26 are there in integers between 1 and 9 inclusive? Solutions. The total number of positive integer solutions is simply ( 2. Thus the answer will be ( 2 minus the number of solutions where at least one of the x i is greater than 9. Let A 1, A 2, A, and A 4 be the sets of positive integer solutions to x 1 + x 2 + x + x 4 = 26 for which x 1 > 9, x 2 > 9, x > 9, and x 4 > 9, respectively. Recall that to calculate A 1, the number of positive integer solutions to x 1 + x 2 + x + x 4 = 26 with x 1 > 9, we can subtract 9 from x 1 so that we simply need the number of integer solutions to x 1 + x 2 + x + x 4 = 17..

This happens to be ( 16. Parallel logic shows that A2 = A = A 4 = ( 16 as well. Reiterating this logic also yields that the cardinality of the pairwise intersections are each ( 7. Observe that the intersection of three or more of these sets is empty, because if three of the x i is greater than 9, then x 1 + x 2 + x + x 4 > 27. The final answer is thus ( ( ( ( ( 2 4 16 4 7 +. 1 2 Example.2. The Hat-Check Problem. A total of n people walk into a party and give their hats to the hat-check guy. However, the hat-check guy completely loses track of which hats belong to which owners. When the party ends, he hands the hats back at random to their n owners. What is the probability that no one gets their own hat back? Solutions. The random hat assignments can be encoded by permutations of the integers from 1 through n where the th number of the permutation being k corresponds to the th person to the party getting back the k th person s hat. What we are interested in are permutations in which no number is in its original position. Such permutations are called derangements. (For example, 21 is a derangement of 1, 2, and, but 21 is not since the second number in the permutation is 2. We count all permutations, and subtract those which are not derangements. Recall that there are n! permutations of the integers from 1 through n. Now let us count the number of permutations of the integers from 1 through n where a particular i of them are fixed. There are ( n i choices for which i elements to fix. Once those i elements are fixed, we need only permute the remaining n i, which can be done in (n i! ways. Combining this fact with PIE gives the total number of derangements as n! ( n ( 1 i 1 i i=1 (n i! = ( n n! + 0 ( n ( 1 i (n i! i 6

= = ( n ( 1 i (n i! i ( 1 i n! i!(n i! (n i! = n! ( 1 i. i! The probability that no one gets their own hat back is thus the above summation divided by n!, which is simply n ( 1 i. Some of you may remember i! from calculus that x i is the Taylor series for e x. From this, we have that i! ( 1 lim i = e 1 = 1/e. Hence, for large n, the probability that no one gets i! n their own hat back is approximately 1/e 0.6787944... Example.. How many surections are there from an n-element set onto an m-element set, assuming that n m? Solution. Recall that a surection is a function whose range equals its codomain. The details for this enumeration are very similar to those of the Hat-Check Problem. We know that the total number of unrestricted functions is m n. To count the number of surections, we subtract the number of functions that miss an element in the codomain from the total number of functions. In particular, if we wish to omit i elements in the codomain from the range, then there are ( m i choices of i elements to exclude, and then (m i n functions from the domain to the newly restricted codomain. Applying PIE begets the total number of surections: m n 0 ( m ( 1 i 1 i i=1 (m i n = ( m 0 m ( m = ( 1 i i (m 0 n + m ( m ( 1 i i i=1 (m i n. (m i n Now if n = m, then the surections between the two sets are precisely the biections between the two sets, which are n! in number. We have thus 7

stumbled across a combinatorial proof of the following identity: ( ( ( ( ( n n n n n n n (n 1 n + (n 2 n (n n + +( 1 n 1 1 n = n!. 0 1 2 n 1 4 Examples for the Brave Example 4.1. (1972 USAMO Problem A random number generator randomly generates the integers 1, 2,, 9 with equal probability. Find the probability that after n numbers are generated, the product of the numbers is a multiple of 10. Solution. There are 9 n possible sequences of n randomly generated numbers. For the product to be a multiple of 10, there must be a and an even number among the n numbers generated. So the number of sequences whose product is not a multiple of 10 is 9 n minus the number of sequences having at least one and one even number. The number of sequences without a is 8 n, the number of sequences without an even number is n, and the number of sequences without a nor even numbers is 4 n. Applying PIE yields the following probability: 9 n 8 n n + 4 n 9 n = 1 ( n 8 9 ( n + 9 ( n 4. 9 Example 4.2. (1989 IMO Problem 6 Let a permutation π of {1, 2,..., 2n} have property P if π(i π(i + 1 = n for at least one i {1, 2,..., 2n 1}. Show that, for each n, there are more permutations with property P than without it. Solution. For each k {1, 2,..., n}, let A k be the set of all permutations of {1, 2,..., 2n} such that k and k + n are adacent to each other. Consider an intersection A k1 A k2 A ki of i sets among the A k. To count the number of permutations of {1, 2,..., 2n} lying in this intersection, we treat each of 8

the pairings {k 1, k 1 + n}, {k 2, k 2 + n},..., {k + k + n} as a single element and then arrange the of these pairings with the remaining 2n 2 elements of {1, 2,..., 2n}. There are (2n! such arrangements. There are then 2 ways to order each of the pairings. Hence A k1 A k2 A k = (2n!2. It follows from PIE that the number of permutations of {1, 2,..., 2n} with property P equals ( n ( 1 1 (2n!2, =1 whereas the number of permutations of {1, 2,..., 2n} without property P is (2n! ( n ( 1 1 =1 (2n!2 = = ( n (2n!2 0 + 0 ( n ( 1 =0 ( n ( 1 (2n!2 =1 (2n!2. Now set Q n = n ( 1 ( n (2n!2 and q = ( n (2n!2 for each =0 so that Q n = q 0 q 1 + q 2 q + + ( 1 n q n. Notice that q 0 = (2n! and q 1 = ( n 1 (2n 1! 2 = (2n! = q0 so that Q n = q 2 q + q 4 q + + ( 1 n q n = q 2 + (q 4 q + (q q 6 +. Furthermore, for each {1, 2,..., n 1}, we have ( n q +1 +1 (2n 1!2 +1 = q (2n!2 ( n = 2 2n = 2 2n n! (+1!(n 1! n!!(n!!(n! ( + 1!(n 1! = 2 2n n + 1 < 1, 9

and so q +1 < q in general. Hence Q n = q 2 + (q 4 q + (q q 6 + ( n < q 2 = (2n 2!2 2 (2n(2n 2(2n 2! = 2 2 < (2n! 2. This implies that less than half of the permutations of {1, 2,..., n} lack property P. The conclusion now follows. 10