Inclusion-exclusion for two sets
Example. Every student in the class is majoring either in CS, or Math,
or both. The number of those majoring in (at least) CS is 25, the number
of those majoring in (at least) Math is 13, and the number of joint CS and
Math majors is 8. How many students are there in the class?
Let A be the set of CS majors, and B the set of Math majors. We need
According to the principle of inclusion-exclusion (Section 1.5),
|A?B| = |A| + |B| - |A?B| = 25 + 13 - 8 = 30.