duaLab Contribute

Lights Out

Contents

Lights Out is a puzzle in which pressing a lamp toggles it and its neighbours; the goal is to turn every lamp off. Which configurations of lamps can be turned off? Over $\mathbb F_2$, the presses form a linear map, and the answer comes from an invariant with values in $\mathbb F_4$ and from the snake lemma.

1. Idea

There are two questions [HH26]. For which sizes can every configuration be turned off? And how do we decide whether a given configuration can be turned off? On a row of three lamps, the configuration in which only the first lamp is on is turned off by two presses. Here $\bullet$ is a lamp that is on, and $\circ$ is a lamp that is off.

\bullet\ \circ\ \circ \arrow[r, "\text{press }2"] & \circ\ \bullet\ \bullet \arrow[r, "\text{press }3"] & \circ\ \circ\ \circ

On a row of two lamps this is impossible: each press toggles both lamps, so $\bullet\ \circ$ only becomes $\circ\ \bullet$.

The method is to give the lamp $i$ the weight $\omega^i$ in the field $\mathbb F_4$, in which $1+\omega+\omega^2=0$; on a board, [HH26] uses the weights $\omega^{i+j}$ in the same way. A press of a lamp $i$ that is not at an end of the row toggles the lamps $i-1$, $i$ and $i+1$, and their weights add up to $\omega^{i-1}(1+\omega+\omega^2)=0$. So such a press does not change the sum of the weights of the lamps that are on. For the two ends of the row, see the extended row.

2. Definition

We write the puzzle in linear algebra over the field $\mathbb F_2$ with two elements.

Definition 2.1 (Lights Out on a row)

Let $n\geq1$. A configuration of a row of $n$ lamps is a vector $a\in\mathbb F_2^n$: the lamp $i$ is on when $a_i=1$. Let $e_1,\dots,e_n$ be the standard basis. Lights Out on a row is given by the linear map $\phi_n:\mathbb F_2^n\to\mathbb F_2^n$ with

$$\phi_n(e_i)=e_{i-1}+e_i+e_{i+1},$$

omitting indices outside $1,\dots,n$. Pressing the lamp $i$ changes a configuration $a$ to $a+\phi_n(e_i)$. The figure in the Idea is the equation $(1,0,0)+\phi_3(e_2)+\phi_3(e_3)=0$.

Remark 2.2 (Solvability and the cokernel)

Pressing the lamps $i$ with $p_i=1$, for a vector $p\in\mathbb F_2^n$, changes $a$ to $a+\phi_n(p)$. So a configuration can be turned off exactly when it lies in the image of $\phi_n$, and the configurations up to presses form $\operatorname{Coker}\phi_n$. It has $2^{\operatorname{corank}\phi_n}$ elements; the corank of $\phi_n$ is the dimension of its cokernel.

Definition 2.3 (Lights Out on a board)

On an $n\times m$ board, the lamp in row $i$ and column $j$ is the basis vector $e_i\otimes e_j$ of $\mathbb F_2^n\otimes\mathbb F_2^m$. A press toggles the lamp and all its neighbours, up to eight. So Lights Out on a board is given by the linear map

$$\phi_{n,m}=\phi_n\otimes\phi_m,\qquad\phi_{n,m}(e_i\otimes e_j)=\sum_{|i-i'|\leq1,\ |j-j'|\leq1}e_{i'}\otimes e_{j'},$$

in which the sum is over the lamps $(i',j')$ of the board.

Example 2.4 (A press on a board)

On the $3\times4$ board with all lamps off, pressing the lamp in row $2$ and column $2$ gives the configuration below. It is $\phi_3(e_2)\otimes\phi_4(e_2)=(1,1,1)\otimes(1,1,1,0)$.

[row sep=tiny, column sep=tiny] \bullet & \bullet & \bullet & \circ \\ \bullet & \bullet & \bullet & \circ \\ \bullet & \bullet & \bullet & \circ

3. One dimension

On a row, an invariant with values in $\mathbb F_4$ decides which configurations can be turned off. The snake lemma explains the form of the test.

Definition 3.1 ($\mathbb F_4$-invariant)

Let $\mathbb F_4=\{0,1,\omega,\omega^2\}$ be the field with four elements, so $\omega^2+\omega+1=0$ and $\omega^3=1$. The $\mathbb F_4$-invariant of a configuration $a\in\mathbb F_2^n$ is

$$\sum_{i=1}^na_i\,\omega^i\in\mathbb F_4.$$

In words, the lamp $i$ has the weight $\omega^i$, and the invariant is the sum of the weights of the lamps that are on.

Example 3.2 (Solution of one-dimensional Lights Out [HH26])

For $n\geq2$, a configuration $a\in\mathbb F_2^n$ can be turned off if and only if its $\mathbb F_4$-invariant lies in the $\mathbb F_2$-span of $1$ and $\omega^{n+1}$; see the lemma below. For $n=3$ this span is all of $\mathbb F_4$, because $\omega^4=\omega$. For $n=2$ it is $\{0,1\}$, because $\omega^3=1$, and the invariant of $(1,0)$ is $\omega$.

Fact 3.3 (Corank in one dimension [Sut88, Sut89])

The corank of $\phi_n$ is $1$ if $n\equiv 2\pmod 3$ and $0$ otherwise. So every configuration of a row of $n$ lamps can be turned off exactly when $n\not\equiv2\pmod3$. It also follows from the criterion above: the elements $1$ and $\omega^{n+1}$ span $\mathbb F_4$ over $\mathbb F_2$ exactly when $\omega^{n+1}\neq1$.

See Sutner 1988, Example 2, Sutner 1989 and Goldwasser–Klostermeyer–Ware 2002.

Definition 3.4 (Extended row)

The extended row is the row of $n$ lamps with one more lamp at each end; its lamps are numbered $0,\dots,n+1$, and only the lamps $1,\dots,n$ are pressed. Its presses and its invariant are the linear maps

$$\begin{gathered}\psi:\mathbb F_2^n\to\mathbb F_2^{n+2},\qquad\psi(e_i)=e_{i-1}+e_i+e_{i+1},\\\tau:\mathbb F_2^{n+2}\to\mathbb F_4,\qquad\tau(x)=\sum_{i=0}^{n+1}x_i\,\omega^i.\end{gathered}$$

For $n=3$ the weights are as follows.

$$\begin{array}{c|ccccc} \text{lamp} & 0 & 1 & 2 & 3 & 4\\ \hline \text{weight} & 1 & \omega & \omega^2 & 1 & \omega\\ \text{pressed} & \text{no} & \text{yes} & \text{yes} & \text{yes} & \text{no} \end{array}$$

Lemma 3.5 (Presses on the extended row)☆

For the extended row, the invariant $\tau$ is surjective, and $\psi$ is an isomorphism from $\mathbb F_2^n$ onto $\operatorname{Ker}\tau$. In words, a configuration of the extended row can be turned off if and only if its invariant is $0$, and then by exactly one set of presses.

Proof

The map $\tau$ is surjective, since $\tau(e_0)=1$ and $\tau(e_1)=\omega$; so $\dim\operatorname{Ker}\tau=n$. The image of $\psi$ lies in $\operatorname{Ker}\tau$, because $\tau\psi(e_i)=\omega^{i-1}(1+\omega+\omega^2)=0$. And $\psi$ is injective: if $i$ is the least index with $p_i=1$, then the $(i-1)$-th coordinate of $\psi(p)$ is $1$. So $\psi$ is an isomorphism onto $\operatorname{Ker}\tau$, by dimension.

Definition 3.6 (End lamps)

The end lamps of the extended row are the lamps $0$ and $n+1$. Let $r:\mathbb F_2^{n+2}\to\mathbb F_2^n$ forget the end lamps, and let $\tau_{\mathrm{edge}}:\mathbb F_2^2\to\mathbb F_4$ be the restriction of $\tau$ to the end lamps; its values on the basis are $1$ and $\omega^{n+1}$. They form the diagram below, with exact rows.

0 \arrow[r] & \mathbb F_2^2 \arrow[r] \arrow[d, "\tau_{\mathrm{edge}}"'] & \mathbb F_2^{n+2} \arrow[r, "r"] \arrow[d, "\tau"] & \mathbb F_2^n \arrow[r] \arrow[d] & 0 \\ 0 \arrow[r] & \mathbb F_4 \arrow[r, equal] & \mathbb F_4 \arrow[r] & 0 \arrow[r] & 0

Lemma 3.7 (Cokernel by the snake lemma)☆

The connecting map $\delta:\mathbb F_2^n\to\operatorname{Coker}\tau_{\mathrm{edge}}$ of the snake lemma for the diagram above induces an isomorphism

$$\operatorname{Coker}\phi_n\cong\operatorname{Coker}\tau_{\mathrm{edge}},\qquad[a]\mapsto\Big[\sum_{i=1}^na_i\,\omega^i\Big].$$

So $\delta$ is the test of the example. It decides whether a configuration of the row extends to a configuration of the extended row with invariant $0$.

Proof

Apply the snake lemma to the diagram. The map $\tau$ is surjective by the lemma, so we get the exact sequence

$$\operatorname{Ker}\tau\xrightarrow{r}\mathbb F_2^n\xrightarrow{\delta}\operatorname{Coker}\tau_{\mathrm{edge}}\to\operatorname{Coker}\tau=0.$$

Since $\operatorname{Ker}\tau=\operatorname{Im}\psi$ and $r\psi=\phi_n$, the connecting map $\delta$ induces $\operatorname{Coker}\phi_n\cong\operatorname{Coker}\tau_{\mathrm{edge}}$. The map $\delta$ extends $a$ by $0$ and applies $\tau$, so $\delta(a)$ is the class of $\sum_{i=1}^na_i\omega^i$ modulo $\operatorname{Im}\tau_{\mathrm{edge}}=\langle1,\omega^{n+1}\rangle$.

4. Two dimensions

On a board, the linear map of the presses is a tensor product. So its rank is the product of the two ranks in one dimension.

Example 4.1 (Two-dimensional Lights Out [HH26])

On an $n\times m$ board with $n,m\geq 2$, the number of configurations up to presses is given by the table below, in which the congruences are modulo $3$.

$$\begin{array}{c|cc} & m\not\equiv2 & m\equiv2\\ \hline n\not\equiv2 & 1 & 2^n\\ n\equiv2 & 2^m & 2^{n+m-1} \end{array}$$

So every configuration can be turned off exactly when neither $n$ nor $m$ is $\equiv2\pmod3$.

Proof

Write $c_n$ for the corank of $\phi_n$; it is $0$ or $1$ by the fact. The rank of a tensor product of linear maps is the product of the ranks, so

$$\operatorname{corank}\phi_{n,m}=nm-(n-c_n)(m-c_m)=m\,c_n+n\,c_m-c_nc_m.$$

Fact 4.2 (Strong products [MP21])

For finite simple graphs $G$ and $H$, the matrices $N[G]=A(G)+I$ of Lights Out satisfy

$$N[G\boxtimes H]=N[G]\otimes N[H]$$

for the strong product $G\boxtimes H$: Lights Out on $G\boxtimes H$ is the tensor product of Lights Out on $G$ and on $H$. So every configuration on $G\boxtimes H$ can be turned off if and only if the same holds on $G$ and on $H$. The $n\times m$ board is the case of two paths, $P_n\boxtimes P_m$.

See Munter–Peters 2021, §2 (p. 418) and Theorem 4.4.

Remark 4.3 (Higashida's solution)

Kyosuke Higashida first solved this puzzle.

6. References

Last edited