For finite sets \(A_1, A_2, \cdots, A_n\), we have the identity:

where

In words, to count the number of elements in a finite union of finite sets, first sum the cardinalities of the individual sets, then subtract the number of elements which appear in more than one set, then add back the number of elements which appear in more than two sets, then subtract the number of elements which appear in more than three sets, and so on. This process naturally ends since there can be no elements which appear in more than the number of sets in the union.

In applications it is common to see the principle expressed in its complementary form. That is, letting \(S\) be a finite universal set containing all of the Ai and letting \(\bar{A}_i\) denote the complement of \(A_i\) in \(S\), by De Morgan’s laws we have

Example - Counting Integers

How many integers in \({1, \cdots, 100}\) are not divisible by \(2\), \(3\) or \(5\)?

Let \(S = {1, \cdots, 100}\) and \(P_1\) the property that an integer is divisible by \(2\), \(P_2\) the property that an integer is divisible by \(3\) and \(P_3\) the property that an integer is divisible by \(5\). Letting \(A_i\) be the subset of \(S\) whose elements have property \(P_i\) we have by elementary counting: \(\lvert A_1 \lvert = 50\), \(\lvert A_2 \lvert = 33\), and \(\lvert A_3 \lvert = 20\). There are \(16\) of these integers divisible by \(6\), \(10\) divisible by \(10\) and \(6\) divisible by \(15\). Finally, there are just \(3\) integers divisible by \(30\), so the number of integers not divisible by any of \(2\), \(3\) or \(5\) is given by:

In the above example, we are using the De Morgan’s law to solve the problem, since it’s hard to find the integers not divisible by \(2\), \(3\) or \(5\) directly, we find the complementary events that the integers divisible by \(2\), \(3\) or \(5\).