Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS154, Lecture 13: P vs NP.

Similar presentations


Presentation on theme: "CS154, Lecture 13: P vs NP."— Presentation transcript:

1 CS154, Lecture 13: P vs NP

2 The EXTENDED Church-Turing Thesis
 Polynomial-Time Turing Machines Everyone’s Intuitive Notion of Efficient Algorithms More generally: TM can simulate every “reasonable” model of computation with only polynomial increase in time A controversial thesis! Potential counterexamples: quantum algorithms

3 Nondeterministic Turing Machines
…are just like standard TMs, except: 1. The machine may proceed according to several possible transitions (like an NFA) 2. The machine accepts an input string if there exists an accepting computation history for the machine on the string

4

5 Definition: A nondeterministic TM is a 7-tuple T = (Q, Σ, Γ, , q0, qaccept, qreject), where:
Q is a finite set of states Σ is the input alphabet, where   Σ Γ is the tape alphabet, where   Γ and Σ  Γ  : Q  Γ → 2(Q  Γ  {L,R}) q0  Q is the start state qaccept  Q is the accept state qreject  Q is the reject state, and qreject  qaccept

6 Defining Acceptance for NTMs
Let N be a nondeterministic Turing machine An accepting computation history for N on w is a sequence of configurations C0,C1,…,Ct where 1. C0 is the start configuration q0w, 2. Ct is an accepting configuration, 3. Each configuration Ci yields Ci+1 Def. N(w) accepts in t time  Such a history exists N has time complexity T(n) if for all n, for all inputs of length n and for all histories, N halts in T(n) time

7 TIME(t(n))  NTIME(t(n)) Is TIME(t(n)) = NTIME(t(n)) for all t(n)?
Definition: NTIME(t(n)) = { L | L is decided by a O(t(n)) time nondeterministic Turing machine } TIME(t(n))  NTIME(t(n)) Is TIME(t(n)) = NTIME(t(n)) for all t(n)?

8 What problems can we efficiently solved nondeterministically, but not

9 The Clique Problem k-clique = complete subgraph on k nodes a d f c b e

10 The Clique Problem Find a clique of 1 million nodes?

11 Assume a reasonable encoding of graphs (example: the adjacency matrix is reasonable)
CLIQUE = { (G,k) | G is an undirected graph with a k-clique } Theorem: CLIQUE  NTIME(nc) for some c > 1 N((V,E),k): Nondeterministically guess a subset S of V with |S| = k For all u, v in S, if (u,v) is not in E then reject Accept

12 The Hamiltonian Path Problem
c d f h i g A Hamiltonian path traverses through each node exactly once

13 HAMPATH = { (G,s,t) | G is a directed graph with
HAMPATH = { (G,s,t) | G is a directed graph with a Hamiltonian path from s to t } Theorem: HAMPATH  NTIME(nc) for some c > 1 N((V,E),s,t): Nondeterministically guess a sequence v1, …, v|V| of vertices If vi = vj for some i ≠ j, reject For all i = 1,…,|V|-1, if (vi,vi+1) is not in E then reject If (v1 = s & vn = t) then accept else reject

14 Nondeterministic Polynomial Time
NP = NTIME(nk) k  N

15 L = { x |  y ϵ Σ* [|y| ≤ |x|k and V(x,y) accepts ] }
Theorem: L  NP  There is a constant k and polynomial-time TM V such that L = { x |  y ϵ Σ* [|y| ≤ |x|k and V(x,y) accepts ] } Proof: If L = { x | y |y| ≤ |x|k and V(x,y) accepts } then L  NP Define the NTM N(x): Guess y of length at most |x|k Run V(x,y) and output answer Then, L(N) is the set of x s.t. [|y| ≤ |x|k & V(x,y) accepts] (2) If L  NP then L = { x | y |y| ≤ |x|k and V(x,y) accepts } Suppose N is a poly-time NTM that decides L. Define V(x,y) to accept iff y encodes an accepting computation history of N on x

16 there are polynomial-length proofs
A language L is in NP if and only if there are polynomial-length proofs (aka. certificates or witnesses) for membership in L CLIQUE = { (G,k) |  subset of nodes S such that S is a k-clique in G } HAMPATH = { (G,s,t) |  Hamiltonian path in graph G from node s to node t }

17 Boolean Formula Satisfiability
logical operations  recedes  precedes  parentheses  = (x  y)  z Boolean variables (0 or 1)

18 Boolean Formula Satisfiability
 = (x  y)  z A satisfying assignment is a setting of the variables that makes the formula true x = 1, y = 1, z = 1 is a satisfying assignment for  (in fact, any assignment with z = 1 is satisfying)  = (x  y)  (z  x) 1

19 A Boolean formula is satisfiable if there is a true/false setting to the variables that makes the formula true a  b  c  d YES (x  y)  x NO SAT = {  |  is a satisfiable Boolean formula }

20 A 3cnf-formula has the form:
(x1  x2  x3)  (x4  x2  x5)  (x3  x2  x1) clauses literals 3SAT = {  |  is a satisfiable 3cnf-formula }

21 3SAT = {  |  is a satisfiable 3cnf-formula }
Theorem: 3SAT  NP We can express 3SAT as 3SAT = {  |  is in 3cnf and  string y that encodes a satisfying assignment to  } The number of variables of  is at most ||, so |y| ≤ ||. Then, argue that the language 3SAT-CHECK = {(,y) |  is in 3cnf and y is a satisfying assignment to } is in P. (Similarly, SAT  NP)

22 NP = Problems with the property that, once you have the solution, it is “easy” to verify the solution When  ϵ SAT, or (G, k) ϵ CLIQUE, or (G,s,t) ϵ HAMPATH, Can prove that with a short proof that can easily been verified What if  ∉ SAT? (G, k) ∉ CLIQUE? Or (G,s,t) ∉ HAMPATH?

23 P = the problems that can be efficiently solved
NP = the problems where proposed solutions can be efficiently verified Is P = NP? can problem solving be automated? Clay Math Institute in the year 2000: “millennium problems”

24 If P = NP: Mathematicians may be out of a job Cryptography as we know it may be impossible In principle, every aspect of life could be efficiently and globally optimized … life as we know it would be different! Conjecture: P  NP

25 Polynomial Time Reducibility
f : Σ*  Σ* is a polynomial time computable function if there is a poly-time Turing machine M that on every input w, halts with just f(w) on its tape Language A is poly-time reducible to language B, written as A P B, if there is a poly-time computable f : Σ*  Σ* so that: w  A  f(w)  B f is a polynomial time reduction from A to B Note there is a k such that for all w, |f(w)| ≤ |w|k

26 f converts any string w into a string f(w) such that w  A  f(w)  B
nc n w f(w) f n nc f converts any string w into a string f(w) such that w  A  f(w)  B

27 Theorem: If A P B and B P C, then A P C
g C n nc ncd

28 Theorem: If A P B and B  P, then A  P
Proof: Let MB be a poly-time TM that decides B. Let f be a poly-time reduction from A to B. We build a machine MA that decides A as follows: MA = On input w, 1. Compute f(w) 2. Run MB on f(w), output its answer w  A  f(w)  B

29 Theorem: If A P B and B  NP, then A  NP
Proof: Analogous…

30 Theorem: If A P B and B  P, then A  P
Theorem: If A P B and B  NP, then A  NP Corollary: If A P B and A ∉ P, then B ∉ P

31 Definition: A language B is NP-complete if:
1. B  NP 2. Every A in NP is poly-time reducible to B That is, A ≤P B When this is true, we say “B is NP-hard” On homework, you showed A language L is recognizable iff L ≤m ATM ATM is “complete for recognizable languages”: ATM is recognizable, and for all recognizable L, L ≤m ATM

32 Suppose L is NP-Complete…
If L  P, then P = NP If L ∉ P, then P ≠ NP

33 Suppose L is NP-Complete…
Then assuming the conjecture P  NP, L is not decidable in nk time, for every k

34 The Cook-Levin Theorem: SAT and 3SAT are NP-complete
3SAT  NP A satisfying assignment is a “proof” that a 3cnf formula is satisfiable 3SAT is NP-hard Every language in NP can be polynomial-time reduced to 3SAT (complex logical formula) Corollary: 3SAT  P if and only if P = NP


Download ppt "CS154, Lecture 13: P vs NP."

Similar presentations


Ads by Google