Sprague–Grundy theorem

From Wikipedia, the free encyclopedia
Jump to: navigation, search
The Sprague-Grundy theorem says that many simple games are mathematically equivalent to the stone-taking game of Nim (pictured).

In combinatorial game theory, the Sprague–Grundy theorem states that every impartial game under the normal play convention is equivalent to a nimber. The Grundy value or nim-value of an impartial game is then defined as the unique nimber that the game is equivalent to. In the case of a game whose positions (or summands of positions) are indexed by the natural numbers (for example the possible heap sizes in nim-like games), the sequence of nimbers for successive heap sizes is called the nim-sequence of the game.

The theorem and its proof encapsulate the main results of a theory discovered independently by R. P. Sprague (1935) and P. M. Grundy (1939).[1]

Definitions[edit]

For the purposes of the Sprague–Grundy theorem, a game is a two-player sequential game of perfect information satisfying the ending condition (all games come to an end: there are no infinite lines of play) and the normal play condition (a player who cannot move loses).

An impartial game is one such as nim, in which each player has exactly the same available moves as the other player in any position. Note that games such as tic-tac-toe, checkers, and chess are not impartial games. In the case of checkers and chess, for example, players can only move their own pieces, not their opponent's pieces. And in tic-tac-toe, one player puts down X's, while the other puts down O's. Positions in impartial games fall into two outcome classes: either the next player (the one whose turn it is) wins (an N-position) or the previous player wins (a P-position).

In this proof, a position is identified with the set of positions that can be reached in one move (these positions are called options). For example, the position is a P-position under normal play, because the current player has no moves and therefore loses. The position , in contrast, is an N-position; the current player has only one option, and that option is a losing position for their opponent.

A nimber is a special position denoted for some ordinal . is , the P-position given as an example earlier. The other nimbers are defined inductively by ; in particular, (the example N-position from above), (a choice between the two example positions), etc. therefore corresponds to a heap of counters in the game of nim, hence the name.

Two positions and can be added to make a new position in a combined game where the current player can choose either to move in or in . Explicit computation of the set is by repeated application of the rule , which incidentally indicates that position addition is both commutative and associative as expected.

Two positions and are defined to be equivalent if for every position , the position is in the same outcome class as . Such an equivalence is written .

First Lemma[edit]

As an intermediate step to proving the main theorem, we show that, for every position and every P-position , the equivalence holds. By the above definition of equivalence, this amounts to showing that and share an outcome class for all .

Suppose that is a P-position. Then the previous player has a winning strategy for : respond to moves in according to their winning strategy for (which exists by virtue of being a P-position), and respond to moves in according to their winning strategy for (which exists for analogous reason). So must also be a P-position.

On the other hand, if is an N-position, then the next player has a winning strategy: choose a P-position from among the options, putting their opponent in the case above. Thus, in this case, must be a N-position, just like .

As these are the only two cases, the lemma holds.

Second Lemma[edit]

As a further step, we show that if and only if is a P-position.

In the forward direction, suppose that . Applying the definition of equivalence with , we find that (which is equal to by commutativity of addition) is in the same outcome class as . But must be a P-position: for every move made in one copy of , the previous player can respond with the same move in the other copy, and so always make the last move.

In the reverse direction, since is a P-position by hypothesis, it follows from the first lemma, , that . Similarly, since is also a P-position, it follows from the first lemma in the form that . By associativity and commutativity, the right-hand sides of these results are equal. Furthermore, is an equivalence relation because equality is an equivalence relation on outcome classes. Via the transitivity of , we can conclude that .

Proof[edit]

We prove that all positions are equivalent to a nimber by structural induction. The more specific result, that the given game's initial position must be equivalent to a nimber, shows that the game is itself equivalent to a nimber.

Consider a position . By the induction hypothesis, all of the options are equivalent to nimbers, say . So let . We will show that , where is the mex (minimum exclusion) of the numbers , that is, the smallest non-negative integer not equal to some .

The first thing we need to note is that , by way of the second lemma. If is zero, the claim is trivially true. Otherwise, consider . If the next player makes a move to in , then the previous player can move to in , and conversely if the next player makes a move in . After this, the position is a P-position by the lemma's forward implication. Therefore, is a P-position, and, citing the lemma's reverse implication, .

Now let us show that is a P-position, which, using the second lemma once again, means that . We do so by giving an explicit strategy for the previous player.

Suppose that and are empty. Then is the null set, clearly a P-position.

Or consider the case that the next player moves in the component to the option where . Because was the minimum excluded number, the previous player can move in to . And, as shown before, any position plus itself is a P-position.

Finally, suppose instead that the next player moves in the component to the option . If then the previous player moves in to ; otherwise, if , the previous player moves in to ; in either case the result is a position plus itself. (It is not possible that because was defined to be different from all the .)

In summary, we have and . By transitivity, we conclude that , as desired.

Development[edit]

If is a position of an impartial game, the unique integer such that is called its Grundy value, or Grundy number, and the function which assigns this value to each such position is called the Sprague–Grundy function. R.L.Sprague and P.M.Grundy independently gave an explicit definition of this function, not based on any concept of equivalence to nim positions, and showed that it had the following properties:

  • The Grundy value of a single nim pile of size (i.e. of the position ) is ;
  • A position is a loss for the next player to move (i.e. a P-position) if and only if its Grundy value is zero; and
  • The Grundy value of the sum of a finite set of positions is just the nim-sum of the Grundy values of its summands.

It follows straightforwardly from these results that if a position has a Grundy value of , then has the same Grundy value as , and therefore belongs to the same outcome class, for any position . Thus, although Sprague and Grundy never explicitly stated the theorem described in this article, it is nevertheless an almost trivial consequence of their results. These results have subsequently been developed into the field of combinatorial game theory, notably by Richard Guy, Elwyn Berlekamp, John Horton Conway and others, where they are now encapsulated in the Sprague–Grundy theorem and its proof in the form described here. The field is presented in the books Winning Ways for your Mathematical Plays and On Numbers and Games.

See also[edit]

References[edit]

External links[edit]