No history yet

Advanced PIE Applications

Beyond Simple Counting

You're already familiar with the basic Principle of Inclusion-Exclusion (PIE), which helps count the elements in the union of several sets. It's a way to handle overcounting by systematically adding and subtracting the sizes of intersections. Now, we'll push this principle further to solve more complex problems.

What if we don't want to count elements that have at least one property, but elements that have exactly a certain number of properties? This requires a more nuanced version of the formula.

Ek=j=kn(1)jk(jk)NjE_k = \sum_{j=k}^{n} (-1)^{j-k} \binom{j}{k} N_j

This formula might look intimidating, but it's a powerful tool for precision counting. The binomial coefficient (jk)\binom{j}{k} accounts for the fact that an element with jj properties is counted in NjN_j once, but it's also counted in the calculations for Nj+1,Nj+2N_{j+1}, N_{j+2}, and so on. This formula corrects for all the layers of over- and under-counting to isolate just the elements with exactly kk properties.

A Proof Using Indicator Functions

A clean way to prove the generalized PIE is by using indicator functions. An indicator function for a set AA is a function that tells you whether an element is in the set or not.

Indicator Function

noun

For a subset A of a universal set U, the indicator function IA:U{0,1}I_A: U \to \{0, 1\} is defined as IA(x)=1I_A(x) = 1 if xAx \in A, and IA(x)=0I_A(x) = 0 if xAx \notin A.

Let's consider an element xx from our universal set. Let P1,P2,,PnP_1, P_2, \dots, P_n be the properties, and let AiA_i be the set of elements with property PiP_i. Suppose xx has exactly mm of these properties. We want to show that its contribution to the right side of the generalized PIE formula is 1 if m=km=k and 0 otherwise.

The number of times xx is counted in NjN_j is (mj)\binom{m}{j}, since we must choose jj properties from the mm properties that xx possesses. If j>mj > m, this value is 0. So, the total count for element xx in the sum is:

j=km(1)jk(jk)(mj)\sum_{j=k}^{m} (-1)^{j-k} \binom{j}{k} \binom{m}{j}

Using the binomial identity (mj)(jk)=(mk)(mkjk)\binom{m}{j}\binom{j}{k} = \binom{m}{k}\binom{m-k}{j-k}, we can rewrite the sum:

(mk)j=km(1)jk(mkjk)\binom{m}{k} \sum_{j=k}^{m} (-1)^{j-k} \binom{m-k}{j-k}

Let's make a substitution s=jks = j-k. The sum becomes s=0mk(1)s(mks)\sum_{s=0}^{m-k} (-1)^{s} \binom{m-k}{s}. By the binomial theorem, this sum is equal to (11)mk(1-1)^{m-k}, which is 0 if mk>0m-k > 0 (i.e., m>km > k) and 1 if mk=0m-k = 0 (i.e., m=km=k).

Therefore, the element xx is counted once if it has exactly kk properties (m=km=k) and zero times otherwise. Summing over all elements proves the generalized PIE formula.

Counting Surjections

One of the classic applications of PIE is counting the number of surjective (or "onto") functions from one finite set to another. A function f:ABf: A \to B is surjective if every element in the codomain BB is mapped to by at least one element in the domain AA. Let's say A=m|A|=m and B=n|B|=n.

The total number of functions from AA to BB is nmn^m, since each of the mm elements in AA can be mapped to any of the nn elements in BB. We want to subtract the functions that are not surjective.

Let's define our properties. Let PiP_i be the property that the element biBb_i \in B is not in the image of the function. We want to find the number of functions with exactly 0 of these properties.

This means we are calculating E0E_0 from our generalized formula, where the properties are 'bad' properties we want to avoid.

Let's calculate NjN_j, the sum of the sizes of all jj-intersections. An intersection of jj sets corresponds to functions that miss at least jj specific elements from the codomain BB. The number of ways to choose these jj elements is (nj)\binom{n}{j}. For each such choice, the number of functions from AA to the remaining njn-j elements of BB is (nj)m(n-j)^m.

So, Nj=(nj)(nj)mN_j = \binom{n}{j}(n-j)^m.

Now we can plug this into the generalized PIE formula with k=0k=0:

E0=j=0n(1)j(j0)Nj=j=0n(1)j(nj)(nj)mE_0 = \sum_{j=0}^{n} (-1)^{j} \binom{j}{0} N_j = \sum_{j=0}^{n} (-1)^{j} \binom{n}{j}(n-j)^m

This result is closely related to Stirling numbers of the second kind, often denoted S(m,n)S(m,n) or {mn}\left\{ \begin{matrix} m \\ n \end{matrix} \right\}, which count the number of ways to partition a set of mm elements into nn non-empty subsets. The number of surjections is n!S(m,n)n! \cdot S(m,n).

The Problème des Ménages

The "problem of the households" is a famous combinatorial problem: In how many ways can nn married couples be seated at a round table such that men and women alternate, and no one sits next to their spouse?

First, let's seat the women. There are (n1)!(n-1)! ways to seat them around a round table. Once they are seated, there are nn empty chairs between them for the men. Let's label the women W1,,WnW_1, \dots, W_n in clockwise order. This fixes the positions. Now there are n!n! ways to seat the men in the empty chairs. The total number of arrangements with alternating genders is (n1)!×n!(n-1)! \times n!.

Now we apply PIE to subtract the arrangements where at least one husband sits next to his wife. A husband HiH_i can sit next to his wife WiW_i in two ways: on her left or on her right. Let PiP_i be the property that husband HiH_i sits next to his wife WiW_i.

The calculation for NjN_j becomes quite complex because the choices of which couples sit together are not independent. For example, if H1H_1 sits next to W1W_1 and H2H_2 sits next to W2W_2, the available seats for other husbands are affected. This problem requires a more careful application of PIE, often involving recurrence relations or rook polynomials, but the core idea remains the same: define properties, calculate the size of intersections, and use an alternating sum to find the final count.

Quiz Questions 1/5

The standard Principle of Inclusion-Exclusion (PIE) counts elements with at least one property. What does the generalized version of PIE allow you to calculate?

Quiz Questions 2/5

Using the Principle of Inclusion-Exclusion to count the number of surjective (onto) functions from a set A of size 'm' to a set B of size 'n', what is the correct formula for the sum of the sizes of all j-intersections, NjN_j?

These advanced applications show how the simple idea of adding and subtracting can be extended to solve highly constrained counting problems. By carefully defining properties and applying the generalized formula, we can isolate exactly the arrangements we want to count.