0% found this document useful (0 votes)
165 views5 pages

NPC 3SATs PDF

The document discusses the NP-completeness of several problems: 1. 3SAT is shown to be NP-complete by reducing the satisfiability problem (SAT) to 3SAT. 2. 1-IN-3SAT, where exactly one literal must be true in each clause, is also proved to be NP-complete by reducing 3SAT to 1-IN-3SAT. 3. MAX 2SAT, where the goal is to satisfy at least k clauses that have at most two literals each, is NP-complete as well, with a reduction from 3SAT to MAX 2SAT constructed.

Uploaded by

Mardig Hagopian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views5 pages

NPC 3SATs PDF

The document discusses the NP-completeness of several problems: 1. 3SAT is shown to be NP-complete by reducing the satisfiability problem (SAT) to 3SAT. 2. 1-IN-3SAT, where exactly one literal must be true in each clause, is also proved to be NP-complete by reducing 3SAT to 1-IN-3SAT. 3. MAX 2SAT, where the goal is to satisfy at least k clauses that have at most two literals each, is NP-complete as well, with a reduction from 3SAT to MAX 2SAT constructed.

Uploaded by

Mardig Hagopian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Algorithms K.

Viswanathan Iyer

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 = e1 ∧ e2 ∧ ... ∧ ek where each ei is a disjunction of literals. We replace each clause ei (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 ei 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.

National Institute of Technology, Tiruchirappalli Scribe : R. Karthik


Algorithms K. Viswanathan Iyer

2. Suppose an ei is the disjunction of two literals, (x + y). We introduce a new variable z


and replace ei 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 ei is the disjunction of three literals it is already in the form required for 3-CNF, so
we take ei as such to construct F .

4. Suppose ei = (x1 +x2 +...+xm ) for some m ≥ 4. We introduce new variables y1 , y2 , ..., ym−3
and replace ei by the conjunction of clauses

(x1 + x2 + y1 )(x3 + y1 + y2 )(x4 + y2 + y3 ) . . . (xm−2 + ym−4 + ym−3 )(xm−1 + xm + ym−3 ). (1)

If there is a truth assignment τ that satisfies ei then at least one literal (one of the x’s)
in x1 + x2 + ... + xm should be true; say τ makes xj true; that is in

. . . (xj−1 + yj−3 + yj−2 )(xj + yj−2 + yj−1 )(xj+1 + yj−1 + yj ) . . .

Then in (1) above, if we make y1 , y2 , ..., yj−2 true and make yj−1 , yj , ..., ym−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 x1 and x2 are false, y1 must be true
(otherwise this clause will become false and will collapse ei to false) in the first clause;
since x3 is false and y1 is false, y2 must be true to keep the situation alive. By continuing
the argument, we will reason that ym−3 is true. But, alas, xm−1 is false, xm is false and
ym−3 is false and we see that ei 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 C1 , ..., Cm , m > 1; each Ci 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 Ci ?

Let X = {x1 , ..., x5 } be the set of variables. Let the clause set C = {C1 , C2 , C3 } be the
following : C1 = {x1 , x2 , x3 }, C2 = {x1 , x4 , x5 }, C3 = {x2 , x4 , x5 }. With this (X, C) we con-
sider 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 C1 we try setting only x1 = >
in C1 . This when applied to C2 requires x4 = ⊥ and x5 = ⊥ for correct satisfaction of C2 .
But x4 = ⊥ and x5 = ⊥ in C3 requires x2 = > for correct satisfaction of C3 —this violates the
correct satisfaction of C1 . Similarly we get a contradiction if we try setting only x2 = > in C1 .
The only solution is x1 = ⊥, x2 = ⊥ and x3 = > and exactly one of x4 or x5 is >. Note that
as a 3SAT instance (X, C) admits other solutions as well.

National Institute of Technology, Tiruchirappalli


Algorithms K. Viswanathan Iyer

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 Ci = {xi1 , xi2 , xi3 } in 3SAT. In the corresponding 1-IN-3SAT instance, we
will produce the following three clauses with the addition of four new variables ai , bi , ci , di :

Ci1 = {xi1 , ai , bi }, Ci2 = {xi2 , bi , ci }, Ci3 = {xi3 , ci , di }

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 Ci , xi1 = ⊥, xi2 = ⊥ and
xi3 = ⊥. We try to extend this truth assignment to a satisfying truth assignment of 1-IN-
3SAT. In the 1-IN-3SAT instance, in Ci2 since xi2 = ⊥ exactly one of bi or ci should be > so
that Ci2 gets correctly satisfied; if bi = >, Ci1 will not get satisfied; if ci = >, Ci3 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 Ci is > in any solution. We con-
sider the following cases that make Ci = > in the 3SAT instance:
1. xi2 = > (we have 4 cases) : In the 1-IN-3SAT instance we can set bi = ⊥, ci = ⊥ in Ci2 ;
we also set ai = xi1 and di = xi3 so that Ci1 and Ci3 are correctly satisfied.

2. xi2 = ⊥, xi1 = >, xi3 = > : In the 1-IN-3SAT instance we can set ai = >, bi = ⊥, ci = >,
di = ⊥ so that Ci1 , Ci2 and Ci3 are correctly satisfied.

3. Only xi1 = > : In the 1-IN-3SAT instance we set ai = ⊥, bi = >, ci = ⊥, di = ⊥. This


correctly satisfies Ci1 , Ci2 and Ci3 .

4. Only xi3 = > : In the 1-IN-3SAT instance we set ai = ⊥, bi = ⊥, ci = >, di = ⊥. This


correctly satisfies Ci1 , Ci2 and Ci3 .
In summary, a satisfying truth assignment to the variables in 3SAT can be extended to a cor-
rectly 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 C1 , ..., Cp of clauses, each being a disjunction of at most two lit-
erals; 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

National Institute of Technology, Tiruchirappalli


Algorithms K. Viswanathan Iyer

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, keep-
ing 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 ex-
tended 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 C1 , ..., Cm where Ci = {xi , yi , zi }, where
each xi , yi , and zi represents either a variable or its negation and 1 ≤ i ≤ m. From S we build
an instance S 0 of MAX 2SAT as follows. Each Ci in S corresponds to a clause group Ci0 in S 0
where

Ci0 = {(wi ), (xi ), (yi ), (zi ), (xi + yi ), (yi + zi ), (xi + zi ), (wi + xi ), (wi + yi ), (wi + zi )}

where wi is a new variable and 1 ≤ i ≤ m. We set k = 7m.

Each clause in S 0 as constructed above has at most two literals. It can be seen that the
clauses in S 0 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 0 appropriately.

Assume that S is satisfiable. Then in a typical clause Ci = {xi , yi , zi } either one or two or
all the three variables are true.

a) Let xi = T, yi = F, zi = F . With this truth assignment in S 0 , if wi = T , six clauses of Ci0


become true; if wi = F , seven clauses of Ci0 become true.

b) Let xi = T, yi = T, zi = F . This truth assignment in S 0 together with wi = T or wi = F ,


makes seven clauses of Ci0 true.

c) Let xi = T, yi = T, zi = T . With this truth assignment in S 0 , if wi = T , seven clauses of


Ci0 become true; if wi = F , six clauses of Ci0 become true.

In summary, a satisfying truth assignment of S can be extended to a satisfying truth assignment


of S 0 where exactly seven clauses in each clause group get satisfied. Moreover no setting of wi
causes more than seven of the ten clauses to be true in each clause group in S 0 .

Now assume that S is not satisfiable. Then in at least one clause Ci = {xi , yi , zi } in S,
we have xi = F, yi = F, zi = F . With this truth assignment in S 0 , if wi = T , four clauses of Ci0
become true; if wi = F , six clauses of Ci0 become true. That is, if S is not satisfiable, no truth
setting can make at least seven clauses true in each clause group Ci0 .

Since 3SAT is NP-complete, we conclude that MAX 2SAT is also NP-complete.

National Institute of Technology, Tiruchirappalli


Algorithms K. Viswanathan Iyer

References
[1] J. E. Hopcroft, R. Motwani, and J. D. Ullman. Introduction to Automata Theory, Lan-
guages, 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.

National Institute of Technology, Tiruchirappalli

You might also like