Principle of Inclusion–Exclusion (PIE): Fundamentals and Extensions

Lesson · Intermediate

Combinatorics

Inclusion–Exclusion Principle for two sets

For finite sets A and B:

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

Inclusion–Exclusion Principle for three sets

For finite sets A, B, and C:

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|

General Inclusion–Exclusion Principle for n sets

For sets A₁, A₂, ..., Aₙ:

A1A2An=iAii<jAiAj+i<j<kAiAjAk \left|A_1\cup A_2\cup\cdots\cup A_n\right| = \sum_i |A_i| -\sum_{i<j}|A_i\cap A_j| +\sum_{i<j<k}|A_i\cap A_j\cap A_k| -\cdots

In compact form, the general principle is:

i=1nAi=k=1n(1)k+11i1<i2<<iknAi1Ai2Aik \left|\bigcup_{i=1}^{n}A_i\right| = \sum_{k=1}^{n}(-1)^{k+1} \sum_{1\le i_1<i_2<\cdots<i_k\le n} \left|A_{i_1}\cap A_{i_2}\cap\cdots\cap A_{i_k}\right|

Counting elements in exactly one set

Let E_j denote the number of elements that are contained in exactly j of the sets A₁, A₂, ..., Aₙ.

For two sets:

E1=A1+A22A1A2 E_1=|A_1|+|A_2|-2|A_1\cap A_2|

For three sets:

E1=A1+A2+A32A1A22A1A32A2A3+3A1A2A3 E_1 = |A_1|+|A_2|+|A_3| -2|A_1\cap A_2| -2|A_1\cap A_3| -2|A_2\cap A_3| +3|A_1\cap A_2\cap A_3|

The coefficients here are different from those in the ordinary Inclusion–Exclusion formula.