MAS334 Combinatorics

10. Inclusion-exclusion for matching problems

Definition 10.1.

Let B be an n×n board, with each square coloured black or white as before. We then write B¯ for the board with the colours exchanged, so the white squares for B are the black squares for B¯ and vice-versa. We call B¯ the complement of B.

Example 10.2.

B and B¯ could be as follows.

As before, we write ck(B) for the number of ways of placing k non-challenging rooks on B, or equivalently the numbers of partial matchings of size k for the corresponding matching problem. Similarly, we write ck(B¯) for the number of ways of placing k non-challenging rooks on B¯. We are particularly interested in cn(B¯), which is the number of full matchings for B¯. It turns out that if we know c0(B),,cn(B) then we can work out cn(B¯):

Theorem 10.3.

cn(B¯)=k=0n(-1)k(n-k)!ck(B).

We will prove this after a preliminary result. The Inclusion-Exclusion Principle (from Section 5) will play a central rôle in the proof. We will then use this theorem to solve the snap problem (Problem 7.15) and the ménage problem (Problem 7.16).

Remark 10.4.

Theorem 10.3 covers only the case of a square board of size n×n, and gives only the top coefficient cn(B¯) in the rook polynomial of the complementary board. However, the statement can be generalised as follows: if B is part of an n×m board, and 0pmin(n,m) then

cp(B¯)=k=0p(-1)k(n-kp-k)(m-kp-k)(p-k)!ck(B).

The proof is quite similar to that of Theorem 10.3, with only a few additional complications; we leave it to the reader to work out the details.

Definition 10.5.

We write S for the set of ways of placing n non-challenging rooks on the full n×n board (so |S|=n! by Proposition 7.11). Now let x be a position on the board. We define SxS to be the set of rook placements that include a rook at x. More generally, given a set X={x1,,xm} of board positions, we put

SX =iSxi=Sx1Sxm
={ non-challenging rook placements with a rook at each position xi}.
Lemma 10.6.

Consider a set X={x1,,xm} as above.

  • (a)

    If there is a row containing two of the positions xi, or a column containing two of the positions xi, then SX= and so |SX|=0.

  • (b)

    Otherwise, we have |SX|=(n-m)!.

Proof.
  • Suppose that some row contains both xi and xj (with ij). Then if we place two rooks at xi and xj, then they will challenge each other, so the placement does not count as an element of SX. This means that it is impossible to have any elements of SX, so SX= and |SX|=0.

  • The same applies if some column contains both xi and xj with ij.

  • Suppose instead that the xi are all in different rows, say r1,,rm, and also in different columns, say c1,,cm. Let A be the set of rows other than r1,,rm, so |A|=n-m. Let B be the set of columns other than c1,,cm, so |B|=n-m. To get a full rook placement in SX we need to place rooks on X, then place n-m rooks on the board A×B, which is an (n-m)×(n-m) board with no black squares. Proposition 7.11 tells us that there are (n-m)! ways to do this, so |SX|=(n-m)!.

Proof of Theorem 10.3.

We need to understand the set Cn(B¯)S. Consider a rook placement P for the full board, so PS. We claim that PxBSx iff PCn(B¯). Indeed, we have PxBSx iff there exists a square xB such that PSx. However, we have PSx iff the placement P has a rook at x. Here x is a white square of B so it is a black square of B¯, so if the placement has a rook at x, then it does not count as a placement on B¯, so PCn(B¯). This argument is reversible, so PxBSx iff PCn(B¯). By the contrapositive, we have PCn(B¯) iff PxBSx, or in other words PSxSx. The negative form of the IEP now tells us that

cn(B¯)=|Cn(B¯)|=XB(-1)|X||SX|.

If X is not a non-challenging rook placement on B, then |SX|=0 by Lemma 10.6(a), so we can ignore these terms. On the other hand, if X is a placement of k non-challenging rooks on B, then |SX|=(n-k)! by Lemma 10.6(a). The number of terms of this type is ck(B), so the sum of all terms of this type is (-1)k(n-k)!ck(B). Putting this together, we get cn(B¯)=k=0n(-1)k(n-k)!ck(B) as claimed. ∎

Remark 10.7.

We can apply Theorem 10.3 to B¯ and note that B¯¯=B; this gives

cn(B)=k=0n(-1)k(n-k)!ck(B¯).
Example 10.8.

As a trivial example, we have cn(Fn)=k=0n(-1)k(n-k)!ck(Fn¯). However, all squares in Fn¯ are black, so we cannot place any rooks there, so ck(Fn¯)=0 for k>0. On the other hand, we always have c0=1, so our equation becomes

cn(Fn)=(-1)0n!c0(Fn¯)=n!,

and we knew this already from Proposition 7.10.

Example 10.9.

Recall from Example 7.6 that Dn is the n×n board with only the diagonal squares coloured white, and that ck(Dn)=(nk)=n!/(k!(n-k)!). We thus have

cn(Dn¯)=k=0n(-1)k(n-k)!ck(Dn)=n!k=0n-1(-1)k/k!.

On the other hand, Problem 7.13 shows that Cn(Dn¯) is the set of derangements of {1,,n}. We saw in Proposition 5.11 that the number of derangements is n!k=0n-1(-1)k/k!, so everything is consistent.

Definition 10.10.

The board Qn consists of 2n-1 white squares in an n×n board arranged in a zigzag pattern as illustrated on the left below. (To see that there are 2n-1 white squares, note that there are n rows, and each row contains two white squares, except for the first row, which contains only one white square.) We also consider the board Qn, which has an extra white square at the top right, making 2n white squares in total.

We call a board of type Qn a staircase.

Proposition 10.11.

For 0kn we have ck(Qn)=(2n-kk). We also have

ck(Qn)=ck(Qn)+ck-1(Qn-1)=(2n-kk)+(2n-1-kk-1).
Proof.

By inspection, two rooks on the staircase challenge each other iff they are adjacent. Thus, the allowable rook placements are just subsets of the staircase that have no adjacent elements; in other words, they must be gappy, as in Definition 1.21. Thus, ck(Qn) is the number of gappy subsets of size k in the staircase. Proposition 1.23 therefore gives ck(Qn)=(m-k+1k), where m is the number of cells in the staircase. This is just m=2n-1, so we get ck(Qn)=(2n-kk).

Now consider Qn. Blocking the top right square gives Qn, and stripping it gives a reflected copy of Qn-1. Thus, Theorem 8.1 gives ck(Qn)=ck(Qn)+ck-1(Qn-1), which is (2n-kk)+(2n-1-kk-1) by the previous paragraph. ∎

We can now complete our analysis of the ménage problem.

Example 10.12.

Using Proposition 10.11, we see that the rook polynomial coefficients of Q5 are as follows:

c0(Q5) =1
c1(Q5) =(91)+(80)=10
c2(Q5) =(82)+(71)=35
c3(Q5) =(73)+(62)=50
c4(Q5) =(64)+(53)=25
c5(Q5) =(55)+(44)=2.

Now note that the board B considered in Problem 7.16 is just the complement of Q5. It follows that

c5(B) =5!c0(Q5)-4!c1(Q5)+3!c2(Q5)-2!c3(Q5)+1!c4(Q5)-0!c5(Q5)
=120×1-24×10+6×35-2×50+1×25-1×0
=13.

Thus, there are precisely 13 full matchings for B. As explained in Problem 7.16, it follows that there are 2×120×13=3120 ways to solve the seating problem described there.

We can also now complete our analysis of the snap problem.

Example 10.13.

Let B denote the board shown in Problem 7.15, which is a 16×16 board with four black blocks of size 4×4 on the diagonal. This means that B¯ consists of four fully disjoint copies of F4. Proposition 7.11) tells us that

rF4(x)=k=04(4k)2k!xk=1+16x+72x2+96x3+24x4.

Moreover, we can use Theorem 8.7 to show that

rB¯(x)=rF4(x)4.

It would be a lot of work to expand this by hand, but it can easily be done with a computer. If rF4(x)4=i=016aixi, we then find that c16(B)=i(-1)i(16-i)!ai. Using a computer again, we find that c16(B)2.483×1011. This is the number of possible games with no snap. On the other hand, the total number of possible games is 16!2.092×1013. Thus, the probability of not getting a snap is

c16(B)/52!2.483×10112.092×10130.012.

In other words, only about one in a hundred games will end without a snap. This was all for the restricted game where we only use aces, kings, queens and jacks. If we want to use the full pack, we need to expand rF4(x)13 as i=052bixi, and then calculate c52(B)=i(-1)i(52-i)!bi, which works out to 1.309×1066. We then divide by 52!8.066×1067 to give a probability of approximately 0.016.