← The Museum of Algorithms
4.3

Wing IV · The Ocean of Possibilities

The Boolean
Maze

Satisfiability, DPLL, and the first hard problem

VOLUME IV — Combinatorial Algorithms SECTION 7.2.2.2 1962 · 1971 DPLL · Cook–Levin

Here is the simplest hard question in all of computing. You are given a bank of switches, each either on or off, and a list of rules, each demanding that at least one of a few named switches be in a certain position. Can you set the switches so that every rule is satisfied at once? That is Boolean satisfiability — SAT — and it looks like a puzzle a patient child could brute-force. Flip switches until everything is happy. But the rules interlock: satisfy this one and you break that one; fix that and three others go dark. With a few dozen switches the settings number in the billions, and the maze of constraints has no obvious exit.

SAT is not merely one hard problem among many. In 1971 Stephen Cook — and, independently, Leonid Levin — proved that it is the hard problem: the first ever shown to be NP-complete. Every problem in NP, the traveling salesperson of the last-but-one room included, can be rewritten as a SAT instance and solved by a SAT solver. If you could crack SAT quickly in every case, the entire edifice of NP would fall and P would equal NP. SAT sits at the exact center of the ocean this wing has been crossing — the master key to every lock in it.

"Satisfiability is a killer app. Any problem in NP can be reduced to it — so a good enough SAT solver is a good enough solver for thousands of problems no one ever wrote a special program for." — after S. Cook (1971) & the modern SAT community

I · The Forced MoveUnit propagation, the solver's reflex

And yet the astonishing modern fact is that SAT solvers work — routinely cracking industrial instances with millions of variables that no brute force could ever touch. Their oldest and most important trick is one any human puzzler already uses without naming it. Suppose a rule requires one of three switches to be on, and you have already turned the other two off. Then the third switch is forced: it must be on, no guessing, no search. Set it — and that forced move may force another, and another, a cascade of certainties rippling through the constraints. This is unit propagation, the engine of the 1962 DPLL algorithm (Davis, Putnam, Logemann, Loveland): guess a switch only when nothing is forced, propagate all the consequences, and the moment a rule goes impossible, back up and try the other way.

Below is a maze of switches and rules — the rules drawn as gates that glow when satisfied. First, try it yourself: flip switches and watch gates light and darken, and feel how quickly a hard instance defeats hand-solving. Then press Solve, and watch DPLL do it: the green wave of forced propagations sweeping through the gates, the gold guesses where it must gamble, the red flash and retreat when a guess dies — until every gate is lit and the exit blazes. Or, on the impossible maze, until the solver has tried every path and proves there is none.

Instrument 4.3
The Logic Gate Panel
SAT · DPLL · unit propagation → the exit
Switches — click to flip (true / false)n switches
Gates — each clause needs one true literal0 / 0 lit
⚑ EXIT
The solver's ledgermanual
Decisions
0
Propagations
0
Backtracks
0
Flip switches to light every gate — or press Solve.

Each gate is a clause; it glows when at least one of its literals is true. A green pulse is a forced assignment (unit propagation); a gold pulse is a guess; a red flash is a clause driven impossible, triggering a backtrack. The exit lights only when every gate is lit at once — a satisfying assignment — which is exactly the certificate an NP problem asks for.

II · Hardest in Theory, Tamed in PracticeThe paradox of SAT

The tension at the heart of this room is one of the deepest in the field. In the worst case SAT is intractable — NP-complete, with instances that can defeat any known method for the age of the universe, and random instances are hardest right at a critical ratio of about 4.26 clauses per variable, a genuine phase transition between easy-mostly-satisfiable and easy-mostly-unsatisfiable. And yet the SAT solvers that ship in industry devour real problems of staggering size. The reconciliation is that real-world instances are not random; they have structure, and modern solvers exploit it ferociously. The great leap beyond DPLL is CDCL — conflict-driven clause learning — which, every time it hits a dead end, deduces why the guess failed, records that reason as a brand-new clause, and leaps back over whole regions of the search it now knows are hopeless. That single idea, with clever restarts and data structures, is why a laptop can verify a microprocessor.

SAT is the problem we proved hardest and then learned to solve anyway. The gap between its worst case and its practical conquest is one of the quiet miracles of computer science.

Knuth gives this the loving, exhaustive treatment of §7.2.2.2 — well over three hundred pages, the longest section in his life's work — because satisfiability is where combinatorial search, logic, probability, and sheer engineering craft all meet. What you watched the little DPLL do by hand, a real solver does with learned clauses and watched literals a billion times faster; the skeleton, though — propagate what is forced, guess when you must, retreat when you fail — is exactly the same.

III · The Master KeyWhere every maze leads

Because everything in NP reduces to it, SAT has become a universal solvent. Hardware and software verification run on it — Intel and AMD prove their chips correct by encoding them as gigantic SAT instances. So do automated planning, scheduling, cryptanalysis, program synthesis, and the theorem provers that certify safety-critical code. When a new hard combinatorial problem appears, the fastest route to a solution is often not a bespoke algorithm at all but a translation into SAT and a call to a solver that thousands of researcher-years have honed. The Boolean maze is the room to which all the other rooms of this wing secretly connect.

"An algorithm must be seen to be believed." — D. E. Knuth

And with it the museum closes its circle. We began in Wing I with Euclid's ruler, the oldest algorithm, measuring two lengths with perfect certainty. We end here, at the Boolean maze, staring at the boundary of what certainty can be bought at any price — the open question of whether finding is truly harder than checking, the line between the problems we can always solve and the ones we merely, miraculously, usually can. Between those two rooms lies everything Knuth spent a lifetime teaching us to see: that an algorithm is a made thing, that its cost can be reasoned about, and that in the reasoning there is not only power but a startling, durable beauty. Flip the switches. Watch the wave. The art of computer programming is the art of finding the exit — and of knowing, exactly, when there is none.