Mirrors that do logic
A program can prove that a mirror puzzle's best solution really is the best, in a fraction of a second. Could some program do that for every mirror puzzle? Almost certainly not, and you can build the reason yourself.
The question the last essay left open
In How do you know 7 is the best? a program proved that a small mirror puzzle couldn't be solved with fewer than seven flips. Its trick, ghost light (pretending each undecided mirror sends light both ways), cut a search over thousands of positions down to a few dozen. But a trick that works on the boards we tried is not a guarantee. In the worst case the solver still tries one flip after another, and each extra mirror can double the number of positions it has to try.
Is that a weakness of this solver, waiting for someone cleverer? Or is something about the puzzle itself hard?
Almost certainly the second. Nobody can prove it outright, because that would settle the most famous open problem in computer science. But we can show something nearly as strong: a fast program for mirror puzzles would also be a fast program for a huge family of other problems that people have tried and failed to solve quickly for fifty years. The way to show it is to make mirrors do logic.
A switch
One lamp, one mirror. Flipped one way, the light goes up; flipped the other way, it goes down. Call up true and down false, and this mirror is a variable, x, that is either true or false. You can see which by where the light goes.
Copying a signal
A formula uses the same variable several times, but a beam can only go one way. A splitter, drawn as a double line, is a half-silvered pane: it lets light through and reflects it. A row of splitters copies one signal to as many places as we need. Below, the TRUE light of x reaches two targets, A and B. Flip the switch, and both go dark at once while the light runs along the FALSE line underneath.
Pieces with a bolt in the middle are bolted down: for now only the switch flips. We'll unbolt them later.
One more thing comes for free. Light passes straight through other light, so two beams can cross on an empty square without disturbing each other. That sounds like a detail, but on a flat board, wires have to cross somewhere, and many proofs about other puzzles spend pages building a "crossover gadget" for exactly that. Here crossing costs nothing.
OR
A target needs light from only one side. Lead three wires into one target, and it lights up if any of them carries light. That is an OR. Here the target is fed by the TRUE line of x, the FALSE line of y, and the TRUE line of z. It goes dark in exactly one of the eight settings. Find it.
An OR of variables, some of them negated (¬y reads "not y"), is called a clause. This one is x ∨ ¬y ∨ z: "x, or not y, or z".
Any formula, as a board
A puzzle is solved when every target is lit. So put several clauses side by side, and the board asks for this clause and that one and the next. A formula built that way, an AND of ORs, is in conjunctive normal form. The widget below turns any such formula, with up to three variables per clause, into a board: one switch per variable down the left, one target per clause along the bottom, and bolted plumbing in between. Each variable gets a TRUE line and a FALSE line, and a splitter drops a copy wherever a clause needs it. Type your own formula or use a preset.
The boards grow, but not fast: a formula with n variables and m clauses becomes a board 3n + 1 squares tall and 4m + 2 wide. So building the board from the formula is quick, and that will matter in a moment.
The last preset has no solution. Each of its four clauses rules out one of the four ways to set a and b, so no setting of the switches lights all four targets. You can check that by hand, because there are only four settings. A formula with 50 variables has 250 of them, about a quadrillion.
Can you cheat?
The real puzzle has no bolts. If every piece could flip, could a player light every target on a board whose formula has no solution, by bending the plumbing?
No. Look at where each bolted piece sends light if it's flipped. The turn just after a switch sends it off the left edge. A splitter on a line sends its copy up and off the top. The mirrors beside a target send light into a wall or off the board. Flipped plumbing only throws light away. It never brings light anywhere new. So the targets can all be lit only if the switches alone can light them, and that happens exactly when the formula has a solution.
I also checked this the slow way: for 2,568 random small formulas with up to three variables (955 of them unsatisfiable), a program tried every orientation of every piece, plumbing included. In every case the board could be fully lit exactly when the formula could be satisfied. Try it yourself. Here nothing is bolted:
What a fast solver would mean
Now the argument. Suppose someone wrote a program that solves every mirror board quickly (boards of lamps, mirrors, splitters, walls and targets, the pieces the compiler uses; boards with mirrors alone are a different question, which this proof doesn't settle). "Quickly" has a precise meaning here: its running time grows like a fixed power of the board's size (say the square, or the cube), rather than doubling with every few extra mirrors. Then you could also solve every formula quickly. Compile the formula (that's fast, and the board is only polynomially larger), run the mirror program, and read the answer off the switches.
Deciding whether such a formula can be satisfied is called 3-SAT. In 1971 Stephen Cook proved (and Leonid Levin, independently, published in 1973) that satisfiability is NP-complete: every problem whose yes-answers can be checked quickly, given the right hint, can be translated into it, much as we translated formulas into mirrors. That class of problems is called NP. A year later Richard Karp showed the same for 3-SAT. So a fast mirror program would make every quickly checkable problem quickly solvable. That is the P versus NP question. It has been open for more than fifty years, and the Clay Mathematics Institute has offered a million dollars for its answer since 2000. Most researchers believe that no such program exists.
A proposed solution to a mirror puzzle is easy to check: trace the light, as the game does after every click. So the mirror puzzle is in NP too, and "can every target be lit?" is itself NP-complete. Finding the fewest flips is at least as hard, since it answers that question along the way. Proving that a given par is the fewest was the question of the last essay.
Ghost light against a formula
Back to the last essay's trick. Leave a switch undecided and its light goes both ways (dashed). If a target can't get even dashed light, then no setting of the undecided switches can light it, and the solver backs up. Click a switch to cycle it: undecided, true, false.
On a compiled board, the rule has a plain meaning: a clause is dead as soon as every one of its variables has been set the wrong way. Backtracking SAT solvers have used that same test since the early 1960s. It still helps a lot. But the count keeps climbing:
At 24 variables, trying every setting means 224, about 17 million, and the solver needed a median of 17,385 positions: a thousand times fewer. But from 6 variables to 24, its count grew from 51 to 17,385, about 1.4 times for each added variable, and the line on the log scale keeps rising. The rate wobbles from size to size, and these sizes are small, so the chart alone can't show that the growth never stops. For random formulas with enough clauses per variable (well above 4.26), a theorem does.
Where that leaves the solver
The solver from the last essay is good, not magic. On boards made to be played, it settles par in a fraction of a second, and ghost light is why. But some boards hide a hard formula in their plumbing. On those, ghost light only slows the doubling. For search that works like this one, deciding switches one at a time and backing up when a clause dies, that's not just experience but a theorem. Vašek Chvátal and Endre Szemerédi proved in 1988 that random formulas with enough clauses per variable almost never have a short proof of "no solution" of the kind such a search produces, so the search needs exponentially many steps. Beame, Karp, Pitassi and Saks later worked out how the bound depends on the number of clauses per variable. The chart's formulas use about 4.26, close to the ratio (believed to be near 4.27) where random formulas switch from almost always satisfiable to almost never. That's where they are, empirically, hardest for typical solvers. Cleverer methods exist, but none is known to escape the doubling on every formula. The hardness isn't in the solver. As far as anyone knows, it's in the puzzle itself.
Related work
Turning a puzzle into logic gates is a standard way to prove a puzzle hard. Richard Kaye's "Minesweeper is NP-complete" (2000) built wires and gates out of Minesweeper patterns; laser-and-mirror games have been treated the same way, for example in "LaserTank is NP-complete" by Alexandersson and Restadh. Robert Hearn and Erik Demaine's book Games, Puzzles, and Computation (2009) collects many such proofs. The construction in this essay is a simple textbook one, not new mathematics. What's different is that you can play it.