Homework 2 Solutions 323
Homework 2 Solutions
1. If the function f is computable by a logspace transducer, then |f(x)| is
polynomial in |x|, because the transducer can run for at most polyno-
mial time before repeating a configuration. Suppose f and g are com-
putable by logspace transducers M and N, respectively. To compute
g(f(x)), we simulate the computation of N on input f(x). The string
f(x) is not computed in advance, but provided to N symbol by symbol
on a demand basis. Whenever N wishes to read the ith symbol of its
input, the number i is provided to a subroutine that simulates M on
input x from scratch, counting and throwing away all output symbols
until the ith, which it returns to the calling procedure. We need only
enough worktape space to hold the worktapes of M and N and a counter
that can count up to |f (x)|. For more details, see [63, Lemmas 13.1 and
13.2].
2. We first show that 2SAT is co-NLOGSPACE-hard by reducing the
MAZE problem, known to be NLOGSPACE-hard, to the complemen-
tary problem, 2CNF unsatisfiability. Given an instance G =(V, E, s, t)
of MAZE, take V as a set of Boolean variables and consider the 2CNF
formula
ϕ
G
= s ∧ (
(u,v)∈E
(u → v)) ∧¬t.
If there is a path from s to t in G, then the clauses in ϕ
G
corresponding
to the edges in this path imply s → t,thusϕ
G
implies s ∧ (s → t) ∧¬t,
which is unsatisfiable. Conversely, if there is no path from s to t, assign
all vertices reachable from s the value 1 and assign all other variables
0. This assignment satisfies ϕ
G
, because s is assigned 1, t is assigned 0,
and there is no clause u → v with u assigned 1 and v assigned 0. Hence
2SAT is hard for co-NLOGSPACE.
We now show that 2SAT is in co-NLOGSPACE, or equivalently, that
2CNF unsatisfiability is in NLOGSPACE.Givena2CNFformulaB,
the clauses in B contain at most two literals, and we can assume exactly
two without loss of generality by replacing any clause of the form (u)
with (u ∨ u). Now we think of every two-literal clause (u ∨ v)asapair
of implications
(¬u → v)and(¬v → u). (2)
Construct a directed graph G =(V, E) with a vertex for every literal and
directed edges corresponding to the implications (2). It is not difficult to