Two-set inclusion–exclusion
Count a union without double-counting the overlap.
Two-set inclusion–exclusion is one of 1 sets formula in the discrete math section of this library, and it is used at high school · university level.
Why two-set inclusion–exclusion works
Counting set A and then set B tallies every element that belongs to both of them twice, once in each list. Subtracting the size of the overlap removes exactly one of those duplicate counts, leaving every element counted once. That single correction is all the repair the two-set case needs.
What each symbol means
$|A|$ means the number of elements in set $A$.
Two-set inclusion–exclusion: when it holds
Sets must be finite for this cardinality form.
When it stops applying
Three sets need a longer version, because subtracting all three pairwise overlaps removes the triple overlap one time too many and it has to be added back. The formula also needs finite sets, since sizes must be actual numbers you can subtract.
Two-set inclusion–exclusion: a worked example
If $|A|=20,|B|=15,|A\cap B|=5$, then $|A\cup B|=30$.
The mistake to avoid
What people do: Students just add the two sizes and report 20 + 15 = 35 for the union.
Why it goes wrong: Anyone in both groups has been counted twice, so the total is inflated by the size of the overlap.
Do this instead: Subtract the shared members once: 20 + 15 − 5 = 30. A quick check is that the union can never be larger than the plain sum, and never smaller than the bigger of the two sets.
Two-set inclusion–exclusion: step by step
- Name the unknown, and the unit the answer has to come out in.
- Match the symbols to your values. $|A|$ means the number of elements in set $A$.
- Check the conditions before substituting. Sets must be finite for this cardinality form.
- Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most discrete math slips.
Where this formula fits
- Subject
- Discrete Math formulas — 11 entries in this library
- Topic
- Sets
- Level
- High school · University
Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where two-set inclusion–exclusion comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.
- Probability Foundations — the lesson behind this formula: model outcomes, complements, and conditional information.
- Discrete Math Calculator — check your substitution and the value it produces.
- Study discrete math — the subject guide that explains the ideas these formulas compress.
- Discrete Math Practice — questions that make you retrieve the formula instead of recognising it.
- All 11 discrete math formulas — the full grouped reference, or the complete formula library.
Questions about two-set inclusion–exclusion
What if the two sets share nothing?
Then the intersection is empty, its size is 0, and the formula collapses to plain addition. Disjoint sets are the special case where simply adding was right all along.
How do I find the overlap if I know the union?
Rearrange the formula: the intersection size equals |A| + |B| − |A ∪ B|. With 20, 15, and a union of 30, the overlap must be 5.
What does the three-set version look like?
Add all three sizes, subtract the three pairwise overlaps, then add the triple overlap back. The pattern of alternating signs continues for any number of sets.
How does this connect to a Venn diagram?
The diagram is the formula drawn. Filling in the middle region first and working outward does the same bookkeeping, which is why Venn diagrams are the fastest way to check an answer.