5 minutes read

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 (2626) and the number of letters in the Russian alphabet (3333), right? 26+33=5926+33=59 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 AA and BB 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.

Two disjoint sets

What if sets AA and BB 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 AA and BB.

The Inclusion-Exclusion Principle for two sets states that the number of elements in the union of sets AA and BB is equal to the sum of the number of elements in the individual sets minus the number of elements in their intersection.

AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|

Combining sets

When sets AA and BB are disjoint, AB=0|A \cap B| = 0. 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?

Set of letters of the English and Russian alphabets

There are 2626 letters in the English alphabet and 3333 in Russian. There are 1212 letters in common. By the Inclusion-Exclusion Principle, there are 26+3312=4726 + 33 - 12 = 47 letters in their combined alphabet.

Case of three sets

The Inclusion-Exclusion Principle for three sets AA, BB and CC is as follows

ABC=A+B+CABACBC+ABC|A \cup B \cup C| = |A| + |B| + |C|- |A \cap B| - |A \cap C| -|B \cap C| + |A \cap B \cap C|

The Inclusion-Exclusion Principle for three sets

Here's how to derive this formula through reasoning. When you sum A+B+C|A| + |B| + |C|, 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 AB|A \cap B|, AC|A \cap C|, and BC|B \cap C|. However, doing this removes the counting of the intersection of all three sets, so you have to add ABC|A \cap B \cap C| 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 10001000. 700700 participants solved task A, 600600 solved task B, and 600600 solved task C. Moreover, 500500 participants solved both tasks A and B, 400400 solved both B and C, and 400400 solved both A and C. 300300 participants solved all tasks. How many participants did not solve any task? Note that when we say "700700 participants solved task A", we mean that 700700 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 UABC|U| - |A \cup B \cup C|.

There are 10001000 participants in total, so U=1000|U| = 1000.

A|A|, B|B|, and C|C| are 700700, 600600, and 600600, respectively.

Since 500500 participants solved both tasks A and B, AB=500|A \cap B| = 500. Likewise, BC=400|B \cap C| = 400 and AC=400|A \cap C| = 400.

300300 participants solved all three tasks, so ABC=300|A \cap B \cap C| = 300.

By the Inclusion-Exclusion Principle,

ABC=A+B+CABACBC+ABC|A \cup B \cup C| = |A| + |B| + |C|- |A \cap B| - |A \cap C| -|B \cap C| + |A \cap B \cap C|=700+600+600500400400+300=900= 700 + 600 + 600 - 500 - 400 - 400 + 300 = 900So, 900900 people solved at least one task.

Now, let's find the number of participants that did not solve any task.

UABC=1000900=100|U| - |A \cup B \cup C| = 1000 - 900 = 100Therefore, 100100 participants solved zero tasks.

The following image is a Venn diagram that shows the number of the participants in each region.

Venn diagram

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.

19 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo