Introduction
When two groups overlap, adding their sizes counts the shared members twice. Inclusion–exclusion corrects this by adding group totals, subtracting overlaps that were counted more than once, and, when necessary, adding back smaller intersections. It is a general counting rule for finding how many distinct possibilities belong to at least one of several sets, without counting any possibility more than once.
- The basic problem: overlapping groups
- The rule for two sets
- Why the correction works
- What changes with three sets?
- The pattern for any number of sets
- Counting numbers with overlapping properties
- Complements can make a count simpler
- Common mistakes and how to avoid them
- Where the principle is useful
- Conclusion
The basic problem: overlapping groups
Imagine a class in which some students study French, some study Spanish, and some study both. If you add the number studying French to the number studying Spanish, every student studying both languages appears in both totals. The sum therefore counts those students twice, even though each student should count once when asking how many study at least one language.
A set is simply a collection of distinct objects. In this example, the French students form one set and the Spanish students another. An intersection is the collection of objects shared by sets. The students studying both languages form the intersection. The union is the collection of objects in one set, the other set, or both.
Inclusion–exclusion gives a precise way to count a union. It includes the sizes of the individual sets, then excludes their shared members to repair the double-counting. With more sets, the same idea extends through intersections of three, four, or more sets.
The rule for two sets
For two sets, usually called A and B, the rule is:
|A ∪ B| = |A| + |B| − |A ∩ B|
The vertical bars mean “the number of elements in.” The symbol ∪ means “union,” or membership in at least one set, while ∩ means “intersection,” or membership in both. In words, the number in A or B is the number in A plus the number in B, minus the number in both.
Consider a hypothetical group of 30 students. Suppose 18 study French, 14 study Spanish, and 6 study both. Adding the first two totals gives 32, but there are only 26 distinct students studying at least one of the languages. The formula shows why: 18 + 14 − 6 = 26. The six students in both groups were included once in each original total, so subtracting six removes the extra count.
Here, “or” has its inclusive mathematical meaning: A or B includes people in A, people in B, and people in both. This is important because everyday speech sometimes uses “or” to mean one choice but not the other. In a union, shared membership is included.
Why the correction works
The formula can be understood by checking how often each kind of element is counted. An element that belongs only to A is counted once in |A| and not at all in |B|. An element only in B is likewise counted once. An element in both appears twice in |A| + |B|, then once is removed by subtracting |A ∩ B|. Its final count is one.
This element-by-element reasoning is the heart of the method. Inclusion–exclusion is not an arbitrary formula: each addition or subtraction adjusts the tally so that every element in the desired union contributes exactly one to the final answer.
The same approach also works when the sets are not groups of people. A set might contain numbers with a certain property, possible outcomes in a finite experiment, objects meeting a description, or events that can occur. The essential question is always how much overlap exists.
What changes with three sets?
With three sets, simply adding the three set sizes counts shared elements too many times. The rule first adds the individual sizes, then subtracts each pairwise intersection, and finally adds the intersection shared by all three:
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
Why add the three-way intersection at the end? An element in all three sets is counted three times when the individual set sizes are added. It is then subtracted once for each of the three pairwise intersections, leaving a count of zero. Adding the three-way intersection once restores its correct final count of one.
For a concrete illustration, suppose a survey asks which of three activities people enjoy. Let A, B, and C represent the people who enjoy each activity. If someone enjoys all three, that person is part of every individual group and every pairwise overlap. The formula accounts for this repeated membership instead of treating the three pairwise overlaps as separate people.
For example, if the three set sizes are 20, 17, and 15; the pairwise intersection sizes are 8, 6, and 5; and 3 people are in all three, then the union has 20 + 17 + 15 − 8 − 6 − 5 + 3 = 36 elements. The final addition is essential: without it, the three people in every set would be omitted from the corrected count.
The pattern for any number of sets
For a larger collection of sets, the pattern continues by intersection size. Add the sizes of the individual sets. Subtract the sizes of all intersections involving pairs of sets. Add intersections involving triples. Subtract intersections involving four sets, and continue alternating signs. The final term depends on how many sets there are.
For four sets, for instance, the calculation includes four individual set sizes, subtracts all six pairwise intersections, adds all four three-way intersections, and subtracts the intersection of all four sets. The plus and minus signs alternate as the intersections grow.
This alternating pattern is called the inclusion–exclusion principle. In a compact form, it can be written as a sum over all nonempty combinations of the sets, with a positive sign for intersections of odd size and a negative sign for intersections of even size. The compact version is useful in advanced work, but the step-by-step pattern is usually easier to understand and check.
As the number of sets increases, the number of intersection terms can grow quickly. The principle still applies, but using it requires reliable information about the relevant overlaps. If some intersection sizes are unknown, the total union may not be determined by the individual set sizes alone.
Counting numbers with overlapping properties
A common application is counting integers that meet at least one condition. For example, consider the positive integers from 1 to 100 that are divisible by 2 or by 5. There are 50 multiples of 2 and 20 multiples of 5 in that range. The numbers divisible by both are multiples of 10, of which there are 10. Therefore, 50 + 20 − 10 = 60 numbers meet at least one condition.
This calculation avoids listing all 60 numbers individually. It also illustrates an important detail: “divisible by both 2 and 5” describes the overlap, not a separate group to add without correction. Every multiple of 10 was already included among the multiples of 2 and among the multiples of 5.
The same method can count numbers divisible by any of several divisors, provided the overlap counts can be found. For three divisors, one must account for every pairwise overlap and the numbers shared by all three. Care is needed because an overlap may itself contain smaller overlaps.
Complements can make a count simpler
Sometimes it is easier to count what does not qualify. If a finite universe contains N elements, and a target condition is “belongs to A or B,” its complement consists of elements in neither A nor B. Thus, the union can also be counted by subtracting the number in neither set from the total:
|A ∪ B| = N − |neither A nor B|
This is especially useful when the nonmembers are easier to count than the overlapping groups. For example, if a question asks how many possible outcomes include at least one specified feature, it may be simpler to count outcomes with none of those features and subtract from the total number of outcomes.
The complement approach does not replace inclusion–exclusion; it offers another route to the same answer. The best method depends on which information is available and which cases are easiest to organize.
Common mistakes and how to avoid them
Adding without subtracting the overlap: For two sets, |A| + |B| counts shared elements twice. Subtract the intersection once. For more sets, use the full alternating pattern rather than applying only the two-set correction.
Subtracting pairwise overlaps but forgetting the triple overlap: In a three-set calculation, elements belonging to all three sets are initially counted three times and then subtracted three times. They need to be added back once to reach a final count of one.
Confusing “at least one” with “exactly one”: A union counts elements in one or more sets, including those in several. To find elements in exactly one set, the calculation must exclude all shared members from the relevant individual sets.
Using inconsistent totals: All counts must refer to the same universe and the same definitions. If one survey count covers a different population or time period from another, combining them may not produce a meaningful union.
Assuming the information is sufficient: Knowing only the sizes of three sets does not generally reveal their union. The pairwise and triple intersections matter. If those values are missing, an exact answer may require additional information or may be impossible to determine.
Where the principle is useful
Inclusion–exclusion appears whenever categories overlap. It can help summarize survey responses, count possible outcomes that satisfy one or more conditions, and solve problems involving divisibility. In probability, the same structure can be applied to events: the probability that at least one of two events occurs equals the sum of their probabilities minus the probability that both occur.
Probability uses the same logic because an outcome in both events would otherwise be included twice. For three events, pairwise intersections are subtracted and the triple intersection is added back. These formulas concern the probability of a union; they do not require the events to be independent.
The principle is useful not only for producing a total but also for clarifying what information a problem needs. It directs attention to the overlaps that matter. A clear diagram or a table of intersections can help organize those quantities before applying the formula, especially when several sets are involved.
Conclusion
Inclusion–exclusion counts a union by correcting for repeated membership. Add the individual set sizes, subtract pairwise overlaps, add triple overlaps, and continue with alternating signs. The method works because each element is ultimately made to contribute exactly once. Whether counting survey groups, number properties, or event probabilities, identifying the overlaps is the key to a reliable total.

