Welcome to... Problem Analysis and Complexity Theory , 3 VU

Size: px
Start display at page:

Download "Welcome to... Problem Analysis and Complexity Theory , 3 VU"

Transcription

1 Welcome to... Problem Analysis and Complexity Theory , 3 VU Birgit Vogtenhuber Institute for Software Technology bvogt@ist.tugraz.at office: Inffeldgasse 16B/II, room IC02044 slides: Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

2 Last Time Two classes of computational models: 1. Deterministic: DTM, multi-tape DTM, RAM all polynomially equivalent: Simulation of - O(f(n))-time multi-tape DTM with O(f(n) 2 )-time DTM - O(f(n))-time RAM with O(f(n) 3 )-time 7-tape DTM 2. Nondeterministic: NTM simulation of NTM by DTM with an exponential blowup in time Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

3 Last Time Church-Turing (hypo)thesis: Conjecture: Deterministic Turing machines are as powerfull as the intuitive notion of algorithms. Number of different configurations of a Turing machine that uses n cells of the tape (roughly): Γ N N Q Definition of complexity classes via bounds on the amount of needed ressources of Turing machines. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

4 Containment Relations L NL P NP PSPACE EXP L NL, P NP: DTM = special case of NTM PSPACE EXP, L P: # configurations of a DTM P PSPACE: O(f(n))-time O(f(n))-space EXP PSPACE NP P NL L NP PSPACE: simulate O(f(n))-time NTM with O(f(n))-space DTM The Halting problem is undecidable: Diagonalization P EXP: Use diagonalization similar to Halting problem Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

5 This Time 1. Formally introduce reductions 2. Prove the Cook-Levin-Theorem: Show that SAT is NP-complete 3. Show NP-completness for other problems Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

6 Reductions Motivation: Reductions are a main tool for comparing problems. Objective: Formalize the notion of reductions. Overview: Define Karp reductions (notation: P ) Example: show HAMPATH P HAMCYCLE Closeness under reductions Define other types of redurctions Discuss Completeness Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

7 Reductions Concept: Consider two problems / languages A and B. Assume we can make an efficient procedure for problem A using an efficient procedure for problem B Then it follows that A cannot be radically harder than B, or, in other words, B is at least as hard as A. Notation: A x B Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

8 Karp Reductions: Definition Definition: A language A is polynomial time (Karp) reducible to a language B (denoted by A P B), if there exists a polynomial time computable function f : Σ A Σ B (called reduction-function), such that w A f(w) B. there exists a DTM which computes f(w) from w in polynomial time Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

9 Karp Reductions: Definition Definition: A language A is polynomial time (Karp) reducible to a language B (denoted by A P B), if there exists a polynomial time computable function f : Σ A Σ B (called reduction-function), such that w A f(w) B. A f B Σ A \A Σ B \B Questions: Σ of DTM for f? Bounds on f(w)? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

10 Karp Reductions: Definition Definition: A language A is polynomial time (Karp) reducible to a language B (denoted by A P B), if there exists a polynomial time computable function f : Σ A Σ B (called reduction-function), such that w A f(w) B. Teminology: This type of reductions is also called polynomial time Karp reduction... polynomial time many-one reduction... polynomial time mapping reduction Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

11 Reductions and Efficiency Concept: Consider two problems / languages A and B. Assume we can make an efficient procedure for problem A using an efficient procedure for problem B Realization: x polynomial-time algorithm for B x B? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

12 Reductions and Efficiency Concept: Consider two problems / languages A and B. Assume we can make an efficient procedure for problem A using an efficient procedure for problem B Realization: w polynomial-time algorithm for f f(w) polynomial-time algorithm for B f(w) B? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

13 Reductions and Efficiency Concept: Consider two problems / languages A and B. Assume we can make an efficient procedure for problem A using an efficient procedure for problem B Realization: w a polynomial time algorithm for A polynomial-time algorithm for f f(w) polynomial-time algorithm for B f(w) B? w A? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

14 How to Reduce? Steps to show A P B: 1. Come up with a reduction function f. 2. Show that f is polynomial time computable. 3. Prove that f is a reduction (of A to B), i.e., show: w A f(w) B f(w) B w A Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

15 HAMPATH P HAMCYCLE HAMPATH: Hamiltonian path L = {(G, s, t) G is a directed graph with a Hamiltonian path from s to t } Instance: A directed graph G = (V, E) and two vertices s t V. Problem: Decide if G contains a Hamiltonian path from s to t, i.e., a path that goes through each node of G exactly once. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

16 HAMPATH P HAMCYCLE HAMCYCLE: Hamiltonian cycle L = {G G is a directed graph with a Hamiltonian cycle } Instance: A directed graph G = (V, E) Problem: Decide if G contains a Hamiltonian cycle, i.e., a cycle that goes through each node of G exactly once. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

17 HAMPATH P HAMCYCLE Steps to show HAMPATH P HAMCYCLE: 1. Come up with a reduction function f: f(g=(v, E), s, t) := G =(V u, E {(u, s), (t, u)}) 2. Show that f is polynomial time computable. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

18 HAMPATH P HAMCYCLE Steps to show HAMPATH P HAMCYCLE: 1. Come up with a reduction function f: f(g=(v, E), s, t) := G =(V u, E {(u, s), (t, u)}) 2. Show that f is polynomial time computable. 3. Prove that f is a reduction: w HAMP AT H f(w) HAMCY CLE: Given a Hamiltonian path (s,..., t) in G, (s,..., t, u) is a Hamiltonian cycle in G. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

19 HAMPATH P HAMCYCLE Steps to show HAMPATH P HAMCYCLE: 1. Come up with a reduction function f: f(g=(v, E), s, t) := G =(V u, E {(u, s), (t, u)}) 2. Show that f is polynomial time computable. 3. Prove that f is a reduction: w HAMP AT H f(w) HAMCY CLE: f(w) HAMCY CLE w HAMP AT H: In a Ham. cycle in G, u must be preceeded by t and followed by s A Ham. cycle in G is of the form (s,..., t, u). Removing u yields a Ham. path (s,..., t) in G. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

20 Definition: Closeness: Definition A complexity class C is closed under (some type x of) reductions, if L is x-reducible to L and L C L C as well. Theorem: The complexity classes P, NP, PSPACE, and EXP are closed under polynomial time (Karp) reductions. Proof: Exercise Question: What could be a different type of reduction? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

21 Definition: Log-Space Reductions A language A is log-space (Karp) reducible to a language B (denoted by A L B), if there exists a log-space computable function f : Σ A Σ B (called reduction-function), such that w A f(w) B. A f B Σ A \A Σ B \B Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

22 Definition: Log-Space Reductions A language A is log-space (Karp) reducible to a language B (denoted by A L B), if there exists a log-space computable function f : Σ A Σ B (called reduction-function), such that w A f(w) B. Theorem: The complexity classes L, NL, P, NP, PSPACE, and EXP are closed under log-space (Karp) reductions. Question: What could be a different type of reduction? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

23 Definition: Cook Reductions A language A is Cook reducible to a language B (denoted by A P T B), if there exists an algorithm that solves A using a polynomial number of calls to a subroutine for B, and polynomial time outside of these subroutine calls. Teminology: Cook reductions are also called polynomial time Turing reductions algorithm for A O(p(n)) calls algorithm for B Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

24 Definition: Cook Reductions A language A is Cook reducible to a language B (denoted by A P T B), if there exists an algorithm that solves A using a polynomial number of calls to a subroutine for B, and polynomial time outside of these subroutine calls. Teminology: Cook reductions are also called polynomial time Turing reductions Exercise: Make Cook reductions for HAMPATH P T HAMCYCLE P T HAMCYCLE, HAMPATH. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

25 Question: Cook vs. Karp Reductions How do Cook reductions and polynomial time Karp reductions differ? Cook reductions allow us to call the procedure many times (instead of only once) When Karp reducing we must output the answer of the procedure (no post-processing) polynomial time Karp reductions are a special case of Cook reductions Question: Which complexity classes are closed under Cook reductions? From now on: mostly Karp reductions Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

26 Completeness Definition: Let C be a complexity class and let L be a language. We say that L is C-complete (w.r.t. x-red.), if 1. L is in C, and 2. for every language L in C, L is x-reducible to L. some type x of reductions In other words: L is at least as hard as any language in C. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

27 Completeness Definition: Let C be a complexity class and let L be a language. We say that L is C-complete (w.r.t. x-red.), if 1. L is in C, and 2. for every language L in C, L is x-reducible to L. Theorem: If two complexity classes C and C are both closed under x-reductions and there is a language L which is complete (w.r.t. x-red.) for both, C and C, then C = C. Proof: We only show C C : All languages in C are x-reducible to L. Since C is closed under x-reductions, it follows that C C. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

28 P-Completeness Definition: A language L is P-complete (w.r.t. P ), if 1. L is in P (membership), and 2. for every language L in P: L P L (hardness). Question: Question: Which languages in P are P-complete (with respect to P )? Which are not? What about P-completeness with respect to Cook reductions? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

29 NP-Completeness Definition: A language L is NP-complete (w.r.t. P ), if 1. L is in NP (membership), and 2. for every language L in NP: L P L (hardness). Theorem: If there exists any language that is NP-complete and is in P, then it follows that P = NP. Proof: Exercise Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

30 What we achieved: Discussion We ve introduced different types of reductions: Cook / Karp reductions log-space / poly-time reductions We ve defined the notions of closeness and completeness We ve seen how this can help us to prove equality of complexity classes Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

31 What we achieved: Discussion We ve introduced different types of reductions: Cook / Karp reductions log-space / poly-time reductions We ve defined the notions of closeness and completeness We ve seen how this can help us to prove equality of complexity classes What s missing: We do not yet know any NP-complete languages. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

32 What we achieved: Discussion We ve introduced different types of reductions: Cook / Karp reductions log-space / poly-time reductions We ve defined the notions of closeness and completeness We ve seen how this can help us to prove equality of complexity classes What s next: Present the first NP-complete problem: SAT Prove its NP-completenes: The Cook-Levin theorem Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

33 SAT: Definition SAT: Satisfiability of Boolean formulas SAT = {φ φ is a satisfiable Boolean formula} Boolean formula: Boolean variables (values 0/F, 1/T) Boolean operations (,, ) Instance: A Boolean formula φ Examples: ((x 1 x 2 x 3 ) x 1 ) (x 3 x 2 ) x 1 x 1 Problem: Decide if there exists a truth assignment for the variables of φ such that φ evaluates to TRUE. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

34 SAT is NP-complete: Overview To show that SAT is NP-complete, we need to show... membership: SAT NP. hardness: L P SAT L NP. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

35 Theorem: SAT is in NP. Proof: SAT is a member of NP Exercise Given a boolean formula φ and a truth assignment T for the variables of φ We can verify efficiently if φ(t ) evaluates to true. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

36 SAT is NP-hard To show that SAT is NP-hard, we need to show that for every problem L NP, L P SAT. Recall: The necessay steps to show L P SAT are: 1. Come up with a reduction function f. 2. Show that f is polynomial time computable. 3. Prove that f is a reduction (of L to SAT), i.e., show: w L f(w) SAT f(w) SAT w L Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

37 SAT is NP-hard To show that SAT is NP-hard, we need to show that for every problem L NP, L P SAT. Observation: If L NP, then there must exist an NTM N that decides L in at most p(n) = O(n c ) steps. Proof Idea: Given a p(n)-time NTM N and an input x for N, construct a Boolean formula φ N,x such that φ N,x satisfiable N accepts x. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

38 SAT is NP-hard 1a. The NTM N = (Q, Σ, Γ,, q 0, q accept, q reject ): States: Q = {q 0,... q k } Alphabet: Γ = {a 1,... a l } Input: x = {x 1,... x n } additional Input : x 0 := x j := j {n + 1,..., p(n)} x 1 x 2 x 3 x 4 Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

39 SAT is NP-hard 1b. The variables for our formula φ N,x : variable indices meaning state t,q t {0,..., p(n)} state t,q T N is in q Q state q after t steps pos t,i t, i {0,..., p(n)} pos t,i T N s head is on cell i after t steps tape t,i,a t, i {0,..., p(n)} tape t,i,a T cell i a Γ contains symbol a after t steps Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

40 SAT is NP-hard 1c. Overview of the formula φ N,x : The formula φ N,x consists of several parts: the boundary conditions B, the start conditions S, the transition conditions T 1, T 2, and the end condition E Altogether, φ N,x is of the form φ N,x := B S T 1 T 2 E Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

41 SAT is NP-hard 1d. The helping formula G: We will repeatedly use the following formula: ( m ) m 1 m G(v 1,..., v m ) := v i (v i v j ) i=1 j=1 i=j+1 Question: When is G(v 1,..., v m ) true? G(v 1,..., v m ) T exactly one v i T. Question: What is the size of G with respect to m? G has size O(m 2 ). Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

42 SAT is NP-hard 1e. The boundary conditions B for φ N,x : ensure that at any point t of time... the NTM N is in exactly one state, the head of N is at exactly one position, and on the tape of N there is exactly one symbol per position. Altogether, we obtain B := p(n) t=0 G(state t,q 0,..., state t,qk ) p(n) t=0 G(pos t,0,..., pos t,p(n) ) p(n) i=0 G(tape t,i,a 1,..., tape t,i,al ) p(n) t=0 Observation: The size of B is O(p(n) 3 ). Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

43 SAT is NP-hard 1f. The start conditions S for φ N,x : guarantee that for t = 0: the NTM N is in its start state q 0, the head of N is at position zero, and on the tape of N there is the initial input. Altogether, we obtain S := state 0,q0 pos 0,0 p(n) j=0 tape 0,j,xj Observation: The size of S is O(p(n)). Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

44 SAT is NP-hard 1g. The transition conditions T 1 for φ N,x : describe the changes during a transition from t to t + 1: the local situation before the transition: T b (t, i, q, a) := (state t,q pos t,i tape t,i,a ) the local situation after the transition: T a (t, i, q, a) := (state t+1,q pos t+1,i+d(r) tape t+1,i,a ) (q,a,r) (q,a) with D(left) := 1, D(right) := 1, and A B D( ) := := A 0 B Altogether, we obtain T 1 := p(n) t,i=0 q Q,a Γ (T b (t, i, q, a) T a (t, i, q, a)) Size of T 1 = O(p(n) 2 ) Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

45 SAT is NP-hard 1h. The transition conditions T 2 for φ N,x : ensures that all band positions but the one where the head is currently are not altered by a transition: T 2 := p(n) ( ( post,i tape t,i,a ) tape t+1,i,a ) t,i=0 a Γ Size of T 2 = O(p(n) 2 ) 1i. The end condition E for φ N,x : checks whether the accepting state q a is reached. Assuming that once reached, the accepting state is never left again, it suffices to check for t = p(n). E := state p(n),qa Size of E = O(1) Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

46 SAT is NP-hard 1c. Overview of the formula φ N,x : The formula φ N,x consists of several parts: the boundary conditions B, the start conditions S, the transition conditions T 1, T 2, and the end condition E Altogether, φ N,x is of the form 2. All of size polynomial in p(n) φ N,x := B S T 1 T 2 E Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

47 SAT is NP-hard To show that SAT is NP-hard, we need to show that for every problem L NP, L P SAT. Recall: The necessay steps to show L P SAT are: 1. Come up with a reduction function f. 2. Show that f is polynomial time computable. 3. Prove that f is a reduction (of L to SAT), i.e., show: w L f(w) SAT f(w) SAT w L Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

48 Conclusion: SAT is NP-complete We just proved that SAT is NP-hard. Together with the before proof that SAT NP, we obtain the famous... Cook-Levin theorem: SAT is NP-complete. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

49 Discussion We ve just shown that for language in NP, testing membership in it can be reduced to SAT. So from now on we can also prove NP-completeness of a new problem in NP by just reducing SAT to it. any NP problem P already shown SAT P will imply NPC new NP problem Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

50 Discussion We ve just shown that for language in NP, testing membership in it can be reduced to SAT. So from now on we can also prove NP-completeness of a new problem in NP by just reducing SAT to it. Moreover, every NP-complete problem we discover provides us with a new way for showing problems to be NP-complete. any NP problem P when shown NP hard problem new NP problem Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term P will imply NPC

51 Discussion We ve just shown that for language in NP, testing membership in it can be reduced to SAT. So from now on we can also prove NP-completeness of a new problem in NP by just reducing SAT to it. Moreover, every NP-complete problem we discover provides us with a new way for showing problems to be NP-complete. If SAT (or any other NPC problem) turns out to be in P, then P = NP If SAT (or any other NPC problem) turns out to be not in P, then P NP Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

52 Next Currently, SAT is our only NP-complete problem. Unfortunately, SAT is not very comfortable to work with. Thus, well start by showing that a special case of SAT is NP-complete as well: 3SAT. Then we can use 3SAT as a base problem. any NP problem P next to show 3SAT new NP problem Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term P will imply NPC

53 3SAT: Definition 3SAT (3CNF): Satisfiability of 3CNF formulas L = {φ φ is a satisfiable 3CNF formula} Instance: A 3CNF formula φ. Problem: 3CNF formulas: Decide if φ is satisfiable. in Conjunctive Normal Form 3 literals in each clause Examples: (x y z) (x y z) (x x x) ( x x x) Exercise: Are these examples satisfiable? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

54 Proof: 3SAT is a member of NP Theorem: 3SAT is in NP. Exercise Given a 3CNF formula φ and a truth assignment T for the variables of φ We can verify efficiently if φ(t ) evaluates to true. Or even shorter: 3SAT is a special case of SAT which we know is in NP. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

55 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. Recall: The necessay steps to show SAT P 3SAT are: 1. Come up with a reduction function f. 2. Show that f is polynomial time computable. 3. Prove that f is a reduction (of SAT to 3SAT): w SAT f(w) 3SAT f(w) 3SAT w SAT Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

56 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. more detailed: 1. Convert φ to an equivalent 3CNF formula using distributive law: (x (y z)) = ((x y) (x z)) double negative law: x = x De Morgan s laws: (x y) = ( x) ( y) (x y) = ( x) ( y) 2. Show that this conversion is polynomial Problem: Exercise: This conversion might be exponential! Convert (x 1 y 1 ) (x 2 y 2 ) to a CNF. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

57 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. more detailed: 1. Convert φ to an equivalent 3CNF formula using distributive law: equisatisfiable (x (y z)) = ((x y) (x z)) double negative law: x = x De Morgan s laws: (x y) = ( x) ( y) (x y) = ( x) ( y) 2. Show that this conversion is polynomial Problem: Solution: This conversion might be exponential! A different formula that s true iff φ is true. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

58 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. more detailed: 1. Convert φ to an equisatisfiable 3CNF formula: take the formula φ N,φ from the SAT-hardness proof convert this formula to a CNF formula φ N,φ convert the CNF formula to a 3CNF formula φ N,φ 2. Show that this conversion φ φ N,φ is polynomial Observation: Let N be an NTM that decides SAT in p(n) = O(n c ) steps. Then: satisfiable φ satisfiable. φ N,φ Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

59 3SAT is NP-hard 1a. Overview of the formula φ N,φ : The formula φ N,φ consists of several parts: the boundary conditions B in CNF, the start conditions S in CNF, the transition conditions T 1 and T 2 in CNF, and the end condition E in CNF Altogether, φ N,φ is of the form φ N,φ := B S T 1 T 2 E Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

60 3SAT is NP-hard 1b. The helping formula G : We repeatedly used the following formula: ( m ) m 1 m G(v 1,..., v m ) := v i (v i v j ) i=1 j=1 i=j+1 Question: What is the equivalent CNF G for G? ( m ) m 1 m G (v 1,..., v m ) := v i ( v i v j ) i=1 j=1 i=j+1 Question: What is the size of G with respect to m? G has size O(m 2 ), just as G. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

61 3SAT is NP-hard 1c. The boundary conditions B for φ N,φ : ensure that at any point t of time... the NTM N is in exactly one state, the head of N is at exactly one position, and on the tape of N there is exactly one symbol. Altogether, we obtain B := p(n) t=0 G (state t,q0,..., state t,qk ) p(n) p(n) t=0 Question: Is B in CNF? t=0 G (pos t,0,..., pos t,p(n) ) p(n) i=0 G (tape t,i,a1,..., tape t,i,al ) Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

62 3SAT is NP-hard 1d. The start conditions S for φ N,φ : guarantee that for t = 0: the NTM N is in its start state q 0, the head of N is at position zero, and on the tape of N there is the initial input. Altogether, we obtain S := state 0,q0 pos 0,0 p(n) j=0 tape 0,j,φj Observation: S is in CNF as well. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

63 3SAT is NP-hard 1e. The transition conditions T 1 for φ N,φ : describe the changes during a transition from t to t + 1: the local situation before the transition: T b (t, i, q, a) := (state t,q pos t,i tape t,i,a ) the local situation after the transition: T a (t, i, q, a) := (state t+1,q pos t+1,i+d(r) tape t+1,i,a ) (q,a,r) (q,a) with D(left) := 1, D(right) := 1, and D( ) := 0 A B := A B Altogether, we obtain T 1 := p(n) t,i=0 q Q,a Γ CNF(T b (t, i, q, a) T a (t, i, q, a)) Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

64 3SAT is NP-hard 1e. The transition conditions T 1 for φ N,φ : T b (t, i, q, a) := (state t,q pos t,i tape t,i,a ) T a (t, i, q, a) := (state t+1,q pos t+1,i+d(r) tape t+1,i,a ) (q,a,r) (q,a) A B := A B T 1 := p(n) t,i=0 q Q,a Γ CNF(T b (t, i, q, a) T a (t, i, q, a)) Question: What are the sizes of T b (t,i,q,a) T a (t,i,q,a) and of its equivalent CNF-formula? Question: What is the size of T 1 w.r.t. the original T 1? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

65 3SAT is NP-hard 1f. The transition conditions T 2 for φ N,φ : ensures that all band positions but the one where the head is currently are not altered by a transition: T 2 := p(n) CNF(( pos t,i tape t,i,a ) tape t+1,i,a ) t,i=0 a Γ = p(n) CNF( ( pos t,i tape t,i,a ) tape t+1,i,a ) t,i=0 a Γ = p(n) CNF(pos t,i tape t,i,a tape t+1,i,a ) t,i=0 a Γ Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

66 3SAT is NP-hard 1g. The end condition E for φ N,φ : checks whether the accepting state q a is reached. Assuming that once reached, the accepting state is never left again, it suffices to check for t = p(n). E := state p(n),qa Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

67 3SAT is NP-hard 1a. Overview of the formula φ N,φ : The formula φ N,φ consists of several parts: the boundary conditions B in CNF, the start conditions S in CNF, the transition conditions T 1 and T 2 in CNF, and the end condition E in CNF 2. All of size polynomial in p(n) Altogether, φ N,φ is of the form φ N,φ := B S T 1 T 2 E Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

68 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. more detailed: 1. Convert φ to an equisatisfiable 3CNF formula: take the formula φ N,φ from the SAT-hardness proof convert this formula to a CNF formula φ N,φ convert the CNF formula to a 3CNF formula φ N,φ 2. Show that this conversion φ φ N,φ is polynomial Observation: Let N be an NTM that decides SAT in p(n) = O(n c ) steps. Then: φ N,φ satisfiable φ satisfiable. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

69 3SAT is NP-hard 1h. Conversion of φ N,φ to φ N,φ : Observation: The conversion CNF 3CNF can be done independently for every clause. clauses with = 3 literals: (x y z) already fine :-) clauses with < 3 literals: (x y), ( z) duplicate literals: (x y y), ( z z z) clauses with > 3 literals: (x 1 x 2 x 3... x m ) split using new variables c 2,... c m 2 : (x 1 x 2 c 2 ) ( c 2 x 3 c 3 )... ( c m 2 x m 1 x m ) Altogether: φ = n φ = O(n) Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

70 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. more detailed: 1. Convert φ to an equisatisfiable 3CNF formula: take the formula φ N,φ from the SAT-hardness proof convert this formula to a CNF formula φ N,φ convert the CNF formula to a 3CNF formula φ N,φ 2. Show that this conversion φ φ N,φ is polynomial Observation: Let N be an NTM that decides SAT in p(n) = O(n c ) steps. Then: satisfiable φ satisfiable. φ N,φ Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

71 3SAT is NP-hard Theorem: 3SAT is NP-hard. Proof idea: Show SAT P 3SAT. Recall: The necessay steps to show SAT P 3SAT are: 1. Come up with a reduction function f. 2. Show that f is polynomial time computable. 3. Prove that f is a reduction (of SAT to 3SAT): w SAT f(w) 3SAT f(w) 3SAT w SAT Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

72 Conclusion: 3SAT is NP-complete We just proved that 3SAT is NP-hard. Together with the before proof that 3SAT NP, we obtain that 3SAT is NP-complete. In fact we ve not only shown SAT P 3SAT, but even (half) directly L P 3SAT L NP. Exercise: What about ksat for some fixed k 3? For example, k = 2, k = 4? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

73 SAT is NP-complete. Discussion 3SAT (3CNF) is NP-complete. ksat any NP problem 2SAT On the way: Sketched: P NTM φ SAT CNF CNF is NP-complete, ksat (kcnf) is NPC for fixed k 3. 2SAT (2CNF) is not NPC. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term P φ φ 3SAT

74 Next NP-complete problems from graph theory: INDEPENDENT SET CLIQUE VERTEX COVER INDEP. SET any NP problem P NTM φ 3SAT P NEXT CLIQUE VERTEX COVER Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

75 INDEPENDENT SET: Definition In an (undirected) graph G = (V, E), an independent set is a subset V V of the vertices such that none of the vertices in V are connected: u, v V (u, v) E. Optimization problem: What is (the size of) a largest independent set in a given graph G? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

76 INDEPENDENT SET: Definition In an (undirected) graph G = (V, E), an independent set is a subset V V of the vertices such that none of the vertices in V are connected: u, v V (u, v) E. Optimization problem: What is (the size of) a largest independent set in a given graph G? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

77 INDEPENDENT SET: Definition In an (undirected) graph G = (V, E), an independent set is a subset V V of the vertices such that none of the vertices in V are connected: u, v V (u, v) E. Optimization problem: What is (the size of) a largest independent set in a given graph G? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

78 INDEPENDENT SET: Definition In an (undirected) graph G = (V, E), an independent set is a subset V V of the vertices such that none of the vertices in V are connected: u, v V (u, v) E. Decision problem: Does a given graph G contain an independent set of size k? k = 4 : k = 5 :? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

79 INDEPENDENT SET: Definition In an (undirected) graph G = (V, E), an independent set is a subset V V of the vertices such that none of the vertices in V are connected: u, v V (u, v) E. Decision problem: Does a given graph G contain an independent set of size k? Instance: A graph G and an integer k. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

80 INDEPENDENT SET is in NP Theorem: INDEPENDENT SET is in NP. Proof: Exercise Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

81 INDEPENDENT SET is in NPC Theorem: INDEPENDENT SET is NP-hard. Proof: We ll show 3SAT P INDEPENDENT SET φ = (x y z) ( x y z) ( x y z) f(φ) = (G, k) φ satisfiable G has indep. set of size k k Symbol picture Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

82 INDEPENDENT SET is in NPC 1. The construction of f(φ) = (G, k): A triangle for every clause of φ (3 vertices, 3 edges) An edge between c and c (IF in different clauses of φ) k is the number of clauses of φ φ = (x y z) ( x y z) ( x y z) G x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

83 INDEPENDENT SET is in NPC 1. The construction of f(φ) = (G, k): A triangle for every clause of φ (3 vertices, 3 edges) An edge between c and c (IF in different clauses of φ) k is the number of clauses of φ φ = (x y z) ( x y z) ( x y z) G x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

84 INDEPENDENT SET is in NPC 1. The construction of f(φ) = (G, k): A triangle for every clause of φ (3 vertices, 3 edges) An edge between c and c (IF in different clauses of φ) k is the number of clauses of φ φ = (x y z) ( x y z) ( x y z) G k =3 x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

85 INDEPENDENT SET is in NPC 2. The size of f(φ) = (G, k) (with φ = n): One vertex per literal: V = O(n) At most one edge between 2 vertices: E, G = O(n 2 ) In total: (G, k) = O(n 2 ) polynomial φ = (x y z) ( x y z) ( x y z) G k =3 x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

86 INDEPENDENT SET is in NPC 3a. Searching an independent set of size k in G: At most one vertex per triangle Size k exactly one vertex per triangle For any variable c: At most c OR c φ = (x y z) ( x y z) ( x y z) G k =3 x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

87 INDEPENDENT SET is in NPC 3b. φ satisfiable G has indep. set of size k: φ satisfiable choose some true literal per clause. indep. set of size k set all literals for V to true 1 true literal per clause; valid: (c, c) E. φ = (x y z) ( x y z) ( x y z) G k =3 x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

88 INDEPENDENT SET is in NPC Theorem: INDEPENDENT SET is NP-hard. Proof: We ll show 3SAT P INDEPENDENT SET Corollary: INDEPENDENT SET is NP-complete. G x x x z y z y z y Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

89 CLIQUE: Definition In an (undirected) graph G = (V, E), a clique is a subset V V of the vertices such that all of the vertices in V are pairwise connected: u, v V (u, v) E. Optimization problem: What is (the size of) a largest clique in a given graph G? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

90 CLIQUE: Definition In an (undirected) graph G = (V, E), a clique is a subset V V of the vertices such that all of the vertices in V are pairwise connected: u, v V (u, v) E. Optimization problem: What is (the size of) a largest clique in a given graph G? Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

91 k = 4 : k = 5 :? CLIQUE: Definition In an (undirected) graph G = (V, E), a clique is a subset V V of the vertices such that all of the vertices in V are pairwise connected: u, v V (u, v) E. Decision problem: a clique of size k? Does a given graph G contain Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

92 CLIQUE: Definition In an (undirected) graph G = (V, E), a clique is a subset V V of the vertices such that all of the vertices in V are pairwise connected: u, v V (u, v) E. Decision problem: Does a given graph G contain a clique of size k? Instance: A graph G and an integer k. Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

93 Theorem: CLIQUE is in NP. Proof: CLIQUE is in NP Given a graph G = (V,E) and a subset V V of size k We can verify efficiently if V is a clique: Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

94 Theorem: CLIQUE is NP-hard. CLIQUE is in NPC Proof: We ll show INDEPENDENT SET P CLIQUE k f(g, k) = (G, k ) k Symbol picture G has indep. set of size k G has k -clique Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

95 CLIQUE is in NPC 1. The construction of f(g, k) = (G, k ): The vertices: V = V. The edges: (u, v) E (u, v) E. The size: k = k. k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

96 CLIQUE is in NPC 1. The construction of f(g, k) = (G, k ): The vertices: V = V. The edges: (u, v) E (u, v) E. The size: k = k. k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

97 CLIQUE is in NPC 1. The construction of f(g, k) = (G, k ): The vertices: V = V. The edges: (u, v) E (u, v) E. The size: k = k. k k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

98 CLIQUE is in NPC 2. The size of f(g, k) = (G, k ) (with (G, k) = n): The vertices: V = V = O(n). The edges: E V 2 = O(n 2 ). In total: (G, k ) = O(n 2 ) polynomial k k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

99 CLIQUE is in NPC 3. G has indep. set of size k G has k -clique: G has indep. set V i V V i is clique in G. G has clique V c V V c is indep. set in G k k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

100 Theorem: CLIQUE is NP-hard. CLIQUE is in NPC Proof: We ll show INDEPENDENT SET P CLIQUE Corollary: CLIQUE is NP-complete. k k Birgit Vogtenhuber Problem Analysis and Complexity Theory, , summer term

CSE 135: Introduction to Theory of Computation NP-completeness

CSE 135: Introduction to Theory of Computation NP-completeness CSE 135: Introduction to Theory of Computation NP-completeness Sungjin Im University of California, Merced 04-15-2014 Significance of the question if P? NP Perhaps you have heard of (some of) the following

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

NP-Complete Problems. More reductions

NP-Complete Problems. More reductions NP-Complete Problems More reductions Definitions P: problems that can be solved in polynomial time (typically in n, size of input) on a deterministic Turing machine Any normal computer simulates a DTM

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 25 Last time Class NP Today Polynomial-time reductions Adam Smith; Sofya Raskhodnikova 4/18/2016 L25.1 The classes P and NP P is the class of languages decidable

More information

Lecture 16: Time Complexity and P vs NP

Lecture 16: Time Complexity and P vs NP 6.045 Lecture 16: Time Complexity and P vs NP 1 Time-Bounded Complexity Classes Definition: TIME(t(n)) = { L there is a Turing machine M with time complexity O(t(n)) so that L = L(M) } = { L L is a language

More information

Chapter 7: Time Complexity

Chapter 7: Time Complexity Chapter 7: Time Complexity 1 Time complexity Let M be a deterministic Turing machine that halts on all inputs. The running time or time complexity of M is the function f: N N, where f(n) is the maximum

More information

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem. 1 More on NP In this set of lecture notes, we examine the class NP in more detail. We give a characterization of NP which justifies the guess and verify paradigm, and study the complexity of solving search

More information

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions Polynomial time reduction and NP-completeness Exploring some time complexity limits of polynomial time algorithmic solutions 1 Polynomial time reduction Definition: A language L is said to be polynomial

More information

NP Complete Problems. COMP 215 Lecture 20

NP Complete Problems. COMP 215 Lecture 20 NP Complete Problems COMP 215 Lecture 20 Complexity Theory Complexity theory is a research area unto itself. The central project is classifying problems as either tractable or intractable. Tractable Worst

More information

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler Complexity Theory Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 15 May, 2018 Reinhard

More information

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

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181. Complexity Theory Complexity Theory Outline Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität

More information

Chapter 2 : Time complexity

Chapter 2 : Time complexity Dr. Abhijit Das, Chapter 2 : Time complexity In this chapter we study some basic results on the time complexities of computational problems. concentrate our attention mostly on polynomial time complexities,

More information

Essential facts about NP-completeness:

Essential facts about NP-completeness: CMPSCI611: NP Completeness Lecture 17 Essential facts about NP-completeness: Any NP-complete problem can be solved by a simple, but exponentially slow algorithm. We don t have polynomial-time solutions

More information

Welcome to... Problem Analysis and Complexity Theory , 3 VU

Welcome to... Problem Analysis and Complexity Theory , 3 VU Welcome to... Problem Analysis and Complexity Theory 716.054, 3 VU Birgit Vogtenhuber Institute for Software Technology email: bvogt@ist.tugraz.at office: Inffeldgasse 16B/II, room IC02044 slides: http://www.ist.tugraz.at/pact17.html

More information

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

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch 6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch Today: More Complexity Theory Polynomial-time reducibility, NP-completeness, and the Satisfiability (SAT) problem Topics: Introduction

More information

Lecture 3: Nondeterminism, NP, and NP-completeness

Lecture 3: Nondeterminism, NP, and NP-completeness CSE 531: Computational Complexity I Winter 2016 Lecture 3: Nondeterminism, NP, and NP-completeness January 13, 2016 Lecturer: Paul Beame Scribe: Paul Beame 1 Nondeterminism and NP Recall the definition

More information

NP-Complete Reductions 1

NP-Complete Reductions 1 x x x 2 x 2 x 3 x 3 x 4 x 4 CS 4407 2 22 32 Algorithms 3 2 23 3 33 NP-Complete Reductions Prof. Gregory Provan Department of Computer Science University College Cork Lecture Outline x x x 2 x 2 x 3 x 3

More information

Advanced Topics in Theoretical Computer Science

Advanced Topics in Theoretical Computer Science Advanced Topics in Theoretical Computer Science Part 5: Complexity (Part II) 30.01.2014 Viorica Sofronie-Stokkermans Universität Koblenz-Landau e-mail: sofronie@uni-koblenz.de 1 Contents Recall: Turing

More information

NP-Completeness. A language B is NP-complete iff B NP. This property means B is NP hard

NP-Completeness. A language B is NP-complete iff B NP. This property means B is NP hard NP-Completeness A language B is NP-complete iff B NP A NP A P B This property means B is NP hard 1 3SAT is NP-complete 2 Result Idea: B is known to be NP complete Use it to prove NP-Completeness of C IF

More information

Theory of Computation Time Complexity

Theory of Computation Time Complexity Theory of Computation Time Complexity Bow-Yaw Wang Academia Sinica Spring 2012 Bow-Yaw Wang (Academia Sinica) Time Complexity Spring 2012 1 / 59 Time for Deciding a Language Let us consider A = {0 n 1

More information

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München Complexity Theory Jörg Kreiker Chair for Theoretical Computer Science Prof. Esparza TU München Summer term 2010 Lecture 4 NP-completeness Recap: relations between classes EXP PSPACE = NPSPACE conp NP conp

More information

BBM402-Lecture 11: The Class NP

BBM402-Lecture 11: The Class NP BBM402-Lecture 11: The Class NP Lecturer: Lale Özkahya Resources for the presentation: http://ocw.mit.edu/courses/electrical-engineering-andcomputer-science/6-045j-automata-computability-andcomplexity-spring-2011/syllabus/

More information

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete) CS5371 Theory of Computation Lecture 19: Complexity IV (More on NP, NP-Complete) Objectives More discussion on the class NP Cook-Levin Theorem The Class NP revisited Recall that NP is the class of language

More information

Lecture 4 : Quest for Structure in Counting Problems

Lecture 4 : Quest for Structure in Counting Problems CS6840: Advanced Complexity Theory Jan 10, 2012 Lecture 4 : Quest for Structure in Counting Problems Lecturer: Jayalal Sarma M.N. Scribe: Dinesh K. Theme: Between P and PSPACE. Lecture Plan:Counting problems

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 18 February 16, 2018 February 16, 2018 CS21 Lecture 18 1 Outline the complexity class NP 3-SAT is NP-complete NP-complete problems: independent set, vertex cover,

More information

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

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory

More information

The Cook-Levin Theorem

The Cook-Levin Theorem An Exposition Sandip Sinha Anamay Chaturvedi Indian Institute of Science, Bangalore 14th November 14 Introduction Deciding a Language Let L {0, 1} be a language, and let M be a Turing machine. We say M

More information

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

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B That is, A P B When this is true, we say B is NP-hard On

More information

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office? N P NP Completeness Announcements Friday Four Square! Today at 4:15PM, outside Gates. Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Explore P, NP, and their connection. Did

More information

1. Introduction Recap

1. Introduction Recap 1. Introduction Recap 1. Tractable and intractable problems polynomial-boundness: O(n k ) 2. NP-complete problems informal definition 3. Examples of P vs. NP difference may appear only slightly 4. Optimization

More information

Finish K-Complexity, Start Time Complexity

Finish K-Complexity, Start Time Complexity 6.045 Finish K-Complexity, Start Time Complexity 1 Kolmogorov Complexity Definition: The shortest description of x, denoted as d(x), is the lexicographically shortest string such that M(w) halts

More information

Lecture 19: Finish NP-Completeness, conp and Friends

Lecture 19: Finish NP-Completeness, conp and Friends 6.045 Lecture 19: Finish NP-Completeness, conp and Friends 1 Polynomial Time Reducibility f : Σ* Σ* is a polynomial time computable function if there is a poly-time Turing machine M that on every input

More information

NP-Completeness and Boolean Satisfiability

NP-Completeness and Boolean Satisfiability NP-Completeness and Boolean Satisfiability Mridul Aanjaneya Stanford University August 14, 2012 Mridul Aanjaneya Automata Theory 1/ 49 Time-Bounded Turing Machines A Turing Machine that, given an input

More information

Complexity (Pre Lecture)

Complexity (Pre Lecture) Complexity (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2018 Dantam (Mines CSCI-561) Complexity (Pre Lecture) Fall 2018 1 / 70 Why? What can we always compute efficiently? What

More information

Lecture 13, Fall 04/05

Lecture 13, Fall 04/05 Lecture 13, Fall 04/05 Short review of last class NP hardness conp and conp completeness Additional reductions and NP complete problems Decision, search, and optimization problems Coping with NP completeness

More information

SAT, Coloring, Hamiltonian Cycle, TSP

SAT, Coloring, Hamiltonian Cycle, TSP 1 SAT, Coloring, Hamiltonian Cycle, TSP Slides by Carl Kingsford Apr. 28, 2014 Sects. 8.2, 8.7, 8.5 2 Boolean Formulas Boolean Formulas: Variables: x 1, x 2, x 3 (can be either true or false) Terms: t

More information

Correctness of Dijkstra s algorithm

Correctness of Dijkstra s algorithm Correctness of Dijkstra s algorithm Invariant: When vertex u is deleted from the priority queue, d[u] is the correct length of the shortest path from the source s to vertex u. Additionally, the value d[u]

More information

NP-Complete Reductions 2

NP-Complete Reductions 2 x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 CS 447 11 13 21 23 31 33 Algorithms NP-Complete Reductions 2 Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline NP-Complete

More information

NP Completeness. Richard Karp, 1972.

NP Completeness. Richard Karp, 1972. NP Completeness In this paper we give theorems that suggest, but do not imply, that these problems as well as many others, will remain intractable perpetually. Richard Karp, 1972. Reductions At the heart

More information

CS154, Lecture 17: conp, Oracles again, Space Complexity

CS154, Lecture 17: conp, Oracles again, Space Complexity CS154, Lecture 17: conp, Oracles again, Space Complexity Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode: Guess string

More information

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k. Complexity Theory Problems are divided into complexity classes. Informally: So far in this course, almost all algorithms had polynomial running time, i.e., on inputs of size n, worst-case running time

More information

Polynomial-time Reductions

Polynomial-time Reductions Polynomial-time Reductions Disclaimer: Many denitions in these slides should be taken as the intuitive meaning, as the precise meaning of some of the terms are hard to pin down without introducing the

More information

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

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015 CS 374: Algorithms & Models of Computation, Spring 2015 NP Completeness Lecture 23 November 19, 2015 Chandra & Lenny (UIUC) CS374 1 Spring 2015 1 / 37 Part I NP-Completeness Chandra & Lenny (UIUC) CS374

More information

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

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1 NP CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu 320 NP 1 NP Complete A class of problems where: No polynomial time algorithm has been discovered No proof that one doesn t exist 320

More information

Computability Theory

Computability Theory CS:4330 Theory of Computation Spring 2018 Computability Theory The class NP Haniel Barbosa Readings for this lecture Chapter 7 of [Sipser 1996], 3rd edition. Section 7.3. Question Why are we unsuccessful

More information

Time Complexity. CS60001: Foundations of Computing Science

Time Complexity. CS60001: Foundations of Computing Science Time Complexity CS60001: Foundations of Computing Science Professor, Dept. of Computer Sc. & Engg., Measuring Complexity Definition Let M be a deterministic Turing machine that halts on all inputs. The

More information

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65 Undecidable Problems Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, 2018 1/ 65 Algorithmically Solvable Problems Let us assume we have a problem P. If there is an algorithm solving

More information

NP-Completeness. Subhash Suri. May 15, 2018

NP-Completeness. Subhash Suri. May 15, 2018 NP-Completeness Subhash Suri May 15, 2018 1 Computational Intractability The classical reference for this topic is the book Computers and Intractability: A guide to the theory of NP-Completeness by Michael

More information

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine. The Class NP NP is the problems that can be solved in polynomial time by a nondeterministic machine. NP The time taken by nondeterministic TM is the length of the longest branch. The collection of all

More information

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

Lecture 17: Cook-Levin Theorem, NP-Complete Problems 6.045 Lecture 17: Cook-Levin Theorem, NP-Complete Problems 1 Is SAT solvable in O(n) time on a multitape TM? Logic circuits of 6n gates for SAT? If yes, then not only is P=NP, but there would be a dream

More information

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

CSE 555 HW 5 SAMPLE SOLUTION. Question 1. CSE 555 HW 5 SAMPLE SOLUTION Question 1. Show that if L is PSPACE-complete, then L is NP-hard. Show that the converse is not true. If L is PSPACE-complete, then for all A PSPACE, A P L. We know SAT PSPACE

More information

SAT, NP, NP-Completeness

SAT, NP, NP-Completeness CS 473: Algorithms, Spring 2018 SAT, NP, NP-Completeness Lecture 22 April 13, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Part I Reductions Continued Ruta (UIUC)

More information

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170 UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, 2003 Notes 22 for CS 170 1 NP-completeness of Circuit-SAT We will prove that the circuit satisfiability

More information

1 Non-deterministic Turing Machine

1 Non-deterministic Turing Machine 1 Non-deterministic Turing Machine A nondeterministic Turing machine is a generalization of the standard TM for which every configuration may yield none, or one or more than one next configurations. In

More information

Complexity, P and NP

Complexity, P and NP Complexity, P and NP EECS 477 Lecture 21, 11/26/2002 Last week Lower bound arguments Information theoretic (12.2) Decision trees (sorting) Adversary arguments (12.3) Maximum of an array Graph connectivity

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 26 Computational Intractability Polynomial Time Reductions Sofya Raskhodnikova S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.1 What algorithms are

More information

NP Completeness and Approximation Algorithms

NP Completeness and Approximation Algorithms Winter School on Optimization Techniques December 15-20, 2016 Organized by ACMU, ISI and IEEE CEDA NP Completeness and Approximation Algorithms Susmita Sur-Kolay Advanced Computing and Microelectronic

More information

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

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA. Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA NP Completeness Susmita Sur-Kolay Advanced Computing and Microelectronics Unit

More information

TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP. THURSDAY Mar 20

TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP. THURSDAY Mar 20 TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP THURSDAY Mar 20 COMPLEXITY THEORY Studies what can and can t be computed under limited resources such as time, space, etc Today:

More information

CS 6505, Complexity and Algorithms Week 7: NP Completeness

CS 6505, Complexity and Algorithms Week 7: NP Completeness CS 6505, Complexity and Algorithms Week 7: NP Completeness Reductions We have seen some problems in P and NP, and we ve talked about space complexity. The Space Hierarchy Theorem showed us that there are

More information

CSCI3390-Lecture 16: NP-completeness

CSCI3390-Lecture 16: NP-completeness CSCI3390-Lecture 16: NP-completeness 1 Summary We recall the notion of polynomial-time reducibility. This is just like the reducibility we studied earlier, except that we require that the function mapping

More information

Definition: conp = { L L NP } What does a conp computation look like?

Definition: conp = { L L NP } What does a conp computation look like? Space Complexity 28 Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode: Guess string y of x k length and the machine accepts

More information

CS151 Complexity Theory. Lecture 1 April 3, 2017

CS151 Complexity Theory. Lecture 1 April 3, 2017 CS151 Complexity Theory Lecture 1 April 3, 2017 Complexity Theory Classify problems according to the computational resources required running time storage space parallelism randomness rounds of interaction,

More information

Week 3: Reductions and Completeness

Week 3: Reductions and Completeness Computational Complexity Theory Summer HSSP 2018 Week 3: Reductions and Completeness Dylan Hendrickson MIT Educational Studies Program 3.1 Reductions Suppose I know how to solve some problem quickly. How

More information

Show that the following problems are NP-complete

Show that the following problems are NP-complete Show that the following problems are NP-complete April 7, 2018 Below is a list of 30 exercises in which you are asked to prove that some problem is NP-complete. The goal is to better understand the theory

More information

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

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch] NP-Completeness Andreas Klappenecker [based on slides by Prof. Welch] 1 Prelude: Informal Discussion (Incidentally, we will never get very formal in this course) 2 Polynomial Time Algorithms Most of the

More information

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation Lecture 20: PSPACE November 15, 2016 CS 1010 Theory of Computation Recall that PSPACE = k=1 SPACE(nk ). We will see that a relationship between time and space complexity is given by: P NP PSPACE = NPSPACE

More information

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

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition. Lecture #14: 0.0.1 NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition. 0.0.2 Preliminaries: Definition 1 n abstract problem Q is a binary relations on a set I of

More information

Theory of Computation Chapter 9

Theory of Computation Chapter 9 0-0 Theory of Computation Chapter 9 Guan-Shieng Huang May 12, 2003 NP-completeness Problems NP: the class of languages decided by nondeterministic Turing machine in polynomial time NP-completeness: Cook

More information

Complexity: moving from qualitative to quantitative considerations

Complexity: moving from qualitative to quantitative considerations Complexity: moving from qualitative to quantitative considerations Textbook chapter 7 Complexity Theory: study of what is computationally feasible (or tractable) with limited resources: running time (main

More information

conp, Oracles, Space Complexity

conp, Oracles, Space Complexity conp, Oracles, Space Complexity 1 What s next? A few possibilities CS161 Design and Analysis of Algorithms CS254 Complexity Theory (next year) CS354 Topics in Circuit Complexity For your favorite course

More information

Computability and Complexity CISC462, Fall 2018, Space complexity 1

Computability and Complexity CISC462, Fall 2018, Space complexity 1 Computability and Complexity CISC462, Fall 2018, Space complexity 1 SPACE COMPLEXITY This material is covered in Chapter 8 of the textbook. For simplicity, we define the space used by a Turing machine

More information

Theory of Computer Science

Theory of Computer Science Theory of Computer Science E3. Proving NP-Completeness Gabriele Röger University of Basel May 16, 2018 Course Overview Theory Background Logic Automata Theory Computability Complexity Nondeterminism P,

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Complexity Professor Daniel Leeds dleeds@fordham.edu JMH 332 Computability Are we guaranteed to get an answer? Complexity How long do we have to wait for an answer? (Ch7)

More information

Polynomial-Time Reductions

Polynomial-Time Reductions Reductions 1 Polynomial-Time Reductions Classify Problems According to Computational Requirements Q. Which problems will we be able to solve in practice? A working definition. [von Neumann 1953, Godel

More information

SOLUTION: SOLUTION: SOLUTION:

SOLUTION: SOLUTION: SOLUTION: Convert R and S into nondeterministic finite automata N1 and N2. Given a string s, if we know the states N1 and N2 may reach when s[1...i] has been read, we are able to derive the states N1 and N2 may

More information

P = k T IME(n k ) Now, do all decidable languages belong to P? Let s consider a couple of languages:

P = k T IME(n k ) Now, do all decidable languages belong to P? Let s consider a couple of languages: CS 6505: Computability & Algorithms Lecture Notes for Week 5, Feb 8-12 P, NP, PSPACE, and PH A deterministic TM is said to be in SP ACE (s (n)) if it uses space O (s (n)) on inputs of length n. Additionally,

More information

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof T-79.5103 / Autumn 2006 NP-complete problems 1 NP-COMPLETE PROBLEMS Characterizing NP Variants of satisfiability Graph-theoretic problems Coloring problems Sets and numbers Pseudopolynomial algorithms

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 25 NP Completeness Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 NP-Completeness Some

More information

Spring Lecture 21 NP-Complete Problems

Spring Lecture 21 NP-Complete Problems CISC 320 Introduction to Algorithms Spring 2014 Lecture 21 NP-Complete Problems 1 We discuss some hard problems: how hard? (computational complexity) what makes them hard? any solutions? Definitions Decision

More information

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017 ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness Prof. Peter Bermel January 11, 2017 Outline Overview Definitions Computing Machines Church-Turing Thesis Polynomial Time (Class P)

More information

COP 4531 Complexity & Analysis of Data Structures & Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms COP 4531 Complexity & Analysis of Data Structures & Algorithms Lecture 18 Reductions and NP-completeness Thanks to Kevin Wayne and the text authors who contributed to these slides Classify Problems According

More information

NP Completeness and Approximation Algorithms

NP Completeness and Approximation Algorithms Chapter 10 NP Completeness and Approximation Algorithms Let C() be a class of problems defined by some property. We are interested in characterizing the hardest problems in the class, so that if we can

More information

NP-Completeness. Sections 28.5, 28.6

NP-Completeness. Sections 28.5, 28.6 NP-Completeness Sections 28.5, 28.6 NP-Completeness A language L might have these properties: 1. L is in NP. 2. Every language in NP is deterministic, polynomial-time reducible to L. L is NP-hard iff it

More information

ITCS:CCT09 : Computational Complexity Theory Apr 8, Lecture 7

ITCS:CCT09 : Computational Complexity Theory Apr 8, Lecture 7 ITCS:CCT09 : Computational Complexity Theory Apr 8, 2009 Lecturer: Jayalal Sarma M.N. Lecture 7 Scribe: Shiteng Chen In this lecture, we will discuss one of the basic concepts in complexity theory; namely

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Logistics HW7 due tonight Thursday's class: REVIEW Final exam on Thursday Dec 8, 8am-11am, LEDDN AUD Note card allowed

More information

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

Lecture 25: Cook s Theorem (1997) Steven Skiena.   skiena Lecture 25: Cook s Theorem (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Prove that Hamiltonian Path is NP

More information

Introduction. Pvs.NPExample

Introduction. Pvs.NPExample Introduction Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 09 NP-Completeness (Chapter 34) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu I

More information

Intractable Problems [HMU06,Chp.10a]

Intractable Problems [HMU06,Chp.10a] Intractable Problems [HMU06,Chp.10a] Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions A 10 Minute Motivation https://www.youtube.com/watch?v=yx40hbahx3s 1 Time-Bounded TM s A Turing

More information

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP CS 301 - Lecture 29 P, NP, and NP-Completeness Fall 2008 Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata Equivalence of

More information

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

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9 1 Computational Complexity and Intractability: An Introduction to the Theory of NP Chapter 9 2 Objectives Classify problems as tractable or intractable Define decision problems Define the class P Define

More information

Computability and Complexity Theory: An Introduction

Computability and Complexity Theory: An Introduction Computability and Complexity Theory: An Introduction meena@imsc.res.in http://www.imsc.res.in/ meena IMI-IISc, 20 July 2006 p. 1 Understanding Computation Kinds of questions we seek answers to: Is a given

More information

Computational Models Lecture 11, Spring 2009

Computational Models Lecture 11, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models Lecture 11, Spring 2009 Deterministic Time Classes NonDeterministic Time Classes

More information

A An Overview of Complexity Theory for the Algorithm Designer

A An Overview of Complexity Theory for the Algorithm Designer A An Overview of Complexity Theory for the Algorithm Designer A.1 Certificates and the class NP A decision problem is one whose answer is either yes or no. Two examples are: SAT: Given a Boolean formula

More information

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010 CS311 Computational Structures NP-completeness Lecture 18 Andrew P. Black Andrew Tolmach 1 Some complexity classes P = Decidable in polynomial time on deterministic TM ( tractable ) NP = Decidable in polynomial

More information

6.841/18.405J: Advanced Complexity Wednesday, February 12, Lecture Lecture 3

6.841/18.405J: Advanced Complexity Wednesday, February 12, Lecture Lecture 3 6.841/18.405J: Advanced Complexity Wednesday, February 12, 2003 Lecture Lecture 3 Instructor: Madhu Sudan Scribe: Bobby Kleinberg 1 The language MinDNF At the end of the last lecture, we introduced the

More information

NP and NP-Completeness

NP and NP-Completeness CSC 364S Notes University of Toronto, Spring, 2003 NP NP and NP-Completeness NP is a class of languages that contains all of P, but which most people think also contains many languages that aren t in P.

More information

Lecture 2 (Notes) 1. The book Computational Complexity: A Modern Approach by Sanjeev Arora and Boaz Barak;

Lecture 2 (Notes) 1. The book Computational Complexity: A Modern Approach by Sanjeev Arora and Boaz Barak; Topics in Theoretical Computer Science February 29, 2016 Lecturer: Ola Svensson Lecture 2 (Notes) Scribes: Ola Svensson Disclaimer: These notes were written for the lecturer only and may contain inconsistent

More information

: Computational Complexity Lecture 3 ITCS, Tsinghua Univesity, Fall October 2007

: Computational Complexity Lecture 3 ITCS, Tsinghua Univesity, Fall October 2007 80240233: Computational Complexity Lecture 3 ITCS, Tsinghua Univesity, Fall 2007 16 October 2007 Instructor: Andrej Bogdanov Notes by: Jialin Zhang and Pinyan Lu In this lecture, we introduce the complexity

More information