which can be written in closed form as
:
where the last sum runs over all subsets "I" of the indices 1, ..., "n" which contain exactly "k" elements.
According to the Bonferroni inequalities, the sum of the first terms in the formula is alternately an upper bound and a lower bound for the LHS. This can be used in cases where the full formula is too cumbersome.
For a general measure space ("S","Σ","μ") and measurable subsets "A"1, ..., "An" of finite measure, the above identities also hold when the probability measure is replaced by the measure "μ".
Proof
To prove the inclusion-exclusion principle in general, we first have to verify the identity
:
for indicator functions. There are at least two ways to do this:
First possibility: If suffices to do this for every "x" in the union of "A"1, ..., "An". Suppose "x" belongs to exactly "m" sets with 1 ≤ "m" ≤ "n", for simplicity of notation say "A"1, ..., "Am". Then the identity at "x" reduces to
:
The number of subsets of cardinality "k" of an "m"-element set is the combinatorical interpretation of the binomial coefficient . Since , we have
:
Putting all terms to the left-hand side of the equation, we obtain the expansion for (1 – 1)"m" given by the binomial theorem, hence we see that (*) is true for "x".
Second possibility: Let "A" denote the union of the sets "A"1, ..., "An". Then
:
because both sides are zero for an "x" not in "A", and if "x" belongs to one of the sets, say "Am", then the corresponding "m"th factor is zero. By expanding the product on the right-hand side, equation (*) follows.
Use of (*): To prove the inclusion-exclusion principle for the cardinality of sets, sum the equation (*) over all "x" in the union of "A"1, ..., "A""n". To derive the version used in probability, take the expectation in (*). In general, integrate the equation (*) with respect to "μ". Always use linearity.
Other forms
The principle is sometimes stated in the form that says that if
:
then
:
In that form it is seen to be the Möbius inversion formula for the incidence algebra of the partially ordered set of all subsets of "A".
Applications
In many cases where the principle could give an exact formula (in particular, counting prime numbers using the sieve of Eratosthenes), the formula arising doesn't offer useful content because the number of terms in it is excessive. If each term individually can be estimated accurately, the accumulation of errors may imply that the inclusion-exclusion formula isn't directly applicable. In number theory, this difficulty was addressed by Viggo Brun. After a slow start, his ideas were taken up by others, and a large variety of sieve methods developed. These for example may try to find upper bounds for the "sieved" sets, rather than an exact formula.
Derangements
A well-known application of the inclusion-exclusion principle is to the combinatorial problem of counting all derangements of a finite set. A "derangement" of a set "A" is a bijection from "A" into itself that has no fixed points. Via the inclusion-exclusion principle one can show that if the cardinality of "A" is "n", then the number of derangements is ["n"! / "e"] where ["x"] denotes the nearest integer to "x"; a detailed proof is available here.
This is also known as the subfactorial of "n", written !"n". It follows that if all bijections are assigned the same probability then the probability that a random bijection is a derangement quickly approaches 1/"e" as "n" grows.
Counting intersections
The principle of inclusion-exclusion, combined with de Morgan's theorem, can be used to count the intersection of sets as well. Let represent the complement of "A""k" with respect to some universal set "A" such that for each "k". Then we have
:
thereby turning the problem of finding an intersection into the problem of finding a union.
ee also
* Combinatorial principles
* Boole's inequality
* Necklace problem
* Schuette–Nesbitt formula
* Maximum-minimums identity
References