csci 4325 / 6339 theory of computation zhixiang chen

28
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Upload: brent-stewart

Post on 16-Dec-2015

243 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

CSCI 4325 / 6339Theory of Computation

Zhixiang Chen

Page 2: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Chapter 8Space Complexity

Page 3: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Topics

Savitch’s Theorem PSPACE Class, PSPACE-Completeness,

The TQBE Problem L and NL NL-Completeness, the PATH Problem NL=co-NL

Page 4: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Space Complexity

Definition. Let M be a DTM that halts on all inputs. The space

complexity of M is the function where f(n) is the maximum number of tape cells that M scans on any input of length n. We say M runs in space f(n).

If M is a NTM wherein all branches halt on all inputs, we define its space complexity f(n) to be the maximum number of tape cells that M scans on any branch of its computation for any input of length n.

,: NNf

Page 5: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Space Complexity Classes

Definition

Let be a function. We define space complexity classes

L is a language decided by an O(f(n)) space DTM}

L is a language decided by an O(f(n)) space NTM}

RNf :

|{))(( LnfSPACE

|{))(( LnfNSPACE

Page 6: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Examples

).(nSPACESAT

).(nNSPACEALLNFA

Page 7: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Savitch’s Theorem Theorem. For any function

where we have

,: RNf

,)( nnf

)).(())(( 2 nfSPACEnfNSPACE

Page 8: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Proof.

For space O(f(n)), the total number of config’s is

Use “binary-search” to decide whether C-start yields c-accept in steps. Use a stack to maintain the recursive calls.

.2 ))(( nfO

Initial Config C-start

Final Config c-accept

mid Config c-middle

))((2 nfO

Page 9: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

PSPACE vs. NPSPACE

Definition

By Savitch’s Theorem,

).(

).(

k

k

k

k

nNSPACENPSPACE

nSPACEPSPACE

.NPSPACEPSPACE

Page 10: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

A New World

P

NP

NP-complete

PSPACEEXPTIME

Page 11: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

PSPACE-Completeness

Definition

A language B is PSPACE-complete if 1. B is in PSPACE

2. Every language in PSPACE is ploy-time reducible to B.

If M merely satisfies condition 2, we say B is PSPACE-hard.

Page 12: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

The TQBF Problem

Quantified Boolean functions or

and is a Boolean CNF formula.

is true if exists some value of is true. is true if for all values of is true.

Example

],[2211 nnxxx , i i

][1 x

][1 x

,1x,1x

)].()[( yxyxyx

Page 13: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

TQBF

TQBF is the set of all true fully quantified Boolean formulas.

The TQBF problem is to determine whether a fully quantified Boolean formula is true or false.

Page 14: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

TQBF is PSPACE-complete.

Proof. We can view the evaluation process of a given fully

quantified formula as a tree, performing depth-first search of the tree gives a poly-space algorithm. So, TQBF is in PSPACE.

To prove TQBF is PSPACE-hard, we need to construct a fully quantified Boolean formula to simulate the computation of a given space TM M so that )( knO

. accepts only and if trueis )( , wMww

Page 15: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

steps 2in accept - start - accepts M

s.config' 2 are there space )()(

)(

k

k

nO

nOk

ccw

nO

)]2/,,()}[,(),,{(),(),,(

Then,

steps. most at in yields iff ),,(

Define

43211143121

2121

tcccmmcccmtcc

tcctcc

Page 16: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

formula.Boolean quantifiedfully size |) a is )(

.2logafter stop Will. expand toContinue

)]2/2,,()}[,(),,{(),(

)2,accept-,start-()(

iff

432111431

poly(|ww

stepsdn

cccmmcccm

ccw

kdn

dn

dn

k

k

k

steps 2in accept - start - accepts M

.constant somefor 22Let )(

)(

k

kk

nO

dnnO

ccw

d

Page 17: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

The Classes L and NL

Sublinear space TM: A TM M with one read-only input tape and read/write work tape. The read head remains in the portion of the input tape containing the input. The space used on the work tape contributes to the space complexity.

Definition

Example

n) SPACE(logNL

n) SPACE(log

L

n) SPACE(log}0 |10{ k kA k

Page 18: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

The PATH problem

.graph given ain node a to node a frompath

directed a is here whether tdetermine tois problem PATH The

} to frompath

directed a has graph that directed a is |,,{

Gts

ts

GtsGPATH

Page 19: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

PATH is in P Easy

PATH is in NL Starting a node s, the machine records only the

current node and nondeterministically guesses the next node among those adjacent to the current node. Repeat until t is found, or all m guesses have been done, where m is the number of nodes. This is done in NL.

Page 20: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

New Configurations

If M is a TM that has a separate read-only input tape and w is an input, a configuration of M on w is the setting the state, the work tape, and the positions of the two tape heads. The input w is not part of the configuration of M on w.

q.||

,2 is on M of ionsconfigurat of

number then space, )(in runs M If))((

wn

nw

nfnfO

Page 21: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

NL-Completeness

Log space transducer: A TM with a r-only input tape, and r/w work tape and a w-only output tape. A log space transducer computes a function using log space of work tape, the result of the function is written on the output tape.

Log space reduction:

B. A to reducing

function computable space log a is thereif ,BA L

Page 22: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

A language B is NL-complete if

However, L=?NL is also open.

B. toreducible space log is NLin A Every (2)

and NL, B )1(

NL.L then L,in is language complete-NLany If

. then , and if

LALBBA L

Page 23: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

PATH is NL-Complete

Proof. PATH is in NL is known Need to show every A in NL is log space reducible to

PATH. Let the log space NTM M computing A. Simulate the computation of M on w, find all possible configurations of M on w to express nodes for a directed graph. Let s be and t be the start and accept configurations of M on w. Have an edge from one node to another node is the first yields the second. M accepts w iff there is a directed path from the start node to

the accept node.

Page 24: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

. since , PPATHPNLL

Page 25: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

NL=Co-NL

Proof. Since PATH is in NL, it suffices to show

.-

}|{-

NLcoNL

NLAANLco

.NLPATH

Page 26: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Suppose we know that the number of nodes in G that are reachable from s is c.

Nondeterministically select exactly c nodes reachable from s, not including t, and prove that each is reachable from s by guessing the path. If this is true, then the remaining nodes, including t, is not reachable from s, so accept. Otherwise, reject.

Page 27: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

How to compute the number of nodes reachable from s?

.in not isit then ,in shown been not has and found, If rejects.

branch n computatio thisso found,been not has all ,not is in be to

verifiednodes ofnumber total theif loop,inner theof completion At the

counted. is in nodes ofnumber thely,Additional .in is then

yes, If edge.an is her test whet,in be to verified nodeseach For

. from most at distance ofpath a guessingby verifiedis guess positive

Each .in iseach whether guess andG in nodes theall through go to

loopinner an use ,in is vnode a whether decide To : find To )3(

.1},{ )2(

.||Let . distancein

from reachabke nodes ofset thebe let ,0 )1(

11

1

11

00

ii

iii

ii

i

i

ii

ii

i

AAv

AcA

AAv

(u,v)Au

si

A

AA

csA

Aci

sAmi

Page 28: CSCI 4325 / 6339 Theory of Computation Zhixiang Chen