Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

Similar documents
Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P

1. Introduction Recap

NP and Computational Intractability

Correctness of Dijkstra s algorithm

Lecture 4: NP and computational intractability

NP and Computational Intractability

Limitations of Algorithm Power

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

NP-Complete Reductions 1

Polynomial-Time Reductions

1.1 P, NP, and NP-complete

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Complete Reductions 2

Computational Intractability 2010/4/15. Lecture 2

Polynomial-time Reductions

Lecture 18: More NP-Complete Problems

Introduction to Complexity Theory

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

NP-Complete problems

Chapter 34: NP-Completeness

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

NP-Complete Problems. More reductions

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP-Completeness. Subhash Suri. May 15, 2018

CS 350 Algorithms and Complexity

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

CS 350 Algorithms and Complexity

IE418 Integer Programming

8.5 Sequencing Problems

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

More NP-Complete Problems

Computational Complexity

SAT, Coloring, Hamiltonian Cycle, TSP

Agenda. What is a complexity class? What are the important complexity classes? How do you prove an algorithm is in a certain class

NP-Completeness. NP-Completeness 1

Chapter 8. NP and Computational Intractability

Complexity, P and NP

SAT, NP, NP-Completeness

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Design and Analysis of Algorithms

Discrete Optimization 2010 Lecture 12 TSP, SAT & Outlook

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Lecture 19: Finish NP-Completeness, conp and Friends

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

ECS122A Handout on NP-Completeness March 12, 2018

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

NP Complete Problems. COMP 215 Lecture 20

CSE 548: (Design and) Analysis of Algorithms

NP Completeness and Approximation Algorithms

Introduction. Pvs.NPExample

Spring Lecture 21 NP-Complete Problems

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

Discrete Optimization 2010 Lecture 12 TSP, SAT & Outlook

No Harder Than. We want these transformations to effectively be a problem-hardness version of #, which we will call No Harder Than.

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

There are two types of problems:

Chapter 3: Proving NP-completeness Results

Algorithm Design and Analysis

CS 6505, Complexity and Algorithms Week 7: NP Completeness

CS21 Decidability and Tractability

Polynomial-time reductions. We have seen several reductions:

P, NP, NP-Complete, and NPhard

Essential facts about NP-completeness:

Theory of Computation Chapter 9

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

COMP Analysis of Algorithms & Data Structures

NP and NP Completeness

Intro to Theory of Computation

Chapter 3. Complexity of algorithms

Algorithm Design and Analysis

Non-Deterministic Time

CS Fall 2011 P and NP Carola Wenk

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

1 Primals and Duals: Zero Sum Games

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Data Structures in Java

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

NP Completeness and Approximation Algorithms

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Algorithm Design and Analysis

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

CS/COE

A An Overview of Complexity Theory for the Algorithm Designer

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

CSI 4105 MIDTERM SOLUTION

NP-Completeness. Dr. B. S. Panda Professor, Department of Mathematics IIT Delhi, Hauz Khas, ND-16

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

Transcription:

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness Marc Uetz University of Twente m.uetz@utwente.nl Lecture 9: sheet 1 / 31 Marc Uetz Discrete Optimization

Outline 1 N P and co-n P 2 N P-completeness 3 Clique is N P-complete Lecture 9: sheet 2 / 31 Marc Uetz Discrete Optimization

!"#$%&"'()"#*+'%,*#$%&-".'$#/%0%1'2"-*34#/ Some Problems with Poly-Time Algorithms!!"#"$%$&'()##"#*&+,--&.!'+/&0#&-1*-23-"*45-16&%#1",-75-1&*,)(4! 8,"$9 :;*0,"54$<& =.! > /!?,%9@);9 :;*0,"54$ =." ;0*&"/!!)A"$%$&B;03&.!B/&"#&)&1",-75-16&7)()7"5)5-1&*,)(4! '40,5-95&:%*$-#5"#*&8)54&:;*0,"54$<& =.! > "/! C"*4-95&;)D-;&8,-E;0328%94&:;*0,"54$< =.! > " FG> /! '40,5-95GH0#*-95&8)54&.'8/&0#&-1*-23-"*45-1&1",-75-1&*,)(4! )7I7;"7&1"*,)(4< =."/! #0##-*)5"J-&),7&3-"*459&.K"L@95,)/< =.! > /! ),D"5,),I&1"*,)(4M&);;&()",9&.B;0I12N),94);;/< =.! O /! '0,5"#*&! #%$D-,9! P%DD;-&'0,5< =.! > /!!-,*-&'0,5< =.! ;0*&!/! H"#-),&8,0*,)$$"#*&.H8/! Q;;"(90"1&!-5401&.?4)74"I)#R9 +4-0,-$/ =..!S"/ T! H.#$%$&/ > /! '"$(;-A&:;*0,"54$ #05 (0;I#0$");&5"$-U (in.v05"7-<&b0,&*,)(4&(,0d;-$96&! case of LP, A Q m n, L( "9&54-&#%$D-,&0E&#01-96&" ) = encoding length of 54-&#%$D-,&0E&),79M&E0,& A, b, c) H"#-),&8,0*,)$$"#*6&! )#1&" ),-&54-&$)5,"A&1"$-#9"0#9<&# "9&)# ""! $)5,"A/ Lecture 9: sheet 3 / 31 Marc Uetz Discrete Optimization

!"#$%&'"()$#*%+,-."/- &")0-,#$ 1)2"',-.#* Some Problems without Poly-Time Algorithms!!"#$%&'()*+#&%,-#(*."/0&%-*1!+.2! 3(4%)%"*5'(%#"*."/)"#--'()! 6#7'-8-*9&':8%*18(;'"%<4%;*)"#=>2! 6#7'-8-*3(;%=%(;%(4*+%4*18(;'"%<4%;*)"#=>2! 6#?%,=#( +<>%;8&'()! @%>'<&%*A/84'()*."/0&%-! 6#7'-8-*984*18(;'"%<4%;*)"#=>2*! @%"4%7*9/$%"B*+%4*9/$%"B*+%4*.#<?'()! C(#=,#<?*."/0&%-! D'(*.#<?'()*."/0&%-! +#4',E'#0'&'4F! G*G*G* Lecture 9: sheet 4 / 31 Marc Uetz Discrete Optimization

Outline 1 N P and co-n P 2 N P-completeness 3 Clique is N P-complete Lecture 9: sheet 5 / 31 Marc Uetz Discrete Optimization

Problem class N P: Nondeterministic Polynomial Time Given: Decision problem P, I encoding length of instance I P Definition Algorithm A is nondeterministic polynomial time algorithm for P if For all Yes instances I, poly-length certificate z(i ) (i.e., z(i ) p( I ) for some polyn. p), and A(I, z(i )) = Yes For all No instances I, and any poly-length input z ( fake certificate ), A(I, z) = No A(I, z) is a poly-time algorithm for any poly-length z Definition P N P : P has nondeterministic poly-time algorithm Yes instances of P have a polynomial certificate that can be verified in polynomial time Lecture 9: sheet 6 / 31 Marc Uetz Discrete Optimization

Example of N P-problem TSP: Given graph G = (V, E) with V = n, integer edge weights d e 0 and k N: exist Hamiltonian cycle of total length k? Theorem TSP N P Proof: Encoding length TSP: Ω(n + log U), with U = max e d e Certificate Yes instance: The set of edges of the tour, T E O( n ) Certificate checking: Check if the following exhausts all nodes: start with any e = {u, v} T, in T \ {e} look for edge e incident with v, and iterate with e O( n 2 ) Check if e T d e k O( n 2 log U ) Lecture 9: sheet 7 / 31 Marc Uetz Discrete Optimization

Problem class co-n P: Complement-N P Given: Decision problem P, I encoding length of instance I P Definition Algorithm A is nondeterministic polynomial time algorithm for complement problem P if For all No instances I, poly-length certificate z(i ) (i.e., z(i ) p( I ) for some polyn. p), and A(I, z(i )) = Yes For all Yes instances I, and any poly-length input z ( fake certificate ), A(I, z) = No A(I, z) is a poly-time algorithm for any poly-length z Definition P co-n P: No instances of P have a polynomial certificate that can be verified in polynomial time P N P Lecture 9: sheet 8 / 31 Marc Uetz Discrete Optimization

Example of co-n P Problem TUM: Given integer matrix A Z m n : is A totally unimodular? Theorem TUM con P Proof Encoding length A: Ω(n + m) Certificate No instance: Square submatrix B of A with det(b) {0, ±1} O( nm ) Certifcate checking: Compute det(b) this is non-trivial, because well-known Laplace formula det(b) = j b ij( 1) i+j det(b i, j ) requires Ω(n!) time possible via computing LU decomposition of B, where B = LU, with L = lower triangular, U = upper triangular O( n 3 ) Lecture 9: sheet 9 / 31 Marc Uetz Discrete Optimization

P, N P, and co-n P Theorem P N P and P co-n P TSP N P P co-n P TUM MST Open conjectures P N P, worth 1.000.000$ claymath.org/millennium/p vs NP/ P = N P co-n P, worth world-fame and recognition as scientist Lecture 9: sheet 10 / 31 Marc Uetz Discrete Optimization

Proof P N P,co-N P Given Problem Q P. To show: Q N P i.e., for all Yes instances I Q exists polynomial length certificate z(i ), and an algorithm A that verifies the certificate in poly-time, so A(I, z(i )) = Yes I = Yes. Proof: We know Q P, so Q has a poly-time algorithm A Q with A Q (I ) = Yes I = Yes Now use z(i ) =, and define A(I, ) := A Q (I ) To see P co-n P, replace all underlined Yes by No, and let A(I, ) := A Q (I ) Lecture 9: sheet 11 / 31 Marc Uetz Discrete Optimization

Outline 1 N P and co-n P 2 N P-completeness 3 Clique is N P-complete Lecture 9: sheet 12 / 31 Marc Uetz Discrete Optimization

Completeness Informal Definition Given a class of decision problems X, problem P X is complete for that class if it is among the most difficult problems of X Needed: Formalization of most difficult, or at least as difficult as polynomial transformations and reductions between problems Lecture 9: sheet 13 / 31 Marc Uetz Discrete Optimization

Reduction (Turing Reduction) Definition Given two problems P and Q, say P polynomially reduces to Q (P α Q), if the following is true: Assuming a poly-time algorithm for Q, there is a poly-time algorithm for P. Intuition: Q is at least as hard as P (as to poly-time solvability) Definition Problems P, Q are polynomially equivalent if P α Q and Q α P Example: Q = decision problem and P = optimization problem for matching are polynomially equivalent (same for TSP) Lecture 9: sheet 14 / 31 Marc Uetz Discrete Optimization

Transformation (Karp or Many-One Reduction)!"#$%&'"(#)*'$%+,#-%'.+/#"0123456)*'$%7 Definition Given decision problems P and Q, say P polynomially transforms to Q!"#$%$&$'%()*$+"%)&,')-".'/%$&$'%)0-'12"34)P if the following is true: There is a polynomial 5%6)Q7)&8"% time algorithm P 0'29%'3$5229 &-5%4#'-34)&')Q $#)&8")#'22',$%/)$4)&-:"();8"-")"<$4&4)5)0'29%'3$52)&$3") (the transformation) T : P Q, such that 52/'-$&83)=&8")&-5%4#'-35&$'%>)T() ()P! Q7)4:.8)&85&) instance $%4&5%.")I I P " = P $4)?@AB Yes @ABC # $%4&5%.");=)I instance T >)" (I ) Q $4)?@AB Q @ABC = Yes 1!"#!"# &'()*+,'-(&.,)//! $% $% 0 note: T need not be injective neither surjective Lecture 9: sheet 15 / 31 Marc Uetz Discrete Optimization

Example of a transformation P!"#$%&'( P = Clique )%*(+"),-./"G!0V,E12"! 3$%&'("C " V 4%5/""6C6"# k 7 GivenQ G!"8+9(.(+9(+5":(5 = (V, E), k, is there a clique C V of size C k? )%*(+"),-./"G!0V,E12"! %+9(.(+9(+5";(5"S " V 4%5/""6S6"# k 7 Q = Independent Set Given G = (V, E), k, is there a indep. set S V of size S k? <(=%+(">,-+;=?,@-5%?+" >,-+;=?,@-5%?+"TA" A"P $ Q BC" T A"G $ G c Define4/(,("""G T : P c Q!"0V,E by T c (G) 1"3?@.$(@(+5"?="GA""""e := G c, where G c = %(V E, c E& c ) e and! E0G1""" e E c e E! T is polynomial time transformation, time O( n 2 ) clique C k in G indep. set S k in T (G) = G c Lecture 9: sheet 16 / 31 Marc Uetz Discrete Optimization

Reductions and Transformations Theorem Let decision problems P, Q be given. If P polynomially transforms to Q P α Q Proof. To show: If Q is poly-time solvable, so is P Assume a poly-time algorithm for Q, A Q. We know, poly-time transformation T : P Q. Poly-time algorithm for P: given instance I P compute T (I ) Q return Yes if A Q (T (I )) = Yes, No otherwise Lecture 9: sheet 17 / 31 Marc Uetz Discrete Optimization

Problem Class N P-complete Definition Given decision problem Q, then Q is N P-complete if 1 Q N P 2 P N P : P polynomially transforms to Q (Q is N P-hard) In words: Q is at least as hard as any problem in N P (as to poly-time solvability) Theorem If N P-complete problem X has a poly-time algorithm, P=N P. Proof: P N P, poly-time transf. T P : P X, X is poly-time solvable by A X, so A X T P yields poly-time algorithm for P Lecture 9: sheet 18 / 31 Marc Uetz Discrete Optimization

How N P-completeness helps us Garey & Johnson (1979): Computers and Intractability Lecture 9: sheet 19 / 31 Marc Uetz Discrete Optimization

On N P-completeness Is definition practical? need existence of T : P Q, P N P! Remark Transformations are transitive: given poly-time T 1 : P Q, T 2 : Q R, yield poly-time transf. T : P R, T := T 2 T 1. Theorem (Cook 1971) There exists an N P-complete problem, namely Satisfiability (SAT). Since 1971, showing that problem Q is N P-complete is easy show Q NP show poly-time transformation T : SAT Q (Transitivity may use any N P-complete problem instead of SAT.) Lecture 9: sheet 20 / 31 Marc Uetz Discrete Optimization

Satisfiability (SAT)!"#$!%$"&$'$#()*!"#+ SAT: Is a formula F in conjunctive normal form satisfiable?!"##$%&'()&*+&,$%- x boolean variables x 1,.... /(0 /(x, x n, each n 1(((x j! 23&$-%/(4*5%6( x j {false, true}!7$&5-%- C clauses C 1,.. /(0 /(C., C m, m /(((%&89(C each C i is i 9&-(&(3#*:(&-(3#$$#;- disjunction of certain literals C i <(4*5%(+3(&4($%&-4(#'%( $+4%*&$(+-(4*5% 7$&5-% =+4%*&$ =+4%*&$(>?%@&4+#'(#3(x A 1(4*5%(+3(x A <(3&$-%B F = C 1 C m = true : all C i = true! " &(4*549(&--+@':%'4(3#*( 4*549(&--+@':%'4(3#*(x. /(0/( /(x -589(49&4(C<&$$(8$&5-%- n &*%(4*5%1 Satisfiability problem: x {false, true} n such that F = true?!de5+f&$%'4$g/ x j! 2H/.6( Cook s theorem: Any N P problem can be equivalently reformulated as a SAT problem Lecture 9: sheet 21 / 31 Marc Uetz Discrete Optimization

!"#$%&'()$*$!"+,-./0#)#$1'-20#.($3456$!'45(7-'.4)&-5(8 The First Six N P-complete problems SATISFIABILITY!""#$%&'()*+, %&'()*+,$%-%- 3 - SATISFIABILITY 3-DIMENSIONAL MATCHING VERTEX COVER PARTITION HAMILTONIAN CYCLE CLIQUE 3-SAT? SAT with exactly 3 literals per clause Lecture 9: sheet 22 / 31 Marc Uetz Discrete Optimization

Clique is N P-complete Clique Given G = (V, E), is there a clique C V of size C k? 1 Clique N P Certificate for Yes instances: clique C itself (note C n, verifiable in O( n 2 ) time) 2 Give a poly-time transformation: T : 3-SAT Clique, where m = #clauses, n = #variables in 3-SAT, so that F 3-SAT = Yes G = T (F ) Clique = Yes F satisfiable G has clique of size m (Our graph will have 7m nodes) Lecture 9: sheet 23 / 31 Marc Uetz Discrete Optimization

Lecture 9: sheet 24 / 31 Marc Uetz Discrete Optimization

Clique is N P-complete The transformation For each clause C i : 7 nodes that correspond to all 7 partial truth assignments that make C i true (partial truth assignment? only 3 variables appear in clause C i, all other variables remain undecided, marked d figure) O( mn ) time introduce an edge between any two partial truth assignments if they are compatibe (don t contradict each other on a truth value of any variable) figure O( m 2 n ) time The proof (main idea) Any clique in G can only have one node per clause C i Thus a clique of size m is equivalent with a (partial) truth assignment that makes all m clauses C i true Lecture 9: sheet 25 / 31 Marc Uetz Discrete Optimization

The Simplest N P-complete problem: Partition Given Natural numbers a i 0, i = 1,..., n, with n i=1 a i = 2B (that is to say, i a i is even). Question Does there exist a subset S {1,..., n} with Theorem Partition is N P-complete Proof N P-hardness: Literature a i = a i? i S i S Lecture 9: sheet 26 / 31 Marc Uetz Discrete Optimization

N P-hard Optimization Problems Definition We call an optimization problem Q N P-hard if the corresponding decision problem is N P-complete. (Note: a poly-time algorithm for solving Q would yield P=N P) Lecture 9: sheet 27 / 31 Marc Uetz Discrete Optimization

Knapsack Problem Given n items with weights w j 0 and value v j 0 a knapsack with total (weight) capacity W Problem find subset S of items with weight W and maximal value Theorem The Knapsack problem is N P-hard (Exercise). Lecture 9: sheet 28 / 31 Marc Uetz Discrete Optimization

Solving the Knapsack Problem weights w j : values v j : 1 2 3 v 1 = 2 v 2 = 3 v 3 = 4 capacity W = 4 Construct directed graph G = (V, A): nodes u jk, k = w j,..., W, edges (u ik, u jl ) with lengths v j i < j and l k = w j item 1 2 size v 1 1 2 3 4 = W u 11 u 12 u 13 u 14 v 2 v 2 s v 2 u 22 u 23 u 24 t 3 v 3 v 3 u 33 u 34 length 0 Lecture 9: sheet 29 / 31 Marc Uetz Discrete Optimization

Solving the Knapsack Problem!"#$%&'%()*%"'(+,%-.*/-%0(1#23-%-#2! Observations!"#$%&'(!"#$%&'%(%$)(*+,#-'. )*(&!"%(+#$! /+-(0123(12#43(5+(.67+(%$5"-$%$8(,60+(*%5+*. any (s, t)-path traverses some rows of the digraph,.9)'(-'%-(0123(".(%,(9&& thereby 9&& 569,0 collecting :6$(-'+(.'6$-+.-(&%-'(:$67(.(-6(2(12#4;.3< the corresponding items! ='+(,60+(*%5+*.(0123(%$+(.'6$-+.-(&%-'(*+,#-'.(":(%,0(6,*8(": by definition, all these items fit in the knapsack, w i W 01>3(! 01,3?) length of path = total value,%- :6$(%**(12@>3#A of items collected along the path longest (s, t)-path = optimal solution Knapsack! $ "! " How to compute! longest paths in digraphs? " Same * as shortest paths only with -inequality + 2 reversed: (&) d(s, w) ) d(s, $ v) + c) vw %&' (digraph is acyclic,! so we even have a linear time algorithm) $ # #! # " ) 2> > Lecture 9: sheet 30 / 31 Marc Uetz Discrete Optimization

Solving the Knapsack Problem Knapsack is N P-hard Longest Path is polynomially solvable, so P And we have a transformation T : Knapsack Longest Path Hence, can we conclude that P=N P and claim 1.000.000 $ from the Clay Mathematics Institute? Lecture 9: sheet 31 / 31 Marc Uetz Discrete Optimization