Computation

When a press skips its own light

In Lights Out every board can be turned from all off to all on, because each press toggles its own light. Change the rule so a press toggles only the neighbours and the guarantee is gone: 310 of the 3,600 boards up to sixty by sixty cannot be lit. A single comparison of powers of two predicts every one of them, and on general graphs the answer depends on whether the number of vertices is odd or even, for a reason that is one line of algebra.

Worth reading first: Every light on, from every light off · The boards on which every light goes out.

Every light on, from every light off proved Klaus Sutner’s theorem: on any board, and any network of lights, the pattern with every light on can be reached from the pattern with every light off. The proof was a parity argument that used one feature of the rules in an essential way. Pressing a light toggles that light as well as its neighbours, so the press matrix has ones all down its diagonal. The essay ended by asking what happens without that feature, when a press toggles the neighbours and leaves the pressed light alone.

The answer is that the guarantee disappears and something more interesting replaces it. Some boards can be lit and some cannot, and which is which follows a rule simple enough to state in a sentence and not obvious from anything in the setup. On general networks the answer depends on whether the number of lights is even or odd, and that dependence never fades, however large the network.

When a press skips its own light: one board lit, one proved impossible. 4 by 4: solved with 10 presses; 5 by 5: unsolvable, witness set of 5 lights each seeing an even number of the set.
Fig. 1 Pressing a light toggles its four neighbours but not itself. Left, a four-by-four board turned from all off to all on by the ten marked presses. Right, a five-by-five board with five lights marked such that every light has an even number of marked neighbours (the small numbers) — a certificate that all on can never be reached.

The same algebra with an empty diagonal

The setting is the linear algebra of the earlier boards. Each light is a coordinate in a vector over the field with two elements, where 1+1=01 + 1 = 0. Each press adds a fixed vector — the set of lights it toggles — and pressing a set of lights adds their vectors. The patterns reachable from all off are the column space of the press matrix. With the original rule that matrix is the graph’s adjacency matrix plus the identity. With the new rule it is the adjacency matrix AA alone, with nought on the diagonal.

All on is reachable exactly when the all-ones vector 1\mathbf 1 lies in the column space of AA. Because AA is symmetric, a standard duality turns that into a statement about the kernel: 1\mathbf 1 is in the column space exactly when it is orthogonal to every vector xx with Ax=0Ax = 0, which means every such xx has an even number of ones.

A vector with Ax=0Ax = 0 is a set of lights SS such that every light on the board, in SS or not, has an even number of neighbours in SS. Call it a silent set: pressing all of it changes nothing. The silent sets form a subspace, the kernel of AA, and like the cycle and cut spaces of the cycles and the cuts its dimension is read from a rank over this field. If some silent set has an odd number of members, all on is unreachable, and the reason can be checked by counting. Every press toggles an even number of the lights in SS — that is what silence means, read the other way — so the number of lit lights inside SS is always even. All on would make it odd.

The hero figure’s five-by-five board has such a set, five lights placed on a diagonal pattern, each light on the board seeing nought or two of them. That one count is a complete proof that the board can never be lit. The four-by-four board has silent sets too, but every one of them is even. Its ten presses work.

Why the old proof no longer applies

Sutner’s proof was short. For any vector xx, the number xT(A+I)xx^{\mathsf T}(A + I)x counts, modulo two, the pairs of lights in xx joined by an edge — each counted twice, so contributing nothing — plus the lights of xx themselves. So it equals the size of xx modulo two. If xx is silent for the original rules, (A+I)x=0(A + I)x = 0, so xT(A+I)x=0x^{\mathsf T}(A + I)x = 0, so xx has even size. Every silent set is even, and all on is always reachable.

With the identity removed, the same computation gives xTAx=0x^{\mathsf T} A x = 0 for every vector xx, silent or not, since the diagonal that used to contribute the size is gone. The quantity that carried the proof now carries no information. Matrices with this property, symmetric with nought on the diagonal over the two-element field, are called alternating, and nothing forces their silent sets to be even. Whether all on is reachable has to be decided board by board.

Every board to sixty by sixty

For rectangular boards the decision is fast, by the light-chasing method of the earlier boards. Treat the presses in the top row as unknowns. Each light in the top row has exactly one neighbour in the second row, the light directly below it, and that press is forced: it must be made exactly when the top light would otherwise end in the wrong state. The second row’s presses then force the third’s, and so on to the bottom. The only conditions left are on the bottom row, mm equations in the mm unknowns of the top row. A board of 3,600 lights becomes a system of sixty equations.

Every board to sixty by sixty, and the ones that cannot be lit. 310 of 3600 boards cannot be lit when a press skips itself; failures exactly where n, m odd and n+1, m+1 share their power of two. First failures: 1×1, 1×5, 3×3, 5×5, 7×7, 3×11.
Fig. 2 Every board from 1×11 \times 1 to 60×6060 \times 60 under the neighbours-only rule, marked where all on cannot be reached: 310 of the 3,600. No board with an even side ever fails; the failures among odd-by-odd boards fall on lines spaced by powers of two.

The picture has a structure that is visible before anything is measured. No board with an even number of rows or columns ever fails. Among the odd-by-odd boards the failures sit on a lattice. The 1×11 \times 1 board fails, since its single press touches nothing. So do 1×51 \times 5, 1×91 \times 9 and every board whose two sides both leave remainder 1 on division by 4. Then 3×33 \times 3, 3×113 \times 11, 11×1111 \times 11: both sides leaving remainder 3 on division by 8. Then 7×77 \times 7 and 7×237 \times 23: remainder 7 on division by 16.

The pattern has a compact statement. Write v2(k)v_2(k) for the exponent of the largest power of two dividing kk. Then an n×mn \times m board fails exactly when nn and mm are both odd and

v2(n+1)=v2(m+1).v_2(n + 1) = v_2(m + 1).

The figure’s computation checks this on every one of the 3,600 boards, and it holds on all of them.

The rule as a table of powers

Sorting the odd-by-odd boards by the two exponents makes the rule unmistakable.

The boards that cannot be lit, sorted by powers of two. (1,1): 0 lit/225 fail, (1,2): 120 lit/0 fail, (1,3): 60 lit/0 fail, (1,4): 30 lit/0 fail, (1,5): 15 lit/0 fail; (2,1): 120 lit/0 fail, (2,2): 0 lit/64 fail, (2,3): 32 lit/0 fail, (2,4): 16 lit/0 fail, (2,5): 8 lit/0 fail; (3,1): 60 lit/0 fail, (3,2): 32 lit/0 fail, (3,3): 0 lit/16 fail, (3,4): 8 lit/0 fail, (3,5): 4 lit/0 fail; (4,1): 30 lit/0 fail, (4,2): 16 lit/0 fail, (4,3): 8 lit/0 fail, (4,4): 0 lit/4 fail, (4,5): 2 lit/0 fail; (5,1): 15 lit/0 fail, (5,2): 8 lit/0 fail, (5,3): 4 lit/0 fail, (5,4): 2 lit/0 fail, (5,5): 0 lit/1 fail.
Fig. 3 The odd-by-odd boards up to 60×6060 \times 60, sorted by the exact power of two dividing n+1n + 1 (down) and m+1m + 1 (across). Every failure lies on the diagonal and every diagonal board fails: 225, 64, 16, 4 and 1 of them.

The diagonal cells hold every failure and contain nothing else: 225 boards where both n+1n + 1 and m+1m + 1 are twice an odd number, 64 where both are four times an odd number, then 16, 4 and the single 31×3131 \times 31 board. Off the diagonal, every board in every cell can be lit. The whole table of 3,600 boards is described by comparing two numbers’ powers of two.

Why powers of two should govern a board game is a fact about polynomials over the two-element field, the same algebra that decided the original boards, and the same field that the field with four elements began from. Light chasing on a board of width mm produces, row by row, a sequence of polynomials in the shift that moves a row along itself — Chebyshev polynomials reduced modulo two. Over the two-element field squaring is additive, (a+b)2=a2+b2(a + b)^2 = a^2 + b^2, so these polynomials obey identities that relate the index kk to the index 2k+12k + 1, and that is where powers of two enter. Whether two boards fail together comes down to whether their polynomials share a particular factor, and the measured rule says this happens exactly when the binary expansions of n+1n + 1 and m+1m + 1 end in the same number of zeros. This essay checks the rule on every board to sixty and does not prove it in general; the polynomial identities are the route a proof would take.

Paths and cycles

The simplest networks show the same phenomenon in one dimension.

Paths and cycles that can and cannot be lit. paths failing: 1, 5, 9, 13, 17, 21, 25, 29, 33, 37; cycles failing: 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42.
Fig. 4 Paths on 1 to 40 vertices and cycles on 3 to 42, marked by whether all on can be reached under the neighbours-only rule. A path fails exactly when its length leaves remainder 1 on division by 4; a cycle can be lit only when its length is a multiple of 4.

A path is a board with one row, so the grid rule applies with n=1n = 1: a path on kk vertices fails exactly when v2(k+1)=1v_2(k+1) = 1, which is to say k≡1(mod4)k \equiv 1 \pmod 4. The single vertex fails; so do five, nine and thirteen. The witness on a path of five is the first, third and fifth lights. Each light has an even number of these as neighbours, nought or two, and there are three of them.

Cycles are stricter. On a cycle of odd length the whole ring is a silent set: every light has exactly two neighbours, both in the ring, and the ring is odd. On a cycle whose length is twice an odd number, every other light makes a silent set of odd size — each light sees either nought or two of them. Only when the length is a multiple of four are all silent sets even, and only then can the cycle be lit. A cycle of six lights, which is about the simplest network one could draw, cannot be lit.

The same matrix as rule 90

On a path, the neighbours-only press matrix is a familiar object under another name. A row of cells in which each cell’s next state is the sum, modulo two, of its two neighbours’ current states is the cellular automaton called rule 90. Its one-step update is exactly the matrix AA of a path, and run from a single live cell it draws the Sierpiński triangle of eight rules and a triangle. The original Lights Out press on a path, which adds the cell itself, is rule 150.

So the question this essay asks of a path is a question about rule 90 run for one step on a finite row with dead cells beyond each end. Can the row of all live cells be produced from some earlier row? A configuration that no earlier row produces is called a Garden of Eden, and the answer measured above is that the all-live row of length kk is one exactly when kk leaves remainder 1 on division by 4. Sutner, who proved the theorem about the original game, came to it from exactly this direction: he studied which configurations of linear cellular automata like these have predecessors, and the press-matrix language and the automaton language are two descriptions of one computation over the two-element field.

The correspondence also explains why linearity makes the question decidable at all. For a general automaton, deciding whether a configuration has a predecessor means searching; for a linear one it is the rank computation of a grid of bits whose rank stops at the state, done once for the whole matrix. The difference between rule 90 and rule 150, which is the difference between the two games, is one entry on each row of that matrix, and it is the entry that decides whether every pattern can be built.

Every network, by parity

For a general network the question has no rule of this kind, but the share of networks that can be lit can be measured exactly for small sizes and by sampling for larger ones.

How often a graph can be lit, and why it depends on the parity of its size. 1: 0/1; 2: 1/2; 3: 3/8; 4: 35/64; 5: 435/1024; 6: 18259/32768; 7: 914067/2097152; random even 0.562, odd 0.437.
Fig. 5 The share of networks on kk vertices on which all on can be reached under the neighbours-only rule: exact over every labelled network to seven vertices, and from 1,500 random networks for kk from 8 to 40. Even sizes sit near 0.56, odd sizes near 0.44, at every size.

There are 221=2,097,1522^{21} = 2{,}097{,}152 labelled networks on seven vertices, and 914,067 of them can be lit, a share of 0.4360.436. On six vertices the share is 18,25918{,}259 out of 32,76832{,}768, or 0.5570.557. On five it is 0.4250.425, on four 0.5470.547. The shares alternate, and random networks up to forty vertices keep alternating: about 0.560.56 on even sizes and about 0.440.44 on odd ones, with no sign of converging to a common value.

The parity of the number of lights never stops mattering. That is unusual. Most properties of large random networks depend smoothly on their size, and the networks here have no structure that cares whether they have twenty or twenty-one vertices. The cause is in the algebra rather than the networks.

Alternating matrices have even rank

The cause is a classical fact about alternating matrices: over any field, an alternating matrix has even rank. Such a matrix describes a form that pairs coordinates, and a pairing of a space can only be nondegenerate on a space of even dimension. A symmetric matrix with nought on its diagonal over the two-element field is alternating, so its rank is even.

A graph's adjacency matrix has even rank over the two-element field. 20 vertices: rank 20: 0.424, rank 18: 0.552, rank 16: 0.024; 21 vertices: rank 20: 0.827, rank 18: 0.172, rank 16: 0.001.
Fig. 6 The rank over the two-element field of the adjacency matrices of 3,000 random networks on 20 vertices (warm) and 21 (cool). Only even ranks occur, so on 21 vertices the matrix is never invertible, while on 20 it is invertible 42% of the time.

On twenty vertices the rank can be twenty, and it is in 42% of random networks; then AA is invertible, every pattern of lights can be reached, and all on in particular. On twenty-one vertices the rank can be at most twenty. The matrix is never invertible, the kernel always contains a nonzero silent set, and all on is reachable only when every silent set happens to be even. The figure confirms that no rank is ever odd in 6,000 random networks.

The difference between 0.56 and 0.44 is exactly this. An even network can be lit either because its matrix is invertible or because its silent sets are all even. An odd network has only the second way. The original Lights Out has no such effect, because the identity added to the adjacency matrix destroys the alternating property. Its matrices can have any rank, and Sutner’s argument shows that all on is reachable regardless.

What the computation cannot establish

The board rule is checked on 3,600 boards and stated as a rule; the polynomial argument sketched above is how it would be proved, and the essay does not carry that proof through. The network shares beyond seven vertices are sampled, with a few per cent of sampling error at each size, and their limits are not computed. Whether the even and odd shares converge to definite constants, and what those constants are, is a question about random alternating matrices that the figures only estimate.

Nor do the figures say anything about the number of presses needed. When all on is reachable, the press patterns that reach it form a translate of the kernel. The smallest one is an odd open dominating set of the network — every light having an odd number of pressed neighbours — and finding the smallest is computationally hard in general, as the corresponding problem for the original rules is.

Still open: which networks can be lit

For the original rules there is nothing to ask. Sutner’s theorem answers every network at once. For the neighbours-only rules there is no comparable criterion. The question is equivalent to asking whether a network has an odd open dominating set, a set of vertices such that every vertex has an odd number of neighbours in it. The answer is known for grids, paths, cycles, trees, and several other families, each by its own argument. A characterisation in terms of simple properties of the network, of the kind that makes the original game trivial, is not known and may not exist.

The probabilistic version is open too. For random networks the chance of being litable is close to 0.560.56 on even sizes and 0.440.44 on odd ones, and these numbers should be computable from the theory of random matrices over finite fields, in which the distribution of the rank of a random alternating matrix is known exactly. What that theory does not directly give is the chance that the all-ones vector lies in the column space. That vector is not random, and how it sits relative to the kernel is not captured by the rank alone. A clean formula for the limiting shares would need to describe that position, and none is known.

A rule hidden in the diagonal

One change to the rules — a press no longer toggles its own light — removes the identity from the press matrix, and with it the parity argument that made every board solvable. What replaces it is a rule for grids stated by powers of two: an n×mn \times m board fails exactly when n+1n + 1 and m+1m + 1 are both even and divisible by the same power of two. For networks it is a permanent split between even and odd sizes, inherited from the even rank of alternating matrices.

Whenever all on cannot be reached there is a short proof that it cannot, a silent set of odd size. The five lights on the five-by-five board are one such proof: a count that anyone can check, and that no sequence of presses can get around.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Finite fieldKernelLinear systemParityRankSymmetric matrix