Professional Documents
Culture Documents
3-CNF Satisfiability: X X X X X X X X X
3-CNF Satisfiability: X X X X X X X X X
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 )
NP-Complete Problem
V V V
O(2 )
V V1
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
2.
(u , v ) E (u , v ) E
(u , v ) E
certificate. It checks if
s S '
S'
st.
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
E 1
2 4
j 0
iff
( s, t ) SUBSET SUM
It is clear
s t
s S '
Suppose
s t , and
s S '
Proof.
1.
HAM CYCLE NP
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.
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: 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 ,
TSP NP
TSP
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.