wiki

SAT

The Boolean satisfiability problem, usually called SAT, is the problem of deciding whether a propositional formula has a satisfying assignment: a choice of true or false for each variable that makes the whole formula true[3]. A formula with a satisfying assignment is satisfiable; one without is unsatisfiable, and its negation is a tautology. SAT was the first problem proved NP-complete, by Stephen Cook in 1971 and independently by Leonid Levin[1][2]: any problem whose solutions can be checked in polynomial time can be translated into SAT in polynomial time. No algorithm is known that solves every instance in less than exponential time. Yet programs called SAT solvers, which search for an assignment and learn from their failures, routinely settle formulas from industry with millions of variables and clauses[6][7][8]. Because so many problems can be encoded as satisfiability, a good SAT solver serves as a general-purpose engine for verification, planning, scheduling and combinatorial mathematics.

§ 01

Definition

A propositional formula is built from Boolean variables with negation, conjunction and disjunction. SAT solvers take their input in conjunctive normal form (CNF): a conjunction of clauses, each a disjunction of literals, each a variable or its negation. For example,

is satisfied by setting , and all false. CNF is no restriction: the Tseitin transformation converts any formula into a CNF formula that is satisfiable exactly when the original is, with only linear growth. The form suits solvers because the two facts that drive the search are immediate in it: a clause whose literals are all false is a conflict, and a clause with all literals but one false forces the remaining one, which is unit propagation. Instances are exchanged in the DIMACS text format.

Restrictions of SAT are named by the clause length: in -SAT every clause has at most literals. 2-SAT can be solved in linear time[18], as can Horn-SAT, where each clause has at most one positive literal, while 3-SAT is already NP-complete. Schaefer's dichotomy theorem of 1978 classified all such restrictions defined by the allowed kinds of constraint: each is either in P or NP-complete[11].

§ 02

Complexity

SAT is in NP because a satisfying assignment, once guessed, can be checked in linear time. The Cook–Levin theorem shows that it is also NP-hard: the computation of a nondeterministic Turing machine on an input, for a polynomial number of steps, can be described by a polynomial-size formula whose satisfying assignments are exactly the accepting computations[1][2]. Karp showed in 1972 that 21 classical combinatorial problems are NP-complete by reductions starting from SAT[19], and thousands more have followed. A polynomial-time algorithm for SAT would therefore give one for every problem in NP, and it is widely believed that none exists. The exponential time hypothesis states the stronger conjecture that 3-SAT needs time for variables.

For unsatisfiable formulas, no short certificate is known either: whether every unsatisfiable formula has a proof of unsatisfiability of polynomial size is the question of whether NP equals co-NP. For the proof systems that solvers use, the answer is known to be no; the pigeonhole formulas have only exponentially long resolution refutations.

§ 03

Solvers

Complete solvers, which can prove unsatisfiability, descend from the procedure of Davis, Putnam, Logemann and Loveland, DPLL, of 1962: assign a variable, propagate the consequences, and backtrack on a conflict[5]. Its successor, conflict-driven clause learning (CDCL), analyzes each conflict to learn a new clause that prevents it from recurring and jumps back over irrelevant decisions[6]. Engineering made CDCL fast: watched literals for propagation, the VSIDS branching heuristic, restarts and clause deletion[7][8]. Incomplete solvers based on local search, such as WalkSAT, start from a random assignment and repeatedly flip variables in unsatisfied clauses; they can find assignments for some large satisfiable formulas quickly, but cannot prove that none exists[10].

Encoding graph colouring as SAT: a variable for each vertex and colour, clauses saying that each vertex has exactly one colour and adjacent vertices differ. The solver is a CDCL solver of about 200 lines, not shown.

(* Graph colouring as SAT: variable x(v,c) says vertex v has colour c. *)
let colouring ~vertices ~edges ~colours =
let x v c = (v * colours) + c + 1 in
let some_colour = List.init vertices (fun v -> List.init colours (x v)) in
let one_colour = List.concat (List.init vertices (fun v ->
List.concat (List.init colours (fun c ->
List.init (colours - c - 1) (fun d -> [ - (x v c); - (x v (c + d + 1)) ]))))) in
let proper = List.concat_map (fun (u, v) -> List.init colours (fun c -> [ - (x u c); - (x v c) ])) edges in
(Cnf.of_clauses (some_colour @ one_colour @ proper), fun model v ->
List.find (fun c -> model.(x v c)) (List.init colours Fun.id))
(* The Petersen graph: an outer 5-cycle, an inner pentagram, and spokes. *)
let petersen =
List.init 5 (fun i -> (i, (i + 1) mod 5)) @ List.init 5 (fun i -> (5 + i, 5 + ((i + 2) mod 5)))
@ List.init 5 (fun i -> (i, i + 5))

Colouring the Petersen graph.

Petersen graph, 2 colours: 20 variables, 50 clauses: impossible
Petersen graph, 3 colours: 30 variables, 85 clauses: 2 1 2 1 0 1 2 0 0 1

The same pattern, variables for the choices and clauses for the constraints, encodes scheduling, planning[15], circuit equivalence and puzzle solving. For bounded model checking, the states of a system over steps become variables and a satisfying assignment is a trace that violates the property[12].

§ 04

Random formulas

Random -SAT formulas, with clauses chosen uniformly among those of distinct variables, show a sharp phase transition. For 3-SAT, formulas with fewer than about 4.27 clauses per variable are almost always satisfiable when is large, and formulas with more are almost always unsatisfiable[9][17]. The hardest formulas for complete solvers lie at the threshold: below it, satisfying assignments are plentiful and easy to find; above it, contradictions are dense and quickly found.

Deciding 100 random 3-SAT formulas at each ratio of clauses to variables.

(* Random 3-SAT with n variables and m = r n clauses: how often is it
satisfiable, and how hard is it to decide? *)
let median l = let a = Array.of_list (List.sort compare l) in a.(Array.length a / 2)

Running it.

ratio n=50 sat n=150 sat n=150 median conflicts
3.00 100% 100% 4
3.50 100% 100% 31
3.80 98% 100% 188
4.00 90% 94% 580
4.20 65% 62% 1857
4.30 51% 41% 2059
4.40 38% 25% 2158
4.60 27% 2% 1910
5.00 5% 0% 1122
5.50 0% 0% 745
6.00 0% 0% 503
0%25%50%75%100%33.544.555.56clauses per variable% satisfiablen = 50n = 150
The fraction of satisfiable formulas drops from 100% to 0% around 4.3 clauses per variable, and the drop sharpens as the number of variables grows.
0500100015002000250033.544.555.56clauses per variablemedian conflicts
The median number of conflicts the solver needs peaks near the same ratio.

Mitchell, Selman and Levesque observed the easy–hard–easy pattern in 1992[9]. Statistical physicists predicted the 3-SAT threshold at 4.267 and designed survey propagation, an algorithm that solves random formulas very close to it[17]. Ding, Sly and Sun proved that the threshold exists and determined its value for all sufficiently large in 2015[16]; for it remains a conjecture.

§ 05

Certificates

A satisfying assignment is its own certificate. An unsatisfiability claim needs a proof, and the annual SAT competition requires solvers to emit one, usually in the DRAT format, a sequence of clause additions and deletions, each of which a separate checker can verify in polynomial time in the size of the proof[14]. Proofs can be enormous. The Boolean Pythagorean triples problem, whether the integers from 1 to 7825 can be split into two parts neither of which contains a Pythagorean triple, was settled negatively in 2016 with a DRAT proof of about 200 terabytes[13].

§ 06

History

Davis and Putnam gave a procedure for propositional satisfiability in 1960 as part of a method for first-order logic, based on eliminating variables by resolution[4]; Davis, Logemann and Loveland replaced the elimination by backtracking search in 1962[5]. Cook's 1971 paper introduced NP-completeness with SAT as its first example[1], and Levin found the same result independently in the Soviet Union[2]. Practical solving advanced slowly until the 1990s: local search methods appeared in 1992 and 1994[10], GRASP introduced conflict-driven clause learning in 1996[6], and Chaff's watched literals and VSIDS in 2001 made solvers one to two orders of magnitude faster[7]. MiniSat, published in 2003, became the standard small solver on which many others were built[8]. SAT competitions have been held since 2002, and the Handbook of Satisfiability collects the field[3].

see also

referenced by

further reading

  1. [1]S. A. Cook, “The complexity of theorem-proving procedures”, STOC (1971).
  2. [2]L. A. Levin, “Universal sequential search problems”, Problems of Information Transmission 9 (1973).
  3. [3]A. Biere, M. Heule, H. van Maaren, T. Walsh (eds.), Handbook of Satisfiability, IOS Press (2nd ed., 2021).
  4. [4]M. Davis, H. Putnam, “A computing procedure for quantification theory”, Journal of the ACM 7 (1960).
  5. [5]M. Davis, G. Logemann, D. Loveland, “A machine program for theorem-proving”, Communications of the ACM 5 (1962).
  6. [6]J. P. Marques-Silva, K. A. Sakallah, “GRASP: a search algorithm for propositional satisfiability”, IEEE Transactions on Computers 48 (1999).
  7. [7]M. W. Moskewicz, C. F. Madigan, Y. Zhao, L. Zhang, S. Malik, “Chaff: engineering an efficient SAT solver”, DAC (2001).
  8. [8]N. Eén, N. Sörensson, “An extensible SAT-solver”, SAT, Lecture Notes in Computer Science 2919 (2004).
  9. [9]D. Mitchell, B. Selman, H. Levesque, “Hard and easy distributions of SAT problems”, AAAI (1992).
  10. [10]B. Selman, H. Kautz, B. Cohen, “Noise strategies for improving local search”, AAAI (1994).
  11. [11]T. J. Schaefer, “The complexity of satisfiability problems”, STOC (1978).
  12. [12]A. Biere, A. Cimatti, E. Clarke, Y. Zhu, “Symbolic model checking without BDDs”, TACAS (1999).
  13. [13]M. J. H. Heule, O. Kullmann, V. W. Marek, “Solving and verifying the Boolean Pythagorean triples problem via cube-and-conquer”, SAT (2016).
  14. [14]N. Wetzler, M. J. H. Heule, W. A. Hunt, “DRAT-trim: efficient checking and trimming using expressive clausal proofs”, SAT (2014).
  15. [15]H. Kautz, B. Selman, “Planning as satisfiability”, ECAI (1992).
  16. [16]J. Ding, A. Sly, N. Sun, “Proof of the satisfiability conjecture for large k”, STOC (2015).
  17. [17]M. Mézard, G. Parisi, R. Zecchina, “Analytic and algorithmic solution of random satisfiability problems”, Science 297 (2002).
  18. [18]B. Aspvall, M. F. Plass, R. E. Tarjan, “A linear-time algorithm for testing the truth of certain quantified Boolean formulas”, Information Processing Letters 8 (1979).
  19. [19]R. M. Karp, “Reducibility among combinatorial problems”, in Complexity of Computer Computations, Plenum (1972).

last updated