Lably
Skip to content

Inclusion–exclusion principle

Counting technique in combinatorics

  • 17 min read
  • 9 chapters

Related on Lably

Through Combinatorics, Cardinality and Venn diagram

The inclusion-exclusion principle, being a generalization of the two-set case, is perhaps more clearly seen in the case of three sets, which for the sets A, B and C is given by |A∪B∪C|=|A|+|B|+|C|−|A∩B|−|A∩C|−|B∩C|+|A∩B∩C| This formula can be verified by counting how many times each region in the Venn diagram figure is included in the right-hand side of the formula. In this case, when removing the contributions of over-counted elements, the number of elements in the mutual intersection of the three sets has been subtracted too often, so must be added back in to get the correct total.

Generalizing the results of these examples gives the principle of inclusion–exclusion. To find the cardinality of the union of n sets:

  1. Include the cardinalities of the sets.
  2. Exclude the cardinalities of the pairwise intersections.
  3. Include the cardinalities of the triple-wise intersections.
  4. Exclude the cardinalities of the quadruple-wise intersections.
  5. Include the cardinalities of the quintuple-wise intersections.
  6. Continue, until the cardinality of the n-tuple-wise intersection is included (if n is odd) or excluded (n even).

The name comes from the idea that the principle is based on over-generous inclusion, followed by compensating exclusion. This concept is attributed to Abraham de Moivre (1718), although it first appears in a paper of Daniel da Silva (1854) and later in a paper by J. J. Sylvester (1883). Sometimes the principle is referred to as the formula of Da Silva or Sylvester, due to these publications. The principle can be viewed as an example of the sieve method extensively used in number theory and is sometimes referred to as the sieve formula.

As finite probabilities are computed as counts relative to the cardinality of the probability space, the formulas for the principle of inclusion–exclusion remain valid when the cardinalities of the sets are replaced by finite probabilities. More generally, both versions of the principle can be put under the common umbrella of measure theory.

In a very abstract setting, the principle of inclusion–exclusion can be expressed as the calculation of the inverse of a certain matrix. This inverse has a special structure, making the principle an extremely valuable technique in combinatorics and related areas of mathematics. As Gian-Carlo Rota put it:

"One of the most useful principles of enumeration in discrete probability and combinatorial theory is the celebrated principle of inclusion–exclusion. When skillfully applied, this principle has yielded the solution to many a combinatorial problem."

Formula

In its general formula, the principle of inclusion–exclusion states that for finite sets A1, ..., An, one has the identity

This can be compactly written as |⋃i=1nAi|=∑k=1n(−1)k+1(∑1⩽i1<⋯<ik⩽n|Ai1∩⋯∩Aik|) or |⋃i=1nAi|=∑∅≠J⊆{1,…,n}(−1)|J|+1|⋂j∈JAj|.

In words, to count the number of elements in a finite union of finite sets, first sum the cardinalities of the individual sets, then subtract the number of elements that appear in at least two sets, then add back the number of elements that appear in at least three sets, then subtract the number of elements that appear in at least four sets, and so on. This process always ends since there can be no elements that appear in more than the number of sets in the union. (For example, if n=4, there can be no elements that appear in more than 4 sets; equivalently, there can be no elements that appear in at least 5 sets.)

In applications it is common to see the principle expressed in its complementary form. That is, letting S be a finite universal set containing all of the Ai and letting Ai¯ denote the complement of Ai in S, by De Morgan's laws we have |⋂i=1nAi¯|=|S−⋃i=1nAi|=|S|−∑i=1n|Ai|+∑1⩽i<j⩽n|Ai∩Aj|−⋯+(−1)n|A1∩⋯∩An|.

As another variant of the statement, let P1, ..., Pn be a list of properties that elements of a set S may or may not have, then the principle of inclusion–exclusion provides a way to calculate the number of elements of S that have none of the properties. Just let Ai be the subset of elements of S which have the property Pi and use the principle in its complementary form. This variant is due to J. J. Sylvester.

Notice that if you take into account only the first m<n sums on the right (in the general form of the principle), then you will get an overestimate if m is odd and an underestimate if m is even.

Sign in to keep reading

8 more chapters are free with a Lably account.

More in Discrete mathematics