Professional Documents
Culture Documents
A set of solutions
Mapping
Abstract (encoding) Concrete
problem
problem
Mapping
(encoding)
A set of solutions
∆ /@,R
∆
/∆
,L
1/∆ ,R
p1 q1
,R
0/∆ ,R
@/∆ ,R
/∆
, L ∆
/0 ,L
0 /1
1/1,R
0/0,R
1
p4 p2 q2
0/
∆ /∆ ,L
∆ /1,L
,L
p3 h
prithviraj_cs@rediffmail. NP-complete Problems 17
com
How a DTM works
s
∆ /∆ ,L
∆ /@,R
1/∆ ,R
p1 q1 ∆
∆ ∆1
@ 0 ∆0 ∆0 ∆
1 ∆0 ∆0 ∆0 ∆
∆ /∆ ,R
0/0,L 0/∆ ,R
@/∆ ,R
1/1,L
0/0,R
p4 p2 1/1,R q2
∆ /1,L
∆ /∆ ,L
0/∆ ,L On the input 0001000,
p3 h the TM halts.
prithviraj_cs@rediffmail. NP-complete Problems 18
com
How a DTM works
s
∆ /∆ ,L
∆ /@,R
1/∆ ,R
p1 q1 ∆ ∆0 ∆0 ∆0 ∆
@ 0 ∆0 ∆0 ∆0 ∆
∆ /∆ ,R
0/0,L 0/∆ ,R
@/∆ ,R
1/1,L
0/0,R
p4 p2 1/1,R q2
∆ /1,L On the input 0000000,
∆ /∆ ,L
0/∆ ,L the TM hangs.
p3 h
prithviraj_cs@rediffmail. NP-complete Problems 19
com
Example of NTM
Let L={ww| w∈{0,1}*}
,R r0 0/
@ 0/0,R
L
0, , L /∆ ,R
s /
0 /1 ,L
1 /∆
@ 1/1,R
∆
q0 t0
R
∆ /@,
,L 0/ ,R
0/0,L /∆ ∆
1/1,L 0 ,L /∆
∆
∆ /@,
v L p 1/
∆ /∆ ,R
u ∆
@/∆ ,L
h
∆ ,L /∆
,L ∆ ,R
0/0,R 1/
1/1,R
0/0,L q1 @ t1
1/1,L /∆ ,R
∆ /∆ ,L ,R @
1/ 0/0,R
r1 1/1,R
A language L is accepted/decided in
polynomial time by a Turing machine T if, L
is accepted/decided in O(nk) by a Turing
machine T, for some constant k.
NP P co-NP
C
B
A E F
C
B
A E F
~P P
~S
S
~R ~R
~P P
~S
S
~R ~R
~P
P
Q
Q
R
~R
~P ~R
Q
~P
P
Q
Q
R
~R
~P ~R
Q
Proof:
Let L1 and L2 be languages over Σ , L1≤ L2, and L2 be
in co-NP.
Thus, L1 is co-NP.
prithviraj_cs@rediffmail. NP-complete Problems 49
com
NP-completeness
NP-completeness
A language (or problem) L is NP-hard if, for
any language L' in NP, L' ≤ L.
Proof:
Let f (x)=g1(x)∧g2(x)∧g3(x)∧g4(x)∧g5(x)∧g6(x)∧g7(x).
n N
∆ 0 1 1 0 1 ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆
q0
QN,a
ha
For each time i and states qj0 , qj1 , qj2 , …, qj0 ≠ qj1 ≠
qj2 ≠ … :
To create f(α ):
(A) Create an abstract syntax tree of α so that
internal nodes are logical operators ∧, v, ~, →, or ↔
, and leaf nodes are literals (x or ~x).
→:y2 v:y3
p q ↔ :y4 ~s
∧ (y2 ↔ (p → q )) ~s r q ~r
∧ (y3 ↔ (y4 v ~s))
∧ (y4 ↔ (y5 ↔ y6))
∧ (y5 ↔ (~s v r ))
∧ (y6 ↔ (q ∧ ~r))
α is satisfiable iff β is satisfiable.
prithviraj_cs@rediffmail. NP-complete Problems 69
com
3CNF-SAT is NP-complete
(B) Convert β into CNF.
P ↔ Q is transformed to (P → Q) ∧ (Q → P).
P →Q is transformed to ~P v Q.
~(P v Q) is transformed to ~P ∧ ~Q.
~(P ∧ Q) is transformed to ~P v ~Q.
γ ≡ β
3CNF-SAT is NP-complete.
3CNF-SAT ≤ CLIQUE.
CLIQUE is NP-complete.