0% found this document useful (0 votes)
20 views

Advanced Algorithms and Complexity: The Complexity Class N P

The document discusses the complexity class NP. It defines non-deterministic Turing machines and how they can solve problems in NP. It also discusses the relationship between P and NP and provides examples of problems in NP like the independent set problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Advanced Algorithms and Complexity: The Complexity Class N P

The document discusses the complexity class NP. It defines non-deterministic Turing machines and how they can solve problems in NP. It also discusses the relationship between P and NP and provides examples of problems in NP like the independent set problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Advanced Algorithms and Complexity :

Lecture 2
The Complexity Class N P

August 6, 2018

Non deterministic TM (NTM): NTM’s are generalization of DTM in


which at each step the TM may have more than one possible choice of moves.
If this is the case, then it will select one possible next move, and the moves
will continue in this way. Thus, at each step, NTM makes a “guess” of next
move out of the possible choices. There is one important property of NTM’s
that they always make correct “guess”. By “correct” guess we mean that
the TM will select a move from which it is possible to accept the input (if
there is any possibility of accepting the input). The selection of next moves
is biased towards acceptance and we assume that the TM always “knows”
the correct next move to take without any lookahead of future moves.

Formally, we can define an NTM (one-tape) as a 3-tuple (Γ, Q, δ) where Γ is


the finite set of tape symbols (including the input alphabet and the symbols
. and B). Q is the finite set of states (including q0 and qh ). δ : Q × Γ →
(Q, Γ, {L, R, S})∗ is the transition function specifying the possible moves of
NTM. We say that the NTM accepts a language L if for any x : x ∈ L ⇒ ∃
choice of moves for NTM such that it halts in state qh when started with
input x with initial state q0 and head scanning .. x ∈ / L =⇒ NTM halts in
state q ∈ Q − qh for all possible moves when started with input x with initial
state q0 and head scanning ..

1
Time-complexity of NTM: We say that a given NTM M runs in T (n)
time if for every input x ∈ {0, 1}∗ and every sequence of non deterministic
choices, M reached a halting state (either accepting or non-accepting) within
T(|x|) steps.

NTime(T (n)): For every function T : N → N and L ⊆ {0, 1}∗ we say that
L ∈ NTime(T (n)) if ∃ NTM M such that M accepts L and it runs in time
O(T (n)).
The time complexity class N P is defined as N P = ∪c∈N Ntime(nc ).

Example of NTM: Now we will generalize the DTM for Le = {0, 00, 10,
000, 010, 110, ...} into an NTM as follows:
δ(q0 , .) = {(q1 , ., R)}
δ(q1 , 0) = {(q1 , 0, R), (q3 , 0, R)}
((q3 , 0, R) is an incorrect guess. NTM will always ignore this choice for ac-
cepting inputs.)
δ(q1 , 1) = {(q1 , 1, R)}
δ(q1 , B) = {(q2 , B, L)}
δ(q2 , 0) = {(qh , 0, S)}

We can easily verify that this NTM accepts Le . Its time complexity is
O(n) =⇒ Le ∈ Ntime(T (n)) and also Le ∈ N P .

P ⊆ N P : Given any language L ∈ P , it will have a DTM M running


in polynomial time. Since DTM is a special case of NTM, M can also be
viewed as an NTM =⇒ L ∈ N P =⇒ P ⊆ N P .

Certificate definition of N P : P can be viewed as a set of languages rep-


resenting problems that can be efficiently solved. N P can be viewed as a
set of languages representing problems that can be efficiently verified given a
possible solution. This can be seen in an alternative definition of N P using
DTM that runs in polynomial time, takes as input x, and a “certificate”
u which can be viewed as a possible “solution” to the problem “x ∈ L?”.
The DTM should work in polynomial time. This restricts the length of u as
polynomial in |x| : |y| = p(|x|) where p() is a polynomial.

A Language L ⊆ {0, 1}∗ is in N P if there exists a polynomial p : N → N

2
and a polynomial-time DTM M (called the verifier for L) such that for every
x ∈ {0, 1}∗ , x ∈ L ⇐⇒ ∃u ∈ {0, 1}p(|x|) such that M accepts (x, u).
If x ∈ L and u ∈ {0, 1}p(|x|) satisfy M accepts (x, u), then we call u a certifi-
cate for x (with respect to the language L and machine M ).

Proof of P ⊆ N P using certificate definition of N P : Let L ∈ P =⇒


∃ polynomial-time DTM M such that x ∈ L ⇐⇒ M accepts x. This can
be viewed as belonging to the class N P by setting p(|x|) = 0 =⇒ L ∈ N P .

Example of some problems in N P : We consider the independent set


problem. We can create a language corresponding to the decision version of
independent set problems as follows:

INDSET = {(G, k) | G is the adjacency matrix of an undirected graph hav-


ing a subgraph of at least k vertices having no edge between them}.

INDSET ∈ N P by polynomial time NTM:

1. On input (Gn×n , k), append string of length n after the input by using
the first non-deterministic choice as writing 0, and the second non-
deterministic choice as writing 1.

2. Deterministically verify that the vertices corresponding to 1 make an


independent set of size at least k.

Both steps 1 and 2 can be done in polynomial time using NTM.


If (Gn×n , k) ∈ INDSET, then step 1 will correctly guess an independent set
of size at least k. NTM will verify it correctly and accept the input in step
2.
If (Gn×n , k) ∈
/ INDSET, then every guess in step 1 will not be able to make
an independent set of size at least k. NTM will reject the input in step 2
after verifying it to be either not an independent set, or an independent set
of size less than k.

INDSET ∈ N P by using polynomial-time DTM that takes cartifi-


cates as input: On input (Gn×n , k) and the certificate u, the DTM verifies
that |u| = n and that the vertices corresponding to 1 make an independent

3
set of size at least k.

If (Gn×n , k) ∈ INDSET then there exists an independent set of size at least


k. Then u which encodes this independent set will make the DTM accept
the input ((Gn×n , k), u).

If (Gn×n , k) ∈
/ INDSET then there does not exist any independent set of
size at least k. Then every possible encoding of u will not be able to make
the DTM accept the input ((Gn×n , k), u).

We can clearly see that the DTM runs in polynomial time, and that the
length of the certificate = |u| = n is also a polynomial =⇒ INDSET ∈ N P .

The two definitions of N P (using NTM N (x) and DTM D(x, u)) are equiv-
alent:

Suppose we are given a polynomial-time NTM N (x). The DTM D(x, u)


will simulate N (x) where u will be the encoding of non-deterministic choices
of N (x) runs in polynomial-time =⇒ |u| is a polynomial.

Suppose we are given a DTM D(x, u) that runs in polynomial-time and


|u| is a polynomial. On input x, N (x) will non-deterministically guess u
in polynomial time (|u| is polynomial) and then it will simulate D(x, u) in
polynomial-time. Also, the simulation of N (x) by D(x, u) in the previous
case will run in polynomial-time since N (x) runs in poly-time.

You might also like