Follow your curiosity

What discovery has been shared with you?

Start with one fact. Explore it, go deeper, then follow whichever branch catches your imagination.

Choose subjects for a surprise

Exploring any topic

Begin your discovery

Your next discovery is one click away.

Choose one or more subjects above, or leave Any Topic selected and let curiosity decide.

Mathematics

The Inclusion-Exclusion Principle for Counting with Overlapping Sets

Quick fact

The inclusion-exclusion principle, known since ancient times, allows exact counting of overlapping sets by alternating addition and subtraction of intersections, and it even extends to an infinite number of sets when formalized with measure theory.

Why this is interesting

You need to count everyone in a group who likes either pizza or sushi, but many like both. Simply adding the two counts would double-count those with both. How do you get the exact total?

Read the full explanation

Understanding The Inclusion-Exclusion Principle for Counting with Overlapping Sets

Imagine you're organising a party and need a headcount of guests who will eat either pizza or sushi. You survey everyone: 10 like pizza, 8 like sushi, and 3 like both. If you add 10 and 8, you get 18, but the 3 people who like both were counted twice. To correct this, you subtract that overlap: 10 + 8 - 3 = 15. This is the inclusion-exclusion principle for two sets. The idea is straightforward: add up all the individual groups, then subtract the overlaps you counted too many times. When you have more than two groups, the pattern gets a bit more intricate but follows the same logic: you add all singletons, subtract all pairwise overlaps, add back all triple overlaps, subtract quadruple overlaps, and so on. Each step fixes an overcorrection from the previous step. For example, with three sets A, B, and C: |A∪B∪C| = |A| + |B| + |C| - |A∩B| - |A∩C| - |B∩C| + |A∩B∩C|. This avoids both overcounting and undercounting.

A deeper explanation

The inclusion-exclusion principle is a direct consequence of the fact that each element in the union belongs to a certain number of the sets (say k). In the sum of all singleton sizes, such an element is counted k times. In the sum of all pairwise intersections, it is counted C(k,2) times. In the sum of all triple intersections, C(k,3) times, and so on. The principle's alternating sum yields exactly 1 for each element because of the binomial identity: k - C(k,2) + C(k,3) - ... + (-1)^(k+1)C(k,k) = 1. For k≥1, all terms cancel except the first, leaving exactly one count. Each element is indeed counted exactly once. This pattern, applied to all elements, proves the principle. This mechanism extends to any finite number of sets, and the formula can be generalised as: |∪ᵢ₌₁ⁿ Aᵢ| = Σ|Aᵢ| - Σ|Aᵢ∩Aⱼ| + Σ|Aᵢ∩Aⱼ∩Aₖ| - ... + (-1)ⁿ⁺|∩ᵢ₌₁ⁿ Aᵢ|. This principle is not just a curiosity; it underpins many counting problems, such as computing the number of derangements (permutations with no fixed points) and the probability of a union of events in probability theory. By understanding this mechanism, you gain a powerful tool for precise counting in discrete mathematics.

Keep FACTREE close

Internet access is required. Updates arrive when you reopen or reload the app. You may need to sign in again in the installed app.