contents
§27

Lights Out — Linear algebra over GF(2)

The 1995 Tiger Electronics toy Lights Out: a 5×5 grid of buttons; pressing one toggles itself and its four orthogonal neighbours. Reach all-off from a given lit pattern. Behind this children's puzzle is one of the cleanest examples of linear algebra over : a pattern p is a vector in , each button is a fixed "press vector" , and since presses commute and self-cancel mod 2, "which buttons to press" is itself a vector solving

where A is the symmetric 25 × 25 binary matrix with iff pressing button i toggles light j. In row-major coordinates, A is block tridiagonal:

where is the n × n off-diagonal "adjacency" tridiagonal matrix. View A as a graph operator: it is the reflexive adjacency matrix of the m × n grid graph (a vertex plus its neighbours). All of §27 chases one question — what does this matrix's kernel look like over , because

completely determines both how many patterns are solvable () and how many solutions each solvable pattern has (exactly ).

27.1 Interactive: 3 × 3 and 5 × 5 solvers

The 3 × 3 board's A is full rank — every pattern is solvable in at most 9 presses. The 5 × 5 board has : exactly patterns are solvable (a quarter of all ), each in distinct ways. Both boards below run Gaussian elimination and then pick the minimum-Hamming-weight coset representative. Diameter = 15 on 5 × 5.

3 × 3
full rank · every pattern solvable · diameter 9
lit
0 / 9
solvable
yes
min moves
0
# solutions
1
quiet patterns
0
5 × 5
rank 23 · 2 quiet patterns · 4 solutions per solvable · diameter 15
lit
0 / 25
solvable
yes
min moves
0
# solutions
4
quiet patterns
2

27.2 Quiet patterns

The 5 × 5 kernel has basis . Geometric meaning: pressing exactly the marked buttons restores the all-off board. Adding any quiet pattern to a solution yields another valid solution — that is where the "4 solutions" come from. They also give the solvability test:

(Proof: A is symmetric, hence — the standard finite-dimensional fact, which still holds over .) Toggle cells and watch the two dot products update. A pattern is solvable iff it is orthogonal to both and .

orthogonality test
your pattern p
Q₁ · p·Q₁ = 0
Q₂ · p·Q₂ = 0
verdict
solvable — orthogonal to both quiet patterns
Observation 27.1 — geometry of quiet
is the four-corner-block pattern, is the four-quadrant-block pattern. Both have D₄ symmetry (the 8-element dihedral group) — no coincidence. The 5 × 5 grid itself is D₄-symmetric, so A decomposes under the D₄ representation, and ker A must sit in some isotypic component. Only two non-trivial D₄-invariant solutions to exist on 5 × 5, namely . This is "representation-theoretic subspace decomposition" giving a hard constraint.

27.3 Gaussian elimination — stepping through 3 × 3

The abstract sentence "A is full rank ⇒ solvable" does not tell you how to solve. Real solvers run row reduction over : starting from , swap rows and add rows (XOR over ) until reaching . Each step: in column c, find a non-zero entry at or below row r and swap it up as pivot; then XOR-clear every other row's c-column. After 9 pivots, b has been transformed into the solution x.

3 × 3 Gaussian elimination, step by step
augmented matrix [A | b] — 9 cols of A + 1 col of b · pivot row and eliminating rows highlighted
step 0 / 9pivot r0, c0 · clearing 2 rows
110100000|0
111010000|1
011001000|1
100110100|1
010111010|1
001011001|0
000100110|1
000010111|1
000001011|0

The whole process costs bit operations — on 25 × 25 that is about XORs, microseconds on a modern CPU. This contrasts sharply with the cube: the cube group is non-Abelian and optimal solving is NP-hard (§16); Lights Out, being Abelian, sits comfortably in P.

27.4 The light-chasing heuristic

Every Lights Out player learns to chase the lights: hold the top row, then scan downward — if (r−1, c) is still lit, press (r, c) to kill it. This is one-pass forward elimination; it always clears every row above. But the bottom row's residual need not be zero — it depends on the top-row "kick". The top row has 32 possible kicks; on 5 × 5, exactly 4 of them (because dim ker = 2 and the bottom-row residual must land in the projection of ker onto the bottom row) let the chase finish. Two passes — "chase + correct top row + chase again" — solves any solvable pattern in ≤ 15 moves.

light-chasing animator (5 × 5)
click "start chase" to run forward elimination; non-zero bottom row means you must restart with a different top-row kick (4 valid choices)
pressed: 0
still lit: 12
Top row stays. Sweep downward: if cell (r−1, c) is lit, press (r, c). That always clears row r.

Chase-the-lights is essentially block upper-triangulation: write A using the first m − 1 rows as where S is the Schur complement. The space of admissible top-row kicks is exactly . On a 5 × n board, S is 5 × 5 and its kernel dimension equals dim ker A (so dim = 2 when n = 5). That is the algebraic reason "4 of the 32 top rows work".

27.5 The 1 × n line, and the n-cycle

Reduce Lights Out to a 1 × n line. Now A is the n × n reflexive tridiagonal-symmetric matrix . Its characteristic polynomial obeys a Chebyshev-style recurrence — Sutner's key observation:

Over , reduces to the Fibonacci polynomial mod 2. Consequence: if , else 0. Concretely:

slide n · highlight quiet pattern
kernel dim ker A = 0 · n ≢ 2 (mod 3): every pattern solvable

Now close the line into a ring (index mod n addition) — the σ⁺ game on the cycle . The matrix A becomes cyclic-symmetric (an n × n circulant). Diagonalising over its discrete Fourier basis, one proves over :

Contrast: the line needs n ≡ 2 (mod 3) for a non-trivial kernel; the cycle needs n ≡ 0 (mod 3) and gives dimension 2 (not 1). Same local rule, different topology, completely different kernel. The cleanest small example of "boundary conditions change the global solution space".

27.6 Sutner's recurrence + gcd kernel formula

For a general m × n board, the kernel dimension has a strikingly elegant algebraic formula — due to Sutner (1989) and crystallised by Anderson & Feil (1998). With from §27.5:

Theorem 27.2 (Sutner 1989)
For the m × n Lights Out grid, over , where satisfies with .

Key observation: A is the Kronecker sum . For each eigenvalue λ of over , A restricts on that eigenblock to , which is evaluated at x = λ + 1 (≡ −λ − 1 over ). So A is singular iff some λ satisfies and — i.e. the two polynomials share a root — i.e. their gcd has positive degree.

Compute dim ker for m, n = 1..8 (the table below runs gf2Reduce live in your browser) — a "gold-band" pattern appears: roughly one-third of sizes carry a non-trivial kernel.

dim ker A_{m×n} table — computed live in your browser
dim ker Am×n — the dimension of the "quiet pattern" subspace. Gold = non-trivial kernel ⇒ that board has unreachable patterns. 5×5 is gold (dim = 2), exactly the smallest non-trivial size — which is why Tiger chose it.
12345678
101001001
210201020
302003002
400040000
511302041
600000006
702004002
810201620
Hover any cell for details.
5 × 5 has dim = 2 (Tiger's commercial choice was not coincidental — too small means no kernel, no "unreachable patterns", no flavour; too large and fingers can't keep up. 5 × 5 hits the sweet spot.). The 4 × 4 board is full rank over (dim = 0) — mini-Lights Out has no quiet patterns. 6 × 6 is full rank too. 7 × 7 has dim = 0, but 9 × 9 has dim = 8 — a striking jump.

27.7 σ-game — graph-theoretic generalisation

Sutner's 1989 paper introduced the σ-game on an arbitrary simple graph G = (V, E). Vertices are lights. Pressing vertex v:

Sutner's signature theorem — an "every graph can be all-lit" miracle:

Theorem 27.3 (Sutner 1989 — universal σ⁺ solvability)
For every finite simple graph G, the σ⁺-game's "all-lit" target is solvable — there exists with .

Proof sketch: A + I is symmetric over , so . Key lemma: every kernel vector v ∈ ker(A + I) has even Hamming weight — its support is an "odd closed-neighbourhood subset" of G, and the handshake lemma forces it to be even. Therefore , so , so . QED. A delicious example of a combinatorial lemma getting algebraised.

Here are 5 small graphs. P₅ is a path, C₅ a 5-cycle, K₄ and K₅ complete, Petersen the famous 10-vertex 3-regular graph. Click "show all-ones solution" to see the press set Sutner's theorem guarantees (green ring).

σ⁺ game · 5 preset small graphs
click vertex = press button · live lit-state · or auto-show the Sutner solution
01234
lit0 / 5
pressed0
dim ker A1
all-ones reachableyes

Note Petersen has dim ker = 0 in σ⁺ (full rank), so its all-ones solution is unique. K₅'s A + I is the all-ones 5 × 5 matrix, rank 1 over with nullity 4 — the all-ones target has different solutions (pressing any 1, 3, or 5 of the vertices works).

27.8 Variants — different topologies, different alphabets

Tiger and others have re-issued Lights Out many times; each variant is "swap (G, k)" — change graph G or coefficient ring . The well-studied ones:

variantgraph Gringstate spacedim ker
Lights Out (1995)5 × 5 grid2²³ = 8.4 M2
Mini Lights Out4 × 4 torus2¹⁶ = 65 K0
Lights Out 20005 × 5 grid3²² ≈ 31 G3
Lights Out Cube3 × 3 × 3 surface (54 lights)2⁴⁸ ≈ 281 T6
Lights Out Deluxe6 × 6 grid + diag neighbours2³⁶ ≈ 69 G0
XL-25 (1983, Vulcan)5 × 5 grid (earliest commercial)2²³2
hex Lights Outhexagonal honeycombsize-dependentvaries

The Cube variant's dim ker = 6 stems from the 3 × 3 × 3 surface graph's symmetry: the 24 outer cube rotations give 6 independent "face-symmetric" quiet patterns. The 24-rotation group is the same as the cube symmetries from §14 — but acting on a different algebraic object (adjacency vs permutation), the outcome is completely different.

Lights Out 2000 moves to mod 3: lights cycle through grey / green / red on each press. The same matrix now lives over . Its kernel dimension jumps to 3 — the extra "mod 3 quiet patterns" are invisible from the viewpoint. General fact: depends on p; the integer determinant tells you exactly which primes make A singular. On 5 × 5, over , and the Smith normal form shows the elementary divisors contribute singular behaviour at both mod 2 and mod 3.

27.9 Bridge to coding theory

Lights Out is literally a linear coding problem over . Think of "button configuration" as plaintext and "lit pattern" as codeword , then:

This links the toy puzzle to LDPC / coding theory. Conversely, any solvable -linear system can be re-cast as some Lights Out instance.

27.10 Complexity — why Lights Out ≪ Rubik's cube

Three facts make Lights Out "easy":

Consequence: on an N = mn-cell Lights Out board, is it solvable? and what is a shortest solve? are both in time, or with (fastest known matrix multiplication). Contrast: optimal-solving the n × n × n Rubik's cube is NP-complete (Demaine et al. 2018). Drop any of the three properties above (press order matters → non-Abelian; or 4-state lights with non-linear rule), and Lights Out lands in NP-hard immediately.

"Abelian toys yield to linear algebra; non-Abelian toys yield NP-hardness proofs. Lights Out and Rubik's cube sit on opposite sides of this watershed."

27.11 Historical note

The earliest commercial release was XL-25 (Vulcan Electronics 1983), invented by Hungarian László Mérő — 5 × 5 with both standard and knight's-move rules. Merlin (1978) had used a 3 × 3 with a different rule. Tiger Electronics released Lights Out in 1995 and made it a household toy; Lights Out 2000 (1997) / Cube / Deluxe followed. On the math side: Sutner (1989) introduced the σ-game framework with the recurrence and gcd formula — the foundational paper; Anderson & Feil (1998), "Turning Lights Out with Linear Algebra" in Mathematics Magazine, made it an undergraduate-textbook standard; Goldwasser, Klostermeyer, Trapp (1995–1997) gave the domino/monomino tiling characterisation. A specimen of "one toy puzzle, half a century of academic work".

Side by side with the cube: both emerged into popular culture around 1980 from Hungary / the US, both are symmetric, reversible, group-theoretic discrete systems. The single difference is Abelian vs non-Abelian — and that single bit determines whether linear algebra suffices, planting the two puzzles in different complexity classes (P vs NP-hard). Because Lights Out is in P, it lectures cleanly in elementary olympiad and undergrad linear algebra; the cube cannot, because the algorithms it needs are too special-purpose.

cuberoot.me · Rubik's Cube as a Group · 2026