HW1 Solutions
HW1 Solutions
2 Problem 1.5
Define a TM M to be oblivious if its head movements do not depend on
the input but only on the input length.That is, M is oblivious if for every
input x ∈ {0, 1}∗ and i ∈ N, the location of each of M ’s heads at the ith
step of execution on input x is only a function of |x| and i. Show that
for every time-constructible T : N → N, if L ∈ DTIME(T (n)), then
there is an oblivious TM that decides L in time O(T (n)2 ). Furthermore,
show that there is such a TM that uses only two tapes: one input tape
and one work/output tape.
1
tape by using locations 1, k + 1, 2k + 1, ... to encode the first tape, locations
2, k + 2, 2k + 2, ... to encode the second tape etc. For every symbol a in
M ’s alphabet, M 0 will contain both the symbol a and the symbol â. In
the encoding of each tape, exactly one symbol will be of the “hat type”,
indicating that the corresponding head of M is positioned in that location.
M 0 uses the input and output tape in the same way M does. To simulate one
step of M , the machine M 0 makes two sweeps of its work tape: first it sweeps
the tape in the left-to-right direction and records to its state register the k
symbols that are hatted. Then M 0 uses M ’s transition function to determine
the new state, symbols, and head movements and sweeps the tape back in
the right-to-left direction to update the encoding accordingly.”
We really only need to make a few changes to this to make M 0 into an
oblivious TM M 00 :
• When M 0 updates the encoding in its right-to-left sweep, it may need
to move the ˆ marker to the right. However, M 00 cannot stop and move
right when it finds the hat, because it is oblivious. Therefore, the head
of M 00 must, on its right-to-left sweep, move LRL every time M 0 would
move L, so its movement pattern will look like LRLLRLLRL... That
way, the head always has the opportunity to move the ˆ marker either
left or right when it is encountered.
• We need to know how far out M 00 needs to sweep. One option is to
calculate T (n) in advance and place a special marker at spot kT (n)+1,
so that we always sweep out to T (n) + 1 and back to the beginning.
Alternatively, we simply place a marker at spot k + 1 in step 1, and at
the end of every sweep right, we have M 00 move the marker k cells to
the right. This will work because the original machine M cannot have
gone beyond spot i in step i of its calculation.
• We also need to handle the case where M might halt at different times
depending on the input. We know that M is computable in time T (n)
for some time constructible T . This means that there exists a machine
MT such that on all inputs of length n, MT halts in exactly T (n)
steps. We can simulate M and MT simultaneously on the same input
by adding m tapes (this includes input/output tapes) for simulation
of MT to M 00 . States of the machine M 00 can then be considered as
pairs of states of the above form corresponding to M and MT . M 0 will
continue sweeping back and forth in the oblivious manner described
above until MT halts.
Because we’re sweeping out to a maximum distance of kT (n), and we do
it T (n) times, the machine M 00 runs in time O(T (n)2 ).
2
3 Problem 1.12
A partial function from {0, 1}∗ to {0, 1}∗ is a function that is not neces-
sarily defined on all its inputs. We say that a TM M computes a partial
function f if for every x on which f is defined, M (x) = f (x) and for
every x on which f is not defined M gets into an infinite loop when exe-
cuted on input x.If S is a set of partial functions, we define fS to be the
Boolean function that on input α outputs 1 iff Mα computes a partial
function in S. Rice’s Theorem says that for every nontrivial S (a set
that is not the empty set nor the set of all partial functions computable
by some Turing machine), the function fS is not computable.
(a) Show that Rice’s Theorem yields an alternative proof for Theorem
1.11 by showing that the function HALT is not computable.
(b) Prove Rice’s Theorem.
1.12 (a)
Let S be the set of all partial functions defined on a given input x. If the
function HALT is computable, then we can compute fS by simply checking
if the program halts - if it does, then the function must be defined. This
contradicts Rice’s theorem, so HALT cannot be computable.
1.12 (b)
We assume that Rice’s theorem is false. We want to compute HALT(α, x)
(does TM Mα halt on input x?).
Let S be some nontrivial set of partial functions. Without loss of gener-
ality, assume that S does not contain the function N IL that is not defined
on any input.
We create a machine M that first runs Mα on the input, then computes
a partial function g ∈ S, and finally outputs the result of the latter compu-
tation. Thus, if Mα halts, M is equivalent to a TM that computes g.
We now take the function computed by M and check whether it satisfies
fS (in which case the first part of the computation must have halted) – if so,
we output 1 , otherwise, we output 0. So, for any given TM and input, we
can check whether HALT is satisfied. This is not possible, so Rice’s Theorem
must be true.
4 Problem 2.13
Recall that a reduction f from an NP-language L to an NP-language L0
is parsimonious if the number of certificates of f is equal to the number
3
of certificates of f (x).
(a) Prove that the reduction from every NP-language L to SAT pre-
sented in the proof of Lemma 2.11 can be made parsimonious.
(b) Show a parsimonious reduction from SAT to 3SAT.
2.13 (a)
The textbook’s presentation of Cook’s Theorem seems to already be par-
simonious. To see this, we need to show that there is a bijection between the
set of certificates of the initial TM M , and the set of satisfying assignments
of the final formula φx . First, we show an injection: suppose we have two
distinct certificates u1 and u2 such that M (x, u1 ) = M (x, u2 ) = 1. Any satis-
fying assignment of φx must contain the bits of the corresponding certificate,
and so it’s clear that u1 and u2 must correspond to distinct satisfying as-
signments. Second, we show a surjection: consider any satisfying assignment
v. v consists of y, z1 , z2 , ..., zT (|x|) . φx checks that the first |x| bits of y are
exactly the same as the bits of x, so those are predetermined. Furthermore,
given x and the remaining bits of y (which are meant to be interpreted as
the certificate u), all of the snapshots zi are fully determined, as M is a
deterministic TM.
The ambiguity is how the formula φx verifies that M outputs 1. The
phrase “M outputs 1” is not well defined. If it means that M is in an accept
state and its output tape head is at a cell reading the bit “1”, then this
property can easily be verified on the final snapshot zT (|x|) , and so we conclude
that the reduction of Cook’s Theorem is already parsimonious. However, if
we are not willing to assume this definition, then the reduction in the blook
might allow for more than one “accept” condition. In order to account for
this, we clear the work tape and place a 1 in the leftmost cell before halting
in an accept state, so that there is now exactly one condition under which
the machine can accept, ensuring parsimony.
2.13 (b)
We define parsimonious reduction f : SAT → 3SAT as a repeated ap-
plication of function g, where g maps each clause C = x1 ∨ ... ∨ xk in SAT
instance x to a set of clauses as follows:
• If k < 4, g(C) = C
4
The idea here is that it’s just like the reduction in the book, except we
force z to be false whenever either x1 or x2 is true. This guarantees that
whenever x is satisfied by some assignment of variables, there is a unique
extension to that assignment that satisfies f (x). If x1 and x2 are both false,
z is forced to true; otherwise, z is forced to false. Furthermore, if we take
any satisfying assignment of g(C) and remove all the assignments to new
variables, it’s clear by induction that the resulting assignment satisfies C
(if z is false, then x1 ∨ x2 is true; if z is true, then x3 ∨ ... ∨ xk is true by
induction).
5 Problem 2.14
Cook used a somewhat different notion of reduction: A language L is
polynomial-time Cook reducible to a language L0 if there is a polynomial
time TM M that, given an oracle for deciding L0 , can decide L. An
oracle for L0 is a magical extra tape given to M , such that whenever M
writes a string on this tape and goes into a special “invocation” state,
then the string – in a single step! – gets overwritten by 1 or 0 depending
upon whether the string is or is not in L0 ; see Section 3.4 for a more
precise definition.
Show that the notion of cook reducibility is transitive and that 3SAT
is Cook-reducible to TAUTOLOGY.
5
6 Problem 2.32
Prove that if every unary NP-language is in P then EXP=NEXP. (A
language L is unary iff it is a subset of {1}∗ , see Exercise 2.30.)
We use the proof of Theorem 2.22 from the textbook, which shows that
if P=NP, then EXP=NEXP.
Instead of the actual value x, we simply use the unary representation of
x, which has length O(2|x| ). This gives us a unary NP language L0pad – the
rest of the proof is identical to what is given in the book.