Title: CSci 4011 Lecture 22
1CSci 4011
INHERENT LIMITATIONS OF COMPUTER PROGRAMS
2QUIZ 5
1a) The language L ? TIME(t(n)) if
There is an O(t(n))-time TM to decide L.
1b) The language L is in NP if
There is an O(nc)-time NTM to decide L.
OR
There is an O(nc)-time verifier for L.
1c) 3SAT is the language
? ? is in 3cnf and ? is satisfiable
3QUIZ 5
2) Give a satisfying assignment to ? (x1
? x2) ? (x1 ? x2) ? (x1 ? x2)
x1 0, x2 1
3a) 4n1.2 3n log10 n
O(n1.2)
O(n2)
4TIME 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
5IMPORTANT COMPLEXITY CLASSES
L 2 P iff there is an nc-time TM that decides L.
L 2 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.
6If 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
In 40 years, no one has found a proof that P ?
NP.
7POLY-TIME REDUCIBILITY
A language A is polynomial time reducible to
language B, written A ?P B, if there is a
polynomial time computable function f S ? S,
where for every w,
w ? A ? f(w) ? B
f is called a polynomial time reduction of A to B
8Theorem. If A P B and B 2 P, then A 2 P. (so
if A P B and A ? P, then B ? P.)
Proof. B ? P ?
sb-time program test_b(s) to decide B
A P B ?
wa-time function f s.t. f(w) ?B iff w ?A.
def test_a(w) s f(w) return test_b(s)
TIME COMPLEXITY O(wab)
9HARDEST 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)
10B is NP-Complete
11Theorem. If B is NP-Complete, C2NP, and B P C,
then C is NP-Complete.
NP
P
C
B
12Theorem. If B is NP-Complete and B 2 P, then
PNP.
Corollary. If B is NP-Complete, and P?NP,
there is no fast algorithm for B.
13Let BANTM ltM,x,tgt 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 ltM,x,tgt ? 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 fA(w) ltN,w,wcgt. ltN,w,wcgt ?
BANTM iff N accepts w, iff w ? A.
14BPCP ltP, ngt 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 ltP, ngt ? BPCP.
15BPCP ltP, ngt 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(t1)/2.
Let PCP denote the mapping from ltM,wgt to P.
Our reduction is thus (M,w,t) ltPCP(M,w),sgt
16Let CDTM ltM,x,tgt 9y, y t and M(x,y)
accepts in at most t steps
Theorem. CDTM is NP-Complete.
1. CDTM 2 NP
The string y proves ltM,x,tgt 2 CDTM.
17Let CDTM ltM,x,tgt 9y, y t and M(x,y)
accepts in at most t steps
Theorem. CDTM is NP-Complete.
2. For all A 2 NP, A P CDTM.
A 2 NP ) There is a na-time TM VA and c where A
x 9 y. y xc and VA(x,y) accepts
Define A(w) ltV, w, tgt, where t(wc w)a
18Let EADTM ltM,n,tgt 9y ? 0,1n M accepts y
in at most t steps
Theorem. EADTM is NP-Complete.
1. EADTM 2 NP
The string y proves ltM,n,tgt ? EADTM.
2. CDTM P EADTM.
Define f(M,x,t) ltMx, t, tgt, where Mx(y) run
M(x,y).
19A CIRCUIT
is a collection of gates and inputs connected
by wires.
x1
x2
x0
is satisfiable if some setting of inputs makes
it output 1.
?
has arbitrary fan-in and fan-out
CIRCUIT-SAT ltCgt C is a satisfiable circuit
20Theorem. CIRCUIT-SAT is NP-Complete.
Proof.
1. CIRCUIT-SAT 2 NP.
2. EADTM P CIRCUIT-SAT.
Recall that the language EATM (M, 1n,
1t) M is a TM and 9y ? 0,1n such that M
accepts y in t steps. is NP-Complete. We
prove EATM P C-SAT.
21WARMUP
Given ltM,tgt, there is a function C 0,1t !
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 doesnt this prove the theorem?
22Given 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
23Rows 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.
24EXAMPLE
1?1, R
1??, R
0?0, R
q1
q0
qa
???, L
0??, R
25The 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.
26How big is the circuit if M has m statessymbols?
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.