Download presentation

Presentation is loading. Please wait.

Published byZoie Yeaton Modified over 3 years ago

1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2
QUIZ 5 The language L TIME(t(n)) if: L can be decided by a TM in time O(t(n)) The language L NP if: L can be decided by a NTM in time O(n c ) L has a polynomial time verifier 3SAT is the language: { ϕ | ϕ is a satisfiable 3cnf formula}

3
QUIZ 5 Give a satisfying assignment to x 1 = 0, x 2 = 0 Asymptotic upper bounds for: (a) 4n 2.1 + 2n log 3 n = O(n 2.1 ) (b) 4 (log n)/3 + 8n(n/2) 1/2 = O(n 3/2 )

4
TIME COMPLEXITY Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function f : N N, where f(n) is the maximum number of steps that M uses on any input of length n. Definition: TIME(t(n)) = { L | L is a language decided by a O(t(n)) time Turing Machine }

5
P = TIME(n c ) c N IMPORTANT COMPLEXITY CLASSES Problems in P can be efficiently solved. Problems in NP can be efficiently verified. NP = NTIME(n c ) c N L P iff there is an n c -time TM that decides L. L NP iff there is an n c -time NTM that decides L iff there is an n c -time verifier for L

6
Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) HARDEST PROBLEMS IN NP Theorem: if B is NP-Complete and B P, then NP=P. Corollary: if B is NP-Complete and P NP, then there is no fast algorithm for B. Theorem: if A is NP-Hard and A P B, then B is NP-Hard.

7
P NP B C HARDEST PROBLEMS IN NP

8
Theorem (Cook-Levin): 3SAT is NP-complete Proof: (1) 3SAT NP (2) Every language A in NP is polynomial time reducible to 3SAT Our proof of (2) has three steps. (a) CIRCUIT-SAT is NP-Hard (b) CIRCUIT-SAT P CNF-SAT (c) CNF-SAT P 3SAT Corollary: 3SAT P if and only if P = NP

9
A CIRCUIT … is a collection of (boolean) gates and inputs connected by wires. ¬ x0x0 x1x1 x2x2 … is satisfiable if some setting of inputs makes it output 1. … has arbitrary fan-in and fan-out CIRCUIT-SAT = { C | C is a satisfiable circuit }

10
Given TM M and time bound t, we create a circuit that takes n input bits and runs up to t steps of M. The circuit will have t rows, where the i th row represents the configuration of M after i steps: q00q0010101 0q11q110101 0q10q10101 0q01q0101 01q00q001 010q11q11 010q1q1 010qaqa t t a tableau

11
q0q0 Rows are made up of cells. Each cell has a light for every state and every tape symbol. q1q1 qaqa 01 q0q0 q1q1 qaqa 01 q0q0 q1q1 qaqa 01 q0q0 q1q1 qaqa 01 Each light has a circuit that turns it on or off based on the previous row. q0q0

12
q0q0 EXAMPLE q0q0 q1q1 qaqa 0 0, R 0, R 1 1, R 1, R, L q1q1 qaqa 01 q0q0 q1q1 qaqa 01 q0q0 q1q1 qaqa 01 q0q0 q1q1 qaqa 01 q0q0 q1q1 qaqa 0 1

13
The lights in the first row are connected to the circuit inputs and the tape head is hardwired in: x1x1 x2x2 x3x3 … x n-1 xnxn q0q0 The circuit should output 1 iff M ends in q accept. qaqa qaqa qaqa qaqa qaqa qaqa qaqa qaqa

14
CNF-SAT = { | is a satisfiable CNF formula } Theorem. CIRCUIT-SAT P CNF-SAT. Proof. Given a circuit C, we will output a CNF formula that is satisfiable iff C is. x1x1 x2x2 (x 1 x 2 ) ((x 1 x 2 ) (x 1 x 2 ))

15
x1x1 x2x2 For every gate in the circuit C, we introduce a new variable g i and force g i to satisfy the gate. g 1 = (x 1 x 2 ) g 2 = (x 1 x 2 ) g 3 = (g 1 g 2 ) g 4 = (g 1 g 2 ) g 5 = (g 3 g 4 ) g 1 (x 1 x 2 ) (x 1 x 2 ) g 1 g 2 (x 1 x 2 ) (x 1 x 2 ) g 2 g 3 (g 1 g 2 ) (g 1 g 2 ) g 3 g 4 (g 1 g 2 ) (g 1 g 2 ) g 4 g 5 (g 3 g 4 ) (g 3 g 4 ) g 5 g5g5

16
We can convert to CNF using the fact that (p q) is equivalent to (¬p q) so: g ( 1 2 … n ) (¬g 1 2 … n ) ( 1 2 … n ) g (¬ 1 ¬ 2 … ¬ n g) g ( 1 2 … n ) (¬g 1 ) (¬g 2 ) … (¬g n ) ( 1 2 … n ) g (¬ 1 g) (¬ 2 g) … (¬ n g) The final output is the CNF with all the clauses produced from gates in this way, plus the clause (g i ), where g i corresponds to Cs output gate.

17
If C has k inputs, m gates, n wires, how long is ? O(m+n+k) How long to compute ? O(m+n+k) Suppose an assignment to x 1 …x k and g 1 …g m satisfies. Then C outputs 1 on input x 1 …x k. Suppose C(x 1 …x k )=1. Then setting each g i to the value of the corresponding gate satisfies.

18
Theorem. CNF-SAT P 3SAT. Proof. We show how to create an equivalent 3cnf for any cnf formula. cnf formula is not in 3cnf iff there is a clause C with less than 3 literals or more than 3 literals. if C = ( i ), replace C with ( i _ i _ i ) if C = ( i _ j ), replace C with ( i _ i _ j )

19
We can reduce the number of literals in any clause by one if we introduce a new variable and clause: ( 1 2 … n ) (z 3 … n ) (z ( 1 2 )) (z 3 … n ) (¬z 1 2 )) if we satisfy the first clause by setting z=1, then to satisfy the second, we must set ( 1 2 )=1. Repeat until every clause has three literals.

20
MORE SATISFIABILITY PROBLEMS Let NAESAT = { | is a 3cnf and x. (x)=1 and each clause has 1 false literal} Theorem. NAESAT is NP-Complete. Let DSAT = { | is a cnf with 2 satisfying assignments} Theorem. DSAT is NP-Complete. Let 2-in-4-SAT = { | is a 4cnf and x: each clause has exactly two true literals.} Theorem. 2-in-4-SAT is NP-Complete.

21
SATISFYING CONSTRAINTS A 2csp is a list of constraints on pairs of variables Each constraint C(x,y) is a list of values for (x,y). An assignment satisfies a constraint if (x,y) C(x,y). An assignment satisfies a 2csp if it satisfies all constraints. e.g. Scheduling a project; seating at a wedding… 2CSP = { C | C is a satisfiable 2csp } Theorem. 2CSP is NP-Complete.

22
Proof. 1. 2CSP NP. Given an assignment to the variables we can check that all constraints are satisfied in linear time. 2. 3SAT P 2CSP. Idea: the main difference is that a 2csp constraint should have only two variables. Add variables to the 2csp that represent pairs of variables in the 3cnf, and constraints to enforce consistency with the 3cnf variables.

23
Map 3cnf ϕ with n variables and m clauses to a 2csp C ϕ with 2n+m variables and 3m+n constraints: for each variable x ϕ : add (v x,v ¬x ) {(0,1),(1,0)} for each clause (x y z) ϕ : add v xy {00,01,10,11} add (v xy,v z ) (00,0) add (v xy,v x ) {(00,0), (01,0), (10,1), (11,1)} add (v xy,v y ) {(00,0), (01,1), (10,0), (11,1)} Claim. C ϕ 2CSP ϕ 3SAT: Proof. A satisfying assignment to ϕ can be mapped to a satisfying assignment to C ϕ by assigning each v x = x and each v xy = 2v x +v y because… An assignment to C ϕ maps to an assignment to ϕ by setting each x = v x, because…

24
2SAT 2SAT = { | is in 2cnf and is satisfiable} Theorem. 2SAT P! Idea: a 2SAT clause (x y) is equivalent to (¬x y) and (¬y x). If there is a chain (x z 1 ) (z 1 z 2 ) … (z k ¬x) and (¬xy 1 ) (y 1 y 2 ) … (y k x) then: x ¬x If not, the formula is consistent, so satisfiable. e.g. (x x) (¬x y) (¬y ¬x)

25
def is_satisfiable_2cnf(F): V = Ø, E = Ø, G = (V,E) for l literals(F): V = V {l, ¬l} for (x y) clauses(F): E = E {(¬x,y), (¬y,x)} for x vars(F): if has_path(G,x,¬x) and has_path(G,¬x,x): return False return True (xx)(xx̅)(x̅x) x x x x x x

26
3SAT P DSAT, NAESAT, 2CSP… We will use 3SAT to prove other problems are NP-Complete or NP-Hard. Examples include 3SAT P CLIQUE 3SAT P 0/1-ILP 3SAT P HAMPATH 3SAT P 3COLOR 3SAT P GRADUATION 3SAT P VERTEX-COVER

Similar presentations

OK

1. 2 Lecture outline Basic definitions: Basic definitions: P, NP complexity classes P, NP complexity classes the notion of a certificate. the notion of.

1. 2 Lecture outline Basic definitions: Basic definitions: P, NP complexity classes P, NP complexity classes the notion of a certificate. the notion of.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on solar energy and its uses Ppt on credit policy manual Business intelligence microsoft ppt online Download ppt on indus valley civilization pottery Ppt on first conditional game Ppt on sports day high school Ppt on electrical engineering major projects Mp ppt online counselling 2012 Ppt on blood donation camp Ppt on the art of war by sun