• Aucun résultat trouvé

Definition of Space-Bounded Computation 79

Dans le document This page intentionally left blank (Page 105-109)

PART ONE BASIC COMPLEXITY CLASSES

Exercises 77 A subfieldof complexity theory calledstructural complexity has carriedout a detailed

4.1. Definition of Space-Bounded Computation 79

Input tape

Read only head

Read/write head Read/write head Work

tape

Output tape

Register

Figure 4.1.Space bounded computation. Only cells used in the read-write tapes count toward the space bound.

the input tape) are ever visitedbyM’s headduring its computation on every input of lengthn.

Similarly, we say thatLNSPACE(s(n)) if there is an NDTMM decidingLthat never uses more thanc·s(n)nonblank tape locations on lengthninputs, regardless of its nondeterministic choices.

Actually, none of the machines in this chapter will use their output tapes, so the space boundshouldbe thought of as applying only to the work tape. Analogously to time complexity, we will restrict our attention to space boundsS : N → N that arespace-constructibleby which we mean that there is a TM that computesS(|x|)in O(S(|x|))space givenxas input. Intuitively, ifSis space-constructible, then the machine

“knows” the space boundit is operating under. This is a very mildrestriction since all functions of interest, including logn,n, and2n, are space-constructible.

Since the TM’s work tapes are separatedfrom its input tape, it makes sense to consider space-bounded machines that use space less than the input length, namely, S(n) <n. This is in contrast to time-bounded computation, whereDTIME(T(n))for T(n) <ndoes not make much sense since the TM does not have enough time to read the entire input. We will require however thatS(n) >lognsince the work tape has lengthn, andwe wouldlike the machine to at least be able to “remember” the index of the cell of the input tape that it is currently reading.

DTIME(S(n))SPACE(S(n))since a TM can access only one tape cell per step.

But a SPACE(S(n)) machine can run for much longer than S(n) steps, since space can be reused: A cell on the work tape can be overwritten an arbitrary number of times. In fact, a space S(n)machine can easily run for as much as 2(S(n)) steps—

think for example of the machine that uses its work tape of sizeS(n)to maintain a counter that it increments from 1 to 2S(n)−1. The next theorem (whose proof appears in Section4.1.1) shows that this is tight in the sense that any languages inSPACE(S(n)) (andevenNSPACE(S(n))) is inDTIME(2O(S(n))). Surprisingly enough, up to logarith-mic terms, this theorem contains the only relationships we know between the power of space-boundedandtime-boundedcomputation. Improving this wouldbe a major result.

Theorem 4.2 For every space constructible S:N→N,

DTIME(S(n))SPACE(S(n))NSPACE(S(n))DTIME(2O(S(n))) # Remark 4.3

Some texts define a nondeterministic space-bounded machine with the aditional restric-tion that it has to halt and produce an answer on every input regardless of the sequence of nondeterministic choices. However, if we focus onNSPACE(S(n))whereS(n)is space-constructible, this restriction is unnecessary since the NDTM can be easily modi-fiedto always halt: It simply keeps a counter andhalts if the computation runs for more than 2cS(n)steps for some suitable constantc.

4.1.1 Configuration graphs

To prove Theorem4.2, we use the notion of aconfiguration graphof a Turing machine.

This notion will also be quite useful for us later in this chapter andthe rest of the book. LetMbe a (deterministic or nondeterministic) TM. Aconfigurationof a TMM consists of the contents of all nonblank entries ofM’s tapes, along with its state andhead position, at a particular point in its execution. For every spaceS(n)TMM andinput x∈ {0, 1}, theconfiguration graph of M on input x, denotedGM,x, is a directed graph whose nodes correspond to all possible configurations ofMwhere the input contains the valuexandthe work tapes have at mostS(|x|)nonblank cells. The graph has a directed edge from a configurationCto a configurationCifCcan be reachedfromCin one step according toM’s transition function (see Figure4.2). IfMis deterministic, then the graph has out-degree one, and ifMis nondeterministic, then the graph has out-degree at most two. By modifyingMto erase all its work tapes before halting, we can assume that there is only a single configurationCaccepton whichMhalts andoutputs 1. This means thatMaccepts the inputxiff there exists a directed path inGM,xfromCstartto Caccept. We will use the following claim about configuration graphs, where part 2 will be usedonly in a subsequent section.

Claim 4.4 Let GM,xbe the configuration graph of a space-S(n)machine M on some input x of length n. Then,

Caccept αqβ

Cstart

Figure 4.2.The configuration graphGM,xis the graph of all configurations ofM’s execution onxwhere there is an edge from a configurationC to a configurationCifCcan be obtained fromC in one step. It has out-degree one ifMis deterministic and out-degree at most two ifMis nondeterministic.

4.1. Definition of Space-Bounded Computation 81 1. Every vertex in GM,xcan be described using cS(n)bits for some constant c (depending on M’s alphabet size and number of tapes) and in particular, GM,xhas at most2cS(n)nodes.

2. There is an O(S(n))-size CNF formula ϕM,x such that for every two strings C,C, ϕM,x(C,C)=1if and only if C and Cencode two neighboring configuration in GM,x.# Proof Sketch: Part 1 follows from observing that a configuration is completely described by giving the contents of all work tapes, the position of the head, and the state the TM is in (see Section1.2). We can encode a configuration by first encod-ing the snapshot (i.e., state andcurrent symbol readby all tapes) andthen encodencod-ing in sequence the nonblank contents of all the work tapes, inserting special “marker”

symbols to denote the locations of the heads.

Part 2 follows using similar ideas as in the proof of the Cook-Levin Theorem (Theorem2.10). There we showed that deciding whether two configurations are neigh-boring can be expressed as the AND of many checks, each depending on only a constant number of bits, andsuch checks can be expressedby constant-sizedCNF formulas by Claim2.13. The number of variables is proportional to the workspace.

Now we can prove Theorem4.2.

Proof of Theorem 4.2: ClearlyDTIME(S(n))SPACE(S(n))NSPACE(S(n)), andso we just needto showNSPACE(S(n))DTIME(2O(S(n))). By enumerating over all possible configurations, we can construct the graphGM,xin 2O(S(n))-time andcheck whetherCstartis connectedtoCacceptinGM,xusing the standard (linear in the size of the graph) breadth-first search algorithm for connectivity (e.g., see [CLRS01]).

4.1.2 Some space complexity classes

The following complexity classes will be of particular interest:

Definition 4.5

PSPACE= ∪c>0SPACE(nc) NPSPACE= ∪c>0NSPACE(nc)

L=SPACE(logn)

NL=NSPACE(logn) #

We can think ofPSPACEandNPSPACEas the space analogs of the time com-plexity classesPandNP, respectively. Since time bounds shorter than the input length don’t make much sense, there are no time analogs forLandNL.

EXAMPLE 4.6

We show how3SAT∈PSPACEby describing a TM that decides3SATin linear space (that is,O(n)space, wherenis the size of the3SATinstance). The machine just uses the linear space to cycle through all 2k assignments in order, wherekis the number

of variables. Note that once an assignment has been checkedit can be erasedfrom the work tape, andthe work tape can then be reusedto check the next assignment. A similar idea of cycling through all potential certificates applies to anyNPlanguage, so in fact NPPSPACE.

EXAMPLE 4.7

Using the grade school methodfor arithmetic andthe fact that a logspace machine has enough space to keep a counter up ton, it is easily checkedthat the following languages are inL:

EVEN= {x: xhas an even number of 1s} MULT= {(n, m, nm):n∈N}

It seems difficult to conceive of any complicated computations apart from elemen-tary arithmetic that use onlyO(logn)space. Nevertheless, we cannot currently even rule out that3SAT∈L; in other words, it is open whetherNP=L(see Exercise4.6). Space-bounded computations with spaceS(n)/nseem relevant to computational problems such asweb crawling. The world wide web may be viewed crudely as a directed graph, whose nodes are webpages and edges are hyperlinks. Web crawlers seek to explore this graph for all kinds of information. The following problemPATHis natural in this context:

PATH=

G,s,t: Gis a directed graph in which there is a path fromstot (4.1) We show thatPATH∈NL. Note that if there is a path fromstot, then there is one of length at mostn. Thus a nondeterministic machine can take a “nondeterministic walk”

starting ats, always maintaining the index of the vertex it is at, and using nondeterminism to select a neighbor of this vertex to go to next. The machine accepts iff the walk ends attin at mostnsteps, wherenis the number of nodes. If the nondeterministic walk has run fornsteps already andthas not been encountered, the machine rejects. The work tape only needs to holdO(logn)bits of information at any step, namely, the number of steps that the walk has run for, andthe identity of the current vertex.

IsPATHin Las well? This is an open problem, which, as we will shortly see, is equivalent to whether or notL = NL. That is, PATHcaptures the “essence” ofNL just as3SATcaptures the “essence” ofNP. Formally, we will show thatPATHis NL-complete. A recent surprising result shows that the restriction ofPATHtoundirected graphs is inL; see Chapters7and20.

4.1.3 Space Hierarchy Theorem

Analogously to time-bounded classes, there is also a hierarchy theorem for space-bounded computation.

Theorem 4.8 (Space Hierarchy Theorem[SHL65])

If f,g are space-constructible functions satisfying f(n)=o(g(n)), then

SPACE(f(n))SPACE(g(n)) (4.2)

4.2. Completeness 83

Dans le document This page intentionally left blank (Page 105-109)