Download presentation
Presentation is loading. Please wait.
1
Intro to Theory of Computation
LECTURE 26 Last time Polynomial-time reductions Today NP-completeness CS 464 Adam Smith, Sofya Raskhodnikova 11/12/2018 S. Raskhodnikova; based on slides by N. Hopper and K. Wayne.
2
Classify Problems Desiderata: classify problems according to those that can be solved in polynomial-time and those that cannot. Some problems provably require exponential time (next month): Given a Turing machine, does it halt in at most k steps? Given a board position in an n-by-n generalization of chess, can black guarantee a win? Frustrating news: huge number of fundamental problems have defied classification for decades. Chapters (NP-completeness): Show that these fundamental problems are "computationally equivalent" and appear to be different manifestations of one really hard problem. 11/12/2018
3
Polynomial-time reduction
Given languages A and B, A β€ π B if there is a poly-time computable function π, such that for all strings π€, π€β π΄ iff π(π€)βπ΅. A B π 11/12/2018
4
Implication of poly-time reductions
Theorem. If A β€ π B and Bβπ then Aβπ. (So, if A β€ π B and Aβπ then Bβπ.) Theorem. If A β€ π B and B β€ π C then A β€ π C. (Poly-time reductions compose.) 11/12/2018
5
Reduction by simple equivalence
Basic reduction strategies Reduction by simple equivalence. Reduction from special case to general case. Reduction by encoding with gadgets. 11/12/2018
6
Independent Set Given an undirected graph G, an independent set in G is a set of nodes, which includes at most one endpoint of every edge. INDEPENDENT SET = { πΊ,π β£πΊ is an undirected graph which has an independent set with π nodes} Is there an independent set of size ο³ 6? Yes. Is there an independent set of size ο³ 7? No. independent set Application: find set of mutually non-conflicting points 11/12/2018
7
Vertex Cover Given an undirected graph G, a vertex cover in G is a set of nodes, which includes at least one endpoint of every edge. VERTEX COVER= { πΊ,π β£πΊ is an undirected graph which has a vertex cover with π nodes} Is there vertex cover of size ο£ 4? Yes. Is there a vertex cover of size ο£ 3? No. vertex cover Application: find set of mutually non-conflicting points 11/12/2018
8
Set Cover Given a set U, called a universe, and a collection of its subsets π 1 , π 2 ,β¦, π π , a set cover of U is a subcollection of subsets whose union is U. SET COVER={ π, π 1 , π 2 ,β¦, π π ;π β£ U has a set cover of size π} Sample application. m available pieces of software. Set U of n capabilities that we would like our system to have. The πth piece of software provides the set Si ο U of capabilities. Goal: achieve all π capabilities using fewest pieces of software. U = { 1, 2, 3, 4, 5, 6, 7 } k = 2 S1 = {3, 7} S4 = {2, 4} S2 = {3, 4, 5, 6} S5 = {5} S3 = {1} S6 = {1, 2, 6, 7} 11/12/2018
9
Satisfiability Boolean variables: variables that can take on values T/F (or 1/0) Boolean operations: β¨, β§, and Β¬ Boolean formula: expression with Boolean variables and ops SAT = {β©Ξ¦βͺβ£Ξ¦ is a satisfiable Boolean formula} Literal: A Boolean variable or its negation. Clause: OR of literals. Conjunctive normal form (CNF): AND of clauses. 3SAT = {β©Ξ¦βͺβ£Ξ¦ is a satisfiable Boolean CNF formula, where each clause contains exactly 3 literals} Any logical formula can be expressed in CNF. each corresponds to a different variable Ex: Yes: x1 = true, x2 = true x3 = false. 11/12/2018
10
Summary of reduction strategies
Basic reduction strategies. Simple equivalence: INDEPENDENT-SET οΊ P VERTEX-COVER. Special case to general case: VERTEX-COVER ο£ P SET-COVER. Encoding with gadgets: 3-SAT ο£ P INDEPENDENT-SET. Composition. If X ο£ P Y and Y ο£ P Z, then X ο£ P Z. Thus, 3SAT ο£ P INDEPENDENT-SET ο£ P VERTEX-COVER ο£ P SET-COVER. Are we done now? Proof idea for transitivity: compose the two algorithms. Given an oracle for Z, can solve instance of X: run the algorithm for X using a oracle for Y each time oracle for Y is called, simulate it in a polynomial number of steps by using algorithm for Y, plus oracle calls to Z 11/12/2018
11
A language B is NP-complete if
Hardest problems in NP A language B is NP-complete if π΅βππ B is NP-hard,i.e., every language in NP is poly-time reducible to B. P NP B 11/12/2018
12
Implication of poly-time reductions
Theorem. If B is NP-complete, Cβππ and B β€ π C then C is NP-complete. Theorem. If B is NP-complete and Bβπ then π=ππ. (So, if B is NP-complete and πβ ππ then there is no poly-time algorithm for B.) P NP B C 11/12/2018
13
Implication of poly-time reductions
Theorem. If B is NP-complete, Cβππ and B β€ π C then C is NP-complete. Theorem. If B is NP-complete and Bβπ then π=ππ. (So, if B is NP-complete and πβ ππ then there is no poly-time algorithm for B.) 11/12/2018
14
NP P NP-complete 11/12/2018
15
An NP-complete problem
BANTM = {γM,x,tγ | M is an NTM that accepts x in at most t steps} Technical detail: n denotes 1n. Theorem. BANTM is NP-Complete. 1. BANTM ο NP: The list of guesses M makes to accept x in t steps is the certificate that γM,x,tγ ο BANTM. 2. For all A ο NP, A β€P BANTM. AοNP iff there is an NTM N for A that runs in time O(nk). Let fA(w) = γN,w,c |w|kγ. γN,w, c |w|kγ ο BANTM iff N accepts w, iff w ο A. 11/12/2018
16
Circuit Satisfiability
A circuit is built out of AND, OR and NOT gates. A circuit is satisfiable if one can set the circuit inputs, so that the output is 1. CIRCUIT-SAT = { πΆ | πΆ is a satisfiable circuit}. output ο ο ο yes: ο ο ο 1 ? ? ? hard-coded inputs inputs 11/12/2018
17
The "First" NP-Complete Problem
Theorem. CIRCUIT-SAT is NP-complete. [Cook 1971, Levin 1973] Proof sketch. CIRCUIT-SAT is in NP certificate: input on which circuit is 1. 11/12/2018
18
The "First" NP-Complete Problem
Theorem. CIRCUIT-SAT is NP-complete. [Cook 1971, Levin 1973] Proof sketch. For all A ο NP, A β€P CIRCUIT-SAT. A TM that takes a fixed number of bits as input can be represented by a circuit. Moreover, if algorithm takes poly-time, then circuit is of poly-size. Consider some problem A β NP. It has a poly-time verifier V(w, c). To determine whether wβA, need to know if there exists a certificate c of length p(|w|) such that V(w, c) accepts. View V(w, c) as an algorithm on |w| + p(|c|) bits (input w, certificate c) and convert it into a poly-size circuit C. first |w| bits are hard-coded with w remaining p(|s|) bits represent bits of t Correctness: Circuit C is satisfiable iff V(w, c) accepts. 11/12/2018
19
Idea #1 (on board): Algorithms are circuits
Every circuit is an βalgorithmβ with Fixed length input and Fixed running time Every algorithm with fixed length input π, and upper bound π‘ on running time can be converted into a circuit with π π‘ π+π‘ gates Space usage is at most π+π‘ Imagine a π+π‘ Γπ‘ table where column π is the state of the algorithms memory at time π Circuit just needs to compute state at time π+1 from state at time π. 11/12/2018
20
Example A circuit C whose inputs can be set so that C outputs true iff graph G has an independent set of size 2. ο independent set of size 2? independent set? ο both endpoints of some edge have been chosen? ο ο ο set of size β₯ 2? ο ο ο ο u ο ο ο v w G = (V, E), n = 3 u-v u-w v-w u v w 1 1 ? ? ? hard-coded inputs (graph description) n inputs (nodes in independent set) 11/12/2018
21
3SAT is NP-complete Proof. Suffices to show that CIRCUIT-SATο£ P 3SATsince 3SAT is in NP. Let C be any circuit. Create a 3-SAT variable xi for each circuit element i. Make circuit compute correct values at each node: x2 = ο x ο add 2 clauses: x1 = x4 ο x5 ο add 3 clauses: x0 = x1 ο x2 ο add 3 clauses: Hard-coded input values and output value. x5 = 0 ο add 1 clause: x0 = 1 ο add 1 clause: Final step: turn clauses of length < 3 into clauses of length exactly 3. output x0 ο x1 x2 ο ο x5 x4 x3 11/12/2018
22
Idea #2 (on board): Verifying is easier than computing
Given a circuit πΆ with π input wires and π gates, the reduction constructs a 3CNF formula Ξ¦ with π(π+π) variables and π(π) clauses One variable Ξ¦ for each wire in πΆ Given a satisfying assignment π for πΆ, get a satisfying assignment to Ξ¦: Set variable π₯ π to the value on wire π when πΆ is executed on π Notice the power of nondeterminism Checking that each gate is executed correctly only requires looking at 3 wires at a time 11/12/2018
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.