Solutions For Exercise Sheet 1
Solutions For Exercise Sheet 1
Solutions For Exercise Sheet 1
|x|
2. Question: Let L = {xy | |x| = |y| and Σi=0 xi yi = 1 mod 2}. Prove:
(a) L ∈ DTIME(n)
(b) L ∈ DSPACE(log(n))
Note: You do not need to specify the Turing machines accepting L in full
detail, but you need to give a clear high-level description and argue that
the resource bounds are as claimed.
Solution: This problem is similar to the examples discussed in class of the
Parity and Duplication languages, for which we analyzed the time and space
complexity.
We solve the first part first. We are asked to construct a deterministic
Turing machine M which decides L in linear time. M should accept iff its
input is of the form xy, where |x| = |y|, and if the inner product of x and
y is odd.
For the first condition to hold, the input length should be even. So we count
the input length first - this also allows us to split up the input into x and y,
which facilitates the computation of the inner product. The counting can be
done by implementing a counter on a read/write tape, and incrementing the
counter for each input bit read. This might seem to take Ω(n log(n)) time,
since the counter is of size O(log(n)) and every increment can take time up
to log(n). However, the amortized complexity of repeated incrementation is
linear - we need to use time i for counter incrementation only about 1/2i ’th
fraction of the time. For instance, when the counter is even, incrementing
it just requires changing one bit.
Once we’ve computed the count, we first check if it’s even; if not, we reject.
If the input length is even, we compute n which is half the input length,
simply by removing the least significant bit from the counter. Once we
know n, we can determine the boundary between x and y on the input
tape, simply by incrementing a new counter each time an input bit is read,
and stopping when the counter reaches n.
Since the computation of the inner product involves multiplying xi and
yi for various bit positions i, it’s convenient to have x and y on different
tapes, which can then be read from left to right while the computation is
performed. So, once we know where y begins on the input tape, we copy
it bit by bit onto a new read/write tape. This only takes linear time. We
then initialize the input tape head to the first bit of x and the tape head
of the new read/write tape to the first bit on that tape, which again takes
linear time. Now we simply scan the tapes from left to right, recording
in our state whether the inner product so far is odd or even. This can be
updated in constant time per input bit read. When we come to the end of
Computational Complexity, 2012–13 3
For Turing reductions, this argument doesn’t quite work, since L Turing-
reducible to the full language doesn’t imply L is full. But it does imply L ∈
P, since the full language is in P and P is closed under Turing reductions.
Thus if every language in NP were Turing-reducible to the full language,
NP = P. This statement is simply the contrapositive of what we’re trying
to prove.
6. Question: A polynomial-time computable function f : {0, 1}∗ → {0, 1}∗ is
said to be honest if there is a polynomial p such that |x| 6 p(|f (x)|) for
each x. The function f is said to be polynomial-time invertible if there is a
polynomial-time transducer M such that f (M (y)) = y for any string y in
the range of f . Show that all polynomial-time computable honest functions
are polynomial-time invertible if and only if NP = P.
Solution: We need to show two things. First, that if NP = P, then all
polynomial-time honest functions are polynomial-time invertible. Second,
that if all polynomial-time honest functions are polynomial-time invertible,
then NP = P.
Since we’re dealing with functions here rather than decision problems, it’s
natural to try to apply results about NP = P implying efficient solutions
to NP search problems. Notice that inverting an honest poly-time function
is intuitively an NP search problem. Once you guess the solution, i.e., the
inverse z, then verifying the solution is easy - just compute f (z) and check
if it’s equal to the input y.
We follow the same approach as we did in class for showing NP = P implies
we can find satisfying assignments to satisfiable formulae efficiently. We’re
going to find an inverse bit by bit. Since we’re assuming NP = P, we can
use an NP oracle in our search procedure. We use the following NP language
L as our oracle: a string < w, y > is in L if and only if there is a string z
with prefix w such that f (z) = y. L is in NP since we can just guess z with
prefix w and verify that it maps to y in polynomial time.
Now, given input y, the transducer M first asks the oracle the questions
< 0, y > and < 1, y >. If it gets a no answer to both these questions, then
it outputs an arbitrary string, since in this case y is not in the range of f ,
and we’re only interested in y which is in the range of f . If it gets a yes
answer to at least one questions, assume without loss of generality that the
yes answer is to < 0, y >. It then asks the oracle the questions < 00, y >
and < 01, y >. In general, if it gets a yes answer to the question < w, y >,
it asks the oracle the questions < w0, y > and < w1, y > and sets w to
w0 if the first question is answered yes, and to w1 if the second question is
answered yes. If neither question is answered yes, it outputs w.
The intuition is that w is a prefix of an inverse to y, and we would like to
extend this prefix incrementally and recover the entire inverse. As long as
Computational Complexity, 2012–13 7
w is a proper prefix of an inverse, either the question to < w0, y > or the
question to < w1, y > will receive a yes answer, since the next bit of the
inverse is either 0 or 1. When w is no longer a proper prefix, then neither
question might return yes, but at this point we know that w itself is an
inverse.
The transducer M used an oracle in NP, but since by assumption NP = P,
there is an equivalent polynomial-time transducer without an oracle.
For the other direction, it’s enough to show that if all honest poly-time
functions are invertible, then SAT is in polynomial time. Let’s try to define
an honest poly-time function such that inverting it will enable us to solve
SAT. A natural candidate is the function f that takes the pair < φ, w >
as input, where φ is a formula and w is a candidate assignment, and out-
puts φ0 is w is a satisfying assignment, and φ1 otherwise. This function
is polynomial-time computable, since computing it just involves checking
whether a given assignment is a satisfying assignment. It is also honest,
since the length of an assignment is at most the length of the formula,
hence | < phi, w > | is no more than polynomially bigger than |phi|.
Assume that this function is polynomial-time invertible via a transducer
M . Then we can solve SAT on input φ as follows. We run M on φ0. If the
output of M on this input is w, we check that w is a satisfying assignment to
φ. If yes, we answer yes on φ, otherwise we answer no. This is a polynomial-
time procedure and using the definition of the function f , it is easy to see
that this procedure decides SAT correctly.
Notes: The motivation for this problem is from cryptography where the
notion of a function that is easy to compute but hard to invert (known as
“one-way”) is very important. Intuitively, the easiness of computing a one-
way function corresponds to the easiness of encrypting a message, and the
hardness of inverting the function corresponds to the hardness of decrypting
the message for a malicious adversary.
Related Problems: Is the assumption that the functions are honest strictly
necessary? Why, or why not? Also, show that if we consider log-space
computable honest functions rather than polynomial-time computable ones,
the theorem still goes through (but the condition on invertibility is still that
it can be done in polynomial time).