3SAT
3SAT
and m clauses, where each clause has at most 3 literals, output a satisfying assignment
for f if one exists, or report No if no such assignment exists. Given that SAT is known
to be NP-Complete, prove that the 3SAT problem is NP-Complete.
3SAT is in NP
We first demonstrate that 3SAT is in the class NP. Given an input I to 3SAT, and a candidate
solution S, we can check if each clause in I is satisfied by checking the True/False assignment
from S. As each clause has at most three literals, it is O(1) to check each clause, and there
are m clauses, so it takes O(m) time to verify a candidate solution, which is polynomial.
SAT → 3SAT reduction
We now demonstrate that 3SAT is at least as hard as a problem known to be NP-Complete
by reducing SAT → 3SAT.
Input Transformation:
Let c ∈ C be clauses in the input I to SAT, and c′ ∈ C ′ be clauses in our input to 3SAT.
For each c ∈ C, there are two possibilities. If c has k ≤ 3 literals, simply add c as clause
c′ to C ′ . If, however, c has k > 3 literals,we create c′ as follows: create k − 3 new variables
as Y1 , Y2 , . . . , Yk−3 . Using these new variables, create c′ = (X1 ∨ X2 ∨ Y1 ) ∧ (!Y1 ∨ X3 ∨
Y2 ) . . . (!Yk−4 ∨ Xk−2 ∨ Yk−3 ) ∧ (!Yk−3 ∨ Xk−1 ∨ Xk ) There are m clauses to transform. Each
clause can contain at most n literals, giving a O(mn) runtime which is polynomial.
Output Transformation:
If 3SAT returns NO, we return NO for SAT - there is no satisfying assignment. If 3SAT returns
a satisfying assignment, then we remove the True/False assignments for the added variables
and return the remaining truth assignment as the solution to SAT. There will be at most
n − 3 new variables, removing them takes O(n) linear time.
Correctness Proof:
First we demonstrate that if 3SAT finds a solution, then a solution must exist for SAT. We
note that for any clause c′ that is set to the original clause c, no logic is changed - a truth
assignment which satisfies one will satisfy the other. Now, for each clause c′ that is a con-
version of c, consider each clause c′i . If c′i has all false assignments for those literals X ∈ C
(the original literals), then Yi must be set to true to satisfy c′i . So then !Yi in c′i+1 (the next
clause) will evaluate to false - this forces either X ∈ C or Yi+1 to be true in order to satisfy
c′i+1 . This patterns ensures that the added variables Y1 . . . Yk−3 cannot be used to satisfy all
the c′ clauses - at least one clause must be satisfied by some literal X ∈ C. Therefore, if
3SAT finds a satisfying assignment, then all the original c clauses in SAT will be satisfied.
Now, consider the situation where no assignment can be found to satisfy 3SAT. As we demon-
strated that the additional Y variables cannot be used to satisfy C ′ , this means that no truth
assignment for the literals X ∈ C could be found to satisfy C ′ . Therefore, no assignment
exists which satisfies the original SAT formula.