NPC 3SATs PDF
NPC 3SATs PDF
Viswanathan Iyer
3SAT
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 ?
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
iii) a truth assignment satisfies E if and only if it can be extended to a satisfying truth
assignment for F .
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.
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
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
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.
1-IN-3SAT
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.
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 :
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.
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
efficiently in polynomial time. The following theorem relies on reducing 3SAT to MAX 2SAT.
The proof rewritten slightly essentially follows [2].
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 )}
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.
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 .
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.