250 likes | 375 Views
CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. 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.
E N D
CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS
TIMECOMPLEXITY Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function f : NN, 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(nc) NP = NTIME(nc) c N c N IMPORTANTCOMPLEXITY CLASSES L ∈P iff there is an nc-time TM that decides L. L ∈NP iff there is an nc-time NTM that decides L iff there is an nc-time “verifier” for L Problems in P can be efficiently solved. Problems in NP can be efficiently verified.
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… Mathematicians are out of a job. Cryptography as we know it is impossible. Recognition is the same as Generation. We could design optimal: cars, airplanes, fusion generators, circuits, medicines… In 40+ years, no one has found a proof that P NP.
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 ≤PB and B∈P, then A∈P. (so if A ≤PB and A P, then B P.) Proof. B P ⇒ |s|b-time program test_b(s) to decide B A ≤P B ⇒ |w|a-time function map s.t.map(w) B iffw A. deftest_a(w): s = map(w) return test_b(s) TIME COMPLEXITY = O(|w|ab)
HARDEST PROBLEMS IN NP 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)
NP P B B is NP-Complete
Theorem. If B is NP-Complete, C∈NP, and B ≤PC, then C is NP-Complete. NP P C B
Theorem. If B is NP-Complete and B ∈P, then P=NP. Corollary. If B is NP-Complete, and PNP, there is no fast algorithm for B.
Let BANTM = {〈M,x,t〉 | M is an NTM that accepts x in at most t steps} Hyper-technical detail: we let n denote 1n. Theorem. BANTM is NP-Complete. 1. BANTM NP: The list of guesses M makes to accept x in t steps is the proof that 〈M,x,t〉 BANTM. 2. For all A NP, A ≤P BANTM. ANP iff there is an NTM for A that runs in time O(nc). Let ƒA(w) = 〈N,w,|w|c〉. 〈N,w,|w|c〉 BANTMiff N accepts w, iff w A.
BPCP = {〈P, n〉 | P is a PCP instance with a match of length at most n. } Theorem. BPCP is NP-Complete. 1. BPCP NP. The PCP match of length at most n is the proof that 〈P, n〉 BPCP.
BPCP = { 〈P, n〉 | P is a PCP instance with a match of length at most n. } Theorem. BPCP is NP-Complete. 2. BANTM≤P BPCP. We know how to make a PCP instance P so that a match corresponds to an accepting NTM computation on w. If M accepts in t steps, the match has length s = 3t(t+1)/2. Let ƒPCP denote the mapping from 〈M,w〉 to P. Our reduction is thus ƒ(M,w,t) = 〈ƒPCP(M,w),s〉
Let CDTM = { 〈M,x,t〉| ∃y, |y| ≤ t and M(x,y) accepts in at most t steps} Theorem. CDTM is NP-Complete. 1. CDTM∈ NP: The string y proves 〈M,x,t〉∈ CDTM.
Let CDTM = { 〈M,x,t〉| ∃y, |y| ≤ t and M(x,y) accepts in at most t steps} Theorem. CDTM is NP-Complete. 2. For all A ∈NP, A ≤PCDTM. A ∈NP ⇒There is a na-time TM VA and c where A = { x | ∃y. |y| ≤ |x|cand VA(x,y) accepts } Define ƒA(w) = 〈V, w, t〉, where t=(|w|c + |w|)a
Let EADTM = { 〈M,n,t〉 | ∃y ∈ {0,1}n : M accepts y in at most t steps} Theorem. EADTM is NP-Complete. 1. EADTM∈NP: The string y proves 〈M,n,t〉 EADTM. 2. CDTM≤P EADTM. Define ƒ(M,x,t) = 〈Mx, t, t〉, where Mx(y) = “run M(x,y).”
⋁ ∧ ∧ A CIRCUIT x1 … is a collection of (boolean) gatesand inputs connected by wires. x2 x0 : … 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. EADTM≤PCIRCUIT-SAT. Recall that the language EADTM= { 〈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 EADTM≤PC-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 2k clauses: (x0 ⋁¬x1)∧(¬x0⋁x1) ⇔ 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 ith row represents the configuration of M after i steps: a “tableau” t t
q0 q0 qa q1 q0 qa q0 qa q1 q0 q1 qa q1 1 0 0 0 1 1 0 1 ∧ ∧ ⋁ Rows are made up of cells. Each cell has a “light” for every state and every tape symbol. Each light has a circuit that turns it on or off based on the previous row.
q0 qa qa q1 q0 qa q1 qa q1 q0 q0 q1 qa q0 q1 0 1 0 0 1 0 1 1 0 1 ∧ ∧ ⋁ ∧ ⋁ ∧ ∧ ⋁ ∧ ∧ ∧ ⋁ ⋁ ∧ ∧ ⋁ ⋁ ∧ ∧ ⋁ ∧ ⋁ ∙ ∙ ∙ EXAMPLE 1→□, R 1→1, R 0→0, R q1 qa q0 □→□, L 0→□, R
xn-1 … xn x1 x2 x3 qa qa qa qa qa qa q0 qa qa ⋁ The lights in the first row are connected to the circuit inputs and the tape head is hardwired in: The circuit should output 1 iff M ends in qaccept.
How big is the circuit if M has m states+symbols? O(m2t2) How long does it take to build the circuit? O(m2t2) When is the circuit satisfiable? Iff there is a n-bit input that makes M accept in at most t steps.