Chapter 8. Bonus Chapter: Lights Out
This chapter is an optional example application and can be safely skipped.
§8.1 Rules of Lights Out
Here’s Wikipedia’s description, except I replaced with :
Lights Out is an electronic game released by Tiger Electronics in 1995. The game consists of an grid of lights. When the game starts, a random number or a stored pattern of these lights is switched on. Pressing any of the lights will toggle it and the adjacent lights. The goal of the puzzle is to switch all the lights off.
Here’s a picture of someone playing for , making two moves:
§8.2 Examples of Lights Out theorems
In this chapter we’ll show that Lights Out is really a linear algebra problem over . As a result, by casting the problem appropriately in linear algebra language, we will be able to prove three theorems:
We’ll be able to prove Theorem 8.1 by the end of this chapter. Proving Theorem 8.2 and Theorem 8.3 will need to wait until the end of Chapter 9, at which point we’ll provide exercises to complete those proofs.
These are by no means the only results you can prove about Lights Out. But they give a starting point and a nice showcase of our general theory.
§8.3 Modeling Lights Out using linear algebra
So that we can draw illustrations concretely, we specialize to . Let’s number the cells of the grid from to as shown in Figure 8 (left). We then consider the nine possible moves, encoding each move as a vector in . For example, selecting the cell marked would toggle the cells , , , so we define the move vector
again as in Figure 8 (center and right).
To really make everything fully explicit, here are all move vectors and their corresponding illustrations, in Figure 9. We’ve written the components of the vectors in three lines in a suggestive way, to make it easier to compare to the image, but you should still think of them as vectors in .
Now the punch line is this:
To illustrate, let’s consider the following Lights Puzzle:
We encode the puzzle as a vector as well, in the obvious way:
Then pressing light corresponds to adding the vector :
Now, suppose I tell you that the answer to our in Figure 10 is to press the three lights , , (in any order). To check this, you would compute
which when working modulo is equivalent to
and that’s exactly what we wanted.
In summary, solving Lights Out, for any , is exactly equivalent to writing the given puzzle as a linear combination of the move vectors .
At this point, the first advertised theorem, Theorem 8.1, is complete:
§8.4 Every Lights Out puzzles has a unique solution
In this section, we will still only focus on , but these results do not generalize to all . Our goal is to prove:
The basic strategy of the proof is to show that are spanning in . Then we can apply Proposition 3.17 to conclude are a basis, and then we’re done.
Exercise 8.8. Consider any vector with exactly one (i.e. a standard basis vector for ). Show that it’s in the span of the move vectors, by considering three cases:
- If the is on an “edge” (2,4,6,8), use Exercise 8.7 once.
- If the is on an “corner” (1,3,7,9), use Exercise 8.7 twice.
- If the is the “center” (5), use the Exercise 8.7 times.
Conclude that , …, are indeed spanning.
§8.5 How to beat the 1995 video game
§8.6 Exercises
Exercise 8.11. We will work on Lights Out puzzles.
- Show that if all the lights are on, they can all be turned off.
- Show that the solution you found is not unique. (One way is to rotate or reflect.)
- Conclude that not every Lights Out puzzle can be solved.