INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS.
NP-Hard Nattee Niparnan.
Complexity ©D.Moshkovits 1 Where Can We Draw The Line? On the Hardness of Satisfiability Problems.
Sep 15, 2014 Lirong Xia Computational social choice The easy-to-compute axiom.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
NP-Completeness: Reductions
The Theory of NP-Completeness
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
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
February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Lecture 22 More NPC problems
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
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.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
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.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
SUBSET-SUM Instance: A set of numbers denoted S and a target number t.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
 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
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
P, NP, NP-completeness 2 Reductions 1 Thu, July 7 th 1.
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.
The Theory of NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-complete problems
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 29 NP-Completeness and course wrap-up
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
CS21 Decidability and Tractability
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
More NP-complete Problems
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 30 NP-Completeness
NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
CS21 Decidability and Tractability
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) HARDEST PROBLEMS IN NP 2. A is NP-complete and A · P B If B is NP-Complete and P NP, then There is no fast algorithm for B. Theorem: A language B is NP-complete if:

3SAT P DSAT, NAESAT, 2CSP… We will use 3SAT to prove other problems are NP-Complete or NP-Hard. Examples include 3SAT P CLIQUE 3SAT P 0/1-ILP 3SAT P HAMPATH 3SAT P 3COLOR 3SAT P GRADUATION 3SAT P VERTEX-COVER

2SAT 2SAT = { | is in 2cnf and is satisfiable} Theorem. 2SAT P! Idea: a 2SAT clause (x y) is equivalent to (¬x y) and (¬y x). If there is a chain (x z 1 ) (z 1 z 2 ) … (z k ¬x) and (¬xy 1 ) (y 1 y 2 ) … (y j x) then: x ¬x If not, the formula is consistent, so satisfiable. e.g. (x x) (¬x y) (¬y ¬x)

def is_satisfiable_2cnf(F): V = Ø, E = Ø, G = (V,E) for l literals(F): V = V {l, ¬l} for (x y) clauses(F): E = E {(¬x,y), (¬y,x)} for x vars(F): if has_path(G,x,¬x) and has_path(G,¬x,x): return False return True (xx)(xx̅)(x̅x) x x x x x x

REDUCTION STRATEGIES A reduction by restriction shows that the source problem is a special case of the target problem. For example, 3SAT P CNF-SAT because every satisfiable 3CNF is also a satisfiable CNF. Example. Prove 3SAT P 4SAT by restriction. A 3CNF can be converted to an equivalent 4CNF by repeating one literal in each clause.

COLORING b a e c db ac d b a e c d a bd COLOR = { G,k | G is k-colorable } 3COLOR = { G | G is 3-colorable} Prove that 3COLOR P COLOR

HAMILTONIAN PATHS b a e c d f h i g HAMPATH = { G,s,t | G has a hamiltonian path from s to t }

Prove that HAMPATH P HAMCYCLE. Let HAMCYCLE = { G | G has a simple directed cycle of length n} Let HAMILTONIAN = { G | s,t such that G has a hamiltonian path from s to t } Prove that HAMPATH P HAMILTONIAN Let LPATH = { G,s,t,k | G has a simple path from s to t of length at least k } Prove that HAMPATH P LPATH

VERTEX COVER b a e c d b a e c d VERTEX-COVER = { G,k | G has a vertex cover of size at most k }

INDEPENDENT SET b a e c d b a e c d INDSET = { G,k | G has an independent set of size at least k } Prove that VERTEX-COVER P INDSET.

SUBSET SUM SUBSET-SUM = { y 1,…, y n,t | S {1,…,n}. Σ j S y j =t } Which of the following are in SUBSET-SUM? 1,3,5,7, 10 19,11,27,4, 13 19,11,27,4, 61 YES NO YES

KNAPSACK = { (w 1,v 1 )…,(w n,v n ),W, V | S {1…n} so that Σ i S w i W and Σ i S v i V} 15 lbs $500 ½ lb $15 3 lbs $2000 1lb, $20 50 ×

Theorem. SUBSET-SUM P KNAPSACK Proof. A subset sum instance is a knapsack where the weights are equal to the values: Let ƒ(y 1,…,y n,t) = y 1,y 1 )…(y n,y n ),t,t Then S. Σ i S y i = t iff S. Σ i S y i t and Σ i S y i t, so y 1 …y n,t SUBSET-SUM iff ƒ(y 1 …y n,t) KNAPSACK

Theorem. VERTEX-COVER P SET-COVER SET-COVER = { S 1,…,S n,k | i,S i U and i[1…k] so that S i[1] S i[2] … S i[k] = U } Which of the following are in SET-COVER? {1}, {1,2}, {2}, {3}, 2 {1,4}, {1,2}, {1,3}, {4}, 2 Proof. A vertex cover instance is just a set cover instance where every node is a set of edges. YES NO {1}, {2}, {1,2}, 2 YES

REDUCTION STRATEGIES A reduction from A to B by local replacement shows how to translate between units of A and units of B. Example. vertex cover units are vertices and edges; set cover units are elements and sets. Example. CIRCUIT-SAT units are gates, CNFSAT units are clauses, 3SAT units are 3-literal clauses.

SATISFYING CONSTRAINTS A 2csp is a list of constraints on pairs of variables Each constraint C(x,y) is a list of values for (x,y). An assignment satisfies a constraint if (x,y) C(x,y). An assignment satisfies a 2csp if it satisfies all constraints. e.g. Scheduling a project; seating at a wedding… 2CSP = { C | C is a satisfiable 2csp } Theorem. 2CSP is NP-Complete.

Proof. 1. 2CSP NP. Given an assignment to the variables we can check that all constraints are satisfied in linear time. 2. 3SAT P 2CSP. Idea: the main difference is that a 2csp constraint should have only two variables. Add variables to the 2csp that represent pairs of variables in the 3cnf, and constraints to enforce consistency with the 3cnf variables.

Map 3cnf ϕ with n variables and m clauses to a 2csp C ϕ with 2n+m variables and 3m+n constraints: for each variable x ϕ : add (v x,v ¬x ) {(0,1),(1,0)} for each clause (x y z) ϕ : add v xy {00,01,10,11} add (v xy,v z ) (00,0) add (v xy,v x ) {(00,0), (01,0), (10,1), (11,1)} add (v xy,v y ) {(00,0), (01,1), (10,0), (11,1)} Claim. C ϕ 2CSP ϕ 3SAT: Proof. A satisfying assignment to ϕ can be mapped to a satisfying assignment to C ϕ by assigning each v x = x and each v xy = 2v x +v y because… An assignment to C ϕ maps to an assignment to ϕ by setting each x = v x, because…

GRADUATION A transcript is a set of course numbers a student has taken A major consists of: Pairs: exactly one of which must be taken Lists: at least one course of which must be taken GRADUATION = { T,M | a subset of T satisfies M} For example: T = {1901A, 1902B, 1902A, 2011, 4041A, 4061, 4211} M = [1901A,1901B], [1902A,1902B] (4011,4041A,4041B), (4211,4707), (4061)

GRADUATION NP: The subset is a proof that (T,M) GRADUATION. 3SAT P GRADUATION: (x 1 x 2 ¬x 3 ) (¬x 1 x 2 x 2 ) (¬x 2 x 3 x 1 ) T = {101, 102, 201, 202, 301, 302} M = [101, 102], [201, 202], [301, 302] (101,201,302), (101,201,201), (101,202,301)

GRADUATION NP: The subset is a proof that (T,M) GRADUATION. 3SAT P GRADUATION: Let = C 1 C 2 … C m have variables x 1 …x k For each x i : add classes i01 and i02 to T. add pair (i01,i02) to M. For each C j, we add a triple to M: if x i is a literal in C j, the triple includes i01. if ¬x i is a literal in C j, the triple includes i02.

UHAMPATH A B CD EF No HAM PATH A B CD EF Undirected HAM PATH UHAMPATH = { G,s,t | G is an undirected graph with a Hamiltonian path from s to t}

HAMPATH P UHAMPATH A B CD EF A in A mid A out

HAMPATH P UHAMPATH A B CD EF

f(G,s,t) = (G,s,t) where: For each node u G: add nodes u in, u out, u mid to G. add edges {u in,u mid } and {u mid,u out } to G For each edge (u,v) G, add {u out,v in } to G s = s in, t = t out. If G,s,t HAMPATH, then G,s,t UHAMPATH: (s,u,v,..,t) (s in,s mid,s out,u in,u mid,u out,v in,v mid,v out,…t out )

HAMPATH P UHAMPATH If G,s,t UHAMPATH, then G,s,t HAMPATH: Let (s in =v 1,v 2,…,v 3n =t out ) be the undirected path. i=0: Induction: if v 3i = u out, then v 3i+1 =u in, so v 3i+2 =u mid. Claim: for all i0, there exists u G so that: v 3i+1 =u in, v 3i+2 =u mid, v 3i+3 =u out. The directed Hamiltonian path is (u 1, u 2, …, u n ) If v 2 s mid, then no v i =s mid. So v 2 =s mid, v 3 =s out

3SAT P SUBSET-SUM We transform a 3-cnf formula into y 1 …y n, t : 3SAT y 1 …y n,t SUBSET-SUM The transformation can be done in time polynomial in the length of

(x 1 x 2 x 2 ) (¬x 1 x 2 x 2 ) (x 1 ¬x 2 x 2 ) Each variable and each clause result in two y is. Each y i will have a digit for each clause and variable. C1C1 C2C2 C3C3 y1y y2y y3y y4y y5y5 100 y6y6 100 y7y7 10 y8y8 10 y9y9 1 y 10 1 t11333 x1x1 x2x2 x1x1 x2x2 C1C1 C2C2 C3C3

3SAT P SUBSET-SUM Let = C 1 C 2 … C m have k variables x 1 …x k. We output y 1 … y 2k + 2m, each a k+m-digit number. for each 1 j k: for each 1 I m: the i th digit of y 2j-1 is 1 if x j C i, else 0 the i th digit of y 2j is 1 if ¬x j C i, else 0. digit j+m of y 2j, y 2j-1 is 1. For each 1 j m: y 2k+2j = y 2k+2j-1 = 10 j-1 Output t =