CSCI 1010 Models of Computa3on. Lecture 11 Proving Languages NP-Complete

Similar documents
CSCI 1590 Intro to Computational Complexity

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

CS256 Applied Theory of Computation

CS21 Decidability and Tractability

Theory of Computation Chapter 9

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

Essential facts about NP-completeness:

Lecture 7: Polynomial time hierarchy

NP Completeness. Richard Karp, 1972.

CSCI 1010 Models of Computa3on. Lecture 02 Func3ons and Circuits

NP-Complete Problems. More reductions

Lecture 18: More NP-Complete Problems

CS 161: Design and Analysis of Algorithms

Intro to Theory of Computation

NP-Complete Reductions 2

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

CS154, Lecture 13: P vs NP

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

SAT, NP, NP-Completeness

Lecture 4: NP and computational intractability

NP-Complete Reductions 1

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

COMP 382. Unit 10: NP-Completeness

CS154, Lecture 13: P vs NP

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

Lecture 2. 1 More N P-Compete Languages. Notes on Complexity Theory: Fall 2005 Last updated: September, Jonathan Katz

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

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

Lecture 20: conp and Friends, Oracles in Complexity Theory

CS21 Decidability and Tractability

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

Complexity Classes V. More PCPs. Eric Rachlin

CSCI 1590 Intro to Computational Complexity

Chapter 7: Time Complexity

Non-Approximability Results (2 nd part) 1/19

CSC 373: Algorithm Design and Analysis Lecture 15

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Complexity Classes IV

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

Algorithm Design and Analysis

NP-Complete Reductions 3

NP Complete Problems. COMP 215 Lecture 20

NP-Complete problems

NP and Computational Intractability

COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group

CS 6505, Complexity and Algorithms Week 7: NP Completeness

NP-Completeness. Algorithmique Fall semester 2011/12

Polynomial-Time Reductions

BBM402-Lecture 11: The Class NP

1 Non-deterministic Turing Machine

The Cook-Levin Theorem

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP-Hardness reductions

CSCI 1590 Intro to Computational Complexity

Umans Complexity Theory Lectures

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

Theory of Computation Time Complexity

CSCI3390-Lecture 16: NP-completeness

NP and NP Completeness

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

Approximation Preserving Reductions

CSCI 1590 Intro to Computational Complexity

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Lecture 16: Time Complexity and P vs NP

MTAT Complexity Theory October 13th-14th, Lecture 6

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

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

Lecture 19: Finish NP-Completeness, conp and Friends

More Completeness, conp, FNP,etc. CS254 Chris Pollett Oct 30, 2006.

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

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

NP and NP-Completeness

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Comparison of several polynomial and exponential time complexity functions. Size n

Introduction to Complexity Theory

Design and Analysis of Algorithms

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

NP-Complete Problems

Lecture 13, Fall 04/05

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

CS 151 Complexity Theory Spring Solution Set 5

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

max bisection max cut becomes max bisection if we require that It has many applications, especially in VLSI layout.

Complexity (Pre Lecture)

NP Completeness and Approximation Algorithms

Show that the following problems are NP-complete

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

NP and Computational Intractability

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Lecture 3: Nondeterminism, NP, and NP-completeness

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

Lecture 24 : Even more reductions

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

Computability and Complexity Theory: An Introduction

CSCI3390-Second Test with Solutions

CSI 4105 MIDTERM SOLUTION

6.045 Final Exam Solutions

Time to learn about NP-completeness!

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

Transcription:

CSCI 1010 Models of Computa3on Lecture 11 Proving Languages NP-Complete

Overview P-3me reduc3ons Composi3on of P-3me reduc3ons Reduc3on from CIRCUIT SAT to SAT SAT is NP-complete. 3-SAT is NP-complete. NAESAT is NP-complete. Reduc3on from 3-SAT to INDEPENDENT SET Reduc3on from NAESAT to 3-COLORING John E. Savage CSCI 1010 Lect 11 2

Polynomial-Time Reduc3on Defini6on: A polynomial-6me reduc6on (P- 6me) from language L 1 Γ * to language L 2 Σ * is a reduc6on f : Γ * Σ * (x ε L 1 iff f(x) ε L 2 ) computable by a DTM in 3me polynomial in the length of its input. (f P-6me translates L 1 to L 2 ) w PPP f w R Recognizer R for L 2. The Recognizer for L 1 invokes the recognizer R for L 2. John E. Savage CSCI 1010 Lect 11 3

NP-Complete Language L Γ * is NP-complete if L ϵ NP and L is NP-hard. L is NP-hard if for every L 0 Γ * in NP, we can decide membership in L 0 by invoking a P-3me reduc3on f 0 from L 0 to L. If L is NP-complete and L in P, then P = NP. w PPP f 0 w R Recognizer R for L Recognizer for L 0 in NP invokes recognizer R for L. John E. Savage CSCI 1010 Lect 11 4

Cook and Karp Reduc3ons A Karp reduc3on makes one invoca3on of a P-3me reduc3on from one language to another. Such reduc3ons are called transla6ons. A Cook reduc3on uses a P-3me oracle Turing machine to decide membership in a language. An oracle TM runs, writes a string on the oracle tape, and enters the oracle state. The oracle writes an answer on the oracle tape in one step and the TM resumes. This can be repeated mul3ple 3mes. John E. Savage CSCI 1010 Lect 11 5

Cook Versus Karp Reduc3ons The Cook reduc3on may be more general than the Karp reduc3on although every reduc3on so far is Karp reduc3on. John E. Savage CSCI 1010 Lect 11 6

Composi3on of P-Time Transla3ons Defini6on: Let f 1 : Γ * Σ * and f 2 : Γ * Σ * be transla3ons. The composi6on of f 2 with f 1 computes f 2 ( f 1 (x)). Theorem The composi3on of two P-3me transla3ons is a P-3me transla3on. Proof On input x, DTM compu3ng f 1 generates output f 1 (x) whose length, f 1 (x),is polynomial in x. This is the input to f 2 so its running 3me is polynomial in f 1 (x) which is polynomial in x, the input to the composi3on. John E. Savage CSCI 1010 Lect 11 7

Proving New Languages NP-Complete Theorem Let L a be NP-complete. Let g be a P- 3me transla3on of L a to L b and let L b be in NP. Then, L b is NP-complete. Proof Because L a is NP-complete, for each L 0 in NP there exists an f 0 transla3ng L 0 to L a in P-3me. The composi3on of g with f 0 is a P-3me transla3on. Thus, for each L 0 in NP there exists a P-3me f(x) = g(f 0 (x)) transla3ng L 0 to L b. (L b is NPhard.) Since L b is also in NP, it is NP-complete. John E. Savage CSCI 1010 Lect 11 8

Circuit Sa3sfiability A circuit is sa6sfiable if its nondeterminis3c inputs can be chosen so that the output is 1. CIRCUIT SAT is the set of sa3sfiable circuits. CIRCUIT SAT has been shown NP-complete. We reduce it in P-3me to other problems to show that they are also NP-hard. John E. Savage CSCI 1010 Lect 11 9

Sa6sfiability (SAT) Instance: A set of literals X = {x 1, x 1,..., x n, x n } and clauses C = (c 1,...,c n ), each c i is a subset of X. Yes Instance: There exists an assignment to variables over {0,1} such that each clause has a literal with value 1. No Instance: There is no assignment to variables over {0,1} such that each clause has a literal with value 1. We show that SAT is NP-complete. John E. Savage CSCI 1010 Lect 11 10

Transla3ng CIRCUIT SAT to SAT Consider circuit in SLP form: (1 READ x) g 1 := x; (2 READ y) g 2 := y; (3 NOT 1) g 3 := NOT(g 1 ); (4 NOT 2) g 4 := NOT(g 2 ); (5 AND 1 4) g 5 := g 1 AND g 4 ; (6 AND 3 2) g 6 := g 3 AND g 2 ; (7 OR 5 6) g 7 := g 5 OR g 6 ; (g 7 is the output) John E. Savage CSCI 1010 Lect 11 11

Transla3ng CIRCUIT SAT to SAT These clauses simulate gates. denotes NOT. That is, the clauses are all sa6sfied only when the func6on on the lek is computed. John E. Savage CSCI 1010 Lect 11 12

Transla3ng CIRCUIT SAT to SAT Tables showing why these mappings work. Both clauses sa3sfied when g = x. (g = h ᴠ k) All three clauses sa3sfied when g = h k Note that not all literals in the third clause are True when all clauses sa3sfied. John E. Savage CSCI 1010 Lect 11 13

Transla3ng CIRCUIT SAT to SAT g 1 := x; g 2 := y; (g 1 x) (g 1 x) (g 2 y) (g 2 y) g 3 := NOT(g 1 ); (g 3 g 1 ) (g 3 g 1 ) g 4 := NOT(g 2 ); (g 4 g 2 ) (g 4 g 2 ) g 5 := g 1 AND g 4 ; (g 5 g 1 ) (g 5 g 4 ) (g 5 g 1 g 4 ) g 6 := g 3 AND g 2 ; (g 6 g 3 ) (g 6 g 2 ) (g 6 g 3 g 2 ) g 7 := g 5 OR g 6 ; (g 7 g 5 ) (g 7 g 6 ) (g 7 g 5 g 6 ) (g 7 is the output) (g 7 ) John E. Savage CSCI 1010 Lect 11 14 _ Form AND of all the clauses

SAT is NP-complete Theorem SAT is NP-complete. Proof The above reduc3on from CIRCUIT SAT to SAT maps an instance of CIRCUIT SAT to a instance of SAT. The former is sa3sfied if and only if the laper is sa3sfied. Why? The reduc3on takes 3me polynomial in the length of the input. Thus, SAT is NP-hard. Why is SAT is in NP? It follows that SAT is NP-complete. John E. Savage CSCI 1010 Lect 11 15

3-SAT Instance: Set of literals X = {x 1,x 1,..., x n, x n } & clauses C = (c 1,...,c n ), each c i is a subset of X, c i 3. Yes Instance: There exists an assignment to variables over {0,1} such that each clause has a literal with value 1. No Instance: There is no assignment to variables over {0,1} such that each clause has a literal with value 1. The same proof shows that 3-SAT is NP-complete because each clause has at most three literals. John E. Savage CSCI 1010 Lect 11 16

Not All Equal SAT (NAESAT) NAESAT Instance: An instance of 3-SAT Yes Instance: Each clause is sa3sfied with not all literals being equal (one has value 1, another has value 0). No Instance: Cannot sa3sfy each clause with not all literals being equal. John E. Savage CSCI 1010 Lect 11 17

On Reduc3ons To show that NAESAT is NP-complete, we make the following observa3on: Let f be a transla3on of problem A to problem B, that is, that it maps a Yes instance of A to one of B and a No instance of A to one of B. Instead of showing that f translates a No instance of A to a No instance of B, it suffices to show that the pre-image of f from a Yes instance of B is a Yes instance of A. Then, a No instance of A does not map to a Yes of B. See the following. John E. Savage CSCI 1010 Lect 11 18

Proving Reduc3ons A B Yes A f : A B Yes B No A No B If we show that every element mapping to Yes B is in Yes A, then every element in No A must map to an instance in No B We use this idea to show several problems NP-complete. John E. Savage CSCI 1010 Lect 11 19

NAESAT is NP-Complete Theorem NAESAT is NP-complete. Proof The 3-literal clauses in the reduc3on to 3- SAT have the requisite property (check this). Add a new literal y to the other clauses. We claim that this reduc3on is sa3sfied with not all equal literals iff CIRCUIT SAT is sa3sfied. a) If CIRCUIT SAT is sa3sfied, at least one literal is 1 in each clause. Set y = 0! John E. Savage CSCI 1010 Lect 11 20

NAESAT is NP-Complete Proof (cont.) b) If the instance of NAESAT produced by the reduc3on is a Yes instance, then each clause is sa3sfied with the NAE property. Thus, if we complement all variables, the same property holds. In one of these cases y =0. Choose this case. Then, the values of variables is such as to cause the original instance of CIRCUIT SAT to be sa3sfied. Thus, the instance CIRCUIT SAT is sa3sfied iff the instance of NAESAT is sa3sfied. John E. Savage CSCI 1010 Lect 11 21

Independent Set (IS) Instance: A graph G = (V,E) and integer k. Yes Instance: (G,k) such that there is a set of k ver3ces with no edges between them. Let G be the following graph. Is (G,3) in Independent Set (IS)? If so, why? Is (G,4) in IS? John E. Savage CSCI 1010 Lect 11 22

Independent Set in NP-Complete Theorem Independent Set is NP-complete. Proof We reduce 3-SAT to Independent Set. Modify 3-SAT so that each clause contains three literals and no clause iden3cally true. E.g. if (a+b) exists, add (a+b+z) and (a+b+z), z is new. (a+b) is sa3sfied iff (a+b+z) (a+b+z) is sa3sfied. If a clause contains one variable, create four clauses with all four combina3ons of literals in new variables u and v. This is a P-3me reduc3on. John E. Savage CSCI 1010 Lect 11 23

Independent Set in NP-Complete Proof (cont.) Given an instance of 3-SAT, construct graph G by crea3ng a triangle for each clause. The ver3ces of a triangle are labeled by the literals in a corresponding clause. Add edge between ver3ces in different clauses if one is the NOT of another. Let k = number of clauses. (G,k) an instance of IS. This reduc3on is P-3me. John E. Savage CSCI 1010 Lect 11 24

Example of Reduc3on Example: (x 1 +x 2 +x 3 )(x 1 +x 2 +x 3 )(x 1 +x 2 +x 3 ) maps to (G,3) below. It is sa3sfied by x 1 =x 2 =x 3 =1. John E. Savage CSCI 1010 Lect 11 25

Independent Set in NP-Complete Given a Yes instance of 3-SAT, we show that (G,k) is a Yes instance of IS. Pick one True literal per clause. No edges exist between corresponding ver3ces in (G,k) so they form a Yes instance of IS. John E. Savage CSCI 1010 Lect 11 26

Independent Set in NP-Complete Given a Yes instance (G,k) of IS, we construct a Yes instance of 3-SAT. IS of (G,k) must have one vertex from each triangle. Since labels are not complements, assign value 1 to corresponding literals to obtain a Yes instance of 3- SAT. John E. Savage CSCI 1010 Lect 11 27

3-COLORING Instance: A graph G = (V,E). Yes Instance: G such that three colors can be assigned to ver3ces so that adjacent ver3ces have different colors. Theorem 3-COLORING is NP-complete. Proof By reduc3on from NAESAT. Consider an instance of NAESAT that has three literals in each clause. John E. Savage CSCI 1010 Lect 11 28

3-COLORING Construct a graph G from clauses as follows: Create a variable triangle (ν, x j, x j ) for each j. Create a triangle for each clause. If the r th clause has literals λ 1, λ 2, λ 3 let (r, λ 1 ), (r, λ 1 ), (r, λ 1 ) be labels for the three ver3ces in the rth triangle. Insert edge between (r, λ i ) in a clause triangle and λ i in a variable triangle. John E. Savage CSCI 1010 Lect 11 29

3-COLORING John E. Savage CSCI 1010 Lect 11 30

3-COLORING Given a Yes instance of 3-COLORING, we show it corresponds to a Yes instance of NAESAT. Let colors be {0,1,2}. Let the root ν have color 2. Assign colors in {0,1} to (r, λ i ) and λ i. To the third vertex in clause triangle, assign color 2 If (r, λ i ) has color c in {0,1}, assign value c to λ i. This means that in each clause not all literals have the same value and we have Yes instance of NAESAT. John E. Savage CSCI 1010 Lect 11 31

3-COLORING Given a Yes instance of NAESAT, we show it corresponds to a Yes instance of 3-COLORING. Let ν have color 2 and x j and x j have values that sa3sfy the clauses in the Yes instance. ~ Consider two unequal literals in a clause. If (r, x j ) is one of these, give it a complementary color in ~ {0,1} to x j in the variable triangle. Give the third vertex in clause triangle color 2. This is a 3- COLORING. John E. Savage CSCI 1010 Lect 11 32

Review P-3me reduc3ons Composi3on of P-3me reduc3ons Reduc3on from CIRCUIT SAT to SAT SAT is NP-complete. 3-SAT is NP-complete. NAESAT is NP-complete. Reduc3on from 3-SAT to INDEPENDENT SET Reduc3on from NAESAT to 3-COLORING John E. Savage CSCI 1010 Lect 11 33