28
NP-complete and NP-hard problems • Transitivity of polynomial-time many-one reductions • Definition of complexity class NP – Nondeterministic computation – Problems that can be verified • The P = NP Question – Concept of NP-hard and NP-complete problems

NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

  • View
    234

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

NP-complete and NP-hard problems

• Transitivity of polynomial-time many-one reductions

• Definition of complexity class NP– Nondeterministic computation– Problems that can be verified

• The P = NP Question– Concept of NP-hard and NP-complete problems

Page 2: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Π1 ≤p Π2 & Π2 ≤p Π3 Π1 ≤p Π3

• Let R1 be the reduction used to prove Π1 ≤p Π2

• Let R2 be the reduction used to prove Π2 ≤p Π3

• Let x be an input to Π1

• Define R3(x) to be R2(R1(x))

Page 3: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Answer-preserving argument

• Because R1 is a reduction between Π1 and Π2, we know that R1(x) is a yes input instance of Π2 iff x is a yes input instance of Π1

• Because R2 is a reduction between Π2 and Π3, we know that R2(R1(x)) is a yes input instance of Π3 iff R1(x) is a yes input instance of Π2

• Applying transitivity of iff, we get that R3(x) is a yes input of Π3 iff x is a yes input instance of Π1

Page 4: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Polynomial-time Argument

• Let R1 take time nc1

• Let R2 take time nc2

• Let n be the size of x• Then the R1 call of R3 takes time at most nc1

• Furthermore, R1(x) has size at most max(n,nc1)• Therefore, the R2 call of R3 takes time at most

max(nc2, (nc1)c2) = max (nc2, nc1 c2)• In either case, the total time taken by R3 is

polynomial in n

Page 5: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

NP-complete and NP-hard problems

• Transitivity of polynomial-time many-one reductions

• Definition of complexity class NP– Nondeterministic computation– Problems that can be verified

• The P = NP Question– Concept of NP-hard and NP-complete problems

Page 6: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Traditional definition of NP

• Turing machine model of computation– Simple model where data is on an infinite capacity tape– Only operations are reading char stored in current tape cell,

writing a char to current tape cell, moving tape head left or right one square

• Deterministic versus nondeterministic computation– Deterministic: At any point in time, next move is determined– Nondeterministic: At any point in time, several next moves are

possible

• NP: Class of problems that can be solved by a nondeterminstic turing machine in polynomial time

Page 7: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Turing Machines

A Turing machine has a finite-state-control (its program), a two way infinite tape (its memory) and a read-write head (its program counter)

0 11 110 010 0 1

Head

Tape

…. ….

Finite StateControl

Page 8: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Nondeterministic Running Time

• We measure running time by looking at height of computation tree, NOT number of nodes explored

• Both computation have same height 4 and thus same running time

Deterministic Computation Nondeterministic Computation

Page 9: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

ND computation returning yes

• If any leaf node returns yes, we consider the input to be a yes input.• If all leaf nodes return no, then we consider the input to be a no input.

Yes Result No Result

Page 10: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Showing a problem is in NP

• Hamiltonian Path– Input: Undirected graph G = (V,E)

– Y/N Question: Does G contain a HP?

• Nondeterministic polynomial-time solution– Guess a hamiltonian path P (ordering of vertices)

• V! possible orderings

• For binary tree, V log V height to generate all guesses

– Verify guessed ordering is correct

– Return yes/no if ordering is actually a HP

Page 11: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Illustration

1

2

3

Yes input graph123 132 213 231 312 321

Guess Phase

Nondeterministic

---------------

Verify Phase

Deterministic

1

2

3

No input graph123 132 213 231 312 321

Guess Phase

Nondeterministic

---------------

Verify Phase

Deterministic

Page 12: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Alternate definition of NP

• Preliminary Definitions– Let Π be a decision problem– Let I be an input instance of Π– Let Y(Π) be the set of yes input instances of Π– Let N(Π) be the set of no input instances of Π

• Π belongs to NP iff• For any I ε Y(Π), there exists a “certificate” [solution] C(I)

such that a deterministic algorithm can verify I ε Y(Π) in polynomial time with the help of C(I)

• For any I ε N(Π), no “certificate” [solution] C(I) will convince the algorithm that I ε Y(Π).

Page 13: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Connection

1

2

3

Yes input graph123 132 213 231 312 321

Guess Phase

Nondeterministic

---------------

Verify Phase

Deterministic

1

2

3

No input graph123 132 213 231 312 321

Guess Phase

Nondeterministic

---------------

Verify Phase

Deterministic

•Certificate [Solution]

•A Hamiltonian Path

•C(I1): 123 or 321

•C(I2): none

•Verification Alg:

•Verify certificate is a possible HP

•Check for edge between all adjacent nodes in path

Page 14: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Example: Clique Problem

• Clique Problem– Input: Undirected graph G = (V,E), integer k

– Y/N Question: Does G contain a clique of size ≥ k?

• Certificate– A clique C of size at least k

• Verification algorithm– Verify this is a potential clique of size k

– Verify that all nodes in C are connected in E

Page 15: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Proving a problem is in NP

• You need to describe what the certificate C(I) will be for any input instance I

• You need to describe the verification algorithm – usually trivial

• You need to argue that all yes input instances and only yes input instances have an appropriate certificate C(I)

– also usually trivial (typically do not require)

Page 16: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Example: Vertex Cover

• Vertex Cover– Input: Undirected graph G = (V,E), integer k– Y/N Question: Does G contain a vertex cover of size

≤ k?• Vertex cover: A set of vertices C such that for every edge

(u,v) in E, either u is in C or v is in C (or both are in C)

• Certificate– A vertex cover C of size at most k

• Verification algorithm– Verify C is a potential vertex cover of size at most k– Verify that all edges in E contain a node in C

Page 17: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Example: Satisfiability

• Satisfiability– Input: Set of variables X and set of clauses C

over X– Y/N Question: Is there a satisfying truth

assignment T for the variables in X such that all clauses in C are true?

• Certificate?

• Verification algorithm?

Page 18: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Example: Unsatisfiability

• Unsatisfiability– Input: Set of variables X and set of clauses C over X

– Y/N Question: Is there no satisfying truth assignment T for the variables in X such that all clauses in C are true?

• Certificate and Verification algorithm?• Negative certificate and Negative verification

algorithm?

Page 19: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Example: Exact Vertex Cover

• Exact Vertex Cover– Input: Undirected graph G = (V,E), integer k

– Y/N Question: Does the smallest vertex cover in G have size exactly k?

• Vertex cover: A set of vertices C such that for every edge (u,v) in E, either u is in C or v is in C (or both are in C)

• Certificate and Verification algorithm?• Negative certificate and Negative verification

algorithm?

Page 20: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

NP-complete and NP-hard problems

• Transitivity of polynomial-time many-one reductions

• Definition of complexity class NP– Nondeterministic computation– Problems that can be verified

• The P = NP Question– Concept of NP-hard and NP-complete problems

Page 21: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Definition of NP-hard

• A problem П is NP-hard if – for all П’ εNP П’ ≤p П holds.

• Intuitively, an NP-hard problem П is at least as hard (defined by membership in P) as any problem in NP

Page 22: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Definition of NP-complete

• A problem П is NP-complete if– П is NP-hard and– П is in NP

• Intuitively, an NP-complete problem П is the hardest problem in NP

– That is, if П is in P, then P=NP– If P ≠ NP, then П is not in P

P=NP=NP-complete OR NPP NP-complete

Page 23: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Importance of NP-completenessImportance of “Is P=NP” Question

• Practitioners view– There exist a large number of interesting and

seemingly different problems which have been proven to be NP-complete

– The P=NP question represents the question of whether or not all of these interesting and different problems belong to P

– As the set of NP-complete problems grows, the question becomes more and more interesting

Page 24: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

List of Problem Types from Garey & Johnson, 1979

• Graph Theory• Network Design• Sets and Partitions• Storage and

Retrieval• Sequencing and

Scheduling• Mathematical

Programming

• Algebra and Number Theory

• Games and Puzzles• Logic• Automata and

Languages• Program Optimization• Miscellaneous

Page 25: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Importance of NP-completenessImportance of “Is P=NP” Question

• Theoretician’s view– NP is exactly the set of problems that can be “verified” in

polynomial time– Thus “Is P=NP?” can be rephrased as follows:

• Is it true that any problem that can be “verified” in polynomial time can also be “solved” in polynomial time?

• Hardness Implications– It seems unlikely that all problems that can be verified in

polynomial time also can be solved in polynomial time– If so, then P≠NP– Thus, proving a problem to be NP-complete is a hardness result

as such a problem will not be in P if P≠NP.

Page 26: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Proving a problem П is NP-complete

• Proving a problem П is NP-complete– Show П is in NP (usually easy step)– Prove for all П’ εNP П’ ≤p П holds.

• Show that П’ ≤p П for some NP-hard problemП’– This only works if we have a known NP-hard problem П’ to

reduce from– Also depends on transitivity property proven earlier

• We need to prove the existence of a first NP-hard problem– Cook-Levin Thm

– Developing new reductions is a skill or art form• Over time, it gets easier

Page 27: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Select the right source problem

3-SAT: The old reliable. When none of the other problems seem to work, this is the one to come back to.

Integer Partition: A good choice for number problems.

3-Partition: A good choice for proving “strong” NP-completeness for number problems.

Vertex Cover: A good choice for selection problems.

Hamiltonian Path: A good choice for ordering problems.

Page 28: NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems

Some history

• Cook: “The complexity of theorem-proving procedures” STOC 1971, pp. 151-158

– Polynomial-time reductions– NP complexity class– SAT is NP-complete

• Levin: “Universal sorting problems”, Problemi Peredachi Informatsii 9:3 (1973), pp. 265-266

– Independent discovery of many of the same ideas• Karp: “Reducibility among combinatorial problems”, in

Complexity of Computer Computations, 1972, pp. 85-103

– Showed 21 problems from a wide variety of areas are NP-complete