Result
Decisions
Propagations
Conflicts

  • Decision
  • Forced by a clause
  • Pure literal
  • Second value after a conflict

    Algorithm

    More about SAT solvers

    SAT solver visualizer

    A truth table for 50 variables has 1,125,899,906,842,624 rows, so no computer will ever read them all. A SAT solver answers the same question — is there an assignment that makes every clause true? — without looking at most of them, and modern solvers do it for formulas with millions of variables. Type your clauses, paste a DIMACS file or write any formula and let it be converted to CNF, then step through the search: which clause forces the next value, which clause fails, where the solver goes back to, and which clause it learns from the conflict. Write the formula as clauses ((a ∨ ¬b) ∧ (¬a ∨ c), one clause per line, or with ~ ! & | + '), paste DIMACS, or write any formula with → ↔ ⊕ and let it be converted to CNF. The list of problems loads n queens, a 4 × 4 sudoku, a map to colour, the pigeonhole principle, a random 3-SAT instance or a small teaching example. Step takes one move, Run plays the search at the chosen speed and To the end finishes it. In the clause list satisfied clauses are grey, false literals are struck through, the unit clause that forces the next assignment is outlined and so is the clause that fails.

    How it works

    1. Pick a problem — n queens, a 4 × 4 sudoku, a map to colour, the pigeonhole principle, random 3-SAT or a teaching example — or write your own clauses, such as (a ∨ ¬b) ∧ (¬a ∨ c), one per line.
    2. Press Step for one move or Run to play the search. The clause list greys out satisfied clauses, strikes false literals and outlines the clause that forces the next value or that fails.
    3. Switch between DPLL and CDCL and between the decision heuristics to see how many decisions each one needs, and compare that with the 2ⁿ rows of a truth table.

    How DPLL avoids the truth table

    A clause is satisfied as soon as one of its literals is true, so most of the table never has to be looked at. DPLL works on two rules before it guesses anything. Unit propagation: if a clause has all its literals false but one, that one must be true. The pure literal rule: if a variable occurs only unnegated in the clauses that are still open, setting it true costs nothing. Only when neither applies does the solver pick a variable and try a value, and when some clause ends up with every literal false it goes back to the last value it has not yet flipped. For the 4 × 4 sudoku in the library that means 64 variables and 452 clauses, and unit propagation alone fills the grid in 65 steps without a single guess, against 2⁶⁴ rows in a table.

    What CDCL learns from a conflict

    Plain backtracking forgets why a branch failed, so it can run into the same conflict again and again. CDCL instead analyses it: starting from the failing clause it resolves away the assignments of the current level, newest first, until one literal of that level is left — the first unique implication point. The result is a new clause that follows from the formula and rules out the whole combination that caused the conflict. The solver keeps it and jumps straight back to the second highest level in it, often over several levels at once. On the pigeonhole problem with 8 holes DPLL needs about 40,000 conflicts and CDCL about 3,000.

    Frequently asked questions

    What is the SAT problem?

    Given a propositional formula, is there an assignment of true and false to its variables that makes it true? The formula is usually written in conjunctive normal form: a list of clauses, each an OR of variables and negated variables, all of which must hold. Stephen Cook proved in 1971 that SAT is NP-complete, and Leonid Levin reached the same result independently; it was the first problem shown to be NP-complete, which is why so many other problems are translated into it.

    What is the difference between DPLL and CDCL?

    Both assign variables one at a time and propagate what that forces. DPLL (Davis, Logemann and Loveland, 1962, building on Davis and Putnam, 1960) answers a conflict by going back to the last decision it has not yet flipped and trying the other value. CDCL, introduced by the GRASP solver of Marques-Silva and Sakallah in 1996, first works out which assignments caused the conflict, adds a clause that forbids that combination, and then jumps back to the level where the new clause forces a value — often several levels at once. Chaff added the VSIDS heuristic and watched literals in 2001, and today's solvers handle formulas with millions of clauses.

    What are SAT solvers used for?

    For any problem that can be written as true-or-false constraints: checking that chip designs and software behave correctly, planning and scheduling, product configuration, package managers that pick compatible versions, and puzzles. The examples here show the idea on n queens, a 4 × 4 sudoku and colouring the map of Australia.

    Why is the pigeonhole principle so hard?

    Putting n + 1 pigeons into n holes with at most one pigeon per hole is clearly impossible, and the clauses say so, but a resolution proof of it has to be enormous: Armin Haken proved in 1985 that every such proof grows exponentially in n. Since DPLL and CDCL searches correspond to resolution proofs, both need exponentially many conflicts — you can watch the counter climb from 5,000 at 7 holes to 40,000 at 8. Solvers that may argue about counting, rather than only about clauses, settle it at once.

    What is the 4.26 in random 3-SAT?

    The number of clauses per variable. Below about 4.27 a random 3-SAT formula is almost always satisfiable, above it almost always unsatisfiable, and the switch gets sharper as the number of variables grows; the hardest instances sit right at the threshold. Move the slider to 2.5 and nearly every instance is solved in a few steps; move it to 7 and the solver proves it unsatisfiable quickly too. The existence of such a threshold for large clause lengths was proved by Jian Ding, Allan Sly and Nike Sun in 2015; for 3-SAT the value is still only known from experiments and bounds.

    SAT Solver Visualizer: how do I record a video?

    Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device. Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner. The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF. You can add one of three music tracks: calm, bright or beat.

    Ready to try it?

    Open PictorX in your browser — no install, no credit card required to start.

    Go to Editor