 # INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

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

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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

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

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.

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

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.

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

B is NP-Complete P NP B

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

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.

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.

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.

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

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.

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

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.

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?

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”

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 ⋁

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.