INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



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

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Polynomial-time reductions We have seen several reductions:
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Lecture 21 NP-complete problems
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.
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Mount Holyoke College 2 The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Fall The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Graphs 4/16/2017 8:41 PM NP-Completeness.
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.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
Time Complexity.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
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
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
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 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
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.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.
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.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
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
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Completeness A problem is NP-complete if: It is in NP
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
Intro to Theory of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
Richard Anderson Lecture 28 NP-Completeness
CSC 4170 Theory of Computation The class NP Section 7.3.
CS154, Lecture 13: P vs NP.
NP-Completeness Yin Tat Lee
CS154, Lecture 16: More NP-Complete Problems; PCPs
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 SAT is the language: { ϕ | ϕ is a satisfiable boolean formula}

QUIZ 5 Give a satisfying assignment to x 1 = 0, x 2 = 0 Asymptotic upper bounds for: (a) 14n n (ln n) 1/2 = O(n 1.7 ) (b) 4 (log ₂ n)/3 + 6n(n/3) 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 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 ∧ ⋁ ⋁ ∙ ∧  ∧ ⋁ ⋁ ∙ ∧ ∧ ∧

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 ) ⋁ (x 1 ⋁ x 2 )) ((x 1 ∧ x 2 ) ∧ (x 1 ⋁ x 2 )) ((x 1 ∧ x 2 ) ⋁ (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 C’s 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. A 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.

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 (¬x→y 1 )  (y 1 →y 2 )  …  (y j →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 (x₁∨x₂)∧(x₂∨x̅₃)∧(x̅₁∨x₃) x₁x₁ x₁x₁ 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

REDUCTION STRATEGIES A reduction by restriction shows that the source problem is a special case of the target problem. For example, 3SAT ≤ P CNF-SAT because every satisfiable 3CNF is also a satisfiable CNF. Example. Prove 3SAT ≤ P 4SAT by restriction. A 3CNF can be converted to an equivalent 4CNF by repeating one literal in each clause.

COLORING b a e c db ac d b a e c d a bd COLOR = { 〈 G,k 〉 | G is k-colorable } 3COLOR = { 〈 G 〉 | G is 3-colorable} Prove that 3COLOR ≤ P COLOR

HAMILTONIAN PATHS b a e c d f h i g HAMPATH = { 〈 G,s,t 〉 | G has a hamiltonian path from s to t }

Let HAMILTONIAN = { 〈 G 〉 | ∃ s,t such that G has a hamiltonian path from s to t } Prove that HAMPATH ≤ P HAMILTONIAN Let LPATH = { 〈 G,s,t,k 〉 | G has a simple path from s to t of length at least k } Prove that HAMPATH ≤ P LPATH

VERTEX COVER b a e c d b a e c d VERTEX-COVER = { 〈 G,k 〉 | G has a vertex cover of size at most k }

INDEPENDENT SET b a e c d b a e c d INDSET = { 〈 G,k 〉 | G has an independent set of size at least k } Prove that VERTEX-COVER ≤ P INDSET.

SUBSET SUM SUBSET-SUM = { 〈 y 1,…, y n,t 〉 | ∃ S ⊆ {1,…,n}. Σ j ∈ S y j =t } Which of the following are in SUBSET-SUM? 〈 1,3,5,7, 10 〉 〈 19,11,27,4, 13 〉 〈 19,11,27,4, 61 〉 YES NO YES

KNAPSACK = { 〈 (w 1,v 1 )…,(w n,v n ),W, V 〉 | ∃ S ⊆ {1…n} so that Σ i ∈ S w i ≤ W and Σ i ∈ S v i ≥ V} 15 lbs $500 ½ lb $15 3 lbs $2000 1lb, $20 50 ×

Theorem. SUBSET-SUM ≤ P KNAPSACK Proof. A subset sum instance is a knapsack where the weights are equal to the values: Let ƒ(y 1,…,y n,t) = 〈  y 1,y 1 )…(y n,y n ),t,t 〉  Then ∃ S. Σ i ∈ S y i = t iff ∃ S. Σ i ∈ S y i ≥ t and Σ i ∈ S y i ≤ t, so 〈 y 1 …y n,t 〉 ∈ SUBSET-SUM iff ƒ(y 1 …y n,t) ∈ KNAPSACK

Theorem. VERTEX-COVER ≤ P SET-COVER SET-COVER = { 〈 S 1,…,S n,k 〉 | ∀ i,S i ⊆ U and ∃ i[1…k] so that S i[1] ∪ S i[2] ∪ … ∪ S i[k] = U } Which of the following are in SET-COVER? 〈 {1}, {1,2}, {2}, {3}, 2 〉 〈 {1,4}, {1,2}, {1,3}, {4}, 2 〉 Proof. A vertex cover instance is just a set cover instance where every node is a set of edges. YES NO 〈 {1}, {2}, {1,2}, 2 〉 YES