 # 1 NP-completeness Lecture 2: Jan 11. 2 P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.

## Presentation on theme: "1 NP-completeness Lecture 2: Jan 11. 2 P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many."— Presentation transcript:

1 NP-completeness Lecture 2: Jan 11

2 P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many problems that we don’t know how to solve in polynomial time. e.g. factoring, polynomial identities, graph colouring, etc.

3 NP-completeness

4

5

6 Polynomial Time Reduction How to show that a problem R is not easier than a problem Q? Informally, if R can be solved efficiently, we can solve Q efficiently. Formally, we say Q polynomially reduces to R if: 1.Given an instance q of problem Q 2.There is a polynomial time transformation to an instance f(q) of R 3.q is a “yes” instance if and only if f(q) is a “yes” instance Then, if R is polynomial time solvable, then Q is polynomial time solvable. If Q is not polynomial time solvable, then R is not polynomial time solvable.

7 First Example Clique: a subset of vertices S so that for every two vertices u,v in S are joined by an edge. Instance: A graph G=(V,E) and a positive integer k. Question: Is there a clique of size k or more for G? Independent set: a subset of vertices S so that for every two vertices u,v in S are joined by an edge. Instance: A graph G=(V,E) and a positive integer k. Question: Is there an independent of size k or more for G?

8 First Example Instance: A set X and a size s(x) for each x in X. Question: Is there a subset X’ X such that Instance: A set X and a size s(x) for each x in X, and an integer B. Question: Is there a subset X’ X such that PARTITION SUBSET-SUM

9 First Example Instance: A graph G=(V,E). Question: Does G contains a Hamiltonian cycle, i.e. a cycle which visits every vertex exactly once? Instance: A graph G=(V,E). Question: Does G contains a Hamiltonian path, i.e. a path which visits every vertex exactly once? HAMILTONIAN CYCLE HAMILTONIAN PATH

10 NP Two equivalent definitions: Given a solution, we can check in polynomial time whether it is correct. There is a non-deterministic algorithm (a magic algorithm) that can guess the solution and check if it is correct in polynomial time. P is the class of problems that we can find a solution in polynomial time. NP (Non-deterministic polynomial time): A class of decision problems whose solutions can be “verified” in polynomial time. For each “yes” instance, there is a proof that can be checked in polynomial time.

11 Cook’s Theorem Instance: A set of boolean variables and a set of clauses. Question: Is there a truth assignment that satisfies all the clauses? Satisfiability (SAT) (Cook 1970) If one can solve satisfiability in polynomial time, then one can solve all problems in NP in polynomial time.

12 NP-completeness A problem Q is NP-complete if Q is in NP, and if Q can be solved in polynomial time => every problem in NP can be solved in polynomial time. Then Q is the “hardest” problem in NP. Cook’s theorem (1970): SAT is NP-complete. To show a problem Q is NP-complete: show that Q is in NP show that an NPc problem <= Q

13 3-SAT Instance: Collection C = {c1, c2, …, cm} of clauses on a set U of variables such that |ci| = 3 for all 1 <= i <= m. Question: Is there a truth assignment for U that satisfies all the clauses in C? SAT <= 3SAT

14 Vertex Cover Instance: A graph G=(V,E) and a positive integer k. Question: Is there a vertex cover of size k or less for G? Vertex cover: a subset of vertices S so that for every edge (u,v), at least one of u and v belongs to S. 3SAT <= VERTEX COVER

15 Clique Clique: a subset of vertices S so that for every two vertices u,v in S are joined by an edge. Instance: A graph G=(V,E) and a positive integer k. Question: Is there a clique of size k or more for G? VERTEX COVER <= CLIQUE

16 3D Matching Instance: A set M W x X x Y, where W, X, and Y are disjoint sets having the same number q of elements. Question: Does M contains a matching, a subset M’ M such that |M’|=q and no two elements of M’ agree in any coordinate? 3SAT <= 3DM

17 Partition Instance: A set X and a size s(x) for each x in X. Question: Is there a subset X’ X such that 3DM <= PARTITION

18 Hamiltonia Cycle Instance: A graph G=(V,E). Question: Does G contains a Hamiltonian cycle, i.e. a cycle which visits every vertex exactly once? VERTEX COVER <= HAMILTONIAN CYCLE

19 Techniques 1.Restriction Show that a special case is already NP-complete. 2.Local replacement Replace each basic unit by a different structure. 3.Component design Design “components” with specific functionality.

20 Minimum Cover Instance: Collection C of subsets of a set S, and a positive integer k. Question: Does C contains a cover for S of size k or less, that is, a subset C’ C with |C’| <= k and ? 3DM <= Minimum Cover

21 Subgraph Isomorphism Instance: Two graphs G = (V1,E1) and H = (V2,E2). Question: Does G contain a subgraph isomorphic to H? Two graphs G1 = (V1,E1) and G2 = (V2,E2) are isomorphic if  bijection f: V 1 → V 2 u —v in E 1 iff f (u)—f (v) in E 2 Clique <= Subgraph Isomorphism

22 Bounded Degree Spanning Tree Instance: A graph G=(V,E) and a positive integer k. Question: Is there a spanning tree for G in which no vertex has degree > k? A spanning tree is a connected subgraph with |V|-1 edges. Hamiltonian path <= Bounded degree spanning tree

23 Partition into Triangles Instance: A graph G=(V,E) with |V|=3q vertices. Question: Is there a partition of V into q disjoint sets V1, V2, …, Vq of three vertices so that each Vi is a triangle? 3DM <= Partition into Triangles

24 Sequencing within Intervals Instance: A set T of jobs, each has a release time r(t), a deadline d(t) and a length l(t). Question: Does there exist a feasible schedule for T? Partition <= Sequencing within Intervals

25 Open Problems Instance: Two graphs G = (V1,E1) and H = (V2,E2). Question: Is G isomorphic to H? Instance: Given a number k. Question: Is k = p x q for p > 1 and q > 1? Graph Isomorphism Composite Number

26 Conclusion Why people believe that P NP? I can appreciate good music (being able to verify solutions) doesn’t mean that I can compose good music (to find solutions). (from wikipedia) "Proof by contradiction. Assume P = NP. Let y be a proof that P = NP. The proof y can be verified in polynomial time by a competent computer scientist, the existence of which we assert. However, since P = NP, the proof y can be generated in polynomial time by such computer scientists. Since this generation has not yet occurred (despite attempts by such computer scientists to produce a proof), we have a contradiction." http://www.claymath.org/millennium/P_vs_NP/

Download ppt "1 NP-completeness Lecture 2: Jan 11. 2 P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many."

Similar presentations