3-Satisfiability Is NP-Complete ∗
Total Page:16
File Type:pdf, Size:1020Kb
3-Satisfiability Is NP-complete ∗ Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 [email protected] • These notes are not intended to be complete. They are supplemented with figures, and material that arises during the lecture period in response to questions. ∗Based on Computers and Intractability, Michael R. Garey and David S. Johnson, Freeman, 1979. 1 3-Satisfiability, aka 3SAT, is the restricted form of the Satisfiability problem, where each clause has exactly 3 literals. Theorem: 3-Satisfiability is NP-complete. Proof • It is easy to check whether or not a given truth assignment satisfies a problem instance's clauses in polynomial time: 3SAT 2 NP. • Let { U = fu1; u2; : : : ; ung be a set of variables { C = fc1; c2; : : : ; cmg be a set of clauses making up an arbitrary instance of SAT. 2 • We construct a set C0 of 3-literal clauses on a set U 0 of variables such that C is satisfiable () C0 is satisfiable. • The construction of C0 replaces each clause in C with a set of \equiv- 0 0 alent" clauses in C , based on U and additional variables Uj used only 0 in clauses Cj. m U 0 = U [ 0 U 0 1 B [ j C @ j=1 A and m 0 0 C = [ Cj j=1 • Let an arbitrary clause in C be cj = fz1; z2; : : : ; zkg. 0 0 • The construction of Cj and Uj depends on k, the number of literals in cj. k = 1: 3 0 1 2 Uj = fyj ; yj g 0 1 2 1 2 1 2 1 2 Cj = ffz1; yj ; yj g; fz1; yj ; yj g; fz1; yj ; yj g; fz1; yj ; yj gg 0 All of the clauses in Cj are satisfied if and only if z1 evaluates to T . k = 2: 0 1 Uj = fyj g 0 1 1 Cj = ffz1; z2; yj g; fz1; z2; yj gg 0 All of the clauses in Cj are satisfied if and only if z1 or z2 evaluate to T . k = 3: 0 Uj = ; 0 Cj = fcjg 4 k > 3: 0 i Uj = fyj; 1 ≤ i ≤ k − 3g 0 1 Cj = ffz1; z2; yj gg i i+1 [ ffyj; zi+2; yj g; 1 ≤ i ≤ k − 4g k−3 [ ffyj ; zk−1; zkgg For example, if cj = fz1; z2; z3; z4; z5; z6; z7g then 0 1 1 2 2 3 3 4 4 Cj = ffz1; z2; yj g; fyj ; z3; yj g; fyj ; z4; yj g; fyj ; z5; yj g; fyj ; z6; z7g { 0 If cj is not satisfiable, then Cj is not satisfiable. To see this, eliminate the zis from the clauses. They then cannot all be satisfied. For the example, the reduced set of clauses looks like: 1 1 2 2 3 3 4 4 ffyj g; fyj ; yj g; fyj ; yj g; fyj ; yj g; fyj g: 5 { 0 If cj is satisfiable, then Cj is satisfiable. To see this, let l be the smallest index such that zl evaluates to T . i ∗ If l is 1 or 2, set yj = F . In the example, this looks like 0 Cj = ffz1; z2; F g; fT; z3; F g; fT; z4; F g; fT; z5; F g; fT; z6; z7g i ∗ If l is k − 1 or k, set yj = T . In the example, this looks like 0 Cj = ffz1; z2; T g; fF; z3; T g; fF; z4; T g; fF; z5; T g; fF; z6; z7g ∗ Otherwise, set: i · yj = T for 1 ≤ i ≤ l − 2. i · yj = F for l − 1 ≤ i ≤ k − 3. In the example, if 4 is the smallest index of a literal eval- uating to true, then clauses look like 6 0 Cj = ffz1; z2; T g; fF; z3; T g; fF; z4; F g; fT; z5; F g; fT; z6; z7g The clauses before zl occurs are satisfiable, because they all i contain a yj that is assigned to T ; The clauses after zl occurs are satisfiable, because they all i i contain a yj, where yj is assigned to F . • Thus, the transformation does the right thing. • The transformation clearly can be constructed in polynomial time, given U and C 7.