In this section we will consider some matching problems, which will be represented by their chessboard diagrams. We will try to count the number of partial matchings of various sizes. We will represent partial matchings by placements of non-challenging rooks, as in Example 6.7.
Consider the matching problem with the following chessboard diagram:
(so ).
How many ways are there of placing one rook?
How many ways are there of placing two non-challenging rooks?
How many ways are there of placing three non-challenging rooks?
There are white squares, and thus ways of placing one rook. We can list them as follows:
By inspection, there are ways of placing two non-challenging rooks. They can be listed as follows:
If we place three non-challenging rooks, then there must be one in each row. There are two choices for where to place the rook in row . Then there are again two choices for where to place the rook in row , because it is not allowed to go directly underneath the rook in row . We have now blocked out two of the squares in row , leaving only one possible choice for the third rook. This gives ways of placing three non-challenging rooks. We can list them as follows:
Alternatively, we can display the chessboard diagrams:
It is clearly impossible to place more than three non-challenging rooks. By convention, we also say that there is one way of placing no rooks.
Let be a matching problem (typically represented by an chessboard diagram, with the elements of coloured white, and the elements not in coloured black). We write for the set of partial matchings with . (Such a partial matching corresponds to a placement of non-challenging rooks on .) We write , so is the number of partial matchings of size , or the number of ways of placing non-challenging rooks on . We note that when we have and , and we put
We call this the rook polynomial for .
There is only one way of placing no rooks, so . The number of ways of placing one rook is just the number of white squares in , which will write as , so . This means that
The higher coefficients are harder to calculate. In Problem 7.1, we showed that and and for , so
It is clear that rotating or reflecting a board does not affect the set of non-challenging rook placements, and so does not affect the rook polynomial.
Let be the full board, with all squares white:
It is clearly impossible to place more than one rook on without the rooks challenging each other, so we just have .
Put , so the corresponding chessboard diagram has white squares on the diagonal and black squares everywhere else.
It is clearly impossible for two rooks placed anywhere on to challenge each other. Thus, just consists of all subsets of size in , which means that . This gives
Consider a full board , with all squares white:
There are squares, and thus ways of placing one rook, so . We can list them as follows:
If we place two non-challenging rooks, then they must be in different rows, leaving the third row empty. There are three ways to choose the empty row. Then there are three ways place a rook in the upper non-empty row. This blocks off one of the spaces in the lower non-empty row, leaving only two choices for where to place the second rook. Altogether, this gives ways of placing two non-challenging rooks, so . We can list them as follows:
If we place three non-challenging rooks, then there must be one in each row. There are three choices for where to place the rook in row . Then there are only two choices for where to place the rook in row , because it is not allowed to go directly underneath the rook in row . We have now blocked out two of the squares in row , leaving only one possible choice for the third rook. This gives ways of placing three non-challenging rooks, so . We can list them as follows:
Alternatively, we can display the chessboard diagrams:
We now see that
Now consider the following board :
The possible rook placements are as follows:
so .
so .
so .
so .
so .
(Later, we will discuss a systematic method to construct these lists.) From this we see that the rook polynomial is
We next generalise Example 7.7.
We write for the full board (with all squares white). Thus, as a set, we just have
We also write , so is the full square board.
Consider , which is the set of ways of placing non-challenging rooks on the full board. Then this set can be identified with the set of permutations of , so .
Any element of is a placement of non-challenging rooks. As the rooks do not challenge each other, we have at most one rook per row. As we have rooks and only rows, there must be a rook in every row. Let be the horizontal position of the rook in row , so is a function from the set to itself. Similarly, each column must contain precisely one rook. Let be the vertical position of the rook in column . It is then easy to see that the functions and are inverse to each other, so is a bijection, or in other words a permutation. Conversely, if we are given a permutation then we can place a rook in position for , and this gives us non-challenging rooks. ∎
Consider the full board, denoted by . Then for there are precisely ways of placing non-challenging rooks on , so . Thus, the rook polynomial is
In particular, for a square board of size we have
If we have non-challenging rooks, then they must lie in different rows. There are ways of choosing the rows in which the rooks will appear. Similarly, the rooks must lie in different columns. There are ways of choosing the columns in which the rooks will appear. Now suppose we have chosen the rows and columns. If we ignore all the other rows and columns, we are just left with a board, on which we need to place non-challenging rooks. There are ways to do this, by Proposition 7.10. Thus, we have possibilities altogether. ∎
Let be an board in which the main diagonal squares are black and all other squares are white. The case is shown below.
How many ways are there of placing non-challenging rooks on this board?
This is a problem that we have already solved, but slightly disguised. For any permutation of the set we have a rook placement with rooks in positions . However, we want to ensure that no rooks are on the black squares, which are in positions . Thus, we need to have for all . This is precisely the condition for to be a derangement, as introduced in Definition 5.8. Thus, the number of ways of placing non-challenging rooks is the same as the number of derangements, which is by Proposition 5.11.
Suppose we have people and , and jobs and , with qualifications as follows:
can be done by or ;
can be done by or ;
can be done by or ;
can be done by or .
Is it possible to solve the job allocation problem, and if so, in how many ways?
The chessboard diagram for this matching problem is as follows:
The job allocation problem is equivalent to the problem of placing four non-challenging rooks on this board. This means that we must have a rook in each row. The rook in row must be at , and this means that the rook in row cannot be at , so it must be at or .
Suppose we place a rook at . This blocks , so the rook in row must be at . Now and are blocked by and , so the rook in row must be at . This gives a full matching .
Suppose instead that we place a rook at . This blocks , and is also blocked by , so the rook in row must be at . Now is blocked by , so the rook in row must be at . This gives a full matching .
From this we see that there are precisely two full matchings. Equivalently, there are precisely two ways to allocate the jobs subject to the usual rules: each person should have precisely one job, and each job should be done by precisely one person.
We will next give two examples where we can show that an interesting problem is equivalent to a rook placement problem. However, we will not yet solve the resulting rook placement problems. Instead, we will first develop some general techniques, which will make the task easier.
One version of the game of Snap works as follows. There are two players, each of whom has a full pack of 52 cards. At each turn, both players take a card from the top of their pack. If the two cards have the same value (for example, they are both kings or both sevens) then that counts as a snap, and the game ends. Of course, it could happen that the game continues for 52 turns and the players play all of their cards but still no snap has happened. What is the probability of this?
For simplicity, we will first consider the case where the decks just have the aces, kings, queens and jacks, so there are only 16 cards altogether. We will number the cards as , with cards being the aces, cards being the kings, being the queens and the jacks. We will analyse the problem using the following board:
Squares are coloured black if the corresponding row and column markers have the same value; they are coloured white if the row and column markers have different values. For example, the (K♣,K♥) square is black (because the two markers are both kings) but the (Q♥,J♠) square is white.
We will assume for simplicity that the first player’s pack is unshuffled, so cards to appear in order, but that the second player’s pack is shuffled randomly. (We leave it as an exercise to understand why this simplifying assumption does not really change anything.) Let be the card in position in the second player’s pack, so is a random permutation, and cards and get played at the same time. This permutation can be represented in the usual way by placing rooks on the board, with the ’th rook at position . Suppose, for example, that , so cards 6 and 3 get played together. Card 6 is K♥, and card 3 is A♠. These have different values, so this is not a snap. This corresponds to the fact that the square is white. Suppose, for another example, that , so cards 9 and 11 are played together. Card 9 is Q♣ and card 11 is Q♠, so this is a snap. This corresponds to the fact that the square (9,11) is black. Thus, our game has a snap if there is a rook on a black square, but there is no snap if all the rooks are on white squares. Thus, our main task is to calculate the number of ways of placing 16 non-challenging rooks using the white squares only. We will return to this calculation when we have developed a bit more theory.
Suppose we have a dinner party with ten guests, who are to be seated at a round table. There are five married couples, each consisting of a man and a woman. We want to arrange the seating so that the men alternate with the women, and no one sits next to their spouse. How many ways are there to do this? (This is sometimes called the ménage problem.)
We label the seats as follows:
The first choice to make is whether the women get the seats with letters or the seats with numbers; this will give an overall factor of two. For the rest of the analysis, we will assume that the women get the letters. Next, there are ways to assign the women to seats . Now suppose we have seated the women, and we want to seat the men. We will refer to the woman in seat as woman , and to her husband as man , and so on. Now man is not supposed to sit next to his wife, so he can sit in seats , or but not or . Similarly, man can sit in seats , or , and man can sit in seats , or , and so on. These rules can be represented by the following chessboard diagram:
Our seating problem is equivalent to the problem of finding a full matching for this board. (A rook in position corresponds to putting man in seat , for example.) We will show later that there are such matchings. This means that there are possible solutions to the original problem.