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

Similar documents
CSE 135: Introduction to Theory of Computation NP-completeness

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP

NP-Complete Problems. More reductions

Intro to Theory of Computation

Lecture 16: Time Complexity and P vs NP

Chapter 7: Time Complexity

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

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

NP Complete Problems. COMP 215 Lecture 20

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

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

Chapter 2 : Time complexity

Essential facts about NP-completeness:

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

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

Lecture 3: Nondeterminism, NP, and NP-completeness

NP-Complete Reductions 1

Advanced Topics in Theoretical Computer Science

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

Theory of Computation Time Complexity

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

BBM402-Lecture 11: The Class NP

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

Lecture 4 : Quest for Structure in Counting Problems

CS21 Decidability and Tractability

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

The Cook-Levin Theorem

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

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?

1. Introduction Recap

Finish K-Complexity, Start Time Complexity

Lecture 19: Finish NP-Completeness, conp and Friends

NP-Completeness and Boolean Satisfiability

Complexity (Pre Lecture)

Lecture 13, Fall 04/05

SAT, Coloring, Hamiltonian Cycle, TSP

Correctness of Dijkstra s algorithm

NP-Complete Reductions 2

NP Completeness. Richard Karp, 1972.

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

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

Polynomial-time Reductions

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

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

Computability Theory

Time Complexity. CS60001: Foundations of Computing Science

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

NP-Completeness. Subhash Suri. May 15, 2018

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

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

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

SAT, NP, NP-Completeness

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

1 Non-deterministic Turing Machine

Complexity, P and NP

Algorithm Design and Analysis

NP Completeness and Approximation Algorithms

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

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

CS 6505, Complexity and Algorithms Week 7: NP Completeness

CSCI3390-Lecture 16: NP-completeness

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

CS151 Complexity Theory. Lecture 1 April 3, 2017

Week 3: Reductions and Completeness

Show that the following problems are NP-complete

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

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

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

Theory of Computation Chapter 9

Complexity: moving from qualitative to quantitative considerations

conp, Oracles, Space Complexity

Computability and Complexity CISC462, Fall 2018, Space complexity 1

Theory of Computer Science

CISC 4090 Theory of Computation

Polynomial-Time Reductions

SOLUTION: SOLUTION: SOLUTION:

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

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Design and Analysis of Algorithms

Spring Lecture 21 NP-Complete Problems

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

NP Completeness and Approximation Algorithms

NP-Completeness. Sections 28.5, 28.6

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

CSE 105 THEORY OF COMPUTATION

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

Introduction. Pvs.NPExample

Intractable Problems [HMU06,Chp.10a]

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

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

Computability and Complexity Theory: An Introduction

Computational Models Lecture 11, Spring 2009

A An Overview of Complexity Theory for the Algorithm Designer

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

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

NP and NP-Completeness

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

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

Transcription:

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 Birgit Vogtenhuber Problem Analysis and Complexity Theory, 716.054, summer term 2017 1

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, 716.054, summer term 2017 2-2

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, 716.054, summer term 2017 2-5

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, 716.054, summer term 2017 3

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, 716.054, summer term 2017 4

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, 716.054, summer term 2017 5-1

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, 716.054, summer term 2017 5-4

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, 716.054, summer term 2017 6-2

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, 716.054, summer term 2017 6-4

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, 716.054, summer term 2017 6-5

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, 716.054, summer term 2017 7-2

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, 716.054, summer term 2017 7-3

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, 716.054, summer term 2017 7-4

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, 716.054, summer term 2017 8

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, 716.054, summer term 2017 9-1

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, 716.054, summer term 2017 9-2

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, 716.054, summer term 2017 9-8

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, 716.054, summer term 2017 9-10

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, 716.054, summer term 2017 9-13

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, 716.054, summer term 2017 10

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, 716.054, summer term 2017 11-1

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, 716.054, summer term 2017 11-3

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, 716.054, summer term 2017 12-2

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, 716.054, summer term 2017 12-3

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, 716.054, summer term 2017 13

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, 716.054, summer term 2017 14-3

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, 716.054, summer term 2017 14-5

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, 716.054, summer term 2017 15

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, 716.054, summer term 2017 16

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, 716.054, summer term 2017 17-1

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, 716.054, summer term 2017 17-2

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, 716.054, summer term 2017 17-3

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, 716.054, summer term 2017 18

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, 716.054, summer term 2017 19

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, 716.054, summer term 2017 20

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, 716.054, summer term 2017 21-2

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, 716.054, summer term 2017 21-4

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, 716.054, summer term 2017 21-5

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, 716.054, summer term 2017 21-8

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, 716.054, summer term 2017 21-9

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, 716.054, summer term 2017 21-14

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, 716.054, summer term 2017 21-20

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, 716.054, summer term 2017 21-22

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, 716.054, summer term 2017 21-29

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, 716.054, summer term 2017 21-33

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, 716.054, summer term 2017 21-34

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, 716.054, summer term 2017 21-36

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, 716.054, summer term 2017 22

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, 716.054, summer term 2017 23-2

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, 716.054, summer term 2017 23-3 P will imply NPC

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, 716.054, summer term 2017 23-4

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, 716.054, summer term 2017 24 P will imply NPC

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, 716.054, summer term 2017 25

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, 716.054, summer term 2017 26

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, 716.054, summer term 2017 27-3

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, 716.054, summer term 2017 27-6

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, 716.054, summer term 2017 27-7

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, 716.054, summer term 2017 27-9

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, 716.054, summer term 2017 27-10

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, 716.054, summer term 2017 27-15

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, 716.054, summer term 2017 27-16

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, 716.054, summer term 2017 27-17

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, 716.054, summer term 2017 27-18

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, 716.054, summer term 2017 27-19

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, 716.054, summer term 2017 27-22

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, 716.054, summer term 2017 27-23

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, 716.054, summer term 2017 27-24

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, 716.054, summer term 2017 27-25

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, 716.054, summer term 2017 27-30

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, 716.054, summer term 2017 27-31

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, 716.054, summer term 2017 27-33

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, 716.054, summer term 2017 28

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, 716.054, summer term 2017 29 P φ φ 3SAT

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, 716.054, summer term 2017 30

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, 716.054, summer term 2017 31-3

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, 716.054, summer term 2017 31-4

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, 716.054, summer term 2017 31-5

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, 716.054, summer term 2017 31-8

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, 716.054, summer term 2017 31-9

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

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, 716.054, summer term 2017 33-6

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, 716.054, summer term 2017 33-11

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, 716.054, summer term 2017 33-15

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, 716.054, summer term 2017 33-17

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, 716.054, summer term 2017 33-21

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, 716.054, summer term 2017 33-25

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, 716.054, summer term 2017 33-29

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, 716.054, summer term 2017 33-31

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, 716.054, summer term 2017 34-3

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, 716.054, summer term 2017 34-4

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, 716.054, summer term 2017 34-7

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, 716.054, summer term 2017 34-8

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, 716.054, summer term 2017 35

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, 716.054, summer term 2017 36-6

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, 716.054, summer term 2017 36-9

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, 716.054, summer term 2017 36-11

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, 716.054, summer term 2017 36-13

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, 716.054, summer term 2017 36-14

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, 716.054, summer term 2017 36-20

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, 716.054, summer term 2017 36-22