Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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 }

3 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

4 NP = { } Languages that have “nifty proofs” (certificates) of membership. 3SAT = { ϕ | ∃ y so that ϕ (y)=1 and ϕ is in 3cnf } certificate: the satisfying assignment y HAMPATH = { 〈 G,s,t 〉 | G has a hamiltonian path from s to t} certificate: the hamiltonian path CLIQUE= { 〈 G,k 〉 | G has a clique of size k} certificate: the clique (set of k nodes) FACTOR = { 〈 N,k 〉 | N has a prime factor ≥ k} certificate: the factor p ≥ k

5 If P = NP… Recognition is the same as Generation. We could design optimal: cars, airplanes, fusion generators, circuits, medicines… Cryptography as we know it is impossible. In 40+ years, no one has found a proof that P  NP. Mathematicians are out of a job.

6 POLY-TIME REDUCIBILITY A language A is polynomial time reducible to language B, written A  P B, if there is a polynomial time computable function ƒ: Σ*  Σ*, where for every w, w  A  ƒ(w)  B ƒ is called a polynomial time reduction of A to B

7 Theorem. If A ≤ P B and B ∈ P, then A ∈ P. (so if A ≤ P B and A  P, then B  P.) Proof. B  P ⇒ TIME COMPLEXITY = O(|w| ab ) |s| b -time program test_b(s) to decide B A ≤ P B ⇒ def test_a(w): s = map(w) return test_b(s) |w| a -time function map s.t. map(w)  B iff w  A.

8 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

9 B is NP-Complete P NP B

10 Theorem. If B is NP-Complete, C ∈ NP, and B ≤ P C, then C is NP-Complete. P NP B C

11 Theorem. If B is NP-Complete and B ∈ P, then P=NP. Corollary. If B is NP-Complete, and P  NP, there is no fast algorithm for B.

12 Let BA NTM = { 〈 M,x,t 〉 | M is an NTM that accepts x in at most t steps} Theorem. BA NTM is NP-Complete. 1. BA NTM  NP: The list of guesses M makes to accept x in t steps is the proof that 〈 M,x,t 〉  BA NTM. 2. For all A  NP, A ≤ P BA NTM. A  NP iff there is an NTM for A that runs in time O(n c ). Let ƒ A (w) = 〈 N,w,|w| c 〉. 〈 N,w,|w| c 〉  BA NTM iff N accepts w, iff w  A. Hyper-technical detail: we let n denote 1 n.

13 Let C DTM = { 〈 M,x,t 〉 | ∃ y, |y| ≤ t and M(x,y) accepts in at most t steps} Theorem. C DTM is NP-Complete. 1. C DTM ∈ NP: The string y proves 〈 M,x,t 〉 ∈ C DTM.

14 Let C DTM = { 〈 M,x,t 〉 | ∃ y, |y| ≤ t and M(x,y) accepts in at most t steps} Theorem. C DTM is NP-Complete. 2. For all A ∈ NP, A ≤ P C DTM. A ∈ NP ⇒ There is a n a -time TM V A and c where A = { x | ∃ y. |y| ≤ |x| c and V A (x,y) accepts } Define ƒ A (w) = 〈 V, w, t 〉, where t=(|w| c + |w|) a

15 Let EA DTM = { 〈 M,n,t 〉  | ∃ y ∈ {0,1} n : M accepts y in at most t steps} Theorem. EA DTM is NP-Complete. 2. C DTM ≤ P EA DTM. Define ƒ(M,x,t) = 〈 M x, t, t 〉, where M x (y) = “run M(x,y).” 1. EA DTM ∈ NP: The string y proves 〈 M,n,t 〉  EA DTM.

16 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 } ∧

17 Theorem. CIRCUIT-SAT is NP-Complete. Proof. 1. CIRCUIT-SAT ∈ NP. 2. EA DTM ≤ P CIRCUIT-SAT. Recall that the language EA DTM = { 〈 M, n, t 〉 | M is a TM and ∃ y  {0,1} n such that M accepts y in ≤ t steps.} is NP-Complete. We prove EA DTM ≤ P C-SAT.

18 WARMUP Given 〈 M,t 〉, there is a function C : {0,1} t → {0,1} such that C(x) = 1 iff M(x) accepts in t steps. Any boolean function in k variables can be written as a CNF with at most 2 k clauses: x0x0 x1x1 F 001 010 100 111 ⇔ (x 0 ⋁ ¬x 1 ) ∧ (¬x 0 ⋁ x 1 ) Why doesn’t this prove the theorem?

19 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”

20 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 ∧ ∧ ⋁

21 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 ∧ ⋁ ⋁ ∙ ∧  ∧ ⋁ ⋁ ∙ ∧ ∧ ∧

22 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 ⋁

23 How big is the circuit if M has m states+symbols? O(m 2 t 2 ) How long does it take to build the circuit? O(m 2 t 2 ) When is the circuit satisfiable? Iff there is a n-bit input that makes M accept in at most t steps.


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google