You are on page 1of 8

3-CNF Satisfiability

3-Conjunctive Normal Form (3-CNF):


A Boolean formula that is an AND of clauses, each of which is an OR of exactly
3 distinct literals.
e.g. ( x1 x1 x 2) ( x 3 x 2 x 4) (x1 x 3 x 4)
3-CNF-SAT = { <>: is a satisfiable 3-CNF }

Theorem: 3 CNF SAT NPC


It is obvious that 3 CNF SAT NPC
Now we need to construct the reduction algorithm
SAT

3 CNF SAT

Step 1: Construct a binary parse tree for the input formula, with literals as leaves and
connectives as internal nodes.
see. Fig.36.9 for the parse tree of ((x1 x2) ((x1 x3) x4)) x2
Step 2: Just as we did in pervious theorem, assign a variable for each output of
internal node. Thus, the original formula can be rewritten as the AND of the root
variable and a conjunction of clauses describing the operation of each node.
see. p.944 for an example
Now each clause has at most 3 variables but is not in disjunctive normal form.
For each clause i , identify all possible truth assignments that evaluate it to 0.
Using these assignments, we build a formula in disjunctive normal form that is
equivalent to .
The CNF ofi can be converted by applying DeMorgans law. See p.944 for an
example.
Step 3: We need to convert each clause Ci with less than 3 literals to that with exactly
3 literals.
Case 1. If Ci has 2 literals, say (l 1 l 2) , we can convert it to
(l1 l 2 p ) (l1 l 2 p )

Case 2. If Ci has 1 literal, say l, we can convert it to


(l p q ) (l p q) (l p q ) (l p q)

The resulting formula after this conversion is satisfiable iffis satisfiable.

Besides, the reduction can be done in polynomial time:


Step 1: It introduces at most 1 variable and 1 clause per connective in.
Step 2: Constructing from introduces at most 8 clauses into for each
clause in .
Step 3: Constructing from introduces at most 4 clauses for each clause of
.
Therefore, both the size of the final formula and the time for construction is
polynomial to the size of the input formula.

NP-Complete Problem

See Fig 36.11 for the proof roadmap

Def. A clique in an undirected graph G=(V, E) is a subset V ' V of vertices,


each pair of which is connected by an edge in E.

Def. The clique problem is to find a clique of maximum size in a graph


CLIQUE G , k : G is a graph with a clique of size k

The brute-force algorithm takes

V V V
O(2 )
V V1

Theorem. CLIQUE NPC


The verification algorithm takes G and a subset V of V vertices as the certificate.
It checks whether V is a clique in polynomial time by checking whether, for each pair
u , v V , the edge (u , v ) E .

Lemma. 3 CNF SAT p CLIQUE


Let C1 C 2 Ck be a Boolean formula in 3-CNF with k clauses, where
2

C r l1 r l 2 r l 3 r , 1 r k .

For each clause Cr, place a triple of vertices V1r, V2r, V3r.
r
Regarding edges, 2 vertices (Vi , V ) E iff
1. r s
2. lir and ljs are consistent, i.e. lir is not the negation of ljs.
s

See Fig 36.12 for an example


This graph can be computed in polynomial time (why?)

To show that this transformation of into G is indeed a reduction, we show


1.

Suppose has a satisfying assignment. Therefore, each clauses Ci contains


at least one literal lir that is assigned 1. Besides, any pair of such literals
must be consistent. Therefore, pick one such literal from each clause yields
a set of V of k vertices and V must be a clique.

2.

Suppose G has a clique V of size k. V contains exactly one vertex per


triple. Assigning 1 to each literal lir s.t. Vi r V yields a satisfying
assignment.

See Fig 36.12 for an example

Vertex Cover Problem


Def. A vertex cover of G=(V, E) is a subset V of V s.t. if (u , v ) E , then either
u V or v V

Optimization problem: Find a vertex cover of minimum size.


Decision problem: Determine if there exists a vertex cover of size k.
VERTEX COVER G , k : G has a vertex cov er of size k

Theorem. VERTEX COVER NPC


Proof.
VERTEX COVER NP
1.
The verification algorithm takes G=(V, E) as the input and a subset V of V
of vertices as the certificate. It checks if V k and if every edge (u , v) E ,

whether u V or v V . The execution time is polynomial.


2.

VERTEX COVER NP HARD

We show CLIQUE p VERTEX COVER

Suppose <G, k> is the input of the clique problem. We take G, V k as


the input of the vertex cover problem. To show that the transformation is a
reduction, we show G , V k VERTEX COVER iff G, K CLIQUE

Let V be a clique of size k in G. Then for every u , v V ' ,


that is, V-V is a vertex cover of G

(u , v ) E (u , v ) E

Let V be a vertex cover of G , then for every u , v V V ' ,


i.e. (u , v) E . In other words, V-V is a clique of G.

(u , v ) E

Ex. 36.5.2 in p.960

The subset-sum problem

SUBSET SUM s, t : there exists a subset S ' S s.t. t sS ' s

Theorem. SUBSET SUM NPC


Proof.
1. SUBSET SUM NP
The verification algorithm take S and t as input, and a subset S of S as the

certificate. It checks if

Note that both


2.

s S '

S'

st.

and the verification is polynomial to

SUBSET SUM NP HARD

We show VERTEX COVER p SUBSET SUM

A Graph G=(V, E) can be represented as a 0-1 incidence matrix

1 if edge ej is incident to vi
V E s.t. bij
0 otherwise
4

Note that each column in the incidence matrix has exactly two 1s.

For each vertex Vi, create an integer xi whose base-4 representation consists of a
leading 1 followed by E digits as in the incidence matrix.

For each edge ej E create an integer yi that is just a row in the identity
matrix.
i.e. yi 4 j See Fig 36.14 for a visual example

To construct t, it is observed that a vertex cover of size k consists of k vertices, and


therefore k xis. Besides, each edge must be covered by at least one vertex. (and at
E

most 2). So we define t k 4

E 1

2 4

. This reduction, of course, is polynomial

j 0

time to <G, k>.

We then need to show


(G , K ) VERTEX COVER

iff

( s, t ) SUBSET SUM

Let V of size k be a cover of G, V ' Vi1,Vi 2,...,Vik

S ' xi1, xi 2,..., xik yj : e j is incident on precisely one vertex in V '

It is clear

s t

s S '

Suppose

s t , and

s S '

S ' xi1, xi 2,..., xim yj1, yj 2,..., yjp

We claim m=k and V ' vi1, vi 2,..., vim is a vertex cover of G.


V is a vertex cover because for each edge, at least one and at most 2 xis must
contribute to the sum.
m=k because the only way the leading k in target t can be achieved is by
including k of the xis in the sum.

The Hamiltonian-cycle problem

Theorem. HAM CYCLE NPC


5

Proof.
1.

HAM CYCLE NP

The verification algorithm takes G=(V, E) as the input and a list of V as


the certificate. If checks if each pair of adjacent vertices form an edge in E.
Note that both the list and the verification time is polynomial to G .
2. We show 3 CNF SAT p HAM CYCLE
Consider the A type widget show in Figure 36.15
a

a
A

b
b
Note that (a, a) and (b, b) are exclusive in any Hamiltonian cycle.
Consider the B-type widget shown in Figure 36.16
b1
b2
B
b3
b4

The property with B-type widget has been that there does not exist any
Hamiltonian cycle that connects (b1, b2), (b2, b3), (b3, b4) at the same time.

We now construct a graph consisting of copies of these 2 widgets from a 3-CNF


formula .
1.
Each clause in is represented by a copy of widget B, and
these widgets are serially connected. See Fig 36.17
2.
Each variable xm inis represented by a cycle consisting of at
least 2 vertices xm and xm .
Let the 2 edges (or paths) between xm and xm be denoted as em
and em respectively.
3.
Letij be the jth literal of ith clause in, 1<=i<=k. Ifij =
xm, construct a A-widget between em and (bij, bi,j+1).
4.
If ij= xm , construct a A-widget between em and (bij, bi,j+1).
6

We now want to show that formula is satisfiable iff G contains a


Hamiltonian cycle.

Let the cycle be h. It must follow (b1,1, x1), a path connecting x1 and xm, (xm,
bk,4), a path connecting bk,4 and b1,1.
For the path (e1, e2,,em) connecting x1 and xm, we define a truth
assignment (x1, x2,, xm) where x1=1 iff e1= e1
and x1=0 iff e1 e1
For B-widget (bi1, bi2, bi3, bi4) of each clause i. If (bi1, bi2) is in h, the other
edge in A-widget em must NOT in h. In other words ij evaluates 0.
However, it is clear not every (bij, bi,j+1), j=1, 2, 3 is in h (because of the
property of B-widget).
Therefore i is evaluate to 1, for 1 i k .

Let is satisfied by some truth assignment. By following the same rule, we can
construct a Hamiltonian cycle for G. These rules can indeed be followed.
Finally, we note that graph G can be constructed in polynomial time because
there are k B-widgets, one for each clause in , and 3k A-widgets. Since each
widget is of fixed size, the graph G has O(k) vertices and edges. Thus, this
reduction can be done in polynomial time.

The traveling-salesman problem

The traveling salesman problem: Given a complete graph, where each edge is
associated with a cost, find a tour or a Hamiltonian cycle, such that the total cost
is minimal.

G, C , K : G (V , E ) is a complete graph,

TSP
C is a function from V V Z ,

K Z and G has a tour with cos t at most K

Theorem. TSP NPC


Proof.

TSP NP

The verification algorithm takes G, C, K as the input and a list of V in the


tour as the certificate. It verifies whether the cost incurred to the list is no larger
than K.
TSP NP HARD
HAM CYCLE

TSP

Let G=(V, E) be an instance of HAM-CYCLE. We construct another graph


G=(V, E), where E (i, j ) : i, j V , and the cost function

0 if (i, j) E
C (i , j )
1 otherwise
The instance of TSP is then (G, C, 0), which can be formed in polynomial time.
The proof of G is Hamiltonian iff G has a tour of cost at most 0 is
straightforward.

You might also like