NP and NP Completeness

Similar documents
SAT, NP, NP-Completeness

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

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

More NP-Complete Problems

NP and Computational Intractability

Intro to Theory of Computation

COP 4531 Complexity & Analysis of Data Structures & Algorithms

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

BBM402-Lecture 11: The Class NP

NP Completeness and Approximation Algorithms

Design and Analysis of Algorithms

CS154, Lecture 13: P vs NP

1. Introduction Recap

Essential facts about NP-completeness:

CSC 1700 Analysis of Algorithms: P and NP Problems

CSE 135: Introduction to Theory of Computation NP-completeness

NP-Complete Problems. More reductions

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?

Spring Lecture 21 NP-Complete Problems

Correctness of Dijkstra s algorithm

More on NP and Reductions

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

NP-Hardness reductions

NP-Complete Reductions 1

Computational Intractability 2010/4/15. Lecture 2

CS154, Lecture 13: P vs NP

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

Lecture 4: NP and computational intractability

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

Lecture 19: Finish NP-Completeness, conp and Friends

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

Recap from Last Time

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

COMP Analysis of Algorithms & Data Structures

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples

Introduction to Computational Complexity

1 Primals and Duals: Zero Sum Games

4/22/12. NP and NP completeness. Efficient Certification. Decision Problems. Definition of P

P versus NP. Math 40210, Spring April 8, Math (Spring 2012) P versus NP April 8, / 9

CSE 421 NP-Completeness

Computability and Complexity Theory: An Introduction

Lecture 20: conp and Friends, Oracles in Complexity Theory

Agenda. What is a complexity class? What are the important complexity classes? How do you prove an algorithm is in a certain class

CS21 Decidability and Tractability

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

SAT, Coloring, Hamiltonian Cycle, TSP

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Algorithm Design and Analysis

Week 3: Reductions and Completeness

1.1 P, NP, and NP-complete

Algorithm Design and Analysis

CS 583: Algorithms. NP Completeness Ch 34. Intractability

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

Show that the following problems are NP-complete

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability. Classify Problems

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

4/19/11. NP and NP completeness. Decision Problems. Definition of P. Certifiers and Certificates: COMPOSITES

Intro to Theory of Computation

Computational Complexity

CMSC 441: Algorithms. NP Completeness

CS 5114: Theory of Algorithms

Limitations of Algorithm Power

Introduction. Pvs.NPExample

NP Complete Problems. COMP 215 Lecture 20

NP-Complete problems

Computational Complexity

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

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

CS Lecture 28 P, NP, and NP-Completeness. Fall 2008

Instructor N.Sadagopan Scribe: P.Renjith

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

CSC 373: Algorithm Design and Analysis Lecture 15

NP-Completeness. Until now we have been designing algorithms for specific problems

COMP 382. Unit 10: NP-Completeness

Algorithm Design and Analysis

Complexity, P and NP

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

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

COSE215: Theory of Computation. Lecture 20 P, NP, and NP-Complete Problems

NP-Completeness. Sections 28.5, 28.6

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

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

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

Notes on Complexity Theory Last updated: October, Lecture 6

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

NP-Completeness Part II

Geometric Steiner Trees

A Working Knowledge of Computational Complexity for an Optimizer

Polynomial-time reductions. We have seen several reductions:

CSE 548: (Design and) Analysis of Algorithms

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Complexity Classes IV

Complexity and NP-completeness

NP-problems continued

NP-Completeness. Subhash Suri. May 15, 2018

Algorithms Design & Analysis. Approximation Algorithm

Transcription:

CS 374: Algorithms & Models of Computation, Spring 2017 NP and NP Completeness Lecture 23 April 20, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 44

Part I NP Chandra Chekuri (UIUC) CS374 2 Spring 2017 2 / 44

P and NP and Turing Machines 1 P: set of decision problems that have polynomial time algorithms. 2 NP: set of decision problems that have polynomial time non-deterministic algorithms. Many natural problems we would like to solve are in NP. Every problem in NP has an exponential time algorithm P NP Some problems in NP are in P (example, shortest path problem) Big Question: Does every problem in NP have an efficient algorithm? Same as asking whether P = NP. Chandra Chekuri (UIUC) CS374 3 Spring 2017 3 / 44

Problems with no known polynomial time algorithms Problems 1 Independent Set 2 Vertex Cover 3 Set Cover 4 SAT 5 3SAT There are of course undecidable problems (no algorithm at all!) but many problems that we want to solve are of similar flavor to the above. Question: What is common to above problems? Chandra Chekuri (UIUC) CS374 4 Spring 2017 4 / 44

Efficient Checkability Above problems share the following feature: Checkability For any YES instance I X of X there is a proof/certificate/solution that is of length poly( I X ) such that given a proof one can efficiently check that I X is indeed a YES instance. Chandra Chekuri (UIUC) CS374 5 Spring 2017 5 / 44

Efficient Checkability Above problems share the following feature: Checkability For any YES instance I X of X there is a proof/certificate/solution that is of length poly( I X ) such that given a proof one can efficiently check that I X is indeed a YES instance. Examples: 1 SAT formula ϕ: proof is a satisfying assignment. 2 Independent Set in graph G and k: a subset S of vertices. 3 Homework Chandra Chekuri (UIUC) CS374 5 Spring 2017 5 / 44

Sudoku Given n n sudoku puzzle, does it have a solution? Chandra Chekuri (UIUC) CS374 6 Spring 2017 6 / 44

Certifiers Definition An algorithm C(, ) is a certifier for problem X if the following two conditions hold: For every s X there is some string t such that C(s, t) = yes If s X, C(s, t) = no for every t. The string t is called a certificate or proof for s. Chandra Chekuri (UIUC) CS374 7 Spring 2017 7 / 44

Efficient (polynomial time) Certifiers Definition (Efficient Certifier.) A certifier C is an efficient certifier for problem X if there is a polynomial p( ) such that the following conditions hold: For every s X there is some string t such that C(s, t) = yes and t p( s ). If s X, C(s, t) = no for every t. C(, ) runs in polynomial time. Chandra Chekuri (UIUC) CS374 8 Spring 2017 8 / 44

Example: Independent Set 1 Problem: Does G = (V, E) have an independent set of size k? 1 Certificate: Set S V. 2 Certifier: Check S k and no pair of vertices in S is connected by an edge. Chandra Chekuri (UIUC) CS374 9 Spring 2017 9 / 44

Example: Vertex Cover 1 Problem: Does G have a vertex cover of size k? 1 Certificate: S V. 2 Certifier: Check S k and that for every edge at least one endpoint is in S. Chandra Chekuri (UIUC) CS374 10 Spring 2017 10 / 44

Example: SAT 1 Problem: Does formula ϕ have a satisfying truth assignment? 1 Certificate: Assignment a of 0/1 values to each variable. 2 Certifier: Check each clause under a and say yes if all clauses are true. Chandra Chekuri (UIUC) CS374 11 Spring 2017 11 / 44

Example: Composites Problem: Composite Instance: A number s. Question: Is the number s a composite? 1 Problem: Composite. 1 Certificate: A factor t s such that t 1 and t s. 2 Certifier: Check that t divides s. Chandra Chekuri (UIUC) CS374 12 Spring 2017 12 / 44

Example: NFA Universality Problem: NFA Universality Instance: Description of a NFA M. Question: Is L(M) = Σ, that is, does M accept all strings? 1 Problem: NFA Universality. 1 Certificate: A DFA M equivalent to M 2 Certifier: Check that L(M ) = Σ Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 44

Example: NFA Universality Problem: NFA Universality Instance: Description of a NFA M. Question: Is L(M) = Σ, that is, does M accept all strings? 1 Problem: NFA Universality. 1 Certificate: A DFA M equivalent to M 2 Certifier: Check that L(M ) = Σ Certifier is efficient but certificate is not necessarily short! We do not know if the problem is in NP. Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 44

Example: A String Problem Problem: PCP Instance: Two sets of binary strings α 1,..., α n and β 1,..., β n Question: Are there indices i 1, i 2,..., i k such that α i1 α i2... α ik = β i1 β i2... β ik 1 Problem: PCP 1 Certificate: A sequence of indices i 1, i 2,..., i k 2 Certifier: Check that α i1 α i2... α ik = β i1 β i2... β ik Chandra Chekuri (UIUC) CS374 14 Spring 2017 14 / 44

Example: A String Problem Problem: PCP Instance: Two sets of binary strings α 1,..., α n and β 1,..., β n Question: Are there indices i 1, i 2,..., i k such that α i1 α i2... α ik = β i1 β i2... β ik 1 Problem: PCP 1 Certificate: A sequence of indices i 1, i 2,..., i k 2 Certifier: Check that α i1 α i2... α ik = β i1 β i2... β ik PCP = Posts Correspondence Problem and it is undecidable! Implies no finite bound on length of certificate! Chandra Chekuri (UIUC) CS374 14 Spring 2017 14 / 44

Nondeterministic Polynomial Time Definition Nondeterministic Polynomial Time (denoted by NP) is the class of all problems that have efficient certifiers. Chandra Chekuri (UIUC) CS374 15 Spring 2017 15 / 44

Nondeterministic Polynomial Time Definition Nondeterministic Polynomial Time (denoted by NP) is the class of all problems that have efficient certifiers. Example Independent Set, Vertex Cover, Set Cover, SAT, 3SAT, and Composite are all examples of problems in NP. Chandra Chekuri (UIUC) CS374 15 Spring 2017 15 / 44

Why is it called... Nondeterministic Polynomial Time A certifier is an algorithm C(I, c) with two inputs: 1 I : instance. 2 c: proof/certificate that the instance is indeed a YES instance of the given problem. One can think about C as an algorithm for the original problem, if: 1 Given I, the algorithm guesses (non-deterministically, and who knows how) a certificate c. 2 The algorithm now verifies the certificate c for the instance I. NP can be equivalently described using Turing machines. Chandra Chekuri (UIUC) CS374 16 Spring 2017 16 / 44

Asymmetry in Definition of NP Note that only YES instances have a short proof/certificate. NO instances need not have a short certificate. Example SAT formula ϕ. No easy way to prove that ϕ is NOT satisfiable! More on this and co-np later on. Chandra Chekuri (UIUC) CS374 17 Spring 2017 17 / 44

P versus NP Proposition P NP. Chandra Chekuri (UIUC) CS374 18 Spring 2017 18 / 44

P versus NP Proposition P NP. For a problem in P no need for a certificate! Proof. Consider problem X P with algorithm A. Need to demonstrate that X has an efficient certifier: 1 Certifier C on input s, t, runs A(s) and returns the answer. 2 C runs in polynomial time. 3 If s X, then for every t, C(s, t) = yes. 4 If s X, then for every t, C(s, t) = no. Chandra Chekuri (UIUC) CS374 18 Spring 2017 18 / 44

Exponential Time Definition Exponential Time (denoted EXP) is the collection of all problems that have an algorithm which on input s runs in exponential time, i.e., O(2 poly( s ) ). Chandra Chekuri (UIUC) CS374 19 Spring 2017 19 / 44

Exponential Time Definition Exponential Time (denoted EXP) is the collection of all problems that have an algorithm which on input s runs in exponential time, i.e., O(2 poly( s ) ). Example: O(2 n ), O(2 n log n ), O(2 n3 ),... Chandra Chekuri (UIUC) CS374 19 Spring 2017 19 / 44

NP versus EXP Proposition NP EXP. Proof. Let X NP with certifier C. Need to design an exponential time algorithm for X. 1 For every t, with t p( s ) run C(s, t); answer yes if any one of these calls returns yes. 2 The above algorithm correctly solves X (exercise). 3 Algorithm runs in O(q( s + p(s) )2 p( s ) ), where q is the running time of C. Chandra Chekuri (UIUC) CS374 20 Spring 2017 20 / 44

Examples 1 SAT: try all possible truth assignment to variables. 2 Independent Set: try all possible subsets of vertices. 3 Vertex Cover: try all possible subsets of vertices. Chandra Chekuri (UIUC) CS374 21 Spring 2017 21 / 44

Is NP efficiently solvable? We know P NP EXP. Chandra Chekuri (UIUC) CS374 22 Spring 2017 22 / 44

Is NP efficiently solvable? We know P NP EXP. Big Question Is there are problem in NP that does not belong to P? Is P = NP? Chandra Chekuri (UIUC) CS374 22 Spring 2017 22 / 44

If P = NP... Or: If pigs could fly then life would be sweet. 1 Many important optimization problems can be solved efficiently. Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44

If P = NP... Or: If pigs could fly then life would be sweet. 1 Many important optimization problems can be solved efficiently. 2 The RSA cryptosystem can be broken. Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44

If P = NP... Or: If pigs could fly then life would be sweet. 1 Many important optimization problems can be solved efficiently. 2 The RSA cryptosystem can be broken. 3 No security on the web. Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44

If P = NP... Or: If pigs could fly then life would be sweet. 1 Many important optimization problems can be solved efficiently. 2 The RSA cryptosystem can be broken. 3 No security on the web. 4 No e-commerce... Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44

If P = NP... Or: If pigs could fly then life would be sweet. 1 Many important optimization problems can be solved efficiently. 2 The RSA cryptosystem can be broken. 3 No security on the web. 4 No e-commerce... 5 Creativity can be automated! Proofs for mathematical statement can be found by computers automatically (if short ones exist). Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44

If P = NP this implies that... (A) Vertex Cover can be solved in polynomial time. (B) P = EXP. (C) EXP P. (D) All of the above. Chandra Chekuri (UIUC) CS374 24 Spring 2017 24 / 44

P versus NP Status Relationship between P and NP remains one of the most important open problems in mathematics/computer science. Consensus: Most people feel/believe P NP. Resolving P versus NP is a Clay Millennium Prize Problem. You can win a million dollars in addition to a Turing award and major fame! Chandra Chekuri (UIUC) CS374 25 Spring 2017 25 / 44

Part II NP-Completeness Chandra Chekuri (UIUC) CS374 26 Spring 2017 26 / 44

Hardest Problems Question What is the hardest problem in NP? How do we define it? Towards a definition 1 Hardest problem must be in NP. 2 Hardest problem must be at least as difficult as every other problem in NP. Chandra Chekuri (UIUC) CS374 27 Spring 2017 27 / 44

NP-Complete Problems Definition A problem X is said to be NP-Complete if 1 X NP, and 2 (Hardness) For any Y NP, Y P X. Chandra Chekuri (UIUC) CS374 28 Spring 2017 28 / 44

Solving NP-Complete Problems Proposition Suppose X is NP-Complete. Then X can be solved in polynomial time if and only if P = NP. Proof. Suppose X can be solved in polynomial time 1 Let Y NP. We know Y P X. 2 We showed that if Y P X and X can be solved in polynomial time, then Y can be solved in polynomial time. 3 Thus, every problem Y NP is such that Y P; NP P. 4 Since P NP, we have P = NP. Since P = NP, and X NP, we have a polynomial time algorithm for X. Chandra Chekuri (UIUC) CS374 29 Spring 2017 29 / 44

NP-Hard Problems Definition A problem X is said to be NP-Hard if 1 (Hardness) For any Y NP, we have that Y P X. An NP-Hard problem need not be in NP! Example: Halting problem is NP-Hard (why?) but not NP-Complete. Chandra Chekuri (UIUC) CS374 30 Spring 2017 30 / 44

Consequences of proving NP-Completeness If X is NP-Complete 1 Since we believe P NP, 2 and solving X implies P = NP. X is unlikely to be efficiently solvable. Chandra Chekuri (UIUC) CS374 31 Spring 2017 31 / 44

Consequences of proving NP-Completeness If X is NP-Complete 1 Since we believe P NP, 2 and solving X implies P = NP. X is unlikely to be efficiently solvable. At the very least, many smart people before you have failed to find an efficient algorithm for X. Chandra Chekuri (UIUC) CS374 31 Spring 2017 31 / 44

Consequences of proving NP-Completeness If X is NP-Complete 1 Since we believe P NP, 2 and solving X implies P = NP. X is unlikely to be efficiently solvable. At the very least, many smart people before you have failed to find an efficient algorithm for X. Chandra Chekuri (UIUC) CS374 31 Spring 2017 31 / 44

Consequences of proving NP-Completeness If X is NP-Complete 1 Since we believe P NP, 2 and solving X implies P = NP. X is unlikely to be efficiently solvable. At the very least, many smart people before you have failed to find an efficient algorithm for X. (This is proof by mob opinion take with a grain of salt.) Chandra Chekuri (UIUC) CS374 31 Spring 2017 31 / 44

NP-Complete Problems Question Are there any problems that are NP-Complete? Answer Yes! Many, many problems are NP-Complete. Chandra Chekuri (UIUC) CS374 32 Spring 2017 32 / 44

Cook-Levin Theorem Theorem (Cook-Levin) SAT is NP-Complete. Chandra Chekuri (UIUC) CS374 33 Spring 2017 33 / 44

Cook-Levin Theorem Theorem (Cook-Levin) SAT is NP-Complete. Need to show 1 SAT is in NP. 2 every NP problem X reduces to SAT. Will see proof in next lecture. Steve Cook won the Turing award for his theorem. Chandra Chekuri (UIUC) CS374 33 Spring 2017 33 / 44

Proving that a problem X is NP-Complete To prove X is NP-Complete, show 1 Show that X is in NP. 2 Give a polynomial-time reduction from a known NP-Complete problem such as SAT to X Chandra Chekuri (UIUC) CS374 34 Spring 2017 34 / 44

Proving that a problem X is NP-Complete To prove X is NP-Complete, show 1 Show that X is in NP. 2 Give a polynomial-time reduction from a known NP-Complete problem such as SAT to X SAT P X implies that every NP problem Y P X. Why? Chandra Chekuri (UIUC) CS374 34 Spring 2017 34 / 44

Proving that a problem X is NP-Complete To prove X is NP-Complete, show 1 Show that X is in NP. 2 Give a polynomial-time reduction from a known NP-Complete problem such as SAT to X SAT P X implies that every NP problem Y P X. Why? Transitivity of reductions: Y P SAT and SAT P X and hence Y P X. Chandra Chekuri (UIUC) CS374 34 Spring 2017 34 / 44

3-SAT is NP-Complete 3-SAT is in NP SAT P 3-SAT as we saw Chandra Chekuri (UIUC) CS374 35 Spring 2017 35 / 44

NP-Completeness via Reductions 1 SAT is NP-Complete due to Cook-Levin theorem 2 SAT P 3-SAT 3 3-SAT P Independent Set 4 Independent Set P Vertex Cover 5 Independent Set P Clique 6 3-SAT P 3-Color 7 3-SAT P Hamiltonian Cycle Chandra Chekuri (UIUC) CS374 36 Spring 2017 36 / 44

NP-Completeness via Reductions 1 SAT is NP-Complete due to Cook-Levin theorem 2 SAT P 3-SAT 3 3-SAT P Independent Set 4 Independent Set P Vertex Cover 5 Independent Set P Clique 6 3-SAT P 3-Color 7 3-SAT P Hamiltonian Cycle Hundreds and thousands of different problems from many areas of science and engineering have been shown to be NP-Complete. A surprisingly frequent phenomenon! Chandra Chekuri (UIUC) CS374 36 Spring 2017 36 / 44

Part III Reducing 3-SAT to Independent Set Chandra Chekuri (UIUC) CS374 37 Spring 2017 37 / 44

Independent Set Problem: Independent Set Instance: A graph G, integer k. Question: Is there an independent set in G of size k? Chandra Chekuri (UIUC) CS374 38 Spring 2017 38 / 44

3SAT P Independent Set The reduction 3SAT P Independent Set Input: Given a 3CNF formula ϕ Goal: Construct a graph G ϕ and number k such that G ϕ has an independent set of size k if and only if ϕ is satisfiable. Chandra Chekuri (UIUC) CS374 39 Spring 2017 39 / 44

3SAT P Independent Set The reduction 3SAT P Independent Set Input: Given a 3CNF formula ϕ Goal: Construct a graph G ϕ and number k such that G ϕ has an independent set of size k if and only if ϕ is satisfiable. G ϕ should be constructable in time polynomial in size of ϕ Chandra Chekuri (UIUC) CS374 39 Spring 2017 39 / 44

3SAT P Independent Set The reduction 3SAT P Independent Set Input: Given a 3CNF formula ϕ Goal: Construct a graph G ϕ and number k such that G ϕ has an independent set of size k if and only if ϕ is satisfiable. G ϕ should be constructable in time polynomial in size of ϕ Importance of reduction: Although 3SAT is much more expressive, it can be reduced to a seemingly specialized Independent Set problem. Notice: We handle only 3CNF formulas reduction would not work for other kinds of boolean formulas. Chandra Chekuri (UIUC) CS374 39 Spring 2017 39 / 44

Interpreting 3SAT There are two ways to think about 3SAT Chandra Chekuri (UIUC) CS374 40 Spring 2017 40 / 44

Interpreting 3SAT There are two ways to think about 3SAT 1 Find a way to assign 0/1 (false/true) to the variables such that the formula evaluates to true, that is each clause evaluates to true. Chandra Chekuri (UIUC) CS374 40 Spring 2017 40 / 44

Interpreting 3SAT There are two ways to think about 3SAT 1 Find a way to assign 0/1 (false/true) to the variables such that the formula evaluates to true, that is each clause evaluates to true. 2 Pick a literal from each clause and find a truth assignment to make all of them true Chandra Chekuri (UIUC) CS374 40 Spring 2017 40 / 44

Interpreting 3SAT There are two ways to think about 3SAT 1 Find a way to assign 0/1 (false/true) to the variables such that the formula evaluates to true, that is each clause evaluates to true. 2 Pick a literal from each clause and find a truth assignment to make all of them true. You will fail if two of the literals you pick are in conflict, i.e., you pick x i and x i We will take the second view of 3SAT to construct the reduction. Chandra Chekuri (UIUC) CS374 40 Spring 2017 40 / 44

The Reduction 1 G ϕ will have one vertex for each literal in a clause x 1 x 2 x 1 x 3 x 2 x 1 x 3 x 2 x 4 Figure: Graph for ϕ = ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Chandra Chekuri (UIUC) CS374 41 Spring 2017 41 / 44

The Reduction 1 G ϕ will have one vertex for each literal in a clause 2 Connect the 3 literals in a clause to form a triangle; the independent set will pick at most one vertex from each clause, which will correspond to the literal to be set to true x 1 x 2 x 1 x 3 x 2 x 1 x 3 x 2 x 4 Figure: Graph for ϕ = ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Chandra Chekuri (UIUC) CS374 41 Spring 2017 41 / 44

The Reduction 1 G ϕ will have one vertex for each literal in a clause 2 Connect the 3 literals in a clause to form a triangle; the independent set will pick at most one vertex from each clause, which will correspond to the literal to be set to true x 1 x 2 x 1 x 3 x 2 x 1 x 3 x 2 x 4 Figure: Graph for ϕ = ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Chandra Chekuri (UIUC) CS374 41 Spring 2017 41 / 44

The Reduction 1 G ϕ will have one vertex for each literal in a clause 2 Connect the 3 literals in a clause to form a triangle; the independent set will pick at most one vertex from each clause, which will correspond to the literal to be set to true 3 Connect 2 vertices if they label complementary literals; this ensures that the literals corresponding to the independent set do not have a conflict x 1 x 2 x 1 x 3 x 2 x 1 x 3 x 2 x 4 Figure: Graph for ϕ = ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Chandra Chekuri (UIUC) CS374 41 Spring 2017 41 / 44

The Reduction 1 G ϕ will have one vertex for each literal in a clause 2 Connect the 3 literals in a clause to form a triangle; the independent set will pick at most one vertex from each clause, which will correspond to the literal to be set to true 3 Connect 2 vertices if they label complementary literals; this ensures that the literals corresponding to the independent set do not have a conflict 4 Take k to be the number of clauses x 1 x 2 x 1 x 3 x 2 x 1 x 3 x 2 x 4 Figure: Graph for ϕ = ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Chandra Chekuri (UIUC) CS374 41 Spring 2017 41 / 44

Correctness Proposition ϕ is satisfiable iff G ϕ has an independent set of size k (= number of clauses in ϕ). Proof. Let a be the truth assignment satisfying ϕ Chandra Chekuri (UIUC) CS374 42 Spring 2017 42 / 44

Correctness Proposition ϕ is satisfiable iff G ϕ has an independent set of size k (= number of clauses in ϕ). Proof. Let a be the truth assignment satisfying ϕ 1 Pick one of the vertices, corresponding to true literals under a, from each triangle. This is an independent set of the appropriate size. Why? Chandra Chekuri (UIUC) CS374 42 Spring 2017 42 / 44

Correctness (contd) Proposition ϕ is satisfiable iff G ϕ has an independent set of size k (= number of clauses in ϕ). Proof. Let S be an independent set of size k 1 S must contain exactly one vertex from each clause 2 S cannot contain vertices labeled by conflicting literals 3 Thus, it is possible to obtain a truth assignment that makes in the literals in S true; such an assignment satisfies one literal in every clause Chandra Chekuri (UIUC) CS374 43 Spring 2017 43 / 44