Top Banner
資資資資 資資資 台台台台台 台台http://www.csie.ntu.edu.tw/~hil/algo/
61

資料結構 與 演算法

Feb 15, 2016

Download

Documents

kioshi

資料結構 與 演算法. 台大資工系 呂學一 http://www.csie.ntu.edu.tw/~hil/algo/. Today. P versus NP NP, NP-complete, NP-hard Polynomial-time reduction. Part 1. P versus NP. Millennium problems. Birch and Swinnerton-Dyer Conjecture Hodge Conjecture Navier-Stokes Equations P vs NP - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

http://www.csie.ntu.edu.tw/~hil/algo/

2TodayP versus NPNP, NP-complete, NP-hardPolynomial-time reduction

Part 1P versus NP

4Millennium problemsBirch and Swinnerton-Dyer Conjecture Hodge Conjecture Navier-Stokes Equations P vs NP Poincar Conjecture Riemann Hypothesis Yang-Mills Theory

5US$1,000,000 per problem

http://www.claymath.org/millennium/6David Hilbert1862 ~ 1943German mathematician Presented 23 problems in 1900

7Hilberts 23 problemsCantor Diophantine Kronecker Abel 8Hilberts 23 problems Schubert Monodromy 9Kurt Godel1906~1978Austrian American mathematicianphilosopherIncompleteness theorems25 years oldOne year after his doctorate degree

10Millennium problemsBirch and Swinnerton-Dyer Conjecture Hodge Conjecture Navier-Stokes Equations P vs NP Poincar Conjecture Riemann Hypothesis Yang-Mills Theory

11Grigory Perelman 1966 ~ Russian mathematicianSolved the Poincar Conjecture in 2003Fields medalist, 2006Declined to accept the award

Vinay DeolalikarAug 2010 claimed a proof of P is not equal to NP.12

P = NP ?

14PThe class P consists of all the problems that can be solved in polynomial time.SortingExact string matchingPrimes

15NPNP consists of the problems that can be solved in non-deterministically polynomial time.

P consists of the problems that can be solved in (deterministically) polynomial time.

16Deterministic algorithmInitial configurationInitial configuration17Non-deterministic algorithmInitial configurationInitial configuration18Non-deterministic bubble sortfor i = 1 to nfor j = 1 to n 1if A[j] < A[i+1] thenEither exchange A[j] and A[i+1] or do nothingThis is not a randomized algorithm.19Vertex Cover ProblemInput:A graph GOutput:A smallest vertex subset of G that covers all edges of G.Known to be NP-complete

20Illustration21Vertex Cover (decision version)Input: A Graph G and an integer k.Output: Does G contain a vertex cover of size no more than k?

(computation version)Yes/No(i.e., decision version)k22A nondeterministic algorithm for Vertex CoverLet set S be emptyFor each vertex x of GNon-deterministically insert x to S.If |S| > k, then output no.If S is not a vertex cover, then output no.Output yes.23Correctness of the algorithmIf the correct answer is yes, then there is a computation path of the algorithm that leads to yes..If the correct answer is no, then all computation paths of the algorithm lead to no..24Non-deterministically solving a problemInitial configurationInitial configurationInitial configurationCorrect answer25Non-deterministically polynomial timepolynomial 26P versus NP

Part 2NP, NP-complete, NP-hard28Common mistakesNP stands for non-polynomial time.Correct version: NP stands for non-deterministic polynomial timeTraveling Salesman Problem is an NP problem, so it is a very difficult problem.Correct version:TSP is an NP-complete (or NP-hard) problem, so it is a very difficult problem.29NP-hardnessA problem is NP-hard if it is as least as hard as all the problems in NP.What does it mean?

30NP-hardnessMore precisely, a problem X is NP-hard if the following condition holds:If X can be solved in (deterministic) polynomial time, then all the problems in NP can be solved in (deterministic) polynomial time.31NP-completenessA problem is NP-complete ifit is NP-hard andit is in NP.In other words, an NP-complete problem is one of the hardest problems in the class NP. In other words, an NP-complete problem is a hardness representative problem of the class NP.32Question:Is there any NP-complete problem?33Stephen A. Cook1939 ~Ph.D., HarvardUC BerkeleyCurrently with University of TorontoTuring Award, 1982

34SAT (Satisfiability)Input: A boolean formula with variables, Output: whether there is a truth assignment for the variables that satisfies the input boolean formula.35Cooks contributionSAT is the first known NP-complete problem. Cook [FOCS 1971] proved thatSAT can be solved in non-deterministic polynomial time.If SAT can be solved in deterministic polynomial time, then so can any NP problems.

36SAT: a key to P versus NPIf one proves that SAT can be solved by a polynomial-time algorithm, then NP = P.If somebody proves that SAT cannot be solved by any polynomial-time algorithm, then NP P.Part 3Polynomial-time reduction38QuestionAre there other NP-complete problems?39Richard N. Karp1935 ~Currently with UC BerkeleyTuring award, 1985

40Karps 21 NP-complete problemsCNF-SAT0-1 INTEGER PROGRAMMING CLIQUESET PACKING VERTEX COVER SET COVERING FEEDBACK ARC SET FEEDBACK NODE SET DIRECTED HAMILTONIAN CIRCUIT UNDIRECTED HAMILTONIAN CIRCUIT 3-SAT 41Karps 21 NP-complete problemsCHROMATIC NUMBER CLIQUE COVER EXACT COVER 3-dimensional MATCHING STEINER TREE HITTING SET KNAPSACK JOB SEQUENCING PARTITION MAX-CUT 42Garey and JohnsonA huge collection of NP-complete problems,All except SAT are proved by Karps polynomial-time reduction.

43ReductionProblem A can be reduced (in polynomial time) to Problem B if the following condition holds: if problem B has a polynomial-time algorithm, then so does problem A.We also call this condition as Problem B can be reduced (in polynomial time) from Problem A.44Question 1:If A is an NP-hard problem and B can be reduced from A, then B is an NP-hard problem?45Question 2:If A is an NP-complete problem and B can be reduced from A, then B is an NP-complete problem?46Question 3:If A is an NP-complete problem and B can be reduced from A, then B is an NP-hard problem?Examples of reductions48Hamiltonian pathInput: A graph G and two nodes x and yOutput: whether or not G admits a path from x to y passing each node of G exactly once.Known to be NP-complete

49Longest path problemInput: a graph G and two nodes x and y.Output: a longest simple path in G from x to y.

Prove that the problem is NP-hard.

50A reductionLet (G, x, y) be an input for the Hamiltonian Path problem.Suppose that the Longest-Path Problem has a polynomial-time algorithm A.We run A(G, x, y). If the output path passing all nodes of G exactly once, we answer yes for the Hamiltonian Path problem; answer no otherwise.51Vertex Cover ProblemInput:A graph GOutput:A smallest vertex subset of G that covers all edges of G.Known to be NP-complete

52Illustration53Max Independent SetInput: A graph GOutput: A maximum subset S of Gs nodes such that any two nodes in S are not adjacent in G.

Prove that Max Independent Set problem is NP-hard.54HintLet G = (V, E) be a graph and S be a subset of V. ThenS is a vertex cover of G if and only if V S is an independent set of G.SV - S55A reductionIf G is an input for the vertex cover problem and A is a polynomial-time algorithm for solving the independent set problem. Then we run A(G) to obtain a maximum independent set X of G. By the hint, we know V X has to be a minimum vertex cover of G.A less obvious exampleA reduction from 3-SAT to Independent set57Literal, clause, and CNF58K-SAT59g(f)60Claim61For more examples