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.
( x
1
x
1
x
2
)
( x
3
x
2
x
4
)
(
x
1
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
P
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
((x
1
x
2
)
((
x
1
x
3
)
x
4
))
x
2
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 of ψ i can be converted by applying DeMorgan’s law. See p.944 for an example.
Step 3 : We need to convert each clause C i
with less than 3 literals to that with exactly
3 literals.
Case 1. If C i
has 2 literals, say ( l
1
l
2
) , we can convert it to
( l
1
l
2
p )
( l
1
l
2
p )
Case 2. If C i
has 1 literal, say l , we can convert it to
( l
p
q )
( l
p
q )
( l
p
q )
( l
p
q )
1
The resulting formula after this conversion is satisfiable iff ψ is 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.
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
V
1
O ( 2
V
)
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.
Let
3
CNF
SAT
C
1
C
2
C k
p
CLIQUE
be a Boolean formula in 3-CNF with k clauses, where
C r
l
1 r l
2 r l
3 r
, 1
r
k .
For each clause C r
, place a triple of vertices V
1 r
, V
2 r
, V
3 r
.
Regarding edges, 2 vertices ( V i r
, V j s )
E iff
1. r
s
2. l i r
and l j s
are consistent, i.e. l i r
is not the negation of l j s
.
2
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 C i
contains at least one literal l i r
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 l i r
s.t. V i r
V
yields a satisfying assignment.
See Fig 36.12 for an example
Def . A vertex cover of G =( V , E ) is a subset
V’
of V s.t. if u
V
or v
V
( u , v )
E , then either
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.
1.
VERTEX
COVER
NP
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
We show
COVER
NP
CLIQUE
p
VERTEX
HARD
COVER
Suppose < G , k > is the input of the clique problem. We take
G , V
k
as the
3
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 ' , ( u , v )
E
( u , v )
E
that is, V -
V’
is a vertex cover of G
Let
V’
be a vertex cover of G , then for every u , v
V
V ' , ( u , v )
E i.e. ( u , v )
E . In other words, V-V’ is a clique of G .
Ex. 36.5.2 in p.960
SUBSET
SUM
s , t
: there exists a subset S '
S s .
t .
t
s
S ' 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
s
S ' s
t .
Note that both S ' and the verification is polynomial to S
2.
SUBSET
We show
SUM
VERTEX
NP
COVER
HARD
p
SUBSET
SUM
A Graph G =( V , E ) can be represented as a 0-1 incidence matrix
V
E s .
t .
b ij
1
0 if edge e j is incident to v i otherwise
Note that each column in the incidence matrix has exactly two 1’s.
For each vertex V i
, create an integer x i
whose base-4 representation consists of a
4
leading 1 followed by E digits as in the incidence matrix.
i.e.
For each edge e j
E create an integer y i that is just a row in the identity matrix. y i
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 x i
’s. Besides, each edge must be covered by at least one vertex. (and at most 2). So we define t
k
4
E j
E
1
0
2
4 j . This reduction, of course, is polynomial 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 ,
S '
x i 1
, x i 2
,..., x ik
y j
: e j
V '
V i 1
, V i 2
,..., V ik
is incident on precisely one vertex in V '
It is clear
s
S ' s
t
Suppose
s
S ' s
t , and
We claim m = k and
S '
x i 1
, x i 2
,..., x im y j 1
, y j 2
,..., y jp
V '
v i 1
, v i 2
,..., v im
is a vertex cover of G .
V’ is a vertex cover because for each edge, at least one and at most 2 x i
’s 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 x i
’s in the sum.
Theorem. HAM
CYCLE
NPC
Proof.
1.
HAM
CYCLE
NP
5
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 x m
in ψ is represented by a cycle consisting of at least 2 vertices x m
’ and x m
’’
.
Let the 2 edges (or paths) between x m
’ and x m
’’ be denoted as e m
and e m
respectively.
3.
Let ψ ij
be the j
’th literal of i
’th clause in ψ, 1<= i<=k . If ψ ij
= x m
, construct a A-widget between e m and ( b ij
, b i,j +1
).
4.
If ψ ij
= x m
, construct a A-widget between e m
and ( b ij
, b i,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 ( b
1,1
, x
1
’
), a path connecting x
1
’
and x m
’’
, (x m
’’, b k,4
), a path connecting b k ,4 and b
1,1
.
For the path ( e
1
’
, e
2
’ ,…, e m
’
) connecting x
1
’
and x m
’
, we define a truth assignment ( x
1
, x
2
,…, x m
) where x
1
=1 iff e
1
’
= e
1
and x
1
=0 iff e
1
e
1
For B-widget ( b i 1
, b i 2
, b i 3
, b i 4
) of each clause i . If ( b i 1
, b i 2
) is in h , the other edge in A-widget e
m must NOT in h . In other words ψ ij
evaluates 0.
However, it is clear not every ( b ij
, b i,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 3 k 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: 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.
TSP
G , C , K
: G
( V , E ) is a complete graph ,
C is a
K
Z function and G from V
V has a tour
Z , with cos t at most K
Theorem. TSP
NPC
Proof.
7
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
HAM
HARD
CYCLE
p
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
C ( i , j )
0
1 if ( i , j )
E 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.
8