INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS.
Cook-Levin Theorem Proof and Illustration
Complexity Classes: P and NP
Complexity ©D.Moshkovits 1 Where Can We Draw The Line? On the Hardness of Satisfiability Problems.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 · L 2 means: For some polynomial time computable map r : 8 x: x 2 L 1 iff.
Computability and Complexity 14-1 Computability and Complexity Andrei Bulatov Cook’s Theorem.
CS21 Decidability and Tractability
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
NP-Completeness CS 51 Summer 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AA A A AAA.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
Time Complexity.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
February 20, 2015CS21 Lecture 191 CS21 Decidability and Tractability Lecture 19 February 20, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 ≤ L 2 means: For some polynomial time computable map r : x: x L 1 iff r(x)
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
1 P P := the class of decision problems (languages) decided by a Turing machine so that for some polynomial p and all x, the machine terminates after at.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong The Cook-Levin.
1 How to establish NP-hardness Lemma: If L 1 is NP-hard and L 1 ≤ L 2 then L 2 is NP-hard.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
NPC.
Complexity ©D.Moshkovits 1 2-Satisfiability NOTE: These slides were created by Muli Safra, from OPICS/sat/)
NP-complete Languages
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NP-complete.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
1 SAT SAT: Given a Boolean function in CNF representation, is there a way to assign truth values to the variables so that the function evaluates to true?
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
NP-Completeness A problem is NP-complete if: It is in NP
Chapter 10 NP-Complete Problems.
Computational Complexity Theory
L is in NP means: There is a language L’ in P and a polynomial p so that L1 ≤ L2 means: For some polynomial time computable map r :  x: x  L1 iff.
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
(xy)(yz)(xz)(zy)
NP-complete problems The Chinese University of Hong Kong Fall 2008
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
Intro to Theory of Computation
Where Can We Draw The Line?
Richard Anderson Lecture 25 NP-Completeness
CS154, Lecture 13: P vs NP.
NP-completeness The Chinese University of Hong Kong Fall 2008
CS21 Decidability and Tractability
NP-Completeness Yin Tat Lee
Umans Complexity Theory Lectures
More on NP-completeness
Our First NP-Complete Problem
CS21 Decidability and Tractability
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
Intro to Theory of Computation
Lecture 23 NP-Hard Problems
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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}

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

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 }

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

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.

P NP B C HARDEST PROBLEMS IN NP

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

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 }

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: q00q q11q q10q q01q q00q q11q11 010q1q1 010qaqa t t a tableau

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

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

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

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 ))

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

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.

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.

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 )

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.

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.

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.

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.

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…

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)

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

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