NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT 3SAT The 3SAT problem is the following. INSTANCE : Given a boolean expression E in conjunctive normal form (CNF) that is the conjunction of clauses, each of which is the disjunction of three distinct literals. QUESTION : Is E satisfiable? The CSAT problem is the following. INSTANCE : Given a boolean expression E in CNF. QUESTION : Is E satisfiable; that is, is there a truth assignment to the variables of E so that each clause in E becomes true? The Cook-Levin theorem asserts that SATISFIABILITY is NP-complete. Although 3-CNF expressions are a subset of the CNF expressions, they are complex enough in the sense that testing for satisfiability turns out to be NP-complete. Theorem : 3SAT is NP-complete. Proof : Evidently 3SAT is in NP, since SAT is in NP. To determine whether a boolean expression E in CNF is satisfiable, nondeterministically guess values for all the variables and then evaluate the expression. If E turns out to be true, then accept. This can be carried out in nondeterministic polynomial time. Thus 3SAT is in NP. To prove NP-completeness, we shall reduce CSAT to 3SAT. Let a given CNF expression be E = e 1 e 2... e k where each e i is a disjunction of literals. We replace each clause e i (as shown below) to create a new expression F such that i) F is a clause in 3SAT form. ii) time taken to construct F is linear in the length of E. iii) a truth assignment satisfies E if and only if it can be extended to a satisfying truth assignment for F. The construction of F is as follows. 1. If an e i is a single literal, say (x) or (x) we introduce two new variables u and v. We replace (x) by the conjunction of four clauses as (x+u+v)(x+u+v)(x+u+v)(x+u+v). Since u and v appear in all combinations, the only way to satisfy all four clauses is to make x true. Scribe : R. Karthik
2. Suppose an e i is the disjunction of two literals, (x + y). We introduce a new variable z and replace e i by the conjunction of two clauses (x + y + z)(x + y + z). As in case 1, the only way to satisfy both clauses is to satisfy (x + y). 3. If an e i is the disjunction of three literals it is already in the form required for 3-CNF, so we take e i as such to construct F. 4. Suppose e i = (x 1 +x 2 +...+x m ) for some m 4. We introduce new variables y 1, y 2,..., y m 3 and replace e i by the conjunction of clauses (x 1 + x 2 + y 1 )(x 3 + y 1 + y 2 )(x 4 + y 2 + y 3 )... (x m 2 + y m 4 + y m 3 )(x m 1 + x m + y m 3 ). (1) If there is a truth assignment τ that satisfies e i then at least one literal (one of the x s) in x 1 + x 2 +... + x m should be true; say τ makes x j true; that is in... (x j 1 + y j 3 + y j 2 )(x j + y j 2 + y j 1 )(x j+1 + y j 1 + y j )... Then in (1) above, if we make y 1, y 2,..., y j 2 true and make y j 1, y j,..., y m 3 false, we satisfy all the clauses of (1). Thus τ can be extended to satisfy these clauses. On the other hand, if τ makes all the x s false we can reason (as follows) that it is not possible to extend τ to make (1) true. The reason is that, since x 1 and x 2 are false, y 1 must be true (otherwise this clause will become false and will collapse e i to false) in the first clause; since x 3 is false and y 1 is false, y 2 must be true to keep the situation alive. By continuing the argument, we will reason that y m 3 is true. But, alas, x m 1 is false, x m is false and y m 3 is false and we see that e i cannot be satisfied. The above argument shows how to reduce an instance E of CSAT to an instance F of 3SAT, such that F is satisfiable if and only if E is satisfiable. The construction evidently requires time that is linear in the length of E, because none of the four cases above expand a clause by more than a factor 32/3 (that is the ratio of symbol counts in case 1) and it is possible to built F in polynomial time. Since CSAT is NP-complete, it follows that 3SAT is also NP-complete. 1-IN-3SAT The 1-IN-3SAT problem is the following. INSTANCE : A collection of clauses C 1,..., C m, m > 1; each C i is a disjunction of exactly three literals. QUESTION : Is there a truth assignment to the variables occurring so that exactly one literal is true in each C i? Let X = {x 1,..., x 5 } be the set of variables. Let the clause set C = {C 1, C 2, C 3 } be the following : C 1 = {x 1, x 2, x 3 }, C 2 = {x 1, x 4, x 5 }, C 3 = {x 2, x 4, x 5 }. With this (X, C) we consider the 1-IN-3SAT problem. We say a clause is correctly satisfied if and only if the clause is satisfied due to exactly one literal in it. To correctly satisfy C 1 we try setting only x 1 = in C 1. This when applied to C 2 requires x 4 = and x 5 = for correct satisfaction of C 2. But x 4 = and x 5 = in C 3 requires x 2 = for correct satisfaction of C 3 this violates the correct satisfaction of C 1. Similarly we get a contradiction if we try setting only x 2 = in C 1. The only solution is x 1 =, x 2 = and x 3 = and exactly one of x 4 or x 5 is. Note that as a 3SAT instance (X, C) admits other solutions as well.
Theorem : 1-IN-3SAT is NP-complete. Proof : It can be argued that 1-IN-3SAT is in NP. To prove that the problem is NP-hard, the following reduction shows 3SAT is polynomially reducible to 1-IN-3SAT, where 3SAT is NP-hard. That is, we need to show that any instance of 3SAT can be efficiently transformed to an instance of 1-IN-3SAT so that 3SAT is satsifiable if and only if 1-IN-3SAT is satisfiable. We consider any C i = {x i1, x i2, x i3 } in 3SAT. In the corresponding 1-IN-3SAT instance, we will produce the following three clauses with the addition of four new variables a i, b i, c i, d i : C i1 = {x i1, a i, b i }, C i2 = {x i2, b i, c i }, C i3 = {x i3, c i, d i } Hence if the 3SAT instance has n variables and m clauses, in the 1-IN-3SAT instance, there will be n + 4m variables and 3m clauses. This transformation can be done efficiently. Assume that the 3SAT instance is not satisfiable. Then in any C i, x i1 =, x i2 = and x i3 =. We try to extend this truth assignment to a satisfying truth assignment of 1-IN- 3SAT. In the 1-IN-3SAT instance, in C i2 since x i2 = exactly one of b i or c i should be so that C i2 gets correctly satisfied; if b i =, C i1 will not get satisfied; if c i =, C i3 will not get satisfied. In other words, if the 3SAT instance is not satisfied then no truth assignment of variables can make the 1-IN-3SAT instance satisfied correctly. Now assume that the 3SAT instance is satisfiable. Every C i is in any solution. We consider the following cases that make C i = in the 3SAT instance: 1. x i2 = (we have 4 cases) : In the 1-IN-3SAT instance we can set b i =, c i = in C i2 ; we also set a i = x i1 and d i = x i3 so that C i1 and C i3 are correctly satisfied. 2. x i2 =, x i1 =, x i3 = : In the 1-IN-3SAT instance we can set a i =, b i =, c i =, d i = so that C i1, C i2 and C i3 are correctly satisfied. 3. Only x i1 = : In the 1-IN-3SAT instance we set a i =, b i =, c i =, d i =. This correctly satisfies C i1, C i2 and C i3. 4. Only x i3 = : In the 1-IN-3SAT instance we set a i =, b i =, c i =, d i =. This correctly satisfies C i1, C i2 and C i3. In summary, a satisfying truth assignment to the variables in 3SAT can be extended to a correctly satisfying truth assignment of the variables in 1-IN-3SAT. We conclude that 1-IN-3SAT is also NP-complete. MAX 2SAT The following is the maximum satisfiability with at most two literals per clause (MAX 2SAT) problem. INSTANCE : Given a set C 1,..., C p of clauses, each being a disjunction of at most two literals; and an integer k where 1 k < p. QUESTION : Is there a truth assignment to the variables so that k or more clauses are satisfied? Note that if k = p, the above problem reduces to the 2SAT problem which can be solved
efficiently in polynomial time. The following theorem relies on reducing 3SAT to MAX 2SAT. The proof rewritten slightly essentially follows [2]. Theorem : MAX 2SAT is NP-complete. Proof : First we note that if a truth setting of variable makes at least k clauses true, then by substituting these truth values we can efficiently check the truth or falsity clause by clause, keeping a counter to hold the number of clauses found to be true so far. Hence MAX 2SAT is in NP. The following is a reduction from 3SAT to MAX 2SAT. That is, given an instance of 3SAT we construct an instance of MAX 2SAT so that a satisfying truth assignment of 3SAT can be extended to a satisfying truth assignment of MAX 2SAT. Note that a satisfying truth assignment is one that makes at least k clauses true in the MAX 2SAT instance. Let S be the instance of 3SAT where the clauses are C 1,..., C m where C i = {x i, y i, z i }, where each x i, y i, and z i represents either a variable or its negation and 1 i m. From S we build an instance S of MAX 2SAT as follows. Each C i in S corresponds to a clause group C i in S where C i = {(w i ), (x i ), (y i ), (z i ), (x i + y i ), (y i + z i ), (x i + z i ), (w i + x i ), (w i + y i ), (w i + z i )} where w i is a new variable and 1 i m. We set k = 7m. Each clause in S as constructed above has at most two literals. It can be seen that the clauses in S can be efficiently generated from the clauses in S in polynomial time. We now argue that a satisfying truth assignment of S exists if and only if it can be extended to a satisfying truth assignment for S appropriately. Assume that S is satisfiable. Then in a typical clause C i = {x i, y i, z i } either one or two or all the three variables are true. a) Let x i = T, y i = F, z i = F. With this truth assignment in S, if w i = T, six clauses of C i become true; if w i = F, seven clauses of C i become true. b) Let x i = T, y i = T, z i = F. This truth assignment in S together with w i = T or w i = F, makes seven clauses of C i true. c) Let x i = T, y i = T, z i = T. With this truth assignment in S, if w i = T, seven clauses of C i become true; if w i = F, six clauses of C i become true. In summary, a satisfying truth assignment of S can be extended to a satisfying truth assignment of S where exactly seven clauses in each clause group get satisfied. Moreover no setting of w i causes more than seven of the ten clauses to be true in each clause group in S. Now assume that S is not satisfiable. Then in at least one clause C i = {x i, y i, z i } in S, we have x i = F, y i = F, z i = F. With this truth assignment in S, if w i = T, four clauses of C i become true; if w i = F, six clauses of C i become true. That is, if S is not satisfiable, no truth setting can make at least seven clauses true in each clause group C i. Since 3SAT is NP-complete, we conclude that MAX 2SAT is also NP-complete.
References [1] J. E. Hopcroft, R. Motwani, and J. D. Ullman. Introduction to Automata Theory, Languages, and Computation, third edition. Pearson Addison-Wesley, 2007. [2] M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NP-complete graph problems. Theo. Comp. Sci., 1(3):237 267, 1976. [3] T. J. Schaefer. The complexity of satisfiability problems, in Proceedings of the 10th Annual ACM Symposium on Theory of Computing, pages 216 226, 1978.