How many letters are in the combined alphabet of English and Russian? That seems simple… just add the number of letters in the English alphabet () and the number of letters in the Russian alphabet (), right? letters?
But that's wrong because there are letters, like A, B, and E, that appear in both English and Russian alphabets. So, with this approach, you count some letters twice. The problem with this example is that the two alphabets are not disjoint.
In this topic, you will learn how to use the Inclusion-Exclusion Principle to solve examples like these.
Case of two sets
In a previous topic, you looked at the Rule of Sum. This rule states that if sets and are disjoint, then the number of elements in the union of these two sets is equal to the sum of the number of elements in the individual sets.
What if sets and are not disjoint? By taking the sum, you double-count the elements that are in both sets. So, you need to correct this by subtracting the intersection of sets and .
The Inclusion-Exclusion Principle for two sets states that the number of elements in the union of sets and is equal to the sum of the number of elements in the individual sets minus the number of elements in their intersection.
When sets and are disjoint, . This is how you get the formula for the Rule of Sum.
Let's revisit our example from the introduction. How many letters are in the combined alphabet of English and Russian? In other words, how many elements are in the union of the set of letters in the English alphabet and the set of letters in the Russian alphabet?
There are letters in the English alphabet and in Russian. There are letters in common. By the Inclusion-Exclusion Principle, there are letters in their combined alphabet.
Case of three sets
The Inclusion-Exclusion Principle for three sets , and is as follows
Here's how to derive this formula through reasoning. When you sum , you are counting the elements in the intersections of each two sets twice and the elements in the intersection of all three sets three times. So, you subtract , , and . However, doing this removes the counting of the intersection of all three sets, so you have to add back in.
Let's look at an example. Suppose that there is a programming contest that consists of three tasks A, B, and C. The total number of participants is . participants solved task A, solved task B, and solved task C. Moreover, participants solved both tasks A and B, solved both B and C, and solved both A and C. participants solved all tasks. How many participants did not solve any task? Note that when we say " participants solved task A", we mean that participants in total solved task A — these participants may have also solved other tasks.
You want to find the number of participants that solved zero tasks. That is, you want to find .
There are participants in total, so .
, , and are , , and , respectively.
Since participants solved both tasks A and B, . Likewise, and .
participants solved all three tasks, so .
By the Inclusion-Exclusion Principle,
So, people solved at least one task.
Now, let's find the number of participants that did not solve any task.
Therefore, participants solved zero tasks.
The following image is a Venn diagram that shows the number of the participants in each region.
Conclusion
In this topic, you looked at the Inclusion-Exclusion Principle. It allows you to determine how many elements are in the union of overlapping sets. The general idea behind this principle is that you must consider the number of elements in the overlapping regions to avoid double counting.