Definition
2-SAT4 Algorithm by Literal Enumeration
Given a 2-SAT4 instance, write
wherecontains all clauses of size at most two and are the longer clauses. Enumerate one literal per long clause and test the 2-SAT formula
Accept if at least one test is satisfiable. Becauseis fixed, the algorithm runs in polynomial time.
Construction of the tests
Separate the long clauses without forgetting them
Clauses of length zero, one or two stay in
. An empty clause makes the input unsatisfiable immediately. Deleting the long clauses alone is not enough: an assignment satisfying the remaining formula may violate them. Instead, choose a witness literal for each long clause. For example, let
The tuple
asks whether the short clauses can be satisfied while both and are true. It does not assign all other variables. Choosing one witness per clause also does not require every other literal in that clause to be false.
Force each chosen witness using a unit clause
For tuple
, add the unit clauses to . The resulting formula still has at most two literals per clause, so a 2-SAT solver applies. Different clauses may produce repeated or contradictory witness literals. Repeated unit clauses are harmless; contradictory units make that test unsatisfiable. Neither case requires a special correctness argument outside the solver.
Pseudocode
split F into short clauses F_short and long clauses C[1],...,C[k]
if F contains an empty clause:
return NO
for each tuple (l[1],...,l[k]) in C[1] × ... × C[k]:
H = F_short AND (l[1]) AND ... AND (l[k])
if TwoSAT(H) returns YES:
return YES
return NOWhen
Correctness
A successful test exists exactly when the original formula is satisfiable
Forward: choose witnesses from a satisfying assignment
Let
. Each long clause has some true literal . The algorithm enumerates that tuple. The same assignment satisfies and every unit clause , so its test returns yes. Backward: a successful test satisfies the deleted clauses too
Suppose a test has satisfying assignment
. It satisfies all short clauses. For each long clause , the test forces true, and . Thus is satisfied. Consequently .
Running time
Let
For
For
The fixed bound on the number of long clauses is essential to this analysis. If
Reduction type
The construction produces a polynomial-sized family of 2-SAT instances and accepts if any one is satisfiable. It is therefore a polynomial-time disjunctive Turing reduction: the solver answers are combined by logical OR. All queries can be prepared in advance, so they are nonadaptive.
This construction is not itself a Karp reduction, which must output one target instance with the same yes/no answer. This distinction concerns the construction, not an impossibility of a Karp reduction: once a polynomial decision algorithm is available, one can decide the source and output a fixed satisfiable or unsatisfiable 2-SAT formula.