<<

ComputabilityandComplexity 19-1 ComputabilityandComplexity 19-2

Non-deterministicMachines

Recallthatif NT isanon-deterministicTuringMachine,then NT (x) denotesthetreeofconfigurationswhichcanbeenteredwithinput x, and NT accepts xifthereissomeacceptingpathin NT (x) Non-DeterministicSpace Definition Thespacecomplexityofanon-deterministicTuring

Machine NT isthefunctionsuchthatNSpace NT NSpace NT (x) istheminimalnumberofcellsvisitedinanacceptingpathof NT (x)ifthereisone,otherwiseitistheminimalnumberofcellsin therejectingpaths

(Ifnotpathsof NT (x)halt,thenisundefineNSpace (x) d) ComputabilityandComplexity NT AndreiBulatov

ComputabilityandComplexity 19-3 ComputabilityandComplexity 19-4

NondeterministicSpaceComplexity DefinitionofNPSPACE Definition Foranyfunction f,wesaythatthenondeterministicspace Definition complexityofadecidablelanguage isin O(f)ifthereexists NPSPACE = NSPACE[ nk ] anondeterministicTuringMachine NT whichdecides L,and U > k≥0 constantsandn0 csuchthatforallinputs xwith | x | n0 ≤ NSpace NT (x) cf (| x |)

Definition Thenondeterministicspacecomplexityclass NSPACE[ f]is definedtobetheclassofalllanguageswithnondeterministic spacecomplexityin O(f)

ComputabilityandComplexity 19-5 ComputabilityandComplexity 19-6

≥≥≥ Savitch’sTheorem Proof(for s(n) n) •Let Lbealanguagein NSPACE[ s]

Unliketime,itcaneasilybeshownthatnon-determinismdoesnot •Let NT beanon-deterministicTuringMachinethatdecides L reducethespacerequirementsverymuch: withspacecomplexity s

•Chooseanencodingforthecomputation NT (x)thatuses ks (| x|) symbolsforeachconfiguration Theorem(Savitch) If s(n)≥log n,then •Letbetheinitialconfiguration,andC betheacceptingC 2 0 a NSPACE[ s] ⊆ SPASE[ s ] configuration

•DefineaBooleanfunction reach (C,C′,j)whichis true ifandonlyif configuration C′canbereachedfromconfiguration Cinatmost 2 j Corollary steps PSPACE =NPSPACE •Todecidewhetherornot x∈Lwemustdeterminewhetherornot

isreach (C0 ,Ca ,ks (| x |)) true

1 ComputabilityandComplexity 19-7 ComputabilityandComplexity 19-8

LogarithmicSpace 2 Wecancalculatereach (C0 ,Ca ,ks (| xinspace,|)) O(s(| x |) ) usingadivide-and-conquer: Sincepolynomialspaceissopowerful,itisnaturaltoconsidermore restrictedspacecomplexityclasses reach (C,C', j)

1. If j=0 thenif C=C',or C'canbereachedfrom Cin one Evenlinearspaceisenoughtosolve Satisfiability step,thenreturn true ,elsereturn false . 2. Foreachconfiguration C'' ,if reach (C,C'' ,j–1) and reach (C'' ,C',j–1), thenreturn true . Definition = 3. Return false L SPACE[log n] NL = NSPACE[log n]

Thedepthofrecursionis O(s(| x|)) andeachrecursivecallrequires O(s(| x|)) spacefortheparameters

ComputabilityandComplexity 19-9 ComputabilityandComplexity 19-10

ProblemsinLandNL Examples(L)

Whatsortofproblemsarein Land NL ? Palindromes : Weneedtokeeptwocounter Inlogarithmicspacewecanstore:

= k k ∈ •afixednumberofcounters(tolengthofinput) L 0{1 | k N } Firstcountthenumberof 0s,thencount 1s,subtractingfromthe •afixednumberofpointerstopositionsintheinputstring previousnumberonebyone.Iftheresultis 0,accept; otherwise,reject. Thereforeindeterministiclog-spacewecansolveproblemsthat requireafixednumberofcountersand/orpointersforsolving; innon-deterministiclog-spacewecansolveproblemsthat Brackets (ifbracketsinanexpressionpositionedcorrectly): requireafixednumberofcounters/pointersforverifyinga Weneedonlyacounterofbracketscurrentlyopen.Ifthis solution countergetsnegative,reject;otherwiseacceptifandonlyifthe lastvalueofthecounteriszero

ComputabilityandComplexity 19-11

Examples(NL)

Thefirstproblemdefinedonthiscoursewas Reachability¹

Thiscanbesolvedbythefollowingnon-deterministicalgorithm:

•Defineacounterandinitializeittothenumberofverticesinthegraph

•Defineapointertoholdthe``currentvertex’’andinitializeittothe startvertex •Whilethecounterisnon-zero -Ifthecurrentvertexequalsthetargetvertex,returnyes -Non-deterministicallychooseavertexwhichisconnectedto thecurrentvertex -Updatethepointertothisvertexanddecrementthecounter

•Returnno

¹Alsoknownas Path

2