ppt - CSE Labs User Home Pages

Download Report

Transcript ppt - CSE Labs User Home Pages

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.
Definition: TIME(t(n)) = { L | L is a language
decided by a O(t(n)) time Turing Machine }
IMPORTANT COMPLEXITY CLASSES

NP =  NTIME(n )
P=
c
TIME(n )
cN
L ∈ P iff there is an nc-time TM that decides L.
c
c  cN
L ∈ NP iff there is an n -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 ≤P B and B∈P, then A∈P.
(so if A ≤P B 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
iff w  A.
def test_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)
B is NP-Complete
NP
P
B
Theorem. If B is NP-Complete, C∈NP, and B ≤P C,
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 PNP,
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.
ANP iff there is an NTM for A that runs in
time O(nc). Let ƒA(w) = 〈N,w,|w|c〉.
〈N,w,|w|c〉  BANTM iff N accepts w, iff w  A.
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 ≤P CDTM.
A ∈ NP ⇒ There is a na-time TM VA and c where
A = { x | ∃y. |y| ≤ |x|c and 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
x0
⋁
x2
¬
∧
∧
∧
… is a collection of (boolean)
gates and inputs connected by
wires.
… 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 ≤P CIRCUIT-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 ≤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 2k clauses:
x0
x1
F
0
0
1
0
1
0
1
0
0
1
1
1
⇔
(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”
q00
1
0
1
0
1
0
q11
0
1
0
1
q10
1
0
1
0
q01
0
1
0
1
q00
1
0
1
0
q11
0
1
0
0
1
0
0
t
t
q1
qa
Rows are made up of cells. Each cell has a “light”
for every state and every tape symbol.
q0 q1 qa 0
∧
1
 q0 q1 qa 0
1
 q0 q1 qa 0
q0 q1 qa 0
1

1

∧
⋁
Each light has a circuit that turns it on or off based
on the previous row.
EXAMPLE
1→1, R
1→□, R
0→0, R
q1
q0
0→□, R
q0 q1 qa 0
∧
∧
⋁
∧
⋁
1
∧
 q0 q1 qa 0
⋁
qa
□→□, L
1
 q0 q1 qa 0
∧
∙ ∧∧ ∧∧ ∧∧ ∧
⋁
⋁ ⋁
⋁
q0 q1 qa 0 1 
∧
1

The lights in the first row are connected to the
circuit inputs and the tape head is hardwired in:
x1
x2
x3
… xn-1 xn
q0
qa
qa
qa
qa
qa
qa


qa
qa
⋁
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.