This formula can be generalized in the following beautiful manner. Let be a p-system
of
consisting of sets , ..., , then
(3)
where the sums are taken over k-subsets of .
This formula holds for infinite sets as well as finite sets (Comtet 1974, p. 177).
The principle of inclusion-exclusion was used by Nicholas Bernoulli to solve the recontres problem of finding the number of derangements
(Bhatnagar 1995, p. 8).
For example, for the three subsets , , and of , the following table summarizes the terms appearing
the sum.
#
term
set
length
1
2, 3, 7, 9, 10
5
1, 2, 3, 9
4
2, 4, 9, 10
4
2
2, 3, 9
3
2, 9, 10
3
2, 9
2
3
2,
9
2
is therefore equal to , corresponding to the seven elements .