This slideshow shows how to convert (reduce) a general instance of the Formula Satisfiability problem to a version with exactly 3 literals in every clause (so as to be a valid input to the 3-CNF Satisfiability problem) in polynomial time
Consider a general input to SAT: C1.C2.⋯.Cn. Each clause must be one of the following four cases.
1. It contains three literals. For example: (x1+¯x2+x3).
No reduction is needed for this case.
2. It contains only one literal. For example: (x1).
3. It contains two literals. For example: (x1+¯x2).
4. It contains more than three literals. For example: (x1+¯x2+x3⋯+xk) where k>3.
We now show how a clause C from any of the cases above can be replaced by a collection of one or more clauses (Z) such that:
1. All clauses in Z contain exactly 3 literals.
2. C is satisfiable if and only if Z is satisfiable.
Let Ci=li where li is a literal.
Introduce 2 new variables yi,1 and yi,2.
Replace Ci by Zi, a conjunction of four clauses, where
Zi=
(li+yi,1+yi,2)⋅
(li+¯yi,1+yi,2) ⋅
(li+yi,1+¯yi,2) ⋅
(li+¯yi,1+¯yi,2).
I
II
III
IV
Truth Table :
- li
- yi,1
- yi,2
- I
- II
- III
- IV
- Zi
- T
- T
- T
- T
- T
- T
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- T
- T
- F
- F
- T
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- F
- F
- F
- T
- F
- T
- F
- T
- T
- F
- F
- F
- T
- T
- T
- F
- T
- F
- F
- F
- F
- F
- T
- T
- T
- F
When Ci (i.e. li) is True, Zi is true.
When Ci (i.e. li) is False, Zi is false.
Hence Ci can be reduced to Zi where each clause in Zi contains exactly 3 literals and Ci⟺Zi.
Let Ci = (li,1 + li,2) where li,1 and li,2 are literals.
Introduce a new variable yi.
Replace Ci by conjunction of clauses Zi where
Zi=(li,1+li,2+yi)⋅(li,1+li,2+¯yi).
I
II
Truth Table :
- li,1
- li,2
- yi
- Ci
- I
- II
- Zi
- T
- T
- T
- T
- T
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- T
- F
- F
- T
- T
- T
- T
- F
- T
- T
- T
- T
- T
- T
- F
- T
- F
- T
- T
- T
- T
- F
- F
- T
- F
- T
- F
- F
- F
- F
- F
- F
- F
- T
- F
When Ci is true, Zi is true.
When Ci is false, Zi is false.
Hence Ci can be reduced to Zi where each clause in Zi contains exactly 3 literals and Ci⟺Zi.
Let Ci=(li,1+li,2+li,3+⋯+li,k) where k>3.
Introduce k−3 new variables: y1,y2,⋯,yk−3.
Replace Ci with a sequence of clauses Zi where
Zi=(li,1+li,2+y1)⋅(¯y1+li,3+y2)⋯(¯yj−2+li,j+yj−1)⋯(¯yk−4+li,k−2+yk−3)⋅(¯yk−3+li,k−1+li,k).
We need to prove:
a. When Ci is satisfiable,Zi is satisfiable.
b. When Ci is not satisfiable, Zi is not satisfiable.
Ci=(li,1+li,2+li,3+⋯+li,k) where k>3.
Zi=
(
li,1+li,2
+
y1
)⋅(
¯y1
+
li,3
+
y2
)⋯(
¯yj−3
+
li,j−1
+
yj−2
)⋅(
¯yj−2
+
li,j
+
yj−1
)⋅(
¯yj−1
+
li,j+1
+
yj
)⋯(
¯yk−4
+
li,k−2
+
yk−3
)⋅
(
¯yk−3
+
li,k−1+lk
)
When Ci is satisfiable, at least one literal in li,1...li,k is True.
If any of li,1 or li,2 is True, set all the additional variables y1,y2⋯yk−3 to False.
The first term of all the clauses in Zi other than the first has a literal ¯yn which evaluates to True.
Zi has a satisfying assignment.
If any of li,k−1 or li,k is True, set all the additional variables y1,y2⋯yk−3 to True.
The third term of all the clauses in Zi other than the last has a literal yn which evaluates to True.
If li,j (where j∉{1,2,k−1,k}) is True, set y1⋯yj−2 to True and yj−1⋯yk−3 to False.
Let us call the clause in Zi containing li,j in as C'.
--------------------
C′
The third term of all the clauses in Zi left to C′ has a literal yn (where n∈{1..j−2}) which evaluates to True.
The first term of all the clauses in Zi right to C′ has a literal ¯yn (where n∈{j−1..k−3}) which evaluates to True.
Zi has a satisfying assignment.
Hence when Ci is satisfiable, Zi is satisfiable.
When Ci is not satisfiable, NO literal in { li,1⋯li,k } is True.
For Zi to be satisfiable, all its clauses must evaluate to True.
For the first clause to be True, y1=True.
Now for the second clause to be True, y2=True.
Similarly for the third clause to be True, y3=True.
y3=True⇒y4=True⋯⇒yj−2=True⇒yj−1=True⇒yj=True⋯⇒yk−4=True⇒yk−3=True.
The last clause evaluates to False. Hence Zi is NOT SATISFIABLE.
Hence we have proved:
a. When Ci is satisfiable., Zi is satisfiable
b. When Ci is not satisfiable., Zi is not satisfiable
Hence any clause in a SAT expression can be replaced by a conjunction of clauses which contain 3 literals each.
Therefore, an instance of SAT can be reduced to an equivalent instance of 3-SAT in polynomial time.