Boolean satisfiability problem: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Ftiercel
 
imported>Elestrophe
Fix meaning of sentence since the listed fields are not themselves SAT problems.
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
In [[logic]] and [[computer science]], the '''Boolean satisfiability problem''' (sometimes called '''propositional satisfiability problem''' and abbreviated '''SATISFIABILITY''', '''SAT''' or '''B-SAT''') asks whether there exists an [[Interpretation (logic)|interpretation]] that [[Satisfiability|satisfies]] a given [[Boolean logic|Boolean]] [[Formula (mathematical logic)|formula]]. In other words, it asks whether the formula's variables can be consistently replaced by the values TRUE or FALSE to make the formula evaluate to TRUE. If this is the case, the formula is called ''satisfiable'', else ''unsatisfiable''. For example, the formula "''a'' AND NOT ''b''" is satisfiable because one can find the values ''a'' = TRUE and ''b'' = FALSE, which make (''a'' AND NOT ''b'') = TRUE. In contrast, "''a'' AND NOT ''a''" is unsatisfiable.
In [[logic]] and [[computer science]], the '''Boolean satisfiability problem''' (sometimes called '''propositional satisfiability problem''' and abbreviated '''SATISFIABILITY''', '''SAT''' or '''B-SAT''') asks whether there exists an [[Interpretation (logic)|interpretation]] that [[Satisfiability|satisfies]] a given [[Boolean logic|Boolean]] [[Formula (mathematical logic)|formula]]. In other words, it asks whether the formula's variables can be consistently replaced by the values TRUE or FALSE to make the formula evaluate to TRUE. If this is the case, the formula is called ''satisfiable'', else ''unsatisfiable''. For example, the formula "''a'' AND NOT ''b''" is satisfiable because one can find the values ''a'' = TRUE and ''b'' = FALSE, which make (''a'' AND NOT ''b'') = TRUE. In contrast, "''a'' AND NOT ''a''" is unsatisfiable.


SAT is the first problem that was proven to be [[NP-complete]]—this is the [[Cook–Levin theorem]]. This means that all problems in the complexity class [[NP (complexity)|NP]], which includes a wide range of natural decision and optimization problems, are at most as difficult to solve as SAT. There is no known algorithm that efficiently solves each SAT problem (where "efficiently" informally means "deterministically in polynomial time"), and it is generally believed that no such algorithm exists, but this belief has not been proven mathematically, and resolving the question of whether SAT has a [[polynomial-time]] algorithm is equivalent to the [[P versus NP problem]], which is a famous open problem in the theory of computing.
SAT is the first problem that was proven to be [[NP-complete]]—this is the [[Cook–Levin theorem]]. This means that all problems in the complexity class [[NP (complexity)|NP]], which includes a wide range of natural decision and optimization problems, are at most as difficult to solve as SAT. There is no known algorithm that efficiently solves each SAT problem (where "efficiently" means "deterministically in [[Time complexity#Polynomial time|polynomial time]]"). Although such an algorithm is generally believed not to exist, this belief has not been proven or disproven mathematically. Resolving the question of whether SAT has a [[polynomial-time]] algorithm would settle the [[P versus NP problem]] - one of the most important open problems in the theory of computing.<ref>{{cite journal |author=Fortnow, L. |year=2009 |title=The status of the P versus NP problem |url=https://www.cs.cmu.edu/~15326-f23/CACM-Fortnow.pdf |journal=Communications of the ACM |volume=52 |issue=9 |pages=78–86 |doi=10.1145/1562164.1562186 |s2cid=5969255}}</ref><ref>{{cite journal |author=Fortnow, L. |year=2021 |title=Fifty Years of P Versus NP and the Possibility of the Impossible |url=https://lance.fortnow.com/papers/files/pvnp50.pdf |journal=Proceedings of ACM Conference (Conference'17)}}</ref>


Nevertheless, as of 2007, heuristic SAT-algorithms are able to solve problem instances involving tens of thousands of variables and <!---"clauses" hasn't been introduced here:--->formulas consisting of millions of symbols,<ref name="Codish.Ohrimenko.Stuckey.2007"/> which is sufficient for many practical SAT problems from, e.g., [[artificial intelligence]], [[circuit design]],<ref>{{Cite book|last1=Hong|first1=Ted|last2=Li|first2=Yanjing|last3=Park|first3=Sung-Boem|last4=Mui|first4=Diana|last5=Lin|first5=David|last6=Kaleq|first6=Ziyad Abdel|last7=Hakim|first7=Nagib|last8=Naeimi|first8=Helia|last9=Gardner|first9=Donald S.|last10=Mitra|first10=Subhasish|title=2010 IEEE International Test Conference |chapter=QED: Quick Error Detection tests for effective post-silicon validation |date=November 2010|pages=1–10|doi=10.1109/TEST.2010.5699215|isbn=978-1-4244-7206-2|s2cid=7909084}}</ref> and [[automatic theorem proving]].
Nevertheless, as of 2007, heuristic SAT-algorithms are able to solve problem instances involving tens of thousands of variables and <!---"clauses" hasn't been introduced here:--->formulas consisting of millions of symbols,<ref name="Codish.Ohrimenko.Stuckey.2007"/> which is sufficient for many practical SAT problems occurring in [[artificial intelligence]], [[circuit design]],<ref>{{Cite book|last1=Hong|first1=Ted|last2=Li|first2=Yanjing|last3=Park|first3=Sung-Boem|last4=Mui|first4=Diana|last5=Lin|first5=David|last6=Kaleq|first6=Ziyad Abdel|last7=Hakim|first7=Nagib|last8=Naeimi|first8=Helia|last9=Gardner|first9=Donald S.|last10=Mitra|first10=Subhasish|title=2010 IEEE International Test Conference |chapter=QED: Quick Error Detection tests for effective post-silicon validation |date=November 2010|pages=1–10|doi=10.1109/TEST.2010.5699215|isbn=978-1-4244-7206-2|s2cid=7909084}}</ref> and [[automatic theorem proving]].


==Definitions==
==Definitions==
Line 15: Line 15:
A ''literal'' is either a variable (in which case it is called a ''positive literal'') or the negation of a variable (called a ''negative literal''). A ''clause'' is a disjunction of literals (or a single literal). A clause is called a ''[[Horn clause]]'' if it contains at most one positive literal. A formula is in ''[[conjunctive normal form]]'' (CNF) if it is a conjunction of clauses (or a single clause).
A ''literal'' is either a variable (in which case it is called a ''positive literal'') or the negation of a variable (called a ''negative literal''). A ''clause'' is a disjunction of literals (or a single literal). A clause is called a ''[[Horn clause]]'' if it contains at most one positive literal. A formula is in ''[[conjunctive normal form]]'' (CNF) if it is a conjunction of clauses (or a single clause).


For example, {{math|size=100%|''x''<sub>1</sub>}} is a positive literal, {{math|size=100%|¬''x''<sub>2</sub>}} is a negative literal, and {{math|size=100%|''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>}} is a clause. The formula {{math|size=100%|(''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub>}} is in conjunctive normal form; its first and third clauses are Horn clauses, but its second clause is not. The formula is satisfiable, by choosing ''x''<sub>1</sub>&nbsp;=&nbsp;FALSE, ''x''<sub>2</sub>&nbsp;=&nbsp;FALSE, and ''x''<sub>3</sub> arbitrarily, since (FALSE ∨ ¬FALSE) ∧ (¬FALSE ∨ FALSE ∨ ''x''<sub>3</sub>) ∧ ¬FALSE evaluates to (FALSE ∨ TRUE) ∧ (TRUE ∨ FALSE ∨ ''x''<sub>3</sub>) ∧ TRUE, and in turn to TRUE ∧ TRUE ∧ TRUE (i.e. to TRUE). In contrast, the CNF formula ''a'' ∧ ¬''a'', consisting of two clauses of one literal, is unsatisfiable, since for ''a''=TRUE or ''a''=FALSE it evaluates to TRUE ∧ ¬TRUE (i.e., FALSE) or FALSE ∧ ¬FALSE (i.e., again FALSE), respectively.
For example, {{math|size=100%|''x''<sub>1</sub>}} is a positive literal, {{math|size=100%|¬''x''<sub>2</sub>}} is a negative literal, and {{math|size=100%|''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>}} is a clause. The formula {{math|size=100%|(''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub>}} is in conjunctive normal form; its first and third clauses are Horn clauses, but its second clause is not. The formula is satisfiable, by choosing ''x''<sub>1</sub>&nbsp;=&nbsp;FALSE, ''x''<sub>2</sub>&nbsp;=&nbsp;FALSE, and ''x''<sub>3</sub> arbitrarily, since (FALSE ∨ ¬FALSE) ∧ (¬FALSE ∨ FALSE ∨ ''x''<sub>3</sub>) ∧ ¬FALSE evaluates to (FALSE ∨ TRUE) ∧ (TRUE ∨ FALSE ∨ ''x''<sub>3</sub>) ∧ TRUE, and in turn to TRUE ∧ TRUE ∧ TRUE (i.e. to TRUE). In contrast, the CNF formula ''a'' ∧ ¬''a'', consisting of two clauses of one literal, is unsatisfiable, since for ''a''=TRUE or ''a''=FALSE it evaluates to TRUE ∧ ¬TRUE (i.e., FALSE) or FALSE ∧ ¬FALSE (i.e., again FALSE), respectively.


For some versions of the SAT problem,<!---need not list them in detail here---(viz. [[#Exactly-1 3-satisfiability|Exactly-1 3-satisfiability]], [[#XOR-satisfiability|XOR-satisfiability]], and, more general, [[#Schaefer's dichotomy theorem|Schaefer's dichotomy theorem]], discussed below),---> it is useful to define the notion of a ''generalized conjunctive normal form'' formula, viz. as a conjunction of arbitrarily many ''generalized clauses'', the latter being of the form {{math|''R''(''l''<sub>1</sub>,...,''l''<sub>''n''</sub>)}} for some [[Boolean function]] ''R'' and (ordinary) literals {{mvar|''l''<sub>''i''</sub>}}. Different sets of allowed Boolean functions lead to different problem versions.<!---, see [[#Complexity and restricted versions|below]].---> As an example, ''R''(¬''x'',''a'',''b'') is a generalized clause, and ''R''(¬''x'',''a'',''b'') ∧ ''R''(''b'',''y'',''c'') ∧ ''R''(''c'',''d'',¬''z'') is a generalized conjunctive normal form. This formula is used [[#Exactly-1 3-satisfiability|below]], with ''R'' being the ternary operator that is TRUE just when exactly one of its arguments is.
For some versions of the SAT problem,<!---need not list them in detail here---(viz. [[#Exactly-1 3-satisfiability|Exactly-1 3-satisfiability]], [[#XOR-satisfiability|XOR-satisfiability]], and, more general, [[#Schaefer's dichotomy theorem|Schaefer's dichotomy theorem]], discussed below),---> it is useful to define the notion of a ''generalized conjunctive normal form'' formula, viz. as a conjunction of arbitrarily many ''generalized clauses'', the latter being of the form {{math|''R''(''l''<sub>1</sub>,...,''l''<sub>''n''</sub>)}} for some [[Boolean function]] ''R'' and (ordinary) literals {{mvar|''l''<sub>''i''</sub>}}. Different sets of allowed Boolean functions lead to different problem versions.<!---, see [[#Complexity and restricted versions|below]].---> As an example, ''R''(¬''x'',''a'',''b'') is a generalized clause, and ''R''(¬''x'',''a'',''b'') ∧ ''R''(''b'',''y'',''c'') ∧ ''R''(''c'',''d'',¬''z'') is a generalized conjunctive normal form. This formula is used [[#Exactly-1 3-satisfiability|below]], with ''R'' being the ternary operator that is TRUE just when exactly one of its arguments is.
Line 65: Line 65:
Some authors restrict k-SAT to CNF formulas with '''exactly k literals'''.{{citation needed|date=May 2020}} This does not lead to a different complexity class either, as each clause {{math|''l''<sub>1</sub> ∨ ⋯ ∨ ''l''<sub>''j''</sub>}} with ''j'' < ''k'' literals can be padded with fixed dummy variables to {{math|''l''<sub>1</sub> ∨ ⋯ ∨ ''l''<sub>''j''</sub> ∨ ''d''<sub>''j''+1</sub> ∨ ⋯ ∨ ''d''<sub>''k''</sub>}}. After padding all clauses, 2<sup>''k''</sup>–1 extra clauses{{efn|viz. all [[Canonical form (Boolean algebra)#Maxterms|maxterms]] that can be built with {{math|''d''<sub>1</sub>,⋯,''d''<sub>''k''</sub>}}, except {{math|''d''<sub>1</sub>∨⋯∨''d''<sub>''k''</sub>}}}} must be appended to ensure that only {{math|1=''d''<sub>1</sub> = ⋯ = ''d''<sub>''k''</sub> = FALSE}} can lead to a satisfying assignment. Since ''k'' does not depend on the formula length, the extra clauses lead to a constant increase in length. For the same reason, it does not matter whether '''duplicate literals''' are allowed in clauses, as in {{math|¬''x'' ∨ ¬''y'' ∨ ¬''y''}}.
Some authors restrict k-SAT to CNF formulas with '''exactly k literals'''.{{citation needed|date=May 2020}} This does not lead to a different complexity class either, as each clause {{math|''l''<sub>1</sub> ∨ ⋯ ∨ ''l''<sub>''j''</sub>}} with ''j'' < ''k'' literals can be padded with fixed dummy variables to {{math|''l''<sub>1</sub> ∨ ⋯ ∨ ''l''<sub>''j''</sub> ∨ ''d''<sub>''j''+1</sub> ∨ ⋯ ∨ ''d''<sub>''k''</sub>}}. After padding all clauses, 2<sup>''k''</sup>–1 extra clauses{{efn|viz. all [[Canonical form (Boolean algebra)#Maxterms|maxterms]] that can be built with {{math|''d''<sub>1</sub>,⋯,''d''<sub>''k''</sub>}}, except {{math|''d''<sub>1</sub>∨⋯∨''d''<sub>''k''</sub>}}}} must be appended to ensure that only {{math|1=''d''<sub>1</sub> = ⋯ = ''d''<sub>''k''</sub> = FALSE}} can lead to a satisfying assignment. Since ''k'' does not depend on the formula length, the extra clauses lead to a constant increase in length. For the same reason, it does not matter whether '''duplicate literals''' are allowed in clauses, as in {{math|¬''x'' ∨ ¬''y'' ∨ ¬''y''}}.


==Special cases of SAT==
== Special instances of 3SAT ==


===Conjunctive normal form===
=== Conjunctive normal form ===
Conjunctive normal form (in particular with 3 literals per clause) is often considered the canonical representation for SAT formulas. As shown above, the general SAT problem reduces to 3-SAT, the problem of determining satisfiability for formulas in this form.
Conjunctive normal form (in particular with 3 literals per clause) is often considered the canonical representation for SAT formulas. As shown above, the general SAT problem reduces to 3-SAT, the problem of determining satisfiability for formulas in this form.


===Disjunctive normal form===
===Linear SAT===
SAT is trivial if the formulas are restricted to those in '''[[disjunctive normal form]]''', that is, they are a disjunction of conjunctions of literals. Such a formula is indeed satisfiable if and only if at least one of its conjunctions is satisfiable, and a conjunction is satisfiable if and only if it does not contain both ''x'' and NOT ''x'' for some variable ''x''. This can be checked in linear time. Furthermore, if they are restricted to being in '''full disjunctive normal form''', in which every variable appears exactly once in every conjunction, they can be checked in constant time (each conjunction represents one satisfying assignment).  But it can take exponential time and space to convert a general SAT problem to disjunctive normal form; to obtain an example, exchange "∧" and "∨" in the [[#Definitions|above]] exponential blow-up example for conjunctive normal forms.
 
===Exactly-1 3-satisfiability===
{{Main|1-in-3-SAT}}
 
Another NP-complete variant of the 3-satisfiability problem is the '''one-in-three 3-SAT''' (also known variously as '''1-in-3-SAT''' and '''exactly-1 3-SAT'''). Given a conjunctive normal form with three literals per clause, the problem is to determine whether there exists a truth assignment to the variables so that each clause has ''exactly'' one TRUE literal (and thus exactly two FALSE literals).
 
===Not-all-equal 3-satisfiability===
{{main|Not-all-equal 3-satisfiability}}
Another variant is the '''not-all-equal 3-satisfiability''' problem (also called '''NAE3SAT'''). Given a conjunctive normal form with three literals per clause, the problem is to determine if an assignment to the variables exists such that in no clause all three literals have the same truth value. This problem is NP-complete, too, even if no negation symbols are admitted, by Schaefer's dichotomy theorem.<ref name="schaefer">{{Cite conference | last1 = Schaefer | first1 = Thomas J. | year = 1978 | title = The complexity of satisfiability problems | book-title = Proceedings of the 10th Annual ACM Symposium on Theory of Computing | place = San Diego, California | pages = 216–226 | url = http://www.ccs.neu.edu/home/lieber/courses/csg260/f06/materials/papers/max-sat/p216-schaefer.pdf |doi=10.1145/800133.804350 |citeseerx=10.1.1.393.8951 }}</ref>
 
=== Linear SAT ===
A 3-SAT formula is ''Linear SAT'' (''LSAT'') if each clause (viewed as a set of literals) intersects at most one other clause, and, moreover, if two clauses intersect, then they have exactly one literal in common. An LSAT formula can be depicted as a set of disjoint semi-closed intervals on a line. Deciding whether an LSAT formula is satisfiable is NP-complete.<ref>{{Cite journal|last1=Arkin|first1=Esther M.|last2=Banik|first2=Aritra|last3=Carmi|first3=Paz|last4=Citovsky|first4=Gui|last5=Katz|first5=Matthew J.|last6=Mitchell|first6=Joseph S. B.|last7=Simakov|first7=Marina|date=2018-12-11|title=Selecting and covering colored points|journal=Discrete Applied Mathematics|language=en|volume=250|pages=75–86|doi=10.1016/j.dam.2018.05.011|issn=0166-218X|doi-access=free}}</ref>
A 3-SAT formula is ''Linear SAT'' (''LSAT'') if each clause (viewed as a set of literals) intersects at most one other clause, and, moreover, if two clauses intersect, then they have exactly one literal in common. An LSAT formula can be depicted as a set of disjoint semi-closed intervals on a line. Deciding whether an LSAT formula is satisfiable is NP-complete.<ref>{{Cite journal|last1=Arkin|first1=Esther M.|last2=Banik|first2=Aritra|last3=Carmi|first3=Paz|last4=Citovsky|first4=Gui|last5=Katz|first5=Matthew J.|last6=Mitchell|first6=Joseph S. B.|last7=Simakov|first7=Marina|date=2018-12-11|title=Selecting and covering colored points|journal=Discrete Applied Mathematics|language=en|volume=250|pages=75–86|doi=10.1016/j.dam.2018.05.011|issn=0166-218X|doi-access=free}}</ref>


Line 88: Line 76:
{{Main|2-satisfiability}}
{{Main|2-satisfiability}}


SAT is easier if the number of literals in a clause is limited to at most 2, in which case the problem is called '''[[2-SAT]]'''. This problem can be solved in polynomial time, and in fact is [[NL-complete|complete]] for the complexity class [[NL (complexity)|NL]]. If additionally all OR operations in literals are changed to [[Exclusive or|XOR]] operations, then the result is called '''exclusive-or 2-satisfiability''', which is a problem complete for the complexity class [[SL (complexity)|SL]] = [[L (complexity)|L]].
SAT is easier if the number of literals in a clause is limited to at most 2, in which case the problem is called '''[[2-satisfiability|2-SAT]]'''. This problem can be solved in polynomial time, and in fact is [[NL-complete|complete]] for the complexity class [[NL (complexity)|NL]]. If additionally all OR operations in literals are changed to [[Exclusive or|XOR]] operations, then the result is called '''exclusive-or 2-satisfiability''', which is a problem complete for the complexity class [[SL (complexity)|SL]] = [[L (complexity)|L]].


===Horn-satisfiability===
===Horn-satisfiability===
Line 99: Line 87:
A generalization of the class of Horn formulas is that of renameable-Horn formulae, which is the set of formulas that can be placed in Horn form by replacing some variables with their respective negation. For example, (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> is not a Horn formula, but can be renamed to the Horn formula (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ¬''y''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> by introducing ''y''<sub>3</sub> as negation of ''x''<sub>3</sub>. In contrast, no renaming of (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub> ∨ ¬''x''<sub>3</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> leads to a Horn formula. Checking the existence of such a replacement can be done in linear time; therefore, the satisfiability of such formulae is in P as it can be solved by first performing this replacement and then checking the satisfiability of the resulting Horn formula.
A generalization of the class of Horn formulas is that of renameable-Horn formulae, which is the set of formulas that can be placed in Horn form by replacing some variables with their respective negation. For example, (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> is not a Horn formula, but can be renamed to the Horn formula (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ¬''y''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> by introducing ''y''<sub>3</sub> as negation of ''x''<sub>3</sub>. In contrast, no renaming of (''x''<sub>1</sub> ∨ ¬''x''<sub>2</sub> ∨ ¬''x''<sub>3</sub>) ∧ (¬''x''<sub>1</sub> ∨ ''x''<sub>2</sub> ∨ ''x''<sub>3</sub>) ∧ ¬''x''<sub>1</sub> leads to a Horn formula. Checking the existence of such a replacement can be done in linear time; therefore, the satisfiability of such formulae is in P as it can be solved by first performing this replacement and then checking the satisfiability of the resulting Horn formula.


{| style="float:right"
== Not 3SAT problems ==
| [[File:Boolean satisfiability vs true literal counts.png|thumb|x200px|A formula with 2 clauses may be unsatisfied (red), 3-satisfied (green), xor-3-satisfied (blue), or/and 1-in-3-satisfied (yellow), depending on the TRUE-literal count in the 1st (hor) and 2nd (vert) clause.]]
|}


===XOR-satisfiability===
=== Disjunctive normal form ===
SAT is trivial if the formulas are restricted to those in '''[[disjunctive normal form]]''', that is, they are a disjunction of conjunctions of literals. Such a formula is indeed satisfiable if and only if at least one of its conjunctions is satisfiable, and a conjunction is satisfiable if and only if it does not contain both ''x'' and NOT ''x'' for some variable ''x''. This can be checked in linear time. Furthermore, if they are restricted to being in '''full disjunctive normal form''', in which every variable appears exactly once in every conjunction, they can be checked in constant time (each conjunction represents one satisfying assignment).  But it can take exponential time and space to convert a general SAT problem to disjunctive normal form; to obtain an example, exchange "∧" and "∨" in the [[#Definitions|above]] exponential blow-up example for conjunctive normal forms.


{| align="right" class="wikitable collapsible collapsed" style="text-align:left; margin: 1em; max-width: 95%"
===Exactly-1 3-satisfiability===
|-
{{Main|1-in-3-SAT}}
! Solving an XOR-SAT example<BR>by [[Gaussian elimination]]
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! Given formula
|-
| ("⊕" means XOR, the {{color|#ff8080|red clause}} is optional)
|-
| (''a''⊕''c''⊕''d'') ∧ (''b''⊕¬''c''⊕''d'') ∧ (''a''⊕''b''⊕¬''d'') ∧ (''a''⊕¬''b''⊕¬''c'') {{color|#ff8080|∧ (¬''a''⊕''b''⊕''c'')}}
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! colspan="9" | Equation system
|-
| colspan="9" | ("1" means TRUE, "0" means FALSE)
|-
| colspan="9" | Each clause leads to one equation.
|-
|  || ''a'' || ⊕ ||  || ''c'' || ⊕ ||  || ''d'' || = 1
|-
|  || ''b'' || ⊕ || ¬ || ''c'' || ⊕ ||  || ''d'' || = 1
|-
|  || ''a'' || ⊕ ||  || ''b'' || ⊕ || ¬ || ''d'' || = 1
|-
|  || ''a'' || ⊕ || ¬ || ''b'' || ⊕ || ¬ || ''c'' || = 1
|-
|  {{color|#ff8080|¬}} || {{color|#ff8080|''a''}} || {{color|#ff8080|⊕}} || || {{color|#ff8080|''b''}} || {{color|#ff8080|⊕}} || || {{color|#ff8080|''c''}} || {{color|#ff8080| ≃ 1}}
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! colspan="6" | Normalized equation system
|-
| colspan="6" | using properties of [[Boolean rings]] (¬''x''=1⊕''x'', ''x''⊕''x''=0)
|-
| ''a'' || ⊕ || ''c'' || ⊕ || ''d'' || = '''1'''
|-
| ''b'' || ⊕ || ''c'' || ⊕ || ''d'' || = '''0'''
|-
| ''a'' || ⊕ || ''b'' || ⊕ || ''d'' || = '''0'''
|-
| ''a'' || ⊕ || ''b'' || ⊕ || ''c'' || = '''1'''
|-
| {{color|#ff8080|''a''}} || {{color|#ff8080|⊕}}  || {{color|#ff8080|''b''}} || {{color|#ff8080|⊕}} || {{color|#ff8080|''c''}} || {{color|#ff8080| ≃ '''0'''}}
|-
| colspan="6" | (If the {{color|#ff8080|red equation}} is present, {{color|#ff8080|it}} contradicts
|-
| colspan="6" | the last black one, so the system is unsolvable.
|-
| colspan="6" | Therefore, Gauss' algorithm is
|-
| colspan="6" | used only for the black equations.)
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! colspan="6" | Associated coefficient matrix
|-
| &nbsp;
|-
! ''a'' !! ''b'' !! ''c'' !! ''d'' !!  !! line
|-
| &nbsp;
|-
| 1 || 0 || 1 || 1
! 1
| A
|-
| 0 || 1 || 1 || 1
! 0
| B
|-
| 1 || 1 || 0 || 1
! 0
| C
|-
| 1 || 1 || 1 || 0
! 1
| D
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! colspan="6" |Transforming to echelon form
|-
| &nbsp;
|-
! ''a'' !! ''b'' !! ''c'' !! ''d'' !!  !! operation
|-
| &nbsp;
|-
| 1 || 0 || 1 || 1
! 1
| A
|-
| 1 || 1 || 0 || 1
! 0
| C
|-
| 1 || 1 || 1 || 0
! 1
| D
|-
| 0 || 1 || 1 || 1
! 0
| B (swapped)
|-
| &nbsp;
|-
| 1 || 0 || 1 || 1
! 1
| A
|-
| 0 || 1 || 1 || 0
! 1
| E = C⊕A
|-
| 0 || 1 || 0 || 1
! 0
| F = D⊕A
|-
| 0 || 1 || 1 || 1
! 0
| B
|-
| &nbsp;
|-
| 1 || 0 || 1 || 1
! 1
| A
|-
| 0 || 1 || 1 || 0
! 1
| E
|-
| 0 || 0 || 1 || 1
! 1
| G = F⊕E
|-
| 0 || 0 || 0 || 1
! 1
| H = B⊕E
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! colspan="6" | Transforming to diagonal form
|-
| &nbsp;
|-
! ''a'' !! ''b'' !! ''c'' !! ''d'' !!  !! operation
|-
| &nbsp;
|-
| 1 || 0 || 1 || 0
! 0
| I = A⊕H
|-
| 0 || 1 || 1 || 0
! 1
| E
|-
| 0 || 0 || 1 || 0
! 0
| J = G⊕H
|-
| 0 || 0 || 0 || 1
! 1
| H
|-
| &nbsp;
|-
| 1 || 0 || 0 || 0
! 0
| K = I⊕J
|-
| 0 || 1 || 0 || 0
! 1
| L = E⊕J
|-
| 0 || 0 || 1 || 0
! 0
| J
|-
| 0 || 0 || 0 || 1
! 1
| H
|-
|}
|-
|
{| align="left" class="collapsible collapsed" style="text-align:left"
|-
! Solution:
|-
| If the {{color|#ff8080|red clause}} is present: || Unsolvable
|-
| Else: || ''a'' = 0 = FALSE
|-
| || ''b'' = 1 = TRUE
|-
| || ''c'' = 0 = FALSE
|-
| || ''d'' = 1 = TRUE
|-
| colspan="2" | '''As a consequence:'''
|-
| colspan="2" | ''R''(''a'',''c'',''d'') ∧ ''R''(''b'',¬''c'',''d'') ∧ ''R''(''a'',''b'',¬''d'') ∧ ''R''(''a'',¬''b'',¬''c'') {{color|#ff8080|∧ ''R''(¬''a'',''b'',''c'')}}
|-
| colspan="2" | is not 1-in-3-satisfiable,
|-
| colspan="2" | while (''a'' ∨ ''c'' ∨ ''d'') ∧ (''b'' ∨ ¬''c'' ∨ ''d'') ∧ (''a'' ∨ ''b'' ∨ ¬''d'') ∧ (''a'' ∨ ¬''b'' ∨ ¬''c'')
|-
| colspan="2" |  is 3-satisfiable with ''a''=''c''=FALSE and ''b''=''d''=TRUE.
|}
|}


Another special case is the class of problems where each clause contains XOR (i.e. [[exclusive or]]) rather than (plain) OR operators.{{efn|Formally, generalized conjunctive normal forms with a ternary Boolean function ''R'' are employed, which is TRUE just if 1 or 3 of its arguments is. An input clause with more than 3 literals can be transformed into an equisatisfiable conjunction of clauses á 3 literals similar to [[#3-satisfiability|above]]; i.e. XOR-SAT can be reduced to XOR-3-SAT.}} This is in [[P (complexity class)|P]], since an XOR-SAT formula can also be viewed as a system of linear equations mod 2, and can be solved in cubic time by [[Gaussian elimination]];<ref>{{citation|title=The Nature of Computation|first1=Cristopher|last1=Moore|author1-link=Cristopher Moore|first2=Stephan|last2=Mertens|publisher=Oxford University Press|year=2011|isbn=9780199233212|page=366|url=https://books.google.com/books?id=z4zMiZyAE1kC&pg=PA366}}.</ref> see the box for an example. This recast is based on the [[Boolean algebra (structure)#Boolean rings|kinship between Boolean algebras and Boolean rings]], and the fact that arithmetic modulo two forms the finite field [[GF(2)]]. Since ''a'' XOR ''b'' XOR ''c'' evaluates to TRUE if and only if exactly 1 or 3 members of {''a'',''b'',''c''} are TRUE, each solution of the 1-in-3-SAT problem for a given CNF formula is also a solution of the XOR-3-SAT problem, and in turn each solution of XOR-3-SAT is a solution of 3-SAT; see the picture. As a consequence, for each CNF formula, it is possible to solve the XOR-3-SAT problem defined by the formula, and based on the result infer either that the 3-SAT problem is solvable or that the 1-in-3-SAT problem is unsolvable.
Another NP-complete variant of the 3-satisfiability problem is the '''one-in-three 3-SAT''' (also known variously as '''1-in-3-SAT''' and '''exactly-1 3-SAT'''). Given a conjunctive normal form with three literals per clause, the problem is to determine whether there exists a truth assignment to the variables so that each clause has ''exactly'' one TRUE literal (and thus exactly two FALSE literals).


Provided that the [[P = NP problem|complexity classes P and NP are not equal]], neither 2-, nor Horn-, nor XOR-satisfiability is NP-complete, unlike SAT.
===Not-all-equal 3-satisfiability===
{{main|Not-all-equal 3-satisfiability}}


====Examples====
Another variant is the '''not-all-equal 3-satisfiability''' problem (also called '''NAE3SAT'''). Given a conjunctive normal form with three literals per clause, the problem is to determine if an assignment to the variables exists such that in no clause all three literals have the same truth value. This problem is NP-complete, too, even if no negation symbols are admitted, by Schaefer's dichotomy theorem.<ref name="schaefer">{{Cite conference |last1=Schaefer |first1=Thomas J. |year=1978 |title=The complexity of satisfiability problems |url=http://www.ccs.neu.edu/home/lieber/courses/csg260/f06/materials/papers/max-sat/p216-schaefer.pdf |pages=216–226 |citeseerx=10.1.1.393.8951 |doi=10.1145/800133.804350 |book-title=Proceedings of the 10th Annual ACM Symposium on Theory of Computing |place=San Diego, California}}</ref>
Here is an unsatisfiable XOR-SAT instance of 2 variables and 3 clauses:
:{{math|(''a'' ''b'') ∧ (''a'') ∧ (''b'')}}


Here is a satisfiable XOR-SAT instance of 2 variables and 1 clause admitting 2 solutions:
=== XOR-satisfiability ===
:{{math|(''a'' ⊕ ''b'')}}
{{Main|XOR-SAT}}


And here is a unique XOR-SAT instance, that is to say a satisfiable XOR-SAT instance of 2 variables and 2 clauses admitting exactly one solution:
Another special case is the class of problems where each clause contains XOR (i.e. [[exclusive or]]) rather than (plain) OR operators. This is in [[P (complexity class)|P]], since an XOR-SAT formula can also be viewed as a system of linear equations mod 2, and can be solved in cubic time by [[Gaussian elimination]].<ref>{{citation|title=The Nature of Computation|first1=Cristopher|last1=Moore|author1-link=Cristopher Moore|first2=Stephan|last2=Mertens|publisher=Oxford University Press|year=2011|isbn=9780199233212|page=366|url=https://books.google.com/books?id=z4zMiZyAE1kC&pg=PA366}}.</ref>
:{{math|(''a'' ⊕ ''b'') ∧ (''a'')}}


===Schaefer's dichotomy theorem===
== Schaefer's dichotomy theorem ==
{{Main|Schaefer's dichotomy theorem}}
{{Main|Schaefer's dichotomy theorem}}
The restrictions above (CNF, 2CNF, 3CNF, Horn, XOR-SAT) bound the considered formulae to be conjunctions of subformulas; each restriction states a specific form for all subformulas: for example, only binary clauses can be subformulas in 2CNF.
The restrictions above (CNF, 2CNF, 3CNF, Horn, XOR-SAT) bound the considered formulae to be conjunctions of subformulas; each restriction states a specific form for all subformulas: for example, only binary clauses can be subformulas in 2CNF.
Line 354: Line 116:
{| class="wikitable sortable"
{| class="wikitable sortable"
|+
|+
!Code
! Name
!Name
! Code
!Restrictions
! 3SAT problem?
!Requirements
! Restrictions
!Class
! Requirements
! Class
|-
|-
|3SAT
| ''3-satisfiability''
|3-satisfiability
| <code>3SAT</code>
|Each clause contains 3 literals.
| {{Yes}}
|At least one literal must be true.
| Each clause contains 3 literals.
|NP-c
| At least one literal must be true.
| NP-c
|-
|-
|2SAT
| ''2-satisfiability''
|2-satisfiability
| <code>2SAT</code>
|Each clause contains 2 literals.
| {{Yes}}
|At least one literal must be true.
| Each clause contains 2 literals.
|NL-c
| At least one literal must be true.
| NL-c
|-
|-
|1-in-3-SAT
| ''Exactly-1 3-SAT''
|Exactly-1 3-SAT
| <code>1-in-3-SAT</code>
|Each clause contains 3 literals.
| {{No}}
|Exactly one literal must be true.
| Each clause contains 3 literals.
|NP-c
| Exactly one literal must be true.
| NP-c
|-
|-
|1-in-3-SAT+
| ''Exactly-1 Positive 3-SAT''
|Exactly-1 Positive 3-SAT
| <code>1-in-3-SAT+</code>
|Each clause contains 3 positive literals.
| {{No}}
|Exactly one literal must be true.
| Each clause contains 3 positive literals.
|NP-c
| Exactly one literal must be true.
| NP-c
|-
|-
|NAE3SAT
| ''Not-all-equal 3-satisfiability''
|Not-all-equal 3-satisfiability
| <code>NAE3SAT</code>
|Each clause contains 3 literals.
| {{No}}
|Either one or two literals must be true.
| Each clause contains 3 literals.
|NP-c
| Either one or two literals must be true.
| NP-c
|-
|-
|NAE3SAT+
| ''Not-all-equal positive 3-SAT''
|Not-all-equal positive 3-SAT
| <code>NAE3SAT+</code>
|Each clause contains 3 positive literals.
| {{No}}
|Either one or two literals must be true.
| Each clause contains 3 positive literals.
|NP-c
| Either one or two literals must be true.
| NP-c
|-
|-
|PL-SAT
| ''[[Planar SAT]]''
|[[Planar SAT]]
| <code>PL-SAT</code>
|The incidence graph (clause-variable graph) is [[Planar graph|planar]].
| {{Yes}}
|At least one literal must be true.
| The incidence graph (clause-variable graph) is [[Planar graph|planar]].
|NP-c
| At least one literal must be true.
| NP-c
|-
|-
|LSAT
| ''Linear SAT''
|Linear SAT
| <code>LSAT</code>
|Each clause contains 3 literals, intersects at most one other clause, and the intersection is exactly one literal.
| {{Yes}}
|At least one literal must be true.
| Each clause contains 3 literals, intersects at most one other clause, and the intersection is exactly one literal.
|NP-c
| At least one literal must be true.
| NP-c
|-
|-
|HORN-SAT
| ''Horn satisfiability''
|Horn satisfiability
| <code>HORN-SAT</code>
|Horn clauses (at most one positive literal).
| {{Yes}}
|At least one literal must be true.
| Horn clauses (at most one positive literal).
|P-c
| At least one literal must be true.
| P-c
|-
|-
|XOR-SAT
| ''Xor satisfiability''
|Xor satisfiability
| <code>XOR-SAT</code>
|Each clause contains XOR operations rather than OR.
| {{No}}
|The XOR of all literals must be true.
| Each clause contains XOR operations rather than OR.
|P
| The XOR of all literals must be true.
| P
|}
|}


Line 424: Line 197:
An extension that has gained significant popularity since 2003 is '''[[satisfiability modulo theories]]''' ('''SMT''') that can enrich CNF formulas with linear constraints, arrays, all-different constraints, [[uninterpreted function]]s,<ref name="Bryant.German.Velev.1999">R. E. Bryant, S. M. German, and M. N. Velev, [http://portal.acm.org/citation.cfm?id=709275 Microprocessor Verification Using Efficient Decision Procedures for a Logic of Equality with Uninterpreted Functions], in Analytic Tableaux and Related Methods, pp.&nbsp;1–13, 1999.</ref> etc. Such extensions typically remain NP-complete, but very efficient solvers are now available that can handle many such kinds of constraints.
An extension that has gained significant popularity since 2003 is '''[[satisfiability modulo theories]]''' ('''SMT''') that can enrich CNF formulas with linear constraints, arrays, all-different constraints, [[uninterpreted function]]s,<ref name="Bryant.German.Velev.1999">R. E. Bryant, S. M. German, and M. N. Velev, [http://portal.acm.org/citation.cfm?id=709275 Microprocessor Verification Using Efficient Decision Procedures for a Logic of Equality with Uninterpreted Functions], in Analytic Tableaux and Related Methods, pp.&nbsp;1–13, 1999.</ref> etc. Such extensions typically remain NP-complete, but very efficient solvers are now available that can handle many such kinds of constraints.


The satisfiability problem becomes more difficult if both "for all" ([[∀]]) and "there exists" ([[∃]]) [[Quantifier (logic)|quantifier]]s are allowed to bind the Boolean variables. An example of such an expression would be {{math|size=100%|∀''x'' ∀''y'' ∃''z'' (''x'' ∨ ''y'' ∨ ''z'') ∧ (¬''x'' ∨ ¬''y'' ∨ ¬''z'')}}; it is valid, since for all values of ''x'' and ''y'', an appropriate value of ''z'' can be found, viz. ''z''=TRUE if both ''x'' and ''y'' are FALSE, and ''z''=FALSE else. SAT itself (tacitly) uses only ∃ quantifiers. If only ∀ quantifiers are allowed instead, the so-called '''[[Tautology (logic)|tautology]] problem''' is obtained, which is [[co-NP-complete]]. If any number of both quantifiers are allowed, the problem is called the '''[[quantified Boolean formula problem]]''' ('''QBF'''), which can be shown to be [[PSPACE-complete]]. It is widely believed that PSPACE-complete problems are strictly harder than any problem in NP, although this has not yet been proved. Using highly parallel ''[[P system]]s'', QBF-SAT problems can be solved in linear time.<ref>{{Cite journal | last1 = Alhazov | first1 = Artiom | last2 = Martín-Vide | first2 = Carlos | last3 = Pan | first3 = Linqiang | title = Solving a PSPACE-Complete Problem by Recognizing P Systems with Restricted Active Membranes |  url=https://www.researchgate.net/publication/220444503 | journal = Fundamenta Informaticae | volume = 58 | pages = 67–77 | year = 2003 }} Here: Sect.3, Thm.3.1</ref>
The satisfiability problem becomes more difficult if both "for all" ([[∀]]) and "there exists" ([[∃]]) [[Quantifier (logic)|quantifier]]s are allowed to bind the Boolean variables. An example of such an expression would be {{math|size=100%|∀''x'' ∀''y'' ∃''z'' (''x'' ∨ ''y'' ∨ ''z'') ∧ (¬''x'' ∨ ¬''y'' ∨ ¬''z'')}}; it is valid, since for all values of ''x'' and ''y'', an appropriate value of ''z'' can be found, viz. ''z''=TRUE if both ''x'' and ''y'' are FALSE, and ''z''=FALSE else. SAT itself (tacitly) uses only ∃ quantifiers. If only ∀ quantifiers are allowed instead, the so-called '''[[Tautology (logic)|tautology]] problem''' is obtained, which is [[co-NP-complete]]. If any number of both quantifiers are allowed, the problem is called the '''[[quantified Boolean formula problem]]''' ('''QBF'''), which can be shown to be [[PSPACE-complete]]. It is widely believed that PSPACE-complete problems are strictly harder than any problem in NP, although this has not yet been proved.


Ordinary SAT asks if there is at least one variable assignment that makes the formula true. A variety of variants deal with the number of such assignments:
Ordinary SAT asks if there is at least one variable assignment that makes the formula true. A variety of variants deal with the number of such assignments:
* '''MAJ-SAT''' asks if at least half of all assignments make the formula TRUE. It is known to be complete for [[PP (complexity)|PP]], a probabilistic class. Surprisingly, '''MAJ-kSAT''' is demonstrated to be in P for every finite integer k.<ref>{{Cite book |title=MAJORITY-3SAT (and Related Problems) in Polynomial Time |url=https://ieeexplore.ieee.org/document/9719756 |archive-url=http://web.archive.org/web/20241005152907/https://ieeexplore.ieee.org/document/9719756/ |archive-date=2024-10-05 |access-date=2024-12-25 |date=2022 |doi=10.1109/FOCS52979.2021.00103 |arxiv=2107.02748 |language=en-US |last1=Akmal |first1=Shyan |last2=Williams |first2=Ryan |pages=1033–1043 |isbn=978-1-6654-2055-6 }}</ref>
* '''MAJ-SAT''' asks if at least half of all assignments make the formula TRUE. It is known to be complete for [[PP (complexity)|PP]], a probabilistic class. Surprisingly, '''MAJ-kSAT''' is demonstrated to be in P for every finite integer k.<ref>{{Cite book |title=MAJORITY-3SAT (and Related Problems) in Polynomial Time |date=2022 |doi=10.1109/FOCS52979.2021.00103 |arxiv=2107.02748 |language=en-US |last1=Akmal |first1=Shyan |last2=Williams |first2=Ryan |pages=1033–1043 |isbn=978-1-6654-2055-6 }}</ref>
* '''[[Sharp-SAT|#SAT]]''', the problem of counting how many variable assignments satisfy a formula, is a counting problem, not a decision problem, and is [[Sharp-P-complete|#P-complete]].
* '''[[Sharp-SAT|#SAT]]''', the problem of counting how many variable assignments satisfy a formula, is a counting problem, not a decision problem, and is [[Sharp-P-complete|#P-complete]].
* '''UNIQUE SAT'''<ref>{{Cite journal|last1=Blass|first1=Andreas|last2=Gurevich|first2=Yuri|date=1982-10-01|title=On the unique satisfiability problem|journal=Information and Control|volume=55|issue=1|pages=80–88|doi=10.1016/S0019-9958(82)90439-9|issn=0019-9958|doi-access=free|hdl=2027.42/23842|hdl-access=free}}</ref> is the problem of determining whether a formula has exactly one assignment. It is complete for [[US (complexity)|US]],<ref>{{Cite web|url=https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#US|title=Complexity Zoo:U - Complexity Zoo|website=complexityzoo.uwaterloo.ca|access-date=2019-12-05|archive-date=2019-07-09|archive-url=https://web.archive.org/web/20190709142353/https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#US|url-status=dead}}</ref> the [[complexity class]] describing problems solvable by a non-deterministic polynomial time [[Turing machine]] that accepts when there is exactly one nondeterministic accepting path and rejects otherwise.
* '''UNIQUE SAT'''<ref>{{Cite journal|last1=Blass|first1=Andreas|last2=Gurevich|first2=Yuri|date=1982-10-01|title=On the unique satisfiability problem|journal=Information and Control|volume=55|issue=1|pages=80–88|doi=10.1016/S0019-9958(82)90439-9|issn=0019-9958|doi-access=free|hdl=2027.42/23842|hdl-access=free}}</ref> is the problem of determining whether a formula has exactly one assignment. It is complete for [[US (complexity)|US]],<ref>{{Cite web|url=https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#US|title=Complexity Zoo:U - Complexity Zoo|website=complexityzoo.uwaterloo.ca|access-date=2019-12-05|archive-date=2019-07-09|archive-url=https://web.archive.org/web/20190709142353/https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#US|url-status=dead}}</ref> the [[complexity class]] describing problems solvable by a non-deterministic polynomial time [[Turing machine]] that accepts when there is exactly one nondeterministic accepting path and rejects otherwise.
*'''UNAMBIGUOUS-SAT''' is the name given to the satisfiability problem when the input is [[Promise problem|restricted]] to formulas having at most one satisfying assignment. The problem is also called '''USAT'''.<ref>{{Cite book |chapter-url=https://www.springer.com/gp/book/9781846282973 |chapter=Supplementary Lecture F: Unique Satisfiability |title=Theory of Computation |last=Kozen |first=Dexter C. |date=2006 |publisher=Springer  |isbn=9781846282973 |series=Texts in Computer Science |page=180 |language=en}}</ref> A solving algorithm for UNAMBIGUOUS-SAT is allowed to exhibit any behavior, including endless looping, on a formula having several satisfying assignments. Although this problem seems easier, Valiant and Vazirani have [[Valiant–Vazirani theorem|shown]]<ref>{{Cite journal | last1 = Valiant | first1 = L. | last2 = Vazirani | first2 = V.| doi = 10.1016/0304-3975(86)90135-0 | title = NP is as easy as detecting unique solutions | url = http://www.cs.princeton.edu/courses/archive/fall05/cos528/handouts/NP_is_as.pdf| journal = Theoretical Computer Science | volume = 47 | pages = 85–93 | year = 1986 | doi-access = free }}</ref> that if there is a practical (i.e. [[Bounded-error probabilistic polynomial|randomized polynomial-time]]) algorithm to solve it, then all problems in [[NP (complexity class)|NP]] can be solved just as easily.
*'''UNAMBIGUOUS-SAT''' is the name given to the satisfiability problem when the input formula is [[Promise problem|promised]] to have at most one satisfying assignment. The problem is also called '''USAT'''.<ref>{{Cite book |chapter-url=https://www.springer.com/gp/book/9781846282973 |chapter=Supplementary Lecture F: Unique Satisfiability |title=Theory of Computation |last=Kozen |first=Dexter C. |date=2006 |publisher=Springer  |isbn=9781846282973 |series=Texts in Computer Science |page=180 |language=en}}</ref> A solving algorithm for UNAMBIGUOUS-SAT is allowed to exhibit any behavior, including endless looping, on a formula having several satisfying assignments. Although this problem seems easier, Valiant and Vazirani have [[Valiant–Vazirani theorem|shown]]<ref>{{Cite journal | last1 = Valiant | first1 = L. | last2 = Vazirani | first2 = V.| doi = 10.1016/0304-3975(86)90135-0 | title = NP is as easy as detecting unique solutions | url = http://www.cs.princeton.edu/courses/archive/fall05/cos528/handouts/NP_is_as.pdf| journal = Theoretical Computer Science | volume = 47 | pages = 85–93 | year = 1986 | doi-access = free }}</ref> that if there is a practical (i.e. [[Bounded-error probabilistic polynomial|randomized polynomial-time]]) algorithm to solve it, then all problems in [[NP (complexity class)|NP]] can be solved just as easily.
* '''MAX-SAT''', the [[maximum satisfiability problem]], is an [[FNP (complexity)|FNP]] generalization of SAT. It asks for the maximum number of clauses which can be satisfied by any assignment. It has efficient [[approximation algorithm]]s, but is NP-hard to solve exactly. Worse still, it is [[APX]]-complete, meaning there is no [[polynomial-time approximation scheme]] (PTAS) for this problem unless P=NP.
* '''MAX-SAT''', the [[maximum satisfiability problem]], is an [[FNP (complexity)|FNP]] generalization of SAT. It asks for the maximum number of clauses which can be satisfied by any assignment. It has efficient [[approximation algorithm]]s, but is NP-hard to solve exactly. Worse still, it is [[APX]]-complete, meaning there is no [[polynomial-time approximation scheme]] (PTAS) for this problem unless P=NP.
*'''WMSAT''' is the problem of finding an assignment of minimum weight that satisfy a monotone Boolean formula (i.e. a formula without any negation). Weights of propositional variables are given in the input of the problem. The weight of an assignment is the sum of weights of true variables. That problem is NP-complete (see Th. 1 of <ref>{{Cite book|last1=Buldas|first1=Ahto|last2=Lenin|first2=Aleksandr|last3=Willemson|first3=Jan|last4=Charnamord|first4=Anton|title=Advances in Information and Computer Security |chapter=Simple Infeasibility Certificates for Attack Trees |date=2017|editor-last=Obana|editor-first=Satoshi|editor2-last=Chida|editor2-first=Koji|volume=10418|series=Lecture Notes in Computer Science|language=en|publisher=Springer International Publishing|pages=39–55|doi=10.1007/978-3-319-64200-0_3|isbn=9783319642000}}</ref>).
*'''WMSAT''' is the problem of finding an assignment of minimum weight that satisfy a monotone Boolean formula (i.e. a formula without any negation). Weights of propositional variables are given in the input of the problem. The weight of an assignment is the sum of weights of true variables. That problem is NP-complete (see Th. 1 of<ref>{{Cite book|last1=Buldas|first1=Ahto|last2=Lenin|first2=Aleksandr|last3=Willemson|first3=Jan|last4=Charnamord|first4=Anton|title=Advances in Information and Computer Security |chapter=Simple Infeasibility Certificates for Attack Trees |date=2017|editor-last=Obana|editor-first=Satoshi|editor2-last=Chida|editor2-first=Koji|volume=10418|series=Lecture Notes in Computer Science|language=en|publisher=Springer International Publishing|pages=39–55|doi=10.1007/978-3-319-64200-0_3|isbn=9783319642000}}</ref>).


Other generalizations include satisfiability for [[first-order predicate calculus|first]]- and [[second-order logic]], [[constraint satisfaction problem]]s, [[0-1 integer programming]].
Other generalizations include satisfiability for [[first-order predicate calculus|first]]- and [[second-order logic]], [[constraint satisfaction problem]]s, [[0-1 integer programming]].
Line 447: Line 220:
==Algorithms for solving SAT==
==Algorithms for solving SAT==
{{main|SAT solver}}
{{main|SAT solver}}
[[File:SatComplexity svg.svg|thumb|550px|Exponential complexity of SAT solving vs variable count, clause count, and formula length]]
Since the SAT problem is NP-complete, only algorithms with exponential worst-case complexity are known for it. In spite of this, efficient and scalable algorithms for SAT were developed during the 2000s and have contributed to dramatic advances in the ability to automatically solve problem instances involving tens of thousands of variables and millions of constraints (i.e. clauses).<ref name="Codish.Ohrimenko.Stuckey.2007">{{citation |title=Principles and Practice of Constraint Programming – CP 2007|series=Lecture Notes in Computer Science|volume=4741|year=2007|pages=544–558|contribution=Propagation = Lazy Clause Generation|first1=Olga|last1=Ohrimenko |first2=Peter J.|last2=Stuckey|first3=Michael|last3=Codish|doi=10.1007/978-3-540-74970-7_39|isbn=978-3-540-74969-1 |quote=modern SAT solvers can often handle problems with millions of constraints and hundreds of thousands of variables |citeseerx=10.1.1.70.5471}}.</ref> Examples of such problems in [[electronic design automation]] (EDA) include [[formal equivalence checking]], [[model checking]], [[formal verification]] of [[microprocessor|pipelined microprocessors]],<ref name="Bryant.German.Velev.1999"/> [[automatic test pattern generation]], [[routing (electronic design automation)|routing]] of [[FPGA]]s,<ref>{{Cite journal |last1=Gi-Joon Nam |last2=Sakallah |first2=K. A. |last3=Rutenbar |first3=R. A. |title=A new FPGA detailed routing approach via search-based Boolean satisfiability |journal=IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems |volume=21 |issue=6 |pages=674 |year=2002 |url=http://cs-rutenbar.web.engr.illinois.edu/wp-content/uploads/2012/10/rutenbar-sattranscad02.pdf |doi=10.1109/TCAD.2002.1004311 |bibcode=2002ITCAD..21..674N |access-date=2015-09-04 |archive-date=2016-03-15 |archive-url=https://web.archive.org/web/20160315003856/http://cs-rutenbar.web.engr.illinois.edu/wp-content/uploads/2012/10/rutenbar-sattranscad02.pdf |url-status=dead }}</ref> [[Automated planning and scheduling|planning]], and [[Scheduling algorithm|scheduling problems]], and so on. A SAT-solving engine is also considered to be an essential component in the [[electronic design automation]] toolbox.


Since the SAT problem is NP-complete, only algorithms with exponential worst-case complexity are known for it. In spite of this, efficient and scalable algorithms for SAT were developed during the 2000s and have contributed to dramatic advances in the ability to automatically solve problem instances involving tens of thousands of variables and millions of constraints (i.e. clauses).<ref name="Codish.Ohrimenko.Stuckey.2007">{{citation |title=Principles and Practice of Constraint Programming – CP 2007|series=Lecture Notes in Computer Science|volume=4741|year=2007|pages=544–558|contribution=Propagation = Lazy Clause Generation|first1=Olga|last1=Ohrimenko |first2=Peter J.|last2=Stuckey|first3=Michael|last3=Codish|doi=10.1007/978-3-540-74970-7_39|isbn=978-3-540-74969-1 |quote=modern SAT solvers can often handle problems with millions of constraints and hundreds of thousands of variables |citeseerx=10.1.1.70.5471}}.</ref> Examples of such problems in [[electronic design automation]] (EDA) include [[formal equivalence checking]], [[model checking]], [[formal verification]] of [[microprocessor|pipelined microprocessors]],<ref name="Bryant.German.Velev.1999"/> [[automatic test pattern generation]], [[routing (electronic design automation)|routing]] of [[FPGA]]s,<ref>{{Cite journal |last1=Gi-Joon Nam |last2=Sakallah |first2=K. A. |last3=Rutenbar |first3=R. A. |title=A new FPGA detailed routing approach via search-based Boolean satisfiability |journal=IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems |volume=21 |issue=6 |pages=674 |year=2002 |url=http://cs-rutenbar.web.engr.illinois.edu/wp-content/uploads/2012/10/rutenbar-sattranscad02.pdf |doi=10.1109/TCAD.2002.1004311 |access-date=2015-09-04 |archive-date=2016-03-15 |archive-url=https://web.archive.org/web/20160315003856/http://cs-rutenbar.web.engr.illinois.edu/wp-content/uploads/2012/10/rutenbar-sattranscad02.pdf |url-status=dead }}</ref> [[Automated planning and scheduling|planning]], and [[Scheduling algorithm|scheduling problems]], and so on. A SAT-solving engine is also considered to be an essential component in the [[electronic design automation]] toolbox.
Major techniques used by modern SAT solvers include the [[Davis–Putnam–Logemann–Loveland algorithm]] (or DPLL), [[conflict-driven clause learning]] (CDCL), and [[stochastic]] [[Local search (constraint satisfaction)|local search]] algorithms such as [[WalkSAT]]. Almost all SAT solvers include time-outs, so they will terminate in reasonable time even if they cannot find a solution. Different SAT solvers will find different instances easy or hard, and some excel at proving unsatisfiability, and others at finding solutions. Recent attempts have been made to learn an instance's satisfiability using deep learning techniques.<ref>{{cite arXiv |last1=Selsam |first1=Daniel |last2=Lamm |first2=Matthew |last3=Bünz |first3=Benedikt |last4=Liang |first4=Percy |last5=de Moura |first5=Leonardo |last6=Dill |first6=David L. |title=Learning a SAT Solver from Single-Bit Supervision |eprint=1802.03685 |date=11 March 2019|class=cs.AI }}</ref>


Major techniques used by modern SAT solvers include the [[Davis–Putnam–Logemann–Loveland algorithm]] (or DPLL), [[conflict-driven clause learning]] (CDCL), and [[stochastic]] [[Local search (constraint satisfaction)|local search]] algorithms such as [[WalkSAT]]. Almost all SAT solvers include time-outs, so they will terminate in reasonable time even if they cannot find a solution. Different SAT solvers will find different instances easy or hard, and some excel at proving unsatisfiability, and others at finding solutions. Recent{{When|date=June 2024}} attempts have been made to learn an instance's satisfiability using deep learning techniques.<ref>{{cite arXiv |last1=Selsam |first1=Daniel |last2=Lamm |first2=Matthew |last3=Bünz |first3=Benedikt |last4=Liang |first4=Percy |last5=de Moura |first5=Leonardo |last6=Dill |first6=David L. |title=Learning a SAT Solver from Single-Bit Supervision |eprint=1802.03685 |date=11 March 2019|class=cs.AI }}</ref>
SAT solvers are developed and compared in SAT-solving contests.<ref>{{cite web|url=http://www.satcompetition.org/ |title=The international SAT Competitions web page|access-date=2007-11-15}}</ref> Modern SAT solvers are also having significant impact on the fields of software verification, constraint solving in artificial intelligence, and [[operations research]], among others.


SAT solvers are developed and compared in SAT-solving contests.<ref>{{cite web|url=http://www.satcompetition.org/ |title=The international SAT Competitions web page|access-date=2007-11-15}}</ref> Modern SAT solvers are also having significant impact on the fields of software verification, constraint solving in artificial intelligence, and operations research, among others.
Theoretical algorithms with increasingly better worst-case runtime guarantees have been given in the last decades, including an <math>O^*(1.0638^L)</math> algorithm for clause sets of length (total literal count) <math>L</math>,<ref>{{cite report |title=Further improvements for SAT in terms of formula length |author=Junqiang Peng and Mingyu Xiao |date=Aug 2022 |arxiv=2105.06131 |type=Technical Report}}</ref><ref>{{cite journal |author=Junqiang Peng and Mingyu Xiao |date=Oct 2023 |title=Further improvements for SAT in terms of formula length  |journal=[[Information and Computation]] |volume=294 |pages=Article number 105085  |article-number=105085 |doi=10.1016/j.ic.2023.105085 }}</ref>
an <math>O^*(1.2226^m)</math> algorithm for sets of <math>m</math> clauses,<ref>{{cite report | arxiv=2007.03829 | author=Huairui Chu and Mingyu Xiao and Zhe Zhang | title=An improved upper bound for SAT | institution=arxiv | type=Technical Report | number=2007.03829 |  date=Jul 2020 }}</ref><ref>{{cite journal | doi=10.1016/j.tcs.2021.06.045 | author=Huairui Chu and Mingyu Xiao and Zhe Zhang | title=An improved upper bound for SAT | journal=[[Theoretical Computer Science]] | volume=887 |  pages=51&ndash;62 | date=Oct 2021 }}</ref> and an <math>O^*(1.32793^n)</math> algorithm for 3-SAT with <math>n</math> variables.<ref>{{cite conference | doi=10.4230/LIPIcs.ICALP.2018.88 | author=S. Liu | title=Chain, Generalization of Covering Code, and Deterministic Algorithm for ''k''-SAT | editor=I. Chatzigiannakis and C. Kaklamanis and D. Marx and D. Sannella | conference=Proc. ICALP | publisher=Schloss Dagstuhl | series=LIPIcs | volume=107 | pages=88:1&ndash;13 | date=Jul 2018 | doi-access=free }}</ref> Here, the notation "<math>O^*(.)</math>" means "up to a polynomial factor", i.e. <math>O^*(f(n)) = O(f(n)n^{O(1)})</math>. Earlier runtime guarantees are shown in the diagram.


==See also==
==See also==
Line 488: Line 265:
* {{Cite journal |last1=Clarke |first1=E. |last2=Biere |first2=A. |last3=Raimi |first3=R. |last4=Zhu |first4=Y. |journal=Formal Methods in System Design |volume=19 |pages=7–34 |year=2001 |title=Bounded Model Checking Using Satisfiability Solving |doi=10.1023/A:1011276507260 |s2cid=2484208}}
* {{Cite journal |last1=Clarke |first1=E. |last2=Biere |first2=A. |last3=Raimi |first3=R. |last4=Zhu |first4=Y. |journal=Formal Methods in System Design |volume=19 |pages=7–34 |year=2001 |title=Bounded Model Checking Using Satisfiability Solving |doi=10.1023/A:1011276507260 |s2cid=2484208}}
* {{Cite book | last1 = Giunchiglia | first1 = E. | last2 = Tacchella | first2 = A. | editor1-last = Giunchiglia | editor1-first = Enrico | editor2-first = Armando | title = Theory and Applications of Satisfiability Testing | series = Lecture Notes in Computer Science | volume = 2919 | year = 2004 | isbn = 978-3-540-20851-8 | doi = 10.1007/b95238 | s2cid = 31129008 | editor2-last = Tacchella}}
* {{Cite book | last1 = Giunchiglia | first1 = E. | last2 = Tacchella | first2 = A. | editor1-last = Giunchiglia | editor1-first = Enrico | editor2-first = Armando | title = Theory and Applications of Satisfiability Testing | series = Lecture Notes in Computer Science | volume = 2919 | year = 2004 | isbn = 978-3-540-20851-8 | doi = 10.1007/b95238 | s2cid = 31129008 | editor2-last = Tacchella}}
* {{Cite journal | last1 = Babic | first1 = D. | last2 = Bingham | first2 = J. | last3 = Hu | first3 = A. J. | title = B-Cubing: New Possibilities for Efficient SAT-Solving | journal = IEEE Transactions on Computers | volume = 55 | issue = 11 | pages = 1315 | year = 2006 | url = http://www.domagoj-babic.com/uploads/Pubs/TCOM06/tcom06.pdf| archive-url = https://web.archive.org/web/20161023223352/http://www.domagoj-babic.com/uploads/Pubs/TCOM06/tcom06.pdf| url-status = usurped| archive-date = October 23, 2016| doi = 10.1109/TC.2006.175| s2cid = 14819050 }}
* {{Cite journal | last1 = Babic | first1 = D. | last2 = Bingham | first2 = J. | last3 = Hu | first3 = A. J. | title = B-Cubing: New Possibilities for Efficient SAT-Solving | journal = IEEE Transactions on Computers | volume = 55 | issue = 11 | pages = 1315 | year = 2006 | url = http://www.domagoj-babic.com/uploads/Pubs/TCOM06/tcom06.pdf| archive-url = https://web.archive.org/web/20161023223352/http://www.domagoj-babic.com/uploads/Pubs/TCOM06/tcom06.pdf| url-status = usurped| archive-date = October 23, 2016| doi = 10.1109/TC.2006.175| bibcode = 2006ITCmp..55.1315B | s2cid = 14819050 }}
* {{Cite book | last1 = Rodriguez | first1 = C. | last2 = Villagra | first2 = M. | last3 = Baran | first3 = B. | chapter = Asynchronous team algorithms for Boolean Satisfiability | title = 2007 2nd Bio-Inspired Models of Network, Information and Computing Systems | pages = 66–69 | year = 2007 | chapter-url = http://www.cc.pol.una.py/lcca/publicaciones/optimizacion/2007/Asynchronous%20Team%20Algorithms%20for%20Boolean%20Satisfiability.pdf| doi = 10.1109/BIMNICS.2007.4610083| s2cid = 15185219 }}
* {{Cite book | last1 = Rodriguez | first1 = C. | last2 = Villagra | first2 = M. | last3 = Baran | first3 = B. | chapter = Asynchronous team algorithms for Boolean Satisfiability | title = 2007 2nd Bio-Inspired Models of Network, Information and Computing Systems | pages = 66–69 | year = 2007 | chapter-url = http://www.cc.pol.una.py/lcca/publicaciones/optimizacion/2007/Asynchronous%20Team%20Algorithms%20for%20Boolean%20Satisfiability.pdf| doi = 10.1109/BIMNICS.2007.4610083| s2cid = 15185219 }}
* {{cite book |editor1-first=Frank Van |editor1-last=Harmelen |editor2-first=Vladimir |editor2-last=Lifschitz |editor3-first=Bruce |editor3-last=Porter |title=Handbook of knowledge representation|year=2008|publisher=Elsevier|isbn=978-0-444-52211-5|pages=89–134|first1=Carla P. |last1=Gomes|author1-link=Carla Gomes |first2=Henry |last2=Kautz |first3=Ashish |last3=Sabharwal |first4=Bart |last4=Selman |chapter=Satisfiability Solvers|doi=10.1016/S1574-6526(07)03002-7|series=Foundations of Artificial Intelligence|volume=3}}
* {{cite book |editor1-first=Frank Van |editor1-last=Harmelen |editor2-first=Vladimir |editor2-last=Lifschitz |editor3-first=Bruce |editor3-last=Porter |title=Handbook of knowledge representation|year=2008|publisher=Elsevier|isbn=978-0-444-52211-5|pages=89–134|first1=Carla P. |last1=Gomes|author1-link=Carla Gomes |first2=Henry |last2=Kautz |first3=Ashish |last3=Sabharwal |first4=Bart |last4=Selman |chapter=Satisfiability Solvers|doi=10.1016/S1574-6526(07)03002-7|series=Foundations of Artificial Intelligence|volume=3}}

Latest revision as of 02:49, 5 November 2025

Template:Short description Script error: No such module "redirect hatnote".

In logic and computer science, the Boolean satisfiability problem (sometimes called propositional satisfiability problem and abbreviated SATISFIABILITY, SAT or B-SAT) asks whether there exists an interpretation that satisfies a given Boolean formula. In other words, it asks whether the formula's variables can be consistently replaced by the values TRUE or FALSE to make the formula evaluate to TRUE. If this is the case, the formula is called satisfiable, else unsatisfiable. For example, the formula "a AND NOT b" is satisfiable because one can find the values a = TRUE and b = FALSE, which make (a AND NOT b) = TRUE. In contrast, "a AND NOT a" is unsatisfiable.

SAT is the first problem that was proven to be NP-complete—this is the Cook–Levin theorem. This means that all problems in the complexity class NP, which includes a wide range of natural decision and optimization problems, are at most as difficult to solve as SAT. There is no known algorithm that efficiently solves each SAT problem (where "efficiently" means "deterministically in polynomial time"). Although such an algorithm is generally believed not to exist, this belief has not been proven or disproven mathematically. Resolving the question of whether SAT has a polynomial-time algorithm would settle the P versus NP problem - one of the most important open problems in the theory of computing.[1][2]

Nevertheless, as of 2007, heuristic SAT-algorithms are able to solve problem instances involving tens of thousands of variables and formulas consisting of millions of symbols,[3] which is sufficient for many practical SAT problems occurring in artificial intelligence, circuit design,[4] and automatic theorem proving.

Definitions

A propositional logic formula, also called Boolean expression, is built from variables, operators AND (conjunction, also denoted by ∧), OR (disjunction, ∨), NOT (negation, ¬), and parentheses. A formula is said to be satisfiable if it can be made TRUE by assigning appropriate logical values (i.e. TRUE, FALSE) to its variables. The Boolean satisfiability problem (SAT) is, given a formula, to check whether it is satisfiable. This decision problem is of central importance in many areas of computer science, including theoretical computer science, complexity theory,[5][6] algorithmics, cryptography[7][8] and artificial intelligence.[9]Template:Additional citation needed

Conjunctive normal form

A literal is either a variable (in which case it is called a positive literal) or the negation of a variable (called a negative literal). A clause is a disjunction of literals (or a single literal). A clause is called a Horn clause if it contains at most one positive literal. A formula is in conjunctive normal form (CNF) if it is a conjunction of clauses (or a single clause).

For example, Template:Math is a positive literal, Template:Math is a negative literal, and Template:Math is a clause. The formula Template:Math is in conjunctive normal form; its first and third clauses are Horn clauses, but its second clause is not. The formula is satisfiable, by choosing x1 = FALSE, x2 = FALSE, and x3 arbitrarily, since (FALSE ∨ ¬FALSE) ∧ (¬FALSE ∨ FALSE ∨ x3) ∧ ¬FALSE evaluates to (FALSE ∨ TRUE) ∧ (TRUE ∨ FALSE ∨ x3) ∧ TRUE, and in turn to TRUE ∧ TRUE ∧ TRUE (i.e. to TRUE). In contrast, the CNF formula a ∧ ¬a, consisting of two clauses of one literal, is unsatisfiable, since for a=TRUE or a=FALSE it evaluates to TRUE ∧ ¬TRUE (i.e., FALSE) or FALSE ∧ ¬FALSE (i.e., again FALSE), respectively.

For some versions of the SAT problem, it is useful to define the notion of a generalized conjunctive normal form formula, viz. as a conjunction of arbitrarily many generalized clauses, the latter being of the form Template:Math for some Boolean function R and (ordinary) literals Template:Mvar. Different sets of allowed Boolean functions lead to different problem versions. As an example, Rx,a,b) is a generalized clause, and Rx,a,b) ∧ R(b,y,c) ∧ R(c,dz) is a generalized conjunctive normal form. This formula is used below, with R being the ternary operator that is TRUE just when exactly one of its arguments is.

Using the laws of Boolean algebra, every propositional logic formula can be transformed into an equivalent conjunctive normal form, which may, however, be exponentially longer. For example, transforming the formula (x1y1) ∨ (x2y2) ∨ ... ∨ (xnyn) into conjunctive normal form yields Template:Block indent Template:Block indent Template:Block indent Template:Block indent Template:Block indent Template:Block indent Template:Block indent Template:Block indent while the former is a disjunction of n conjunctions of 2 variables, the latter consists of 2n clauses of n variables.

However, with use of the Tseytin transformation, we may find an equisatisfiable conjunctive normal form formula with length linear in the size of the original propositional logic formula.

Complexity

Script error: No such module "Labelled list hatnote".

SAT was the first problem known to be NP-complete, as proved by Stephen Cook at the University of Toronto in 1971[10] and independently by Leonid Levin at the Russian Academy of Sciences in 1973.[11] Until that time, the concept of an NP-complete problem did not even exist. The proof shows how every decision problem in the complexity class NP can be reduced to the SAT problem for CNFTemplate:Efn formulas, sometimes called CNFSAT. A useful property of Cook's reduction is that it preserves the number of accepting answers. For example, deciding whether a given graph has a 3-coloring is another problem in NP; if a graph has 17 valid 3-colorings, then the SAT formula produced by the Cook–Levin reduction will have 17 satisfying assignments.

NP-completeness only refers to the run-time of the worst case instances. Many of the instances that occur in practical applications can be solved much more quickly. See §Algorithms for solving SAT below.

3-satisfiability

File:Sat reduced to Clique from Sipser.svg
The 3-SAT instance Template:Math reduced to a clique problem. The green vertices form a 3-clique and correspond to the satisfying assignment x=FALSE, y=TRUE.

Like the satisfiability problem for arbitrary formulas, determining the satisfiability of a formula in conjunctive normal form where each clause is limited to at most three literals is NP-complete also; this problem is called 3-SAT, 3CNFSAT, or 3-satisfiability. To reduce the unrestricted SAT problem to 3-SAT, transform each clause Template:Math to a conjunction of Template:Math clauses

Template:Block indent Template:Block indent Template:Block indent Template:Block indent Template:Block indent

where Template:Math are fresh variables not occurring elsewhere. Although the two formulas are not logically equivalent, they are equisatisfiable. The formula resulting from transforming all clauses is at most 3 times as long as its original; that is, the length growth is polynomial.Template:Sfnp

3-SAT is one of Karp's 21 NP-complete problems, and it is used as a starting point for proving that other problems are also NP-hard.Template:Efn This is done by polynomial-time reduction from 3-SAT to the other problem. An example of a problem where this method has been used is the clique problem: given a CNF formula consisting of c clauses, the corresponding graph consists of a vertex for each literal, and an edge between each two non-contradictingTemplate:Efn literals from different clauses; see the picture. The graph has a c-clique if and only if the formula is satisfiable.Template:Sfnp

There is a simple randomized algorithm due to Schöning (1999) that runs in time (4/3)n where n is the number of variables in the 3-SAT proposition, and succeeds with high probability to correctly decide 3-SAT.[12]

The exponential time hypothesis asserts that no algorithm can solve 3-SAT (or indeed k-SAT for any Template:Math) in Template:Math time (that is, fundamentally faster than exponential in n).

Selman, Mitchell, and Levesque (1996) give empirical data on the difficulty of randomly generated 3-SAT formulas, depending on their size parameters. Difficulty is measured in number recursive calls made by a DPLL algorithm. They identified a phase transition region from almost-certainly-satisfiable to almost-certainly-unsatisfiable formulas at the clauses-to-variables ratio at about 4.26.[13]

3-satisfiability can be generalized to k-satisfiability (k-SAT, also k-CNF-SAT), when formulas in CNF are considered with each clause containing up to k literals.Script error: No such module "Unsubst". However, since for any k ≥ 3, this problem can neither be easier than 3-SAT nor harder than SAT, and the latter two are NP-complete, so must be k-SAT.

Some authors restrict k-SAT to CNF formulas with exactly k literals.Script error: No such module "Unsubst". This does not lead to a different complexity class either, as each clause Template:Math with j < k literals can be padded with fixed dummy variables to Template:Math. After padding all clauses, 2k–1 extra clausesTemplate:Efn must be appended to ensure that only Template:Math can lead to a satisfying assignment. Since k does not depend on the formula length, the extra clauses lead to a constant increase in length. For the same reason, it does not matter whether duplicate literals are allowed in clauses, as in Template:Math.

Special instances of 3SAT

Conjunctive normal form

Conjunctive normal form (in particular with 3 literals per clause) is often considered the canonical representation for SAT formulas. As shown above, the general SAT problem reduces to 3-SAT, the problem of determining satisfiability for formulas in this form.

Linear SAT

A 3-SAT formula is Linear SAT (LSAT) if each clause (viewed as a set of literals) intersects at most one other clause, and, moreover, if two clauses intersect, then they have exactly one literal in common. An LSAT formula can be depicted as a set of disjoint semi-closed intervals on a line. Deciding whether an LSAT formula is satisfiable is NP-complete.[14]

2-satisfiability

Script error: No such module "Labelled list hatnote".

SAT is easier if the number of literals in a clause is limited to at most 2, in which case the problem is called 2-SAT. This problem can be solved in polynomial time, and in fact is complete for the complexity class NL. If additionally all OR operations in literals are changed to XOR operations, then the result is called exclusive-or 2-satisfiability, which is a problem complete for the complexity class SL = L.

Horn-satisfiability

Script error: No such module "Labelled list hatnote".

The problem of deciding the satisfiability of a given conjunction of Horn clauses is called Horn-satisfiability, or HORN-SAT. It can be solved in polynomial time by a single step of the unit propagation algorithm, which produces the single minimal model of the set of Horn clauses (w.r.t. the set of literals assigned to TRUE). Horn-satisfiability is P-complete. It can be seen as P's version of the Boolean satisfiability problem. Also, deciding the truth of quantified Horn formulas can be done in polynomial time.[15]

Horn clauses are of interest because they are able to express implication of one variable from a set of other variables. Indeed, one such clause ¬x1 ∨ ... ∨ ¬xny can be rewritten as x1 ∧ ... ∧ xny; that is, if x1,...,xn are all TRUE, then y must be TRUE as well.

A generalization of the class of Horn formulas is that of renameable-Horn formulae, which is the set of formulas that can be placed in Horn form by replacing some variables with their respective negation. For example, (x1 ∨ ¬x2) ∧ (¬x1x2x3) ∧ ¬x1 is not a Horn formula, but can be renamed to the Horn formula (x1 ∨ ¬x2) ∧ (¬x1x2 ∨ ¬y3) ∧ ¬x1 by introducing y3 as negation of x3. In contrast, no renaming of (x1 ∨ ¬x2 ∨ ¬x3) ∧ (¬x1x2x3) ∧ ¬x1 leads to a Horn formula. Checking the existence of such a replacement can be done in linear time; therefore, the satisfiability of such formulae is in P as it can be solved by first performing this replacement and then checking the satisfiability of the resulting Horn formula.

Not 3SAT problems

Disjunctive normal form

SAT is trivial if the formulas are restricted to those in disjunctive normal form, that is, they are a disjunction of conjunctions of literals. Such a formula is indeed satisfiable if and only if at least one of its conjunctions is satisfiable, and a conjunction is satisfiable if and only if it does not contain both x and NOT x for some variable x. This can be checked in linear time. Furthermore, if they are restricted to being in full disjunctive normal form, in which every variable appears exactly once in every conjunction, they can be checked in constant time (each conjunction represents one satisfying assignment). But it can take exponential time and space to convert a general SAT problem to disjunctive normal form; to obtain an example, exchange "∧" and "∨" in the above exponential blow-up example for conjunctive normal forms.

Exactly-1 3-satisfiability

Script error: No such module "Labelled list hatnote".

Another NP-complete variant of the 3-satisfiability problem is the one-in-three 3-SAT (also known variously as 1-in-3-SAT and exactly-1 3-SAT). Given a conjunctive normal form with three literals per clause, the problem is to determine whether there exists a truth assignment to the variables so that each clause has exactly one TRUE literal (and thus exactly two FALSE literals).

Not-all-equal 3-satisfiability

Script error: No such module "Labelled list hatnote".

Another variant is the not-all-equal 3-satisfiability problem (also called NAE3SAT). Given a conjunctive normal form with three literals per clause, the problem is to determine if an assignment to the variables exists such that in no clause all three literals have the same truth value. This problem is NP-complete, too, even if no negation symbols are admitted, by Schaefer's dichotomy theorem.[16]

XOR-satisfiability

Script error: No such module "Labelled list hatnote".

Another special case is the class of problems where each clause contains XOR (i.e. exclusive or) rather than (plain) OR operators. This is in P, since an XOR-SAT formula can also be viewed as a system of linear equations mod 2, and can be solved in cubic time by Gaussian elimination.[17]

Schaefer's dichotomy theorem

Script error: No such module "Labelled list hatnote". The restrictions above (CNF, 2CNF, 3CNF, Horn, XOR-SAT) bound the considered formulae to be conjunctions of subformulas; each restriction states a specific form for all subformulas: for example, only binary clauses can be subformulas in 2CNF.

Schaefer's dichotomy theorem states that, for any restriction to Boolean functions that can be used to form these subformulas, the corresponding satisfiability problem is in P or NP-complete. The membership in P of the satisfiability of 2CNF, Horn, and XOR-SAT formulae are special cases of this theorem.[16]

The following table summarizes some common variants of SAT.

Name Code 3SAT problem? Restrictions Requirements Class
3-satisfiability 3SAT Yes Each clause contains 3 literals. At least one literal must be true. NP-c
2-satisfiability 2SAT Yes Each clause contains 2 literals. At least one literal must be true. NL-c
Exactly-1 3-SAT 1-in-3-SAT No Each clause contains 3 literals. Exactly one literal must be true. NP-c
Exactly-1 Positive 3-SAT 1-in-3-SAT+ No Each clause contains 3 positive literals. Exactly one literal must be true. NP-c
Not-all-equal 3-satisfiability NAE3SAT No Each clause contains 3 literals. Either one or two literals must be true. NP-c
Not-all-equal positive 3-SAT NAE3SAT+ No Each clause contains 3 positive literals. Either one or two literals must be true. NP-c
Planar SAT PL-SAT Yes The incidence graph (clause-variable graph) is planar. At least one literal must be true. NP-c
Linear SAT LSAT Yes Each clause contains 3 literals, intersects at most one other clause, and the intersection is exactly one literal. At least one literal must be true. NP-c
Horn satisfiability HORN-SAT Yes Horn clauses (at most one positive literal). At least one literal must be true. P-c
Xor satisfiability XOR-SAT No Each clause contains XOR operations rather than OR. The XOR of all literals must be true. P

Extensions of SAT

An extension that has gained significant popularity since 2003 is satisfiability modulo theories (SMT) that can enrich CNF formulas with linear constraints, arrays, all-different constraints, uninterpreted functions,[18] etc. Such extensions typically remain NP-complete, but very efficient solvers are now available that can handle many such kinds of constraints.

The satisfiability problem becomes more difficult if both "for all" () and "there exists" () quantifiers are allowed to bind the Boolean variables. An example of such an expression would be Template:Math; it is valid, since for all values of x and y, an appropriate value of z can be found, viz. z=TRUE if both x and y are FALSE, and z=FALSE else. SAT itself (tacitly) uses only ∃ quantifiers. If only ∀ quantifiers are allowed instead, the so-called tautology problem is obtained, which is co-NP-complete. If any number of both quantifiers are allowed, the problem is called the quantified Boolean formula problem (QBF), which can be shown to be PSPACE-complete. It is widely believed that PSPACE-complete problems are strictly harder than any problem in NP, although this has not yet been proved.

Ordinary SAT asks if there is at least one variable assignment that makes the formula true. A variety of variants deal with the number of such assignments:

  • MAJ-SAT asks if at least half of all assignments make the formula TRUE. It is known to be complete for PP, a probabilistic class. Surprisingly, MAJ-kSAT is demonstrated to be in P for every finite integer k.[19]
  • #SAT, the problem of counting how many variable assignments satisfy a formula, is a counting problem, not a decision problem, and is #P-complete.
  • UNIQUE SAT[20] is the problem of determining whether a formula has exactly one assignment. It is complete for US,[21] the complexity class describing problems solvable by a non-deterministic polynomial time Turing machine that accepts when there is exactly one nondeterministic accepting path and rejects otherwise.
  • UNAMBIGUOUS-SAT is the name given to the satisfiability problem when the input formula is promised to have at most one satisfying assignment. The problem is also called USAT.[22] A solving algorithm for UNAMBIGUOUS-SAT is allowed to exhibit any behavior, including endless looping, on a formula having several satisfying assignments. Although this problem seems easier, Valiant and Vazirani have shown[23] that if there is a practical (i.e. randomized polynomial-time) algorithm to solve it, then all problems in NP can be solved just as easily.
  • MAX-SAT, the maximum satisfiability problem, is an FNP generalization of SAT. It asks for the maximum number of clauses which can be satisfied by any assignment. It has efficient approximation algorithms, but is NP-hard to solve exactly. Worse still, it is APX-complete, meaning there is no polynomial-time approximation scheme (PTAS) for this problem unless P=NP.
  • WMSAT is the problem of finding an assignment of minimum weight that satisfy a monotone Boolean formula (i.e. a formula without any negation). Weights of propositional variables are given in the input of the problem. The weight of an assignment is the sum of weights of true variables. That problem is NP-complete (see Th. 1 of[24]).

Other generalizations include satisfiability for first- and second-order logic, constraint satisfaction problems, 0-1 integer programming.

Finding a satisfying assignment

While SAT is a decision problem, the search problem of finding a satisfying assignment reduces to SAT. That is, each algorithm which correctly answers whether an instance of SAT is solvable can be used to find a satisfying assignment. First, the question is asked on the given formula Φ. If the answer is "no", the formula is unsatisfiable. Otherwise, the question is asked on the partly instantiated formula Φ{x1=TRUE}, that is, Φ with the first variable x1 replaced by TRUE, and simplified accordingly. If the answer is "yes", then x1=TRUE, otherwise x1=FALSE. Values of other variables can be found subsequently in the same way. In total, n+1 runs of the algorithm are required, where n is the number of distinct variables in Φ.

This property is used in several theorems in complexity theory:

Algorithms for solving SAT

Script error: No such module "Labelled list hatnote".

File:SatComplexity svg.svg
Exponential complexity of SAT solving vs variable count, clause count, and formula length

Since the SAT problem is NP-complete, only algorithms with exponential worst-case complexity are known for it. In spite of this, efficient and scalable algorithms for SAT were developed during the 2000s and have contributed to dramatic advances in the ability to automatically solve problem instances involving tens of thousands of variables and millions of constraints (i.e. clauses).[3] Examples of such problems in electronic design automation (EDA) include formal equivalence checking, model checking, formal verification of pipelined microprocessors,[18] automatic test pattern generation, routing of FPGAs,[25] planning, and scheduling problems, and so on. A SAT-solving engine is also considered to be an essential component in the electronic design automation toolbox.

Major techniques used by modern SAT solvers include the Davis–Putnam–Logemann–Loveland algorithm (or DPLL), conflict-driven clause learning (CDCL), and stochastic local search algorithms such as WalkSAT. Almost all SAT solvers include time-outs, so they will terminate in reasonable time even if they cannot find a solution. Different SAT solvers will find different instances easy or hard, and some excel at proving unsatisfiability, and others at finding solutions. Recent attempts have been made to learn an instance's satisfiability using deep learning techniques.[26]

SAT solvers are developed and compared in SAT-solving contests.[27] Modern SAT solvers are also having significant impact on the fields of software verification, constraint solving in artificial intelligence, and operations research, among others.

Theoretical algorithms with increasingly better worst-case runtime guarantees have been given in the last decades, including an O*(1.0638L) algorithm for clause sets of length (total literal count) L,[28][29] an O*(1.2226m) algorithm for sets of m clauses,[30][31] and an O*(1.32793n) algorithm for 3-SAT with n variables.[32] Here, the notation "O*(.)" means "up to a polynomial factor", i.e. O*(f(n))=O(f(n)nO(1)). Earlier runtime guarantees are shown in the diagram.

See also

Notes

Template:Notelist

External links

Template:Sister project

References

Template:Reflist

Sources

Further reading

(by date of publication) Template:Refbegin

  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".

Template:Refend

Template:Logic

  1. Script error: No such module "Citation/CS1".
  2. Script error: No such module "Citation/CS1".
  3. a b Script error: No such module "citation/CS1"..
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1". Here: p.86
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "Citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "Citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "Citation/CS1". (pdf) Template:In lang, translated into English by Script error: No such module "Citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "Citation/CS1".
  14. Script error: No such module "Citation/CS1".
  15. Script error: No such module "Citation/CS1".
  16. a b Script error: No such module "citation/CS1".
  17. Script error: No such module "citation/CS1"..
  18. a b R. E. Bryant, S. M. German, and M. N. Velev, Microprocessor Verification Using Efficient Decision Procedures for a Logic of Equality with Uninterpreted Functions, in Analytic Tableaux and Related Methods, pp. 1–13, 1999.
  19. Script error: No such module "citation/CS1".
  20. Script error: No such module "Citation/CS1".
  21. Script error: No such module "citation/CS1".
  22. Script error: No such module "citation/CS1".
  23. Script error: No such module "Citation/CS1".
  24. Script error: No such module "citation/CS1".
  25. Script error: No such module "Citation/CS1".
  26. Script error: No such module "citation/CS1".
  27. Script error: No such module "citation/CS1".
  28. Template:Cite report
  29. Script error: No such module "Citation/CS1".
  30. Template:Cite report
  31. Script error: No such module "Citation/CS1".
  32. Script error: No such module "citation/CS1".