Sets and relations · Definition

Inclusion-exclusion principle

discrete mathematicscountingsets

Before you start you need to know

It solves the problem of counting «those with at least one property» when the properties overlap.

Definition

It counts the elements of the union of finite sets \(A\), \(B\), \(C\), … by adding their sizes and correcting what was counted too often in the intersections.

\[\begin{aligned}|A\cup B|&=|A|+|B|-|A\cap B|\\|A\cup B\cup C|&=|A|+|B|+|C|\\&\quad-|A\cap B|-|A\cap C|-|B\cap C|\\&\quad+|A\cap B\cap C|\end{aligned}\]

If \(|A|\) and \(|B|\) are added, the elements of \(A\cap B\) are counted twice; that is why \(|A\cap B|\) is subtracted once. With three sets, subtracting the three pairwise intersections removes too much from the elements lying in all three (counted three times, subtracted three times), so \(|A\cap B\cap C|\) must be added back.

In general, for \(n\) sets the terms alternate in sign: single sizes are added, pairwise intersections subtracted, triple intersections added, and so on. Each element of the union ends up counted exactly once, which can be checked with the binomial theorem.

A guiding example: the integers from 1 to 100 divisible by 2 or 3 number \(50+33-16=67\), because the 16 multiples of 6 were counted twice. Subtracting from 100 gives those divisible by neither: 33. This trick of counting the complement is very common.

Typical mistakes are forgetting the triple-intersection term or applying the principle to sets that are not finite. If the sets are disjoint, all intersections are empty and the sum rule is recovered.

Think about it

Why is \(|A\cap B\cap C|\) added at the end for three sets?

An element in all three sets is added three times and subtracted three times in the pairwise intersections; it is counted zero times and must be restored once.

What is \(|A\cup B|\) if \(A\) and \(B\) are disjoint?

It is \(|A|+|B|\), since \(|A\cap B|=0\); this is the sum rule.

Exercises 10

What comes next

References

  • Kenneth H. Rosen, Discrete Mathematics and Its Applications, 8th edition, McGraw-Hill, 2019. §8.5
  • Susanna S. Epp, Discrete Mathematics with Applications, 5th edition, Cengage, 2019. §9.3
  • Ralph P. Grimaldi, Discrete and Combinatorial Mathematics: An Applied Introduction, 5th edition, Pearson, 2003. §8.1