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 P : set of decision problems that have polynomial time 1 algorithms. NP : set of decision problems that have polynomial time 2 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 Independent Set 1 Vertex Cover 2 Set Cover 3 SAT 4 3SAT 5 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: SAT formula ϕ : proof is a satisfying assignment. 1 Independent Set in graph G and k : a subset S of vertices. 2 Homework 3 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 Problem: Does G = ( V , E ) have an independent set of size 1 ≥ k ? Certificate: Set S ⊆ V . 1 Certifier: Check | S | ≥ k and no pair of vertices in S is 2 connected by an edge. Chandra Chekuri (UIUC) CS374 9 Spring 2017 9 / 44
Example: Vertex Cover Problem: Does G have a vertex cover of size ≤ k ? 1 Certificate: S ⊆ V . 1 Certifier: Check | S | ≤ k and that for every edge at least one 2 endpoint is in S . Chandra Chekuri (UIUC) CS374 10 Spring 2017 10 / 44
Example: SAT Problem: Does formula ϕ have a satisfying truth assignment? 1 Certificate: Assignment a of 0 / 1 values to each variable. 1 Certifier: Check each clause under a and say “yes” if all clauses 2 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? Problem: Composite . 1 Certificate: A factor t ≤ s such that t � = 1 and t � = s . 1 Certifier: Check that t divides s . 2 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? Problem: NFA Universality . 1 Certificate: A DFA M ′ equivalent to M 1 Certifier: Check that L ( M ′ ) = Σ ∗ 2 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? Problem: NFA Universality . 1 Certificate: A DFA M ′ equivalent to M 1 Certifier: Check that L ( M ′ ) = Σ ∗ 2 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 α i 1 α i 2 . . . α i k = β i 1 β i 2 . . . β i k Problem: PCP 1 Certificate: A sequence of indices i 1 , i 2 , . . . , i k 1 Certifier: Check that α i 1 α i 2 . . . α i k = β i 1 β i 2 . . . β i k 2 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 α i 1 α i 2 . . . α i k = β i 1 β i 2 . . . β i k Problem: PCP 1 Certificate: A sequence of indices i 1 , i 2 , . . . , i k 1 Certifier: Check that α i 1 α i 2 . . . α i k = β i 1 β i 2 . . . β i k 2 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: I : instance. 1 c : proof/certificate that the instance is indeed a YES instance 2 of the given problem. One can think about C as an algorithm for the original problem, if: Given I , the algorithm guesses (non-deterministically, and who 1 knows how) a certificate c . The algorithm now verifies the certificate c for the instance I . 2 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: Certifier C on input s , t , runs A ( s ) and returns the answer. 1 C runs in polynomial time. 2 If s ∈ X , then for every t , C ( s , t ) = ”yes”. 3 If s �∈ X , then for every t , C ( s , t ) = ”no”. 4 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 n 3 ) , ... 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 . For every t , with | t | ≤ p ( | s | ) run C ( s , t ) ; answer “yes” if any 1 one of these calls returns “yes”. The above algorithm correctly solves X (exercise). 2 Algorithm runs in O ( q ( | s | + | p ( s ) | )2 p ( | s | ) ) , where q is the 3 running time of C . Chandra Chekuri (UIUC) CS374 20 Spring 2017 20 / 44
Examples SAT : try all possible truth assignment to variables. 1 Independent Set : try all possible subsets of vertices. 2 Vertex Cover : try all possible subsets of vertices. 3 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. Many important optimization problems can be solved efficiently. 1 Chandra Chekuri (UIUC) CS374 23 Spring 2017 23 / 44
Recommend
More recommend