Inclusion-Exclusion Principle

Theorem
Let $$\mathcal S$$ be an algebra of sets.

Let $$A_1, A_2, \ldots, A_n$$ be finite sets.

Let $$f: \mathcal S \to \R$$ be an additive function.

Then:

$$ $$ $$ $$ $$

Proof
Proof by induction:

For all $$n \in \N^*$$, let $$P \left({n}\right)$$ be the proposition:

$$ $$ $$ $$ $$


 * $$P(1)$$ is true, as this just says $$f \left({A_1}\right) = f \left({A_1}\right)$$.

Basis for the Induction

 * $$P(2)$$ is the case:
 * $$f \left({A_1 \cup A_2}\right) = f \left({A_1}\right) + f \left({A_2}\right) - f \left({A_1 \cap A_2}\right)$$

which is the result Additive Function on Union of Sets.

This is our basis for the induction.

Induction Hypothesis

 * Now we need to show that, if $$P \left({r}\right)$$ is true, where $$r \ge 2$$, then it logically follows that $$P \left({r+1}\right)$$ is true.

So this is our induction hypothesis:

$$ $$ $$ $$ $$

Then we need to show:

$$ $$ $$ $$ $$

Induction Step
This is our induction step:

$$ $$

Consider $$f \left({\bigcup_{i=1}^r A_i \cap A_{r+1}}\right)$$.

By the fact that Intersection Distributes over Union, this can be written:


 * $$f \left({\bigcup_{i=1}^r \left({A_i \cap A_{r+1}}\right)}\right)$$

To this, we can apply the induction hypothesis:

$$ $$ $$ $$ $$

At the same time, we have the expansion of the term $$f \left({\bigcup_{i=1}^r A_i}\right)$$ to take into account.

So we can consider the general term of $$s$$ intersections in the expansion of $$f \left({\bigcup_{i=1}^{r+1} A_i}\right)$$:


 * $$\left({-1}\right)^{s-1} \sum_{{i \in I} \atop {\left|{I}\right| = s}} f \left({\bigcap_{i \in I} A_i}\right) - \left({-1}\right)^{s-2} \sum_{{i \in J} \atop {\left|{J}\right| = s-1}} f \left({\bigcap_{i \in J} A_i \cap A_{r+1}}\right)$$

where:
 * $$I$$ ranges over all sets of $$s$$ elements out of $$\left[{1 \, . \, . \, r}\right]$$;
 * $$J$$ ranges over all sets of $$s-1$$ elements out of $$\left[{1 \, . \, . \, r}\right]$$;
 * $$1 \le s \le r$$

Messy though it is, it can be seen that this expression is merely:


 * $$\left({-1}\right)^{s-1} \sum_{{i \in I'} \atop {\left|{I'}\right| = s}} f \left({\bigcap_{i \in I'} A_i}\right)$$

where this time, $$I'$$ ranges over all sets of $$s$$ elements out of $$\left[{1 \,. \, . \, r+1}\right]$$.

This is the required term in $$s$$ intersections in the expansion of $$f \left({\bigcup_{i=1}^{r+1} A_i}\right)$$.

Just to check, we can see the first term is:


 * $$\sum_{i=1}^r f \left({A_i}\right) + f \left({A_{r+1}}\right) = \sum_{i=1}^{r+1} f \left({A_i}\right)$$

As the expression $$f \left({\bigcup_{i=1}^r A_i \cap A_{r+1}}\right)$$ consists only of intersections of two or more elements of $$\mathcal S$$, we see it does not contribute to this first term.

Finally, let us make sure of the last term - this is:
 * $$- \left({-1}\right)^{r-1} f \left({\bigcap_{i=1}^r A_i \cap A_{r+1}}\right)$$

which works out as:
 * $$\left({-1}\right)^r f \left({\bigcap_{i=1}^{r+1} A_i}\right)$$

We've done enough.

So $$P \left({r}\right) \implies P \left({r+1}\right)$$ and the result follows by the Principle of Mathematical Induction.

Therefore:

$$ $$ $$ $$ $$

Comment
This result is usually quoted in the context of combinatorics, where $$f$$ is the cardinality function.

It is also seen in the context of probability theory, in which $$f$$ is taken to be a probability measure.

Historical Notes
This formula, in various forms, has been attributed to:
 * Abraham de Moivre;
 * Daniel da Silva;
 * Joseph Sylvester;
 * Henri Poincaré.