Polynomial Time P, NP, NP-Hard, and NPC R. Inkulu http://www.iitg

Polynomial Time
P, NP, NP-Hard, and NPC
R. Inkulu
http://www.iitg.ac.in/rinkulu/
(P, NP, NP-Hard, and NPC)
1 / 17
The class P
P = ∪c≥1 DTIME(nc ). In other words, the class P comprises of languages,
each of which has a deterministic polynomial time decider.
ex. Graph Connectivity.
(P, NP, NP-Hard, and NPC)
2 / 17
The class NP
NP = ∪c∈N NTIME(nc ). In other words, the class NP comprises of languages,
each of which has a non-deterministic polynomial time decider.
ex. SAT, 3SAT, CLIQUE, VC, HAM-PATH, SUBSET-SUM
(P, NP, NP-Hard, and NPC)
3 / 17
Yet another definition for the class NP
Equivalently, L ∈ NP whenever there exists a polynomial time DTM, known
as verifier V, such that L = {w | V accepts < w, c > for some certificate
(a.k.a. proof) c}.1
* given a verifier V, construct a NTM N: assuming that V runs in nk time, nondeterministically
generate all proofs of length at most nk
* given a NTM N, construct a verifier V: treat each symbol of proof as a description of the
nondeterministic choice to make at each step
1
The time complexity of a verifier is measured in terms of |w|.
(P, NP, NP-Hard, and NPC)
4 / 17
Padding Technique: a consequence of P = NP
If P = NP, then EXPTIME = NEXPTIME.
|x|c
• L ∈ NEXPTIME ⇒ Lpad = {x12
| x ∈ L} ∈ NP.
• (suppose P = NP) Lpad ∈ P ⇒ L ∈ EXPTIME.
(P, NP, NP-Hard, and NPC)
5 / 17
Karp reduction (a.k.a. polynomial-time reduction)
• Motivation: identifying hardest problems in NP − P
• The mapping reduction function from L1 to L2 is computable in
polynomial time, denoted with ≤p .
• Suppose L1 ≤p L2 . Then,
If L2 ∈ P, then L1 ∈ P
If L1 ∈
/ P, then L2 ∈
/P
(P, NP, NP-Hard, and NPC)
6 / 17
C-Hard and C-Complete
Let C be a complexity class.
• if every language L0 ∈ C is < appropriately >-reducible to L, then L is
said to be C-hard i.e., L is as hard as any problem in C.
• in addition, if L ∈ C then L is said to be C-complete. This set of
problems are considered to be the hardest problems in C.
(P, NP, NP-Hard, and NPC)
7 / 17
NP-hardness
• A language L is said to be NP-hard if ∀L0 ∈NP L0 ≤p L.
• If language L is NP-hard and L ∈ P, then P = NP.
(P, NP, NP-Hard, and NPC)
8 / 17
NP-completeness
• A language L is said to be NP-complete if L is NP-hard and L ∈ NP.
• If language L is NP-complete, then L ∈ P if and only if P = NP.
• If a language B is NP-complete and B ≤p C, for a language C in NP,
then C is NP-complete.
(P, NP, NP-Hard, and NPC)
9 / 17
Relation between P and NP
• Since every DTM is a NDTM, P ⊆ NP.
• However, it is not known whether there exists a polynomial time DTM
for every polynomial time NTM. In other words, it is not known whether
it is P = NP.
But it is widely believed that P 6= NP; hence, P ⊂ NP.
(P, NP, NP-Hard, and NPC)
10 / 17
Conjectured relations
NP−hard
NP
NP−complete
P
ISO: Graph
Isomorphism
SAT
ESP: Euclidean Shortestpaths
in R 3 with polyhedral
obstacles
Graph
Connectivity
ISO ∈ NP; no proof to show that it does/does not belong to P or NPC.
SAT ∈ NPC; no proof to show that it does/does not belong to P.
ESP ∈ NP-hard; again, no proof to show that it does/does not belong to NP.
• Karp’s 21 NP-complete problems.
(P, NP, NP-Hard, and NPC)
11 / 17
Variants of polynomial resource bounds
Consider a problem in which the input comprises of n objects (ex. integers);
after encoding, the input complexity is linear in n and L, where L is the
number of bits used to represent the numerical data. If the esource
requirements of an algorithm asymptotically grows as
• a polynomial in n and independent of L then it is said to be a
(strongly-)polynomial algorithm. Ex. binary search
• a polynomial in both n and L then it is known as a weakly-polynomial.
Ex. GCD finding
• a polynomial in n and exponential in L then it is known as
pseudo-polynomial (appears to be polynomially bounded, but it
exponentially grows with the size of the numeric data). Ex. naively
testing whether the given number is a prime number.
If the input is encoded in unary, the algorithm is polynomial in L.
(P, NP, NP-Hard, and NPC)
12 / 17
Strongly/Weakly NP-complete
• Whenever a NPC problem has an algorithm whose running time is
polynomial on magnitudes of the input data, we term that problem is
weakly NP-complete. (Otherwise, it is strongly NP-complete.)
• In other words, pseudopolynomial time algorithms exist for weakly NPC
problems i.e., these problems admit efficient solutions when the
magnitudes of the input data is small.
ex. (0-1) knapsack (psedopolynomial time algorithm exists)
• Unless P = NP, pseudopolynomial time algorithms do not exist for
strongly NPC problems.
(P, NP, NP-Hard, and NPC)
13 / 17
The class QP
• QP =
S
c
c∈N
DTIME(2(lg n) ) (i.e., for c > 1)
• It is conjectured that NP-complete problems do not have
quasi-polynomial time algorithms
(P, NP, NP-Hard, and NPC)
14 / 17
Two popular conjectures
• Exponential Time Hypothesis (ETH): There is no algorithm that decides
the satisfiability of a 3CNF formula with n variables in 2o(n) , omitting
polynomial factors.
few problems that belong to ETH-hard class: graph k-colorability, finding HAM-cycle, max cliques,
max ind set, vertex graph
• Strong Exponential Time Hypothesis (SETH): There is no algorithm that
decides the satisfiability of a CNF formula with n variables in (2 − )n ,
omitting polynomial factors.
few problems that belong to SETH-hard class: longest common subsequence, dynamic reachability
in graphs, edit distance, Frechet distance
(P, NP, NP-Hard, and NPC)
15 / 17
Few popular classes within P
• 3SUM problem: given a set S of n integers, are there a, b, c ∈ S with
a + b + c = 0?
3SUM conjecture: 3SUM on n integers in {−n3 , . . . , n3 } requires n2−o(1)
time.
few problems in 3SUM-hard class: polygon containment, finding three collinear points in R2 ,
geombase
• OV (orthogonal vectors) problem: given a set S of n vectors in {0, 1}d
for d = O(lg n), are there u, v ∈ S with u.v = 0?
OV conjecture: requires n2−o(1) time
• APSP problem: finding shortest paths between every two nodes of a
given directed graph.
APSP conjecture: APSP on n nodes and O(lg n) bit weights requires
n3−o(1) time.
few problems in APSP-equiv class: graph radius, graph diameter
(P, NP, NP-Hard, and NPC)
16 / 17
Few more popular classes within P
• BMW (boolean matrix multiplication) can be computed in O(nw ) time,
w < 2.38. The best known combinatorial techniques get a runtime of at
3
least lgn4 n time.
BMM conjecture: any combinatorial algorithm for BMW requires
n3−o(1) time
• Hitting set problem: given two sets U and V of n subsets of O(lg n), is
there some u ∈ U such that for all v ∈ V, u ∩ v 6= φ
Hitting set conjecture: requires n2−o(1) time.
• k-clique problem: given a graph on n nodes, are there k nodes that form a
clique?
k-clique conjecture: requires n0.7k time
(P, NP, NP-Hard, and NPC)
17 / 17