February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.
NP-Completeness: Reductions
More NP-completeness Sipser 7.5 (pages ). CS 311 Fall NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
More NP-completeness Sipser 7.5 (pages ).
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
Computability and Complexity 16-1 Computability and Complexity Andrei Bulatov NP-Completeness.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Time Complexity.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
P, NP, and NP-Complete Suzan Köknar-Tezel.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
Additional NP-complete problems
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NPC.
CSC 413/513: Intro to Algorithms
NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
Prof. Busch - LSU1 Busch Complexity Lectures: More NP-complete Problems.
SUBSET-SUM Instance: A set of numbers denoted S and a target number t.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
More NP-Complete and NP-hard Problems
More NP-complete problems
Richard Anderson Lecture 26 NP-Completeness
Lecture 2-2 NP Class.
More NP-complete Problems
Richard Anderson Lecture 26 NP-Completeness
CS21 Decidability and Tractability
Intro to Theory of Computation
CS21 Decidability and Tractability
Lecture 24 NP-Complete Problems
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Chapter 34: NP-Completeness
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Lecture 24 Classical NP-hard Problems
Presentation transcript:

February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015

Outline the class NP –NP-complete problems: Hamilton path and cycle,Traveling Salesperson Problem –NP-complete problems: subset sum –NP-complete problems: NAE-3-SAT, max-cut February 25, 2015CS21 Lecture 212

February 25, 2015CS21 Lecture 213 Hamilton Path Definition: given a directed graph G = (V, E), a Hamilton path in G is a directed path that touches every node exactly once. A language (decision problem): HAMPATH = {(G, s, t) : G has a Hamilton path from s to t}

February 25, 2015CS21 Lecture 214 HAMPATH is NP-complete We are reducing from the language: 3SAT = { φ : φ is a 3-CNF formula that has a satisfying assignment } to the language: HAMPATH = {(G, s, t) : G has a Hamilton path from s to t}

February 25, 2015CS21 Lecture 215 HAMPATH is NP-complete We want to construct a graph from φ with the following properties: –a satisfying assignment to φ translates into a Hamilton Path from s to t –a Hamilton Path from s to t can be translated into a satisfying assignment for φ We will build the graph up from pieces called gadgets that “simulate” the clauses and variables of φ.

February 25, 2015CS21 Lecture 216 HAMPATH is NP-complete The variable gadget (one for each x i ): x i true: x i false: … … …

February 25, 2015CS21 Lecture 217 HAMPATH is NP-complete … … … : “x 1 ” “x 2 ” “x m ” s t path from s to t translates into a truth assignment to x 1 …x m why must the path be of this form?

February 25, 2015CS21 Lecture 218 HAMPATH is NP-complete φ = (x 1  x 2  x 3 )  (  x 1  x 4  x 3 )  …  (…) How to ensure that all k clauses are satisfied? need to add nodes –can be visited in path if the clause is satisfied –if visited in path, implies clause is satisfied by the assignment given by path through variable gadgets

February 25, 2015CS21 Lecture 219 HAMPATH is NP-complete φ = (x 1  x 2  x 3 )  (  x 1  x 4  x 3 )  …  (…) Clause gadget allows “detour” from “assignment path” for each true literal in clause … … … “x 1 ” “x 2 ” “x 3 ” “C 1 ”

February 25, 2015CS21 Lecture 2110 HAMPATH is NP-complete One clause gadget for each of k clauses: … “x 1 ” … “x 2 ” … “x m ” ::: “C 1 ” “C 2 ” “C k ” : for clause 1 for clause 2

February 25, 2015CS21 Lecture 2111 HAMPATH is NP-complete … … … : “x 1 ” “x 2 ” “x m ” s t “C 1 ” “C 2 ” “C k ” : φ = (x 1  x 2  x 3 )  (  x 1  x 4  x 3 )  … f(φ) is this graph (edges to/from clause nodes not pictured) f poly-time computable? # nodes = O(km)

February 25, 2015CS21 Lecture 2112 HAMPATH is NP-complete … … … : “x 1 ” “x 2 ” “x m ” s t “C 1 ” “C 2 ” “C k ” : φ = (x 1  x 2  x 3 )  (  x 1  x 4  x 3 )  … YES maps to YES? first form path from satisfying assign. pick true literal in each clause and add detour

February 25, 2015CS21 Lecture 2113 HAMPATH is NP-complete … … … : “x 1 ” “x 2 ” “x m ” s t “C 1 ” “C 2 ” “C k ” : φ = (x 1  x 2  x 3 )  (  x 1  x 4  x 3 )  … NO maps to NO? try to translate path into satisfying assignment if path has “intended” form, OK.

February 25, 2015CS21 Lecture 2114 HAMPATH is NP-complete What can go wrong? –path has “intended form” unless return from clause gadget to different variable gadget … … … “x i ” “x j ” “x h ” “C l ” we will argue that this cannot happen:

February 25, 2015CS21 Lecture 2115 HAMPATH is NP-complete … … : Case 1 (positive occurrence of v in clause): c xyz path must visit y must enter from x, z, or c must exit to z (x is taken) x, c are taken. can’t happen “v”

February 25, 2015CS21 Lecture 2116 HAMPATH is NP-complete … … : Case 2 (negative occurrence of v in clause): c xy path must visit y must enter from x or z must exit to z (x is taken) x is taken. can’t happen “v” z

February 25, 2015CS21 Lecture 2117 Undirected Hamilton Path HAMPATH refers to a directed graph. Is it easier on an undirected graph? A language (decision problem): UHAMPATH = {(G, s, t) : undirected G has a Hamilton path from s to t}

February 25, 2015CS21 Lecture 2118 UHAMPATH is NP-complete Theorem: the following language is NP- complete: UHAMPATH = {(G, s, t) : undirected graph G has a Hamilton path from s to t} Proof: –Part 1: UHAMPATH  NP. Proof? –Part 2: UHAMPATH is NP-hard. reduce from?

February 25, 2015CS21 Lecture 2119 UHAMPATH is NP-complete We are reducing from the language: HAMPATH = {(G, s, t) : directed graph G has a Hamilton path from s to t} to the language: UHAMPATH = {(G, s, t) : undirected graph G has a Hamilton path from s to t}

February 25, 2015CS21 Lecture 2120 UHAMPATH is NP-complete The reduction: s t G s out t in G’ u v u in u mid u out v in v mid v out replace each node with three (except s, t) (u in, u mid ) (u mid, u out ) (u out, v in ) iff G has (u,v)

February 25, 2015CS21 Lecture 2121 UHAMPATH is NP-complete Does the reduction run in poly-time? YES maps to YES? –Hamilton path in G: s, u 1, u 2, u 3, …, u k, t –Hamilton path in G’: s out, (u 1 ) in, (u 1 ) mid, (u 1 ) out, (u 2 ) in, (u 2 ) mid, (u 2 ) out, … (u k ) in, (u k ) mid, (u k ) out, t in

February 25, 2015CS21 Lecture 2122 UHAMPATH is NP-complete NO maps to NO? –Hamilton path in G’: s out, v 1, v 2, v 3, v 4, v 5, v 6, …, v k-2, v k-1, v k, t in –v 1 = (u i1 ) in for some i 1 (only edges to ins) –v 2 = (u i1 ) mid for some i 1 (only way to enter mid) –v 3 = (u i1 ) out for some i 1 (only way to exit mid) –v 4 = (u i2 ) in for some i 2 (only edges to ins) –... –Hamilton path in G: s, u i1, u i2, u i3, …, u ik, t

February 25, 2015CS21 Lecture 2123 Undirected Hamilton Cycle Definition: given a undirected graph G = (V, E), a Hamilton cycle in G is a cycle in G that touches every node exactly once. Is finding one easier than finding a Hamilton path? A language (decision problem): UHAMCYCLE = {G : G has a Hamilton cycle}

February 25, 2015CS21 Lecture 2124 UHAMCYCLE is NP-complete Theorem: the following language is NP- complete: UHAMCYCLE = {G: G has a Hamilton cycle} Proof: –Part 1: UHAMCYCLE  NP. Proof? –Part 2: UHAMCYCLE is NP-hard. reduce from?

February 25, 2015CS21 Lecture 2125 UHAMCYCLE is NP-complete The reduction (from UHAMPATH): s t G s t G’ H. path from s to t implies H. cycle in G’ H. cycle in G’ must visit u via red edges removing red edges gives H. path from s to t in G u

February 25, 2015CS21 Lecture 2126 Traveling Salesperson Problem Definition: given n cities v 1, v 2, …, v n and inter-city distances d i, j a TSP tour in G is a permutation  of {1…n}. The tour’s length is Σ i = 1 … n d  (i),  (i+1) (where n+1 means 1). A search problem: given the {d i,j }, find the shortest TSP tour corresponding language (decision problem): TSP = {({d i, j : 1 ≤ i<j ≤ n}, k) : these cities have a TSP tour of length ≤ k}

February 25, 2015CS21 Lecture 2127 TSP is NP-complete Theorem: the following language is NP- complete: TSP = {({d i, j : 1 ≤ i<j ≤ n}, k) : these cities have a TSP tour of length ≤ k} Proof: –Part 1: TSP  NP. Proof? –Part 2: TSP is NP-hard. reduce from?

February 25, 2015CS21 Lecture 2128 TSP is NP-complete We are reducing from the language: UHAMCYCLE = {G : G has a Hamilton cycle} to the language: TSP = {({d i, j : 1 ≤ i<j ≤ n}, k) : these cities have a TSP tour of length ≤ k}

February 25, 2015CS21 Lecture 2129 TSP is NP-complete The reduction: –given G = (V, E) with n nodes produce: –n cities corresponding to the n nodes –d u, v = 1 if (u, v)  E –d u, v = 2 if (u, v)  E –set k = n

February 25, 2015CS21 Lecture 2130 TSP is NP-complete YES maps to YES? –if G has a Hamilton cycle, then visiting cities in that order gives TSP tour of length n NO maps to NO? –if TSP tour of length ≤ n, it must have length exactly n. –all distances in tour are 1. Must be edges between every successive pair of cities in tour.