Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Theory of Computation

Similar presentations


Presentation on theme: "Intro to Theory of Computation"β€” Presentation transcript:

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


Download ppt "Intro to Theory of Computation"

Similar presentations


Ads by Google