Definition
2-SAT4 Algorithm by Literal Enumeration
Given a 2-SAT4 instance, write
where contains 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. Because is 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 , the product contains exactly one empty tuple. The algorithm therefore runs the solver once on , rather than performing zero tests.
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 be the total number of literal occurrences in the input, and put , where is the number of variables and the number of clauses. This structural size is polynomially bounded by the input encoding length.
For , the number of tests is
For it is . Each test has size and is solvable in graph operations by the implication-graph algorithm for 2-SAT. Thus the total bound is operations, including constructing the tests. Encoding and indexing overhead remains polynomial.
The fixed bound on the number of long clauses is essential to this analysis. If were part of the input, the bound would not be a polynomial with a fixed exponent.
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.