<<

Texts in Computational Complexity

Space Complexity

Oded Goldreich

Department of Computer Science and Applied Mathematics

Weizmann Institute of Science Rehovot Israel

December

Whereas the number of steps taken during a computation is the primary measure of its eciency

the amount of temp orary storage used by the computation is also a ma jor concern Furthermore

in some settings space is even more scarce than time

This text is devoted to the study of the space complexity of computations while fo cusing on

two rather extreme cases The rst case is that of algorithms having logarithmic space complexity

We view such algorithms as utilizing the naturally minimal amount of temp orary storage where

the term minimal is used here in an intuitive but somewhat inaccurate sense and note that

logarithmic space complexity seems a more stringent requirement than p olynomial time The

second case is that of algorithms having p olynomial space complexity Such algorithms can p erform

almost computational tasks considered in this b o ok ie the class P S P AC E contains almost all

complexity classes considered in this b o ok

In addition to the intrinsic interest in space complexity its study provides an interesting p er

sp ective on the study of time complexity For example in contrast to the common conjecture by

which NP co NP we shall see that analogous space complexity classes eg NL are closed

under complementation eg NL coNL

We stress that as in the case of time complexity the results presented in this chapter hold for

any reasonable mo del of computation In fact when prop erly dened space complexity is even

more robust than time complexity Still for sake of clarity we often refer to the sp ecic mo del of

Turing machines

Organization Space complexity seems to b ehave quite dierently from time complexity and

seems to require a dierent mindset as well as auxiliary conventions Some of these are discussed

in Section We then turn to the study of logarithmic space complexity see Section and the

corresp onding nondeterministic version see Section Finally we consider p olynomial space

complexity see Section

General preliminaries

Space complexity is meant to measure the amount of temp orary storage ie computers memory

used when p erforming a computational task Since much of our fo cus will b e on using an amount

of memory that is sublinear in the input length it is imp ortant to use a mo del in which one can

dierentiate memory used for computation from memory used for storing the initial input or the

nal output That is we do not want to count the input and output themselves within the space of

computation and thus formulate that they are delivered on sp ecial devices that are not considered

memory On the other hand we have to make sure that the input and output devices cannot

b e abused for providing work space which is uncounted for This leads to the convention by

which the input device eg a designated inputtap e of a multitape Turing machine is readonly

whereas the output device eg a designated outputtap e of a such machine is writeonly Thus

space complexity accounts for the use of space on the other storage devices eg the worktapes

of a multitape Turing machine

Fixing a concrete mo del of computation eg multitape Turing machines we denote by

Dspaces the class of decision problems that are solvable in space complexity s The space com

plexity of search problems is dened analogously Sp ecically the standard denition of space

complexity refers to the number of cells of the worktape scanned by the machine on each input

We prefer however an alternative denition which provides a more accurate account of the actual

storage Sp ecically the binary space complexity of a computation refers to the the number of bits

that can be stored in these cells thus multiplying the number of cells by the logarithm of the nite

set of work symbols of the machine

The dierence b etween the two denitions is mostly immaterial since it amounts to a constant

factor and we will discard such factors Nevertheless aside from b eing conceptually right the

denition of binary space complexity will facilitate some technical details b ecause the number of

p ossible congurations is explicitly upp erb ounded in terms of binary space complexity whereas the

relation to the standard denition dep ends on the machine in question Towards such applications

one may also count the nite state of the machine in its space complexity Furthermore for sake of

simplicity we also assume that the machine do es not scan the inputtap e b eyond the b oundaries

of the input which are indicated by sp ecial symbols

On the minimal amount of useful computation space

Bearing in mind that one of our main ob jectives is identifying natural subclasses of P we consider

the question of what is the minimal amount of space that allows for meaningful computations

We note that regular sets Chap are decidable by constantspace Turing machines and that

this is all that the latter can decide see eg Sec It is tempting to say that sub

logarithmic space machines are not more useful than constantspace machines b ecause it seems

imp ossible to allo cate a sublogarithmic amount of space This wrong intuition is based on the

presumption that the allo cation of a nonconstant amount of space requires explicitly computing

the length of the input which in turn requires logarithmic space However this presumption

is wrong the input itself in case it is of a prop er form can b e used to determine its length

whereas in case the input is not of the prop er form then this fact may b e detectable within sub

logarithmic space In fact for n log log n the class DspaceO is a proper superset of

DspaceO see Exercise In contrast to Exercise doublelogarithmic space is indeed the

smallest amount of space that is more useful than constant space that is for n log log n it

holds that Dspaceo DspaceO see Exercise

In spite of the fact that some nontrivial things can b e done in sublogarithmic space complexity

the lowest space that we shall study in depth is logarithmic space see Section

As we shall see this class is the natural habitat of several fundamental computational phenomena

1

We note that unlike in the context of timecomplexity linear sp eed do es not seem to represent an actual

saving in space resources Indeed time can b e sp edup by using stronger hardware ie a Turing machine with a

bigger work alphab et but the actual space is not really aected by partitioning it into bigger chunks ie using

bigger cells

A parenthetical comment or a side lesson Before pro ceeding let us highlight the fact

that a naive presumption ab out generic algorithms ie that the use of a nonconstant amount of

space requires explicitly computing the length of the input could have led us to a wrong conclu

sion This demonstrates the danger in making reasonably lo oking presumptions ab out arbitrary

algorithms which in turn are the sub ject of a complexity lowerbound

Time versus Space

Space complexity b ehaves very dierent from time complexity and indeed dierent paradigms are

used in studying it One notable example is provided by the context of algorithmic comp osition

discussed next

Two comp osition lemmas

Unlike time space can b e used but on the other hand intermediate results of a computation

cannot b e recorded for free These two conicting asp ects are captured in the following comp osition

lemma

Lemma naive comp osition Let f f g f g and f f g f g f g be

def

computable in space s and s respectively Then f dened by f x f x f x is computable

in space s such that

sn maxs n s n n n O

where n max n fjf xjg

xfg

That is f x is computed by rst computing and storing f x and then reusing the space used in

the rst computation when computing f x f x The additional term of n is due to storing

the intermediate result ie f x Lemma is useful when is relatively small but in many cases

maxs s In these cases the following comp osition lemma is more useful

Lemma emulative comp osition Let f f s s and f be as in Lemma Then f is com

putable in space s such that

sn s n s n n O log n n

The alternative comp ositions are depicted in Figure which also shows the most straightforward

comp osition of A and A that makes no attempt to economize space

Pro of The idea is avoiding the storage of the temp orary value of f x by computing each of

its bits on the y whenever it is needed for the computation of f That is we do not start

by computing f x but rather start by computing f x f x although we do not have some of

the bits of the relevant input The missing bits will b e computed and recomputed whenever we

need them in the computation of f x f x Details follow

Let A and A b e the algorithms for computing f and f resp ectively guaranteed in the

n

hypothesis Then on input x f g we invoke algorithm A for computing f Algorithm A

is invoked on a virtual input and so when emulating each of its steps we should provide it with

the relevant bit Thus we should also keep track of the lo cation of A on the imaginary virtual

2

Here and throughout the chapter we assume for simplicity that all complexity b ounds are monotonically

nondecreasing x x x

A1 A1 A1

f1 (x) f1 (x) f1 (x) counters

A2 A2 A2

f(x) f(x) f(x)

The leftmost gure shows the trivial comp osition which just invokes

A and A without attempt to economize storage the middle gure

shows the naive comp osition of Lemma and the rightmost gure

shows the emulative comp osition of Lemma In all gures the lled

rectangles represent designated storage spaces The dotted rectangle

represents a virtual storage device

Figure Algorithmic comp osition for spaceb ounded computation

th

input tap e Whenever A seeks to read the i bit of its input where i n n we provide A

with this bit by reading it from x if i n and invoke A x otherwise When invoking A x we

provide it with a virtual output tap e which means that we get the bits of its output onebyone

th

and do not record them anywhere Instead we count until reaching the i n output bit which

th

we then pass to A as the i bit of hx f x i

Note that while invoking A x we susp end the execution of A but keep its current congura

tion such that we can resume the execution of A once we get the desired bit Thus we need to

allo cate separate space for the computation of A and for the computation of A In addition we

need to allo cate separate storage for maintaining the aforementioned counters ie the bitlo cation

currently read by A and the index of the bit currently pro duced in the current invocation of A

An obvious b ound

The time complexity of an algorithm is essentially upp erb ounded by an exp onential in its space

complexity This is due to an upp erb ound on the number of p ossible instantaneous congurations

of the algorithm as formulated in the pro of of Theorem and the fact that if the computation

passes through the same conguration twice then it must lo op forever

Theorem If an algorithm A has binary space complexity s and halts on every input then it has

snlog sn

2

time complexity t such that tn n

O sn

Note that for sn log n the factor of n can b e absorb ed by and so we may just write

O sn

tn

Pro of The pro of refers to the notion of an instantaneous conguration in a computation Before

starting we warn the reader that this notion may b e given dierent denitions each tailored to

the application at hand All these denitions share the desire to sp ecify variable information that

together with some xed information determines the next step of the computation b eing analyzed

In the current pro of we x an algorithm A and an input x and consider as variable the contents

of the storage device eg worktape of a Turing machine and the machines lo cation on the input

device and on the storage device Thus an instantaneous conguration of Ax consists of the latter

three ob jects ie the contents of the storage device and a pair of lo cations and can b e enco ded

by a binary string of length jxj sjxj log jxj log sjxj

The key observation is that the computation Ax cannot pass through the same computation

twice b ecause otherwise the computation Ax passes through this conguration innitely many

times which means that it do es not halt Intuitively the p oint is that the xed information

ie A and x together with the conguration determines the next step of the computation

Thus whatever happ ens i steps after the rst time that the computation Ax passes through

conguration will also happ en i steps after the second time that the computation Ax passes

through

jxj

By the forgoing observation we infer that tjxj and the theorem follows

Subtleties regarding spaceb ounded reductions

Lemmas and suce for the analysis of the aect of manytoone reductions in the context of

spaceb ounded computations Sp ecically

In spirit of Lemma If f is reducible to g via a manytoone reduction that can b e

computed in space s and g is computable in space s then f is computable in space s such

that sn maxs n s n n where n denotes the maximum length of the image

of the reduction when applied to some nbit string

In spirit of Lemma For f and g as in Item it follows that f is computable in space s

such that sn s n s n O log n

s nlog s n

1 1

2

Note that by Theorem it holds that n n We stress the fact that is not

b ounded by s as in the analogous case of timeb ounded computation but rather by exps

Things gets much more complicated when we turn to general spaceb ounded reductions esp e

cially when referring to such reductions that make a nonconstant number of queries A preliminary

issue is dening the space complexity of general reductions ie of oracle machines In the stan

dard denition the length of the queries and answers is not counted in the space complexity but the

queries of the reduction resp answers given to it are written on resp read from a sp ecial de

vice that is writeonly resp readonly for the reduction and readonly resp writeonly for the

invoked oracle Note that these convention are analogous to the conventions regarding input and

output as well as t the denitions of spaceb ounded manytoone reductions see Section

The rest of the discussion which is quite advanced and laconic and is inessential to the rest of the

chapter concerns two additional issues

Recall that the complexity of the algorithm resulting from the comp osition of an oracle machine

and an actual algorithm dep ends on the length of the queries made by the oracle machine The

length of the rst query is upp erb ounded by an exp onential function in the space complexity of

3

Here and in the next item we refer to the case that f x g f x rather than to the more general case where

1

f x g x f x Consequently s is applied to n rather than to n n

1 2

the oracle machine but the same do es not necessarily hold for subsequent queries unless some

conventions are added to enforce it For example consider a reduction that on input x and access

jz j

to the oracle f such that f z invokes the oracle jxj times where each time it uses as a

query the answer obtained to the previous query This reduction uses constant space but pro duces

queries that are exp onentially longer than the input whereas the rst query of any constantspace

reduction has length that is linear in its input This problem can b e resolved by placing explicit

b ounds on the length of the queries that spaceb ounded reductions are allowed to make for example

we may b ound the length of all queries by the obvious exp onential in the space complexity b ound

that holds for the length of the rst query

With the aforementioned convention or restriction in place let us consider the comp osition

of general spaceb ounded reductions with a spaceb ounded implementation of the oracle Sp ecif

ically we say that a reduction is restricted if on input x all oracle queries are of length at

most jxj and the corresp onding oracle answers are of length at most jxj It turns out that

naive comp osition in the spirit of Lemma remains valid whereas the emulative comp osition of

Lemma breaks down in the sense that it yield very weak results

Following Lemma we claim that if can be computed in space s when given

restricted oracle access to and is solvable is space s then is solvable in space s such

that sn s n s n n n The claim is proved by using a naive emulation

that allo cates separate space for the reduction ie oracle machine itself the emulation of

its query and answer devices and the algorithm solving Note that here we cannot reuse

the space of the reduction when running the algorithm that solves b ecause the reductions

computation continues after the oracle answer is obtained

A related comp osition result is presented in Exercise It yields sn s n s n

s n

1

n log n which for n means sn s n s n n

Turning to the approach underlying Lemma we get into more serious trouble Recomputing

th

the answer of the i query requires recomputing the query itself which unlike in Lemma

is not the input to the reduction but rather dep ends on the answers to prior queries which

need to b e recomputed as well Thus the space required for such an emulation may b e linear

in the number of queries In fact we should not exp ect any b etter b ecause any computation

of space complexity s can b e p erformed by a constantspace s srestricted reduction to a

problem that is solvable in constantspace see Exercise

An alternative notion of spaceb ounded reductions is presented in This notion is more cum

b ersome and more restricted but it allows recursive comp osition with a smaller overhead than the

two options explored ab ove

Complexity hierarchies and gaps

Recall that more space allows for more computation provided that the spaceb ounding function

is nice in an adequate sense Actually the pro ofs of spacecomplexity hierarchies and gaps are

simpler than in the analogous pro ofs for timecomplexity b ecause emulations are easier in the

context of spaceb ounded algorithms

Simultaneous timespace complexity

Recall that for space complexity that is at least logarithmic the time of a computation is always

upp erb ounded by an exp onential function in the space complexity see Theorem Thus p olylog

arithmic space complexity may extend b eyond p olynomialtime and it make sense to dene a class

like SC that consists of all decision problems that may b e solved by a p olynomialtime algorithm

of p olylogarithmic space complexity The class SC is indeed a natural subclass of P and contains

the class which is dened in Section

In general one may dene DTiSpt s as the class of decision problems solvable by an algorithm

that has time complexity t and space complexity s Note that DTiSpt s Dtimet Dspaces

and that a strict containment may hold Lower b ounds on timespace tradeos see eg

Sec may b e stated as referring to the classes DTiSp

Circuit Evaluation

n m

Recall that there exists a p olynomialtime algorithm that given a circuit C f g f g

and an nbit long string x returns C x For circuits of b ounded fanin the space complexity of

such an algorithm can b e made linear in the depth of the circuit and logarithmic in its size This

is obtained by the following DFStype algorithm

The algorithm recursively determines the value of a gate in the circuit by rst determining

the value of its rst incoming edge and next determining the value of the second incoming edge

Thus the recursive pro cedure started at each output terminal of the circuit needs only store the

path that leads to the currently pro cessed vertex as well as the temp orary values computed for each

ancestor Note that this path is determined by indicating for each vertex on the path whether

we currently pro cess its rst or second incoming edge In case we currently pro cess the vertexs

second incoming edge we need also store the value computed for its rst incoming edge

The temp orary storage used by the foregoing algorithm on input C x is thus d O log jxj

C

log jC xj where d denotes the depth of C The rst term in the spaceb ound accounts for the

C

core activity of the algorithm ie the recursion whereas the other terms account for the overhead

involved in assigning the bits of x to the corresp onding input terminals of C and in scanning all

output terminals of C

Logarithmic Space

Although Exercise asserts that there is life b elow logspace logarithmic space seems to b e the

smallest amount of space that supp orts interesting computational phenomena In fact logarithmic

space suces for solving many natural computational problems for establishing reductions among

many natural computational problems and for a stringent notion of uniformity of families of

Bo olean circuits Indeed an imp ortant feature of logarithmic space computations is that they are

a natural sub class of the p olynomialtime computations see Theorem

The class L

Focusing on decision problems we denote by L the class of decision problems that are solvable by

def

algorithms of logarithmic space complexity that is L Dspace where n c log n

c c c

Note that by Theorem L P As hinted many natural computational problems are in L see

Exercises and as well as Section On the other hand it is widely believed that L P

4

We also mention that BPL SC where BPL is the BPP analogue of L

LogSpace Reductions

Another class of imp ortant logspace computations is the class of logarithmic space reductions In

light of the subtleties discussed in x we conne ourselves to the case of manytoone reductions

Analogously to the denition of Karpreductions we say that f is a logspace manytoone reduction

of S to S if f is logspace computable and for every x it holds that x S if and only if f x S

Clearly if S is so reducible to S L then S L Similarly one can dene a logspace variant of

Levinreductions Both types of reductions are transitive see Exercise Note that Theorem

applies in this context and implies that these reductions run in p olynomialtime Thus the notion

of a logspace manytoone reduction is a sp ecial case of a Karpreduction

We observe that all known Karpreductions establishing NPcompleteness results are actually

logspace reductions For example consider the generic reduction to CSAT presented in the pro of

of the NPcompleteness of CSAT The constructed circuit is highly uniform and can b e easily

constructed in logarithmicspace see Section A degeneration of this reduction suces for

proving that every problem in P is logspace reducible to the problem of evaluating a given circuit

on a given input Note that the latter problem is in P and thus we may say that it is Pcomplete

under logspace reductions

Theorem The complexity of Circuit Evaluation Let CEVL denote the set of pairs C such

that C is a Boolean circuit and C Then CEVL is in P and every problem in P is logspace

Karpreducible to CEVL

Pro of Recall that the observation underlying the pro of of the NPcompleteness of CSAT is that

the computation of a Turing machine can b e emulated by a highly uniform circuit In that pro of

one hardwires the input to the reduction denoted x into the circuit denoted C and introduced

x

input terminals corresp onding to the bits of the NPwitness denoted y In the current context

we leave x as an input to the circuit while noting that the auxiliary NPwitness do es not exists

or has length zero Thus the reduction from S P to CEVL maps the instance x for S to the

pair C x where C is a circuit that emulates the computation of the machine that decides

jxj jxj

membership in S on any jxjbit long input

The impact of Pcompleteness under logspace reductions Indeed Theorem implies

that L P if any only if CEVL L Other natural problems were proved to have the same prop erty

ie b eing Pcomplete under logspace reductions cf

Logspace reductions are used to dene completeness with resp ect to other classes that are

assumed to extend b eyond L This restriction of the p ower of the reduction is denitely needed

when the class of interest is contained in P eg NL see Section In general we say that a

problem is C complete under logspace reductions if is in C and every problem in C is logspace

manytoone reducible to In such a case if L then C L

As in the case of p olynomialtime reductions we wish to stress that the relevance of logspace

reductions extends b eyond b eing a to ol for dening complete problems

LogSpace uniformity and stronger notions

Strengthening the standard denition of p olynomialtime uniformity we say that a family of

circuits C is logspace uniform if there exists an algorithm A that on input n outputs C while

n n n

using space that is logarithmic in the size of C As implied by Theorem and implicitly proved

n

in Theorem the computation of any polynomialtime algorithm can be emulated by a logspace

uniform family of b ounded fanin polynomialsize circuits On the other hand in continuation to

Section we note that logspace uniform circuits of bounded fanin and logarithmic depth can be

emulated by an algorithm of logarithmic space complexity ie NC is in logspace see Exercise

Stronger notions of uniformity have b een considered Sp ecically we say that C has a

n n

strongly explicit construction if there exists an algorithm that runs in p olynomialtime and linear

space such that on input n and v the algorithm returns the lab el of vertex v in C as well as the

n

list of its children or an indication that v is not a vertex in C Note that if C has a strongly

n n n

explicit construction then it is logspace uniform b ecause the length of the description of a vertex

in C is logarithmic in the size of C The pro of of Theorem actually establishes the following

n n

Theorem strongly uniform circuits emulating P For every polynomialtime algorithm A

there exists a strongly explicit construction of a family of polynomialsize circuits C such that

n n

for every x it holds that C x Ax

jxj

Undirected Connectivity

Exploring a graph eg towards determining its connectivity is one of the most basic and ubiq

uitous computational tasks regarding graphs The standard graph exploration algorithms eg

BFS and DFS require temp orary storage that is linear in the number of vertices In contrast the

algorithm presented in this section uses temp orary storage that is only logarithmic in the number

of vertices In addition to demonstrating the p ower of logspace computation this algorithm or

rather its actual implementation provides a taste of the type of issues arising in the design of

sophisticated logspace algorithms

The intuitive task of exploring a graph is captured by the task of deciding whether a given

graph is connected In addition to the intrinsic interest in this natural computational problem

we note that related versions of the problem seem harder For example determining directed

connectivity in directed graphs captures the essence of the class NL see Section In view

of this situation we emphasize the fact that the computational problem considered here refers to

undirected graphs by calling it undirected connectivity

Theorem Deciding undirected connectivity UCONN is in L

The starting p oint of the algorithm is the fact that any expander is easy to traverse in deterministic

logarithmicspace and thus the algorithm gradually transforms any graph into an expander while

maintaining the ability to map a traversal of the latter into a traversal of the former Thus the

algorithm traverses a virtual graph which b eing an expander is easy to traverse in deterministic

logarithmicspace and maps the virtual traversal of the virtual graph to a real traversal of the actual

input graph The virtual graph is constructed in logarithmically many iterations where in each

iteration the graph b ecomes easier to traverse Sp ecically in each iteration the expansion prop erty

of the graph improves by a constant factor while the graph itself only grows by a constant factor

and each iteration can b e p erformed or rather emulated in constant space Since each graph

has some noticeable expansion ie expansion inversely related to the size of the graph after

logarithmically many steps this pro cess yields a go o d expander ie constant expansion The

details are presented in a sep erate text which uses a more abstract presentation than the one

in the original work

NonDeterministic Space Complexity

The dierence b etween spacecomplexity and timecomplexity is quite striking in the context of

nondeterministic computations One asp ect is the huge gap b etween the p ower of two formulation

of nondeterministic space complexity see Section while in contrast the analogous formulations

are equivalent in the context of timecomplexity Another asp ect is the contrast b etween the results

regarding the standard mo del of nondeterministic spaceb ounded computation see Section

and the analogous questions in the context of timecomplexity

Two mo dels

Recall that nondeterministic timeb ounded computations were dened via two equivalent mo dels

In the oline mo del underlying the denition of NP as a pro of system nondeterminism is

captured by reference to the existential choice of the contents of the auxiliary nondeterministic

input tap e In the online mo del underlying the traditional denition of NP nondeterminism is

captured by reference to the nondeterministic choices of the machine itself These mo dels are

equivalent b ecause the latter online choices can b e recorded almost for free That is while it is

clear that the oline mo del can emulate the online mo del ie the oline machine can emulate

online choices by using the contents of its nondeterministic input tap e the emulation of the

oline mo del by the online mo del is enabled by the fact that an online machine may store and

reuse a sequence of nondeterministic online choices

The naive emulation of the oline mo del on the online mo del is not p ossible in the context

of spaceb ounded computation b ecause the number of nondeterministic choices is typically much

larger than the spaceb ound The mo dels b ecome equivalent only if the oline mo del is restricted

to access its nondeterministic input tap e in a unidirectional manner Let us formulate the two

mo dels and consider them more closely

In the standard mo del called the online mo del the machine makes nondeterministic choices

on the y or alternatively reads a nondeterministic input from a readonly tap e that can be

read only in a unidirectional way Thus if the machine needs to refer to such a nondeterministic

choice at a latter stage in its computation then it must store the choice on its storage device and

b e charged for it In the socalled oline mo del the nondeterministic choices or the bits of the

nondeterministic input are read from a sp ecial readonly device or tap e that can be scanned in

both directions like the main input

We denote by Nspace s resp Nspace s the class of sets that are acceptable

online oline

by an online resp oline nondeterministic machine having space complexity s We stress

that as in the traditional denition of NP the set accepted by a nondeterministic machine M

is the set of strings x such that there exists a computation of M x that is accepting Clearly

Nspace s Nspace s On the other hand not only that Nspace s

online oline online

Nspace s but rather Nspace s Nspace log s provided that s is at least

oline online oline

linear For details see Exercise

Before pro ceeding any further let us justify the fo cus on the online mo del in the rest of this

section Indeed the oline mo del ts b etter the motivations to NP but the online mo del seems

more adequate for the study of nondeterministic in the context of space complexity One reason is

that an oline nondeterministic tap e can b e used to co de computations see Exercise and in

a sense allows to cheat with resp ect to the actual space complexity of the computation This is

reected in the fact that the oline mo del can emulate the online mo del while using space that is

logarithmic in the space used by the online mo del A related phenomenon is that Nspace s

oline

s

s

whereas Nspace s Dtime This fact is only known to b e contained in Dtime

online

motivates the study of NL Nspace log as a study of a natural subclass of P Indeed

online

the various results regarding NL justify its study in retrosp ect

In light of the foregoing we adopt the standard conventions and let Nspaces Nspace s

online

Our main fo cus will b e the study of NL Nspacelog

NL and directed connectivity

This section is devoted to the study of NL which we view as the nondeterministic analogue of

L Sp ecically NL Nspace where n c log n and the denitional issues p ertaining

c c c

Nspace Nspace are discussed in Section

online

We rst note that the pro of of Theorem can b e easily extended to the online nondeterministic

context The reason b eing that moving from the deterministic mo del to the current mo del do es not

aect the number of instantaneous congurations as dened in the pro of of Theorem whereas

this number b ounds the time complexity Thus NL P

The following problem called directed connectivity stCONN captures the essence of non

deterministic logspace computations and in particular is complete for NL under logspace re

ductions The input to stCONN consists of a directed graph G V E and a pair of vertices

s t and the task is to determine whether there exists a directed path from s to t in G Indeed

the study of NL is often conducted via stCONN For example note that NL P follows easily

from the fact that stCONN is in P and the fact that NL is logspace reducible to stCONN

Completeness and b eyond

Clearly stCONN is in NL see Exercise The NLcompleteness of stCONN under logspace

reductions follows by noting that the computation of any nondeterministic spaceb ounded machine

yields a directed graph in which vertices corresp ond to p ossible congurations and edges represent

the successive relation of the computation In particular for logspace computations the graph

has p olynomial size but in general the relevant graph is strongly explicit in a natural sense see

Exercise

Theorem Every problem in NL is logspace reducible to stCONN via a manytoone reduction

Pro of Sketch Fixing a nondeterministic online machine M and an input x we consider the

following directed graph G V E The vertices of V are p ossible instantaneous congurations

x x x x

of M x where each conguration consists of the contents of the worktape the machines lo cation

on it and the machines lo cation on the input The directed edges represent p ossible single moves

in such a computation Note that such a move dep ends on the machine M as well as on the single

bit of x that resides in the lo cation sp ecied by the rst conguration ie the one corresp onding

to the startp oint of the p otential edge Thus the question of whether x S is represented by

the existence of a directed path from the vertex that corresp onds to the initial conguration to the

vertex that corresp onds to a canonical accepting conguration

We b elieve that the pro of of Theorem see also Exercise justies our choice to say that

stCONN captures the essence of nondeterministic logspace computations rather than merely

saying that stCONN is NLcomplete under logspace reductions

We note the discrepancy b etween the status of undirected connectivity see Theorem and

directed connectivity see Theorem In this context it is worthwhile to note that determining the

5

We note that here and in the sequel s stands for start and t stands for terminate

existence of relatively short paths rather than arbitrary paths in undirected or directed graphs

is also NLcomplete under logspace reductions see Exercise

Relating NSPACE to DSPACE

Recall that in the context of time complexity converting nondeterministic computation to deter

ministic computation is known only when allowing an exp onential blowup in the complexity In

contrast space complexity allows such a conversion at the cost of a p olynomial blowup in the

complexity

Theorem Nondeterministic versus deterministic space For any spaceconstructible s N

N that is at least logarithmic it holds that Nspaces DspaceO s

In particular nondeterministic p olynomialspace is contained in deterministic p olynomialspace

and nondeterministic p olylogarithmic space is contained in deterministic p olylogarithmic space

Pro of Sketch We fo cus on the sp ecial case of NL and the argument extends easily to the general

case Alternatively the general statement can b e derived from the sp ecial case by using a suitable

upwardstranslation lemma see eg Sec The sp ecial case b oils down to presenting a

logsquare space algorithm for deciding directed connectivity

The basic idea is that checking whether or not there is a path of length at most from u to v

in G reduces in logspace to checking whether there is an intermediate vertex w such that there

is a path of length at most d e from u to w and a path of length at most b c from w to v Let

def def

u v if there is a path of length at most from u to v in G and u v otherwise

G G

Thus u v can b e decided recursively by scanning all vertices w in G and checking for each

G

w whether b oth u w d e and w v b c hold

G G

Thus given a directed graph G V E and a pair of vertices s t we should compute

s t jV j This is done by invoking a recursive pro cedure that computes u v by scanning

G G

all vertices in G and computing for each vertex w the values of u w d e and w v b c

G G

We return the value if and only if for some w it holds that u w d e w v b c

G G

Needless to say u v and u v can b e decided easily in logarithmic space

G G

The amount of space taken by each level of the recursion is log jV j for storing the current

value of w and the number of levels is log jV j We stress that when computing u v we

G

make p olynomially many recursive calls but all these calls reuse the same work space That is

when we compute u w d e we reuse the space that was used for computing u w b c

G G

for the previous w and we reuse the same space when we compute w v b c The theorem

G

follows

Placing NL in NC The simple formulation of stCONN facilitates placing NL in complexity

classes such as NC All that is needed is observing that stCONN can b e solved by raising the

adequate matrix ie the adjacency matrix of the graph augmented with entries on the diagonal

to the adequate p ower ie its dimension Squaring a matrix can b e done by a uniform family of

th

logarithmic depth b ounded fanin circuits ie in NC and by rep eated squaring the n p ower

of an nbyn matrix can b e computed by a uniform family of b ounded fanin circuits of p olynomial

size and depth O log n thus NL NC

Complementation or NLcoNL

Recall that natural nondeterministic timecomplexity classes are not known to b e closed under

complementation Furthermore it is widely b elieved that NP coNP In contrast natural

nondeterministic spacecomplexity classes are closed under complementation as captured by the

def

result NL co NL where co NL ff g n S S N Lg Before proving this result let us take

a closer lo ok at the problem it resolves which we rephrase as NL versus NL co NL

Recall that a set S is in NL if there exists a nondeterministic logspace machine M that

accepts S and that the acceptance condition of nondeterministic machines is asymmetric in nature

That is x S implies the existence of an accepting computation of M on input x whereas

x S implies that al l computations of M on input x are nonaccepting Thus the existence of a

accepting computation of M on input x is an absolute indication for x S but the existence of a

rejecting computation of M on input x is not an absolute indication for x S We note that for

S N L coNL there exist absolute indications b oth for x S and for x S or equivalently for

def

S f g n S where each of the two types of indication is provided by a dierent machine x

S Combining b oth machines we obtain a single ie the one accepting S or the one accepting

nondeterministic machine that for every input sometimes outputs the correct answer and always

outputs either the correct answer or a sp ecial dont know symbol This yields the following

denition which refers to Bo olean functions as a sp ecial case

Denition nondeterministic computation of functions We say that a nondeterministic ma

chine M computes the function f f g f g if for every x f g the fol lowing two

conditions hold

Every computation of M on input x yields an output in ff x g where f g is a

special symbol indicating dont know

There exists a computation of M on input x that yields the output f x

Note that S NL co NL if and only if there exists a nondeterministic logspace machine that

computes where x if x S and x otherwise see Exercise It follows that

S S S

NL co NL if and only if for every S NL there exists a nondeterministic logspace machine

that computes

S

Theorem NL co NL For every S NL there exists a nondeterministic logspace ma

chine that computes

S

As in the case of Theorem the result extends to any spaceconstructible s N N that is at least

logarithmic that is for such s and every S Nspaces it holds that f g n S NspaceO s

This extension can b e proved either by generalizing the following pro of or by using an adequate

upwardstranslation lemma

Pro of Sketch It suces to present a nondeterministic online logspace machine that computes

the characteristic function of stCONN denoted ie G s t if there is a directed path

from s to t in G and G s t otherwise

We rst show that the computation of is logspace reducible by two queries to determining

the number of vertices that are reachable from a given vertex in a given graph On input G s t

6

We stress the fact that two queries are used in the reduction b ecause this avoids the diculties discussed in

x regarding emulative comp osition for general spaceb ounded reduction Alternatively we may use a version of

the naive comp osition while relying on the fact that the oracle queries are highly related to the input and that the

answers have logarithmic length For details see Exercises and

the reduction computes the number of vertices that are reachable from s in the graph G and

compares it to the number of vertices reachable from s in the graph obtained by deleting t from

G An alternative reduction that uses a single query is presented in Exercise Note that if

computing f is logspace reducible by a constant number of queries to computing some function g

and there exists a nondeterministic logspace machine that computes g then there exists a non

deterministic logspace machine that computes f see Exercise Thus we fo cus on providing a

nondeterministic logspace machine that compute the number of vertices that are reachable from

a given vertex in a given graph

Fixing an nvertex graph G V E and a vertex v we consider the set of vertices that are

reachable from v by a path of length at most i We denote this set by and observe that R fv g

i

and that for every i it holds that

R R fu w R st w u E g

i i i

th

Our aim is to compute jR j This will b e done in n iterations such that at the i iteration we

n

compute jR j When computing jR j we rely on the fact that jR j is known to us which means

i i i

that we shall store jR j in memory We stress that we discard jR j from memory as so on as we

i i

complete the computation of jR j which we store instead Thus at each iteration i our record of

i

past iterations only contains jR j

i

Computing jR j Given jR j we nondeterministically compute jR j by making a guess for jR j

i i i i

denoted g and verifying its correctness as follows

We verify that jR j g in a straightforward manner That is scanning V in some canonical

i

order we verify for g vertices that they are each in R That is during the scan we select

i

nondeterministically g vertices and for each selected vertex w we verify that w is reachable

from v by a path of length at most i where this verication is p erformed by just guessing

and verifying an adequate path see Exercise

We use log n bits to store the currently scanned vertex ie w and another O log n bits

for implementing the verication of the existence of a path of length at most i from v to w

The verication of the condition jR j g is the interesting part of the pro cedure Here we

i

rely on the fact that we know jR j which allows for a nondeterministic enumeration of

i

R itself which in turn allows for pro ofs of nonmembership in R via the use of Eq

i i

Details follows and an even more structured description is provided in Figure

Scanning V again we verify for n g guessed vertices that they are not in R ie are not

i

reachable from v by paths of length at most i By Eq verifying that u R amounts to

i

proving that for every w R it holds that u w and w u E As hinted the knowledge

i

of jR j allows for the enumeration of R and thus we merely check the aforementioned

i i

condition on each vertex in R Thus verifying that u R is done as follows

i i

a We scan V guessing jR j vertices that are in R and verify each such guess in the

i i

straightforward manner ie as in Step

b For each w R that was guessed and veried in Step a we verify that b oth u w

i

and w u E

7

Note that implicit in Step a is a nondeterministic pro cedure that computes the mapping G v i jR j R

i1 i1

where R denotes the set of vertices that are reachable in G by a path of length at most i from v

i1

By Eq if u passes the foregoing verication then indeed u R

i

Note that we use log n bits to store the vertex u another log n bits to count the number

of vertices that are veried to b e in R another log n bits to store such a vertex w and

i

another O log n bits for verifying that w R as in Step

i

If any of the foregoing verications fails then the pro cedure halts outputting the dont know

symbol Otherwise it outputs g

Given jR j and a guess g the claim g jR j is veried as follows

i i

Set c initializing the main counter

For u n do b egin the main scan

Guess whether or not u R

i

For a negative guess ie u R do b egin

i

Verify that u R via Eq

i

Set c initializing a secondary counter

For w n do b egin the secondary scan

Guess whether or not w R

i

For a p ositive guess ie w R do b egin

i

Verify that w R as in Step

i

Verify that u w and w u E

If some verication failed

then halt with output otherwise increment c

End of hand ling a positive guess for w R

i

End of secondary scan c vertices in R were checked

i

If c jR j then halt with output

i

Otherwise c jR j increment c u veried to be outside of R

i i

End of hand ling a negative guess for u R

i

End of main scan c vertices were shown outside of R

i

If c n g then halt with output

Otherwise n jR j c n g is veried

i

Figure The main step in proving NL coNL

It can b e veried that when given the correct value of jR j the foregoing nondeterministic

i

logspace pro cedure computes the value of jR j That is if all verications are satised then it must

i

hold that g jR j and if g jR j then there are adequate nondeterministic choices that satisfy

i i

all verications

Recall that R is computed iteratively starting with jR j and computing jR j based on

n i

jR j Each iteration i n is nondeterministic and is either completed with the correct

i

value of jR j at which p oint jR j is discarded or halts in failure in which case we halt the entire

i i

pro cess and output This yields a nondeterministic logspace machine for computing jR j and

n

the theorem follows

PSPACE and Games

As stated upfront we will rarely treat computational problems that require less than logarithmic

space On the other hand we will rarely treat computational problems that require more than

p olynomial space The class of decision problems that are solvable in p olynomialspace is denoted

def

c

P S P AC E Dspacep where p n n

c c c

To get a sense of the p ower of P S P AC E we observe that PH P S P AC E for example a

p olynomialspace algorithm can easily verify the quantied condition underlying the denition of

In fact such an algorithm can handle an unbounded number of alternating quantiers see

k

p

c

Theorem On the other hand by Theorem P S P AC E EXP where EXP Dtime

c

c

for p n n

c

The class P S P AC E can b e interpreted as capturing the complexity of determining the winner

in certain ecient twoparty game sp ecically the very games considered in the context of the

PolynomialTime hierarchy Recall that we refer to twoparty games that satisfy the following

three conditions

The parties alternate in taking moves that eect the games global p osition where each

move has a description length that is b ounded by a p olynomial in the length of the initial

p osition

The current p osition is up dated based on the previous p osition and the current partys move

This up dating can b e p erformed in time that is p olynomial in the length of the initial p osition

Equivalently we may require a p olynomialtime up dating pro cedure and p ostulate that the

length of the current p osition b e b ounded by a p olynomial in the length of the initial p osition

The winner in each p osition can b e determined in p olynomialtime

A set S P S P AC E can b e viewed as the set of initial p ositions in a suitable game for which

the rst party has a winning strategy consisting of a polynomial number of moves Sp ecically

x S if starting at the initial p osition x there exists move y for the rst party such that for every

resp onse move y of the second party there exists move y for the rst party etc such that after

p oly jxj many moves the parties reach a p osition in which the rst party wins where the nal

p osition as well as which party wins in it can b e computed in p olynomialtime from the initial

p osition x and the sequence of moves y y The fact that every set in P S P AC E corresp onds

to such a game follows from Theorem which refers to the satisability of quantied Bo olean

formulae QBF

Theorem QBF is complete for P S P AC E under polynomialtime manytoone reductions

Pro of As note b efore QBF is solvable by a p olynomialspace algorithm that just evaluates the

quantied formula Sp ecically consider a recursive pro cedure that eliminates a Bo olean quantier

by evaluating the value of the two residual formulae and note that the space used in the rst

recursive evaluation can b e reused in the second evaluation Alternatively consider a DFStype

pro cedure as in Section Note that the space used is linear in the depth of the recursion which

in turn is linear in the length of the input formula

We now turn to show that any set S P S P AC E is manytoone reducible to QBF The pro of is

similar to the pro of of Theorem except that here we work with an implicit graph rather than

with an explicitly given graph Sp ecically we refer to the directed graph of conguration of

the algorithm A deciding membership in S as dened in Exercise Actually here we use a

dierent notion of a conguration that includes also the input That is in the rest of this pro of

a conguration consists of the contents of al l storage devices of the algorithm including the input

device as well as the lo cation of the algorithm on each device

Recall that for a graph G we dened u v if there is a path of length at most

G

m

from u to v in G and u v otherwise We need to determine s t for s that

G G

enco des the initial conguration of Ax and t that enco des the canonical accepting conguration

where G dep ends on the algorithm A and m p oly jxj is such that Ax uses at most m space

m

and runs for at most steps By the sp ecic denition of a conguration which contains all

relevant information including the input x the value of u v can b e determined easily based

G

solely on the xed algorithm A ie either u v or v is a conguration following u Recall that

u v if and only if there exists a conguration w such that b oth u w and

G G

w v hold Thus we obtain the recursion

G

m

u v w f g u w w v

G G G

where the b ottom of the recursion ie u v is a simple prop ositional formula see foregoing

G

discussion The problem with Eq is that the expression for involves two o ccur

G

rences of which doubles the length of the recursively constructed formula yielding an

G

exp onential blowup

Our aim is to express while using only once The extra restriction which

G G

prevents an exp onential blowup corresp onds to the reusing of space in the two evaluations

of that take place in the computation of u v The main idea is replacing the

G G

condition u w w v by the condition u v fu w w v g u v Next

G G G

we reformulate the nonstandard quantier which ranges over a sp ecic pair of strings by using

additional quantiers as well as some simple b o olean conditions That is u v fu w w v g

m

is replaced by f gu v f g and the auxiliary condition

u u v w u w v v

Thus u v holds if and only if there exist w such that for every there exists u v such

G

that b oth Eq and u v hold Note that the length of this expression for

G G

equals the length of plus an additive overhead term of O m Thus using a recursive

G

construction the length of the formula grows only linearly in the number of recursion steps

m

The reduction itself maps an instance x of S to the quantied Bo olean formula s t

x

where s denotes the initial conguration of Ax t and m p oly jxj are as ab ove and is

x

recursively dened as follows

m m

w f g f gu v f g

u u v w

def

u v

u w v v

u v

with u v if and only if either u v or there is an edge from u to v Note that u v is

a prop ositional formula with Bo olean variables representing the bits of u and v such that u v

is satises if and only if either u v or v is a conguration that follows the conguration u in a

m

computation of A On the other hand note that s t is a quantied formula in which the

x

quantied variables are not shown in the notation

m

We stress that the mapping of x to s t can b e computed in p olynomialtime Firstly

x

note that the prop ositional formula u v having Bo olean variables representing the bits of u

and v expresses extremely simple conditions and can certainly b e constructed in p olynomialtime

ie p olynomial in the number of Bo olean variables which in turn equals m Next note that

given u v which for contains quantied variables that are not shown in the notation

we can construct u v by merely replacing variables names and adding quantiers and Bo olean

conditions as in the recursive denition of Eq This is certainly doable in p olynomialtime

m

Lastly note that the construction of s t dep ends mainly on the length of x where x itself

x

only aects s and do es so in a trivial manner Recalling that m p oly jxj it follows that

x

m

everything is computable in time p olynomial in jxj Thus given x the formula s t can b e

x

constructed in p olynomialtime

m

Finally note that x S if and only if the formula s t is satisable The theorem

x

follows

Other P S P AC E complete problems Several generalizations of natural games give rise to

P S P AC E complete problems see Sec This further justies the title of the current section

Notes

The material presented in the current text is based on a mix of classical results proven in the

s if not earlier and mo dern results proven in the late s and even later What we

wish to emphasize is the time gap b etween the formulation of some questions and their resolution

Details follow

We rst mention the classical results These include the NLcompleteness of stCONN the

emulation of nondeterministic spaceb ounded machines by deterministic spaceb ounded machines

ie Theorem due to Savitch the P S P AC E completeness of QBF and the connections b etween

circuit depth and space complexity see Section and Exercise due to Boro din

Before turning to the mo dern results we mention that some p eople tend to b e discouraged by

the impression that decades of research have failed to answer any of the famous op en problems of

complexity theory In addition to the fact that substantial progress towards the understanding of

many fundamental issues has b een achieved p eople tend to forget that some famous op en problems

were actually resolved Two such examples were presented in this chapter

The question of whether NL co NL was a famous op en problem for almost two decades

Furthermore this question is related to an even older op en problem dating to the early days of

research in the area of formal languages ie to the s This op en problem was resolved

in by Immerman and Szelep csenyi who indep endently proved Theorem ie

NL co NL

For more than two decades undirected connectivity was one of the most app ealing examples

of the computational p ower of randomness Recall that the classical deterministic lineartime

algorithms eg BFS and DFS require an extensive use of extra memory ie space linear in

the size of the graph On the other hand it was known since that with high probability a

random walk of p olynomial length visits all vertices in the corresp onding connected comp onent

Thus the randomized algorithm requires a minimal amount of auxiliary memory ie logarithmic

in the size of the graph In the early s this algorithm as well as the entire class BPL was

8

Sp ecically the class of sets recognized by linearspace nondeterministic machines equals the class of context

sensitive languages see eg Sec and thus Theorem resolves the question of whether the latter class is

closed under complementation

derandomized in p olynomialtime and p olylogarithmic space but despite more than a decade of

research attempts a signicant gap remained b etween the space complexity of randomized and

deterministic p olynomialtime algorithms for this natural and ubiquitous problem This gap was

closed by Reingold who established Theorem in

Exercises

Exercise on the p ower of doublelogarithmic space For any k N let w denote the

k

k

concatenation of all k bit long strings in lexicographic order separated by s ie w

k

def

k k k k

Show that the set S fw k N g f g is not regular

k

and yet is decidable in doublelogarithmic space

Guideline The nonregularity of S can b e shown using standard techniques Towards developing an

k

algorithm note that jw j and thus O log k O log log jw j Membership of x in S is determined by

k k

th

iteratively checking whether x w for i Note that the i iteration can b e implemented in space

i

O log i and that on input x S we halt and reject after at most log jxj iterations

Exercise on the weakness of less than doublelogarithmic space Prove that for n

log log n it holds that Dspaceo DspaceO

Guideline Let s denote the machines binary space complexity see Footnote Assuming that s is

unbounded consider for each m the shortest string x such that on input x the machine uses space at least

m Consider for each lo cation on the input the sequence of the residual congurations of the machine

ie the contents of its temp orary storage at the times in which the machine crosses or rather passes

through this input lo cation For starters note that the length of this crossing sequence is upp erb ounded

def

sjxj

by the number of p ossible congurations which is at most t sjxj Thus the number of such

t t

crossing sequences is upp erb ounded by t t Now if t jxj then there exist three input lo cations

that have the same crossing sequence and two of them hold the same bit value Contracting the string

at these two lo cations we get a shorter input on which the machine b ehaves in exactly the same manner

contradicting the hypothesis that x is the shortest input on which the machine uses space at least m We

t

conclude that t jxj must hold and sjxj log t log log jxj follows

Exercise some logspace algorithms Present logspace algorithms for the following com

putational problems

Addition and multiplication of a pair of integers

Guideline Relying on Lemma rst transform the input to a more convenient format then

p erform the op eration and nally transform the result to the adequate format For example when

P P

n n

i i

y a convenient format is x y x y x and y adding x

i n n i

i i

Transforming the adjacency matrix representation of a graph to its incidence list representa

tion and vice versa

Deciding whether the input graph is acyclic ie has no simple cycles

Guideline Consider a scanning of the graph that pro ceeds as follows Up on entering a vertex v via

th st

the i edge incident at it we exit this vertex using its i if v has degree at least i and exit

9

Note that unlike in the pro of of Theorem the machines lo cation on the input is not part of the notion of

a conguration used here On the other hand although not stated explicitly the conguration also enco des the

machines lo cation on the storage tap e

via the rst edge otherwise Note that when started at any vertex of any tree this scanning p erforms

a DFS On the other hand for every cyclic graph there exists a vertex v and an edge e incident to v

such that if this scanning is started by traversing the edge e from v then it returns to v via an edge

dierent from e

Deciding whether the input graph is a tree

Guideline Use the fact that a graph G V E is a tree if and only if it is acyclic and jE j jV j

Exercise another comp osition result In continuation to the discussion in x prove

that if can be computed in space s when given an restricted oracle access to and

is solvable is space s then is solvable in space s such that sn s n s n n

log n

Guideline Combine the ideas underlying the pro ofs of Lemmas and Sp ecically view the oracleaided

th th

computation of as consisting of iterations such that in the i iteration the i query is determined based

st st

on the initial input the i oracle answer and the contents of the work tap e at the time the i answer

th

was given Comp osing each iteration with the computation of using Lemma we conclude that the i

th

answer can b e computed without storing the i query in space s n s n log n Thus we can

emulate the entire computation using space sn where the extra space s n n is used for storing the

st th

worktape of the oracle machine and the i and i oracle answers

Exercise Referring to the discussion in x prove that any problem having space complexity

s can b e solved by a constantspace s srestricted reduction to a problem that is solvable in

constantspace

Guideline The reduction is to the next conguration function asso ciated with the said algorithm of space

complexity s To facilitate the computation of this function represent each conguration in a redundant

manner eg as a sequence over a ary rather than a binary alphab et The reduction consists of iteratively

copying strings from the input or oracleanswer tap e to the oraclequery or output tap e

Exercise logspace uniform NC is in L Supp ose that a problem is solvable by a fam

ily of logspace uniform b ounded fanin circuits of depth d such that dn log n Prove that is

solvable by an algorithm having space complexity O d

Guideline Combine the algorithm outlined in Section with the denition of logspace uniformity using

Lemma

Exercise transitivity of logspace reductions Prove that logspace Karpreductions are

transitive Dene logspace Levinreductions and prove that they are transitive

Guideline Use Lemma noting that such reductions are merely logspace computable functions

Exercise relating the two mo dels of NSPACE Referring to the denitions in Section

prove that for every function s such that log s is space contructible and at least logarithmic it holds

that Nspace s Nspace log s

online oline

Guideline for Nspace s Nspace O log s Use the nondeterministic tap e of the o

online oline

line machine for enco ding an accepting computation of the online machine that is this tap e should contain

a sequence of consecutive congurations leading from the initial conguration to an accepting conguration

where each conguration contains the contents of the worktape as well as the machines lo cation on the

worktape and on the input tap e The emulating oline machine which veries the correctness of the

sequence of congurations recorded on its nondeterministic input tap e needs only store its location within

the current pair of consecutive congurations that it examines which requires space logarithmic in the length

of a single conguration which in turn equals sn log sn log n Note that this verication relies

on a twodirectional access to the nondeterministic input tap e

Guideline for Nspace s Nspace exps Here we refer to the notion of a crossing

oline online

sequence Sp ecically for each lo cation on the oline nondeterministic tap e consider the sequence of the

residual congurations of the machine where such a residual conguration consists of the bit residing in this

nondeterministic tap e lo cation the contents of the machines temp orary storage and the machines lo cations

on the input and storage tap es but not its lo cation on the nondeterministic tap e Show that the length

of such a crossingsequence is exp onential in the space complexity of the oline machine and that the time

complexity of the oline machine is at most doubleexp onential in its space complexity see Exercise

The online machine merely generates a sequence of crossingsequences on the y and checks that each

consecutive pair of crossingsequences is consistent This requires holding two crossingsequences in storage

which require space linear in the length of such sequences which in turn is exp onential in the space

complexity of the oline machine

Exercise stCONN and variants of it are in NL Prove that the following computational

problem is in NL The instances have the form G v w where G V E is a directed graph

v w V and is an integer and the question is whether G contains a path of length at most

from v to w

Guideline Consider a nondeterministic online machine that generates and veriers an adequate path

th

on the y That is starting at v v the machine pro ceeds in iterations such that in the i iteration it

nondeterministically generates v veriers that v v E and checks whether i and v w Note

i i i i

that this machine need only store the last two vertices on the path ie v and v as well as the number of

i i

edges traversed so far ie i Using a careful implementation it suces to store only one of these vertices

as well as i

Exercise NSPACE and directed connectivity Our aim is to establish a relation b e

tween general nondeterministic spaceb ounded computation and directed connectivity in strongly

constructible graphs that have size exp onential in the space b ound Let s b e space constructible

and at least logarithmic For every S Nspaces present a lineartime oracle machine that given

oracle access to x provides oracle access to a directed graph G of size expsjxj such that x S

x

if and only if there is a directed path b etween the rst and last vertices of G That is on input

x

a pair u v and oracle access to x the machine decides whether or not u v is a directed edge in

G

x

Guideline Follow the pro of of Theorem

Exercise an alternative presentation of the pro of of Theorem We refer to directed

graphs in which each vertex has a selflo op

Viewing the adjacency matrices of directed graphs as oracles cf Exercise present a

linear space oracle machine that determines whether a given pair of vertices is connected

by a directed path of length two in the input graph Note that this machine computes the

adjacency relation of the square of the graph represented in the oracle

Using naive comp osition as in Lemma present a quadratic space oracle machine that

determines whether a given pair of vertices is connected by a directed path in the input

graph

Note that the machine in Item implies that stCONN can b e decided in logsquare space In

particular justify the selflo op assumption made upfront

Exercise nding shortest paths in undirected graphs Prove that the following com

putational problem is NLcomplete under manytoone logspace reductions Given an undirected

graph G V E two designated vertices s and t and an integer K determine whether there is

a path of length at most K from s to t in G

Guideline for NL hardness Reduce from stCONN Sp ecically given a directed graph G V E

jV j

fhi v i v V g and and vertices s t consider a layered graph G V E such that V

i

jV j

ffhi ui hi v ig u v E u v g Note that there exists a directed path from s to t in G if E

i

and only if there exists a path of length jV j b etween hs i and ht jV j i in G

Exercise deciding strong connectivity A directed graph is called strongly connected if

there exists a directed path b etween every ordered pair of vertices in the graph or equivalently a

directed cycle passing through every two vertices Prove that the problem of deciding whether a

directed graph is strongly connected is NLcomplete under manytoone logspace reductions

Guideline for NLhardness Reduce from stCONN noting that G s t is a yesinstance of stCONN

where G V E if and only if the graph G V E fv s v V g ft v v V g is strongly connected

Exercise an op erational interpretation of NL co NL NP co NP etc Referring to

Denition prove that S NL co NL if and only if there exists a nondeterministic logspace

machine that computes where x if x S and x otherwise State and prove

S S S

an analogous result for NP co NP

Guideline A nondeterministic machine computing any function f yields for each value v a machine of

similar complexity that accept fx f x v g Extra hint Invoke the machine M that computes f and accept

if and only if M outputs v On the other hand for any function f of nite range combining machines that

def

fx f x v g we obtain a machine of similar complexity that computes f Extra accept the various S

v

hint On input x the combined machine invokes each of the aforementioned machines on input x and outputs the

value v if and only if the machine accepting S has accepted In the case that none of the machines accepts the

v

combined machine outputs

Exercise a graph algorithmic interpretation of NL co NL Show that there exists a

logspace f such that for every G s t it holds that G s t is a yesinstance

of stCONN if and only if G s t f G s t is a noinstance of stCONN

Exercise As an alternative to the twoquery reduction presented in the pro of of Theorem

show that computing the characteristic function of stCONN is logspace reducible via a single query

to the problem of determining the number of vertices that are reachable from a given vertex in a

given graph

Hint On input G s t where G N E consider the number of vertices reachable from s in the graph

0

G N E ft N i i N g

Exercise reductions and nondeterministic computations Supp ose that computing f

is logspace reducible by a constant number of queries to computing some function g Referring to

the nondeterministic computations as in Denition prove that if there exists a nondeterministic

logspace machine that computes g then there exists a nondeterministic logspace machine that

computes f

Guideline Use the emulative comp osition as in Lemma If any of the nondeterministic computations

of g returns the value then return as the value of f Otherwise use the non values provided by the

nondeterministic computations of g to compute the value of f

Exercise reductions and nondeterministic computations revisited Supp ose that com

puting f is logspace reducible by any number of queries to computing some function g such that

for every x it holds that jg xj O log jxj Referring to the nondeterministic computations as in

Denition prove that if there exists a nondeterministic logspace machine that computes g then

there exists a nondeterministic logspace machine that computes f As a warmup consider the

sp ecial case in which every query to g is computable in logspace based on the input to f

Guideline As in Exercise except that here we use dierent comp osition techniques Sp ecically in the

warmup we use the naive comp osition as in Lemma whereas in the general case we use the seminaive

comp osition of Exercise

Exercise Prove that the problem of determining whether or not the input graph is bipartite

colorable is in NL

Guideline A graph is bipartite if and only if it contains no o ddlength cycles Extra hint Use NL coNL

Exercise Referring to Denition prove that there exists a nondeterministic logspace ma

chine that computes the distance b etween two given vertices in a given undirected graph

Guideline Relate this computational problem to the considered in Exercise and use

NL coNL

References

A Boro din On Relating Time and Space to Size and Depth SIAM Journal on Computing

Vol pages

SA Co ok A overview of Computational Complexity Turing Award Lecture CACM

Vol pages

SA Co ok A Taxonomy of Problems with Fast Parallel Algorithms Information and Control

Vol pages

O Goldreich Proving that Undirected Connectivity is in L with a long app endix

on expander graphs Unpublished note December Availabe from the webpage

httpwwwwisdomweizmannacilodedcctextshtml

JE Hop croft and JD Ullman Introduction to Automata Theory Languages and Computa

tion AddisonWesley

N Immerman Nondeterministic Space is Closed Under Complementation SIAM Journal

on Computing Vol pages

O Reingold Undirected STConnectivity in LogSpace In th ACM Symposium on the

Theory of Computing pages

WJ Savitch Relationships b etween nondeterministic and deterministic tap e complexities

JCSS Vol pages

M Sipser Introduction to the Theory of Computation PWS Publishing Company

R Szelep csenyi A Metho d of Forced Enumeration for Nondeterministic Automata Acta

Informatica Vol pages