0% found this document useful (0 votes)
8 views15 pages

CClasses NP

Uploaded by

t24156
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
8 views15 pages

CClasses NP

Uploaded by

t24156
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Complexity Class-NP Polynomial Time Verification

NP-Completeness Verification Algorithms

Let’s examine a problem for which we know of no polynomial-time


decision algorithm and yet, given a certificate, verification is easy.

Hamiltonian Cycle or Circuit in a graph G is a cycle that visits


every vertex of G exactly once and returns to the starting vertex.

(a) has a Hamilton cycle, whereas (b) does not.


Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

(b) happens to be a bipartite graph of odd size. Hamilton path


requires us to start and finish at the same node and visiting the rest
of the vertices exactly once.

Let’s denote the left and right partitions as V5 and V6 respectively.


If we start at some node in V5 , then one needs to visit the rest of
the four vertices in V5 after visiting four vertices in V6 . To return
back to the starting node, we can possibly visit one more vertex in
V6 , but then we would have to return to starting node without
visiting the last vertex of V6 . Thus, we cannot start from the
smaller partition and get a Hamilton Cycle.

Similarly one can also argue that one cannot start from V6 and form
a Hamilton Cycle.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

We can define the Hamiltonian-cycle problem,


“Does a graph G have a hamiltonian cycle?” as a formal language:

HAM − CYCLE = {< G >: G is a hamiltonian graph}


This language is decidable and one can create an algorithm to
decide this language by using brute force.
A graph of m edges requires O(m) size description (using binary

encoding) as input and it may have Ω( m) vertices.

One can test all possible m! possible orderings of the vertices and
check if any of these orderings form
√ Hamilton Cycles. This
algorithm will run in Ω(m!) = Ω(2 m ) time which is not O(mk ) for
any constant k.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

However, given an sequence of vertices one can easily check if this


sequence forms a Hamilton cycle in O(n2 ) time.

If we are given a sequence of vertices say vi , v2 , v11 . . . v9 , vi , one


can simply check if the edges (vi , v2 ),(v2 , v11 ) . . . (v9 , vi ) are present
in the edge set of the graph.

If all the edges are present in the graph, then one conclude that this
sequence of vertices is a valid Hamilton path otherwise, we conclude
that this is an incorrect solution.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

A verification algorithm is defined as being a two-argument


algorithm A, where one argument is an ordinary input string x and
the other is a binary string y called a certificate.

A two-argument algorithm A verifies an input string x if there exists


a certificate y such that A(x, y ) = 1. The language verified by a
verification algorithm A is

L = {x ∈ {0, 1}∗ : there exists a y ∈ {0, 1}∗ such that A(x, y ) = 1}


Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

Intuitively, an algorithm A verifies a language L if for any string


x ∈ L, there exists a certificate y that A can use to prove that
x ∈ L. Moreover, for any string x ∈ / L, there must be no certificate
proving that x ∈ L.

If a graph is hamiltonian, the hamiltonian cycle itself offers enough


information to verify this fact.
Conversely, if a graph is not hamiltonian, there can be no list of
vertices that fools the verification algorithm into believing that the
graph is hamiltonian.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

The complexity class NP is the class of languages that can be


verified by a polynomial-time algorithm.

A language L belongs to NP if and only if there exist a two-input


polynomial-time algorithm A and a constant c such that

L = {x ∈ {0, 1}∗ : there exists a certificate y with |y | = O(x c )

such that A(x, y ) = 1}


We say that algorithm A verifies language L in polynomial time.
Thus, HAM-CYCLE is in NP.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

Lemma
If L ∈ P =⇒ L ∈ NP.

Proof.
Since L ∈ P, there exists and algorithm A which decides L in
polynomial time.

Let there be an algorithm A′ which takes input string x and a


certificate y as part of input. A′ discards certificate y and simulates
input x on A and returns the answer. This algorithm A′ would now
act an a verification algorithm for L.

Thus, there exists a verification algorithm for L and hence L ∈ NP.


Thus, P ⊆ NP
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

co − NP as the set of languages L such that L̄ ∈ NP.

Example:- The formula ϕ is a tautology if it evaluates to 1 for every


assignment of 1 and 0 to the input variables.
Define TAUTOLOGY as the language of boolean formulas that are
tautologies.
TAUTOLOGY ∈ co − NP

If the formula is not a tautology, it means that there exists at least


on assignment which does not evaluate to 1. Such an assignment
acts a certificate to prove that the formula is not a tautology.
Complexity Class-NP Polynomial Time Verification
NP-Completeness Verification Algorithms

Possible characterizations of the three classes. The option (a) is


considered least and the option (d) is considered most likely by most
of the computer scientists.

Four options are based on whether NP and co-NP are equal or not.
If NP and co-NP are equal, then we have the first two possibilities,
otherwise there exist certain problems which lie in both NP and
co-NP, so the last two possibilities capture the cases when NP and
co-NP have non-empty intersection.
Complexity Class-NP
Definition
NP-Completeness

The most compelling reason why theoretical computer scientists


believe that P ̸= NP comes from the existence of the class of
“NP-complete” problems.

This class has the intriguing property that if any NP-complete


problem can be solved in polynomial time, then every problem in
NP has a polynomial-time solution, that is, P = NP.
The NP-complete languages are, in a sense, the “hardest” languages
in NP.

While studying NP-Completeness, we shall show how to compare


the relative “hardness” of languages using a precise notion called
“polynomial-time reducibility”.
Complexity Class-NP
Definition
NP-Completeness

A language L1 is polynomial-time reducible to a language L2 ,


written L1 ≤P L2 if there exists a polynomial-time computable
function f : {0, 1}∗ → {0, 1}∗ such that for all x ∈ {0, 1}∗

x ∈ L1 ⇐⇒ f (x) ∈ L2
f is called the reduction function and the algorithm which computes
f (x) is called the reduction algorithm. The notation L1 ≤P L2
conveys that complexity of L1 is at most (≤) complexity of L2 and
some polynomial term.
Complexity Class-NP
Definition
NP-Completeness

Theorem
If L1 , L2 ⊆ {0, 1}∗ are languages such that L1 ≤P L2 , then L2 ∈ P
implies L1 ∈ P.

Polynomial-time reductions provide a formal means for showing that


one problem is at least as hard as another, to within a
polynomial-time factor.
That is, if L1 ≤P L2 , then L1 is not more than a polynomial factor
harder than L2 .
We can now define the set of NP-complete languages, which are the
hardest problems in NP.
Complexity Class-NP
Definition
NP-Completeness

A language L ⊆ 0, 1∗ is NP-complete if
1. L ∈ NP
2. L′ ≤P L for every L′ ∈ NP
If a language L satisfies property 2, but not necessarily property 1,
we say that L is NP-hard.
Complexity Class-NP
Definition
NP-Completeness

Theorem
If any NP-complete problem is polynomial-time solvable, then
P = NP. Equivalently, if any problem in NP is not polynomial-time
solvable, then no NP-complete problem is polynomial-time solvable.

Proof.
Suppose that L ∈ P and also that L ∈ NPC . For any L′ ∈ NP, we
have L′ ≤P L by property 2 of the definition of NP-completeness.
Thus, by the previous theorem, we also have that L′ ∈ P, which
proves the first statement of the theorem. The second statement is
just the contrapositive of the first statement.

• Since no polynomial-time algorithm for any NP-complete problem


has yet been discovered, a proof that a problem is NP-complete
provides excellent evidence that it is intractable.

You might also like