Space Complexity

Space Complexity

ComputabilityandComplexity 18-1 ComputabilityandComplexity 18-2 MeasuringSpace Sofarwehavedefinedcomplexitymeasuresbasedonthetimeused bythealgorithm SpaceComplexity Nowweshalldoasimilaranalysisbasedonthespaceused IntheTuringMachinemodelofcomputationthisiseasytomeasure —justcountthenumberoftapecellsreadduringthecomputation Definition1 ThespacecomplexityofaTuringMachine Tisthe functionsuchthatSpaceT SpaceisthenumberofT (x ) distincttapecellsvisitedduringthecomputation T(x) ComputabilityandComplexity (Notethatif T(x)doesnothalt,thenisundefSpace T (x) ined.) AndreiBulatov ComputabilityandComplexity 18-3 ComputabilityandComplexity 18-4 Palindromes AnotherDefinition Considerthefollowing3-tapemachinedecidingifaninputstringisapalindrome •Thefirsttapecontainstheinputstringandisneveroverwritten ByDef.1,thespacecomplexityofthismachineisn •Themachineworksinstages.Onstage iitdoesthefollowing However,itseemstobefairtodefineitsspacecomplexityas log n -thesecondtapecontainsthebinaryrepresentationof i -themachinefindsandremembersthe i-thsymbolofthestringby (1)initializingthe3 rd string j =1 ;(2)if j< ithenincrement j; Definition2 Let TbeaTuringMachinewith2tapessuchthat (3)if j= ithenrememberthecurrentsymbolbyswitchingto thefirsttapecontainstheinputandneveroverwritten.The correspondentstate spacecomplexityof TisthefunctionsuchthatSpace T -inasimilarwaythemachinefindsthe i-thsymbolfromtheend isthenumberofSpace T (x) distinctcellsonthesecondtape ofthestring visitedduringthecomputation T(x) -ifthesymbolsareunequal,haltwith“no” •Ifthe i-thsymbolistheblanksymbol,haltwith“yes” ComputabilityandComplexity 18-5 ComputabilityandComplexity 18-6 Proof Blum’sAxioms 1.isobvious. Blumproposedthatanyusefuldynamiccomplexitymeasureshould 2. satisfythefollowingproperties: Notethatifthemachinehas kstatesand lsymbolsinthealphabet, ⋅ ⋅ r •isdefinedexactlywhenϕ (x) M(x)isdefined thentherearepossibleconfiguratk r l ioninvolvingatmost r M visitedcellsonthesecondtape ϕ = •Theproblem:forgiven M,x,r ,doesisdecidableM (x) r Ifthesameconfigurationoccurstwiceduringthecomputation M(x), thenthemachinegoesintoaninfiniteloopand M(x)(aswellas TheoremSpace T isapropercomplexitymeasure )isnotdefinedSpace M (x) Thereforeafterperformingstepsk ⋅ r ⋅l r M(x)either halts,or visitsmorethan rcells,or goesintoaninfiniteloop 1 ComputabilityandComplexity 18-7 ComputabilityandComplexity 18-8 SpaceComplexityofProblems SpaceComplexityClasses Aswithtimecomplexity,wecannotdefineanexactspacecomplexity foralanguage,butwecangiveanasymptoticform… Nowweareinapositiontodivideupthedecidablelanguagesinto classes,accordingtotheirspacecomplexity Definition Foranyfunction f,wesaythatthespacecomplexityofa Definition decidablelanguage Lisin O(f)ifthereexistsaTuring Thespacecomplexityclass SPACE[ f]isdefinedtobetheclass Machine Twhichdecides L,andconstantsandn0 c ofalllanguageswithtimecomplexityin O(f) > suchthatforallinputs xwith | x | n0 ≤ Space T (x) cf (| x |) (Note,itissometimescalled DSPACE[ f]—forDeterministicSpace) ComputabilityandComplexity 18-9 ComputabilityandComplexity 18-10 PolynomialSpace Timevs.Space Aswithtime,wecanobtainarobustspacecomplexityclassby •Visitingacelltakesatleastonetimestep,sowehave consideringallpolynomialspacecomplexityclasses Theorem TIME[ f ] ⊆ SPACE[ f ] Definition PSPACE = SPACE[ nk ] •Amoresubtleanalysis,basedonthefactthatthereareonly U f (n) k≥0 differentp|Q |⋅ f (n ⋅ |) Σ | ossibleconfigurationswith f(n)non- blanktapecells,gives Theorem SPACE[ f ] ⊆ TIME[ f ⋅k f ] ComputabilityandComplexity 18-11 ComputabilityandComplexity 18-12 ReusingSpace All Thepreviousresultsuggeststhatagivenamountofspaceismore Languages usefulthanagivenamountoftime DecidableLanguages Thisisbecausespacecanbereused Forexample, Satisfiability canbesolvedinlinearspace,bytrying P NP PSPACE eachpossibleassignment,oneatatime,reusingthesamespace Theorem NP ⊆ PSPACE 2 ComputabilityandComplexity 18-13 ComputabilityandComplexity 18-14 ProblemsinPSPACE Quantified Boolean Formula Generalized Geography Instance:AquantifiedBooleanformula Instance:Agamefor2playersconsistingofadirectedgraphG, Φ = andastartvertexs.Playerstaketurnstomovealong (Q1 X1 )( Q2 X 2 )K(Qn X n ) B(X 1, X 2 ,K, X n ) theedgesfromthecurrentvertex.Aplayerwhocannot whereeachisaBooleanvarX iable,B(X , X ,K, X ) l 1 2 n movewithoutreturningtoavertexalreadyvisitedloses isaBooleanexpressioninvolvingandX1, X 2 ,K, X n ∃ ∀ Question:Isthereawinningstrategyforthefirstplayer? eachisaquantifier(Ql or ). Question:Is Φlogicallyvalid? Complexity 13-15 Complexity 13-16 PSPACE-CompleteProblem QuantifiedBooleanFormula PSPACE-Completeness Instance:AquantifiedBooleanformula Φ = (Q1 X1 )( Q2 X 2 )K(Qn X n ) B(X 1, X 2 ,K, X n ) whereeachisaBooleanvarX l iable,B(X 1, X 2 ,K, X n ) Definition isaBooleanexpressioninvolvingandX1, X 2 ,K, X n Alanguage Lissaidtobe PSPACE -completeif,forany ∃ ∀ eachisaquantifier(Ql or ). ∈ ≤ A PSPACE , A L Question:Is Φlogicallyvalid? Theorem QBF isPSPACE-complete Complexity 13-17 Complexity 13-18 Proof Firstweshowthat QBF isin PSPACE, usingthefollowingrecursive Thisalgorithmispolynomialspace,because algorithm •oneveryroundofrecursionitneedstostoreonlyatransformed FortheinputBooleansentence Φ copyoftheinputformula •If Φcontainsnoquantifiers,thenitcontainsnovariables,only •thedepthofrecursionisthenumberofvariables, m constants.Evaluatethisexpression;acceptifitis true ; otherwisereject •Therefore,ituses m⋅|Φ|space Φ = ∃ Ψ Φ Φ ∨Φ •If X then is true ifandonlyifis|X =0 |X =1 true . Φ Φ Recursivelycallthealgorithmon|X =0 and,andaccept|X =1 ifoneofthemisaccepted;otherwisereject Φ = ∀ Ψ Φ Φ ∧Φ •If X then is true ifandonlyifis|X =0 |X =1 true . Φ Φ Recursivelycallthealgorithmon|X =0 and,andaccept|X =1 ifbothofthemisaccepted;otherwisereject 3 Complexity 13-19 Complexity 13-20 WhenprovingCook’stheoremwemanagedtodefineaBooleanCNF Φ Φ formulasuchthatT (X ) T (X ) istrueifandonlyifthevalues ofvariablesdescribeinacertainwayaleX galconfigurationofthe •Let Abealanguagein PSPACE Turingmachine T •Let TbeadeterministicTuringMachinethatdecides A ThenweconstructedaformulawΨ (X ,Y ) hichistrueifandonlyif withspacecomplexity f(n), where fisapolynomial T andrepresentlegalconfigurations,X Y sayand,andC1 C2 TcangofromtoinatmostonestC C ep •Chooseanencodingforthecomputation T(x)thatuses 1 2 k·f(| x|) symbolsforeachconfiguration Thelengthofbothformulasispolynomialintheamountoftapecells Ψ •Letbetheinitialconfiguration,andC0 betheacceptingCa involvedinthecomputation.DenotethelengthofbyT g(| x|) configuration WeconstructaformulawhiΩ( X ,Y ,t) chistrueifandonlyif andrepresentlegalconfigurations,X Y sayand,andC1 C2 t TcangofromtoinatmostC1 C2 2 steps Ω Finally, Taccepts xifandonlyif(C0 ,Ca , f (| x |)) istrue Complexity 13-21 Theformulaisbuiltrecursively Straightforwardapproach: Ω = Ψ (X ,Y )0, T (X ,Y ) Ω(X ,Y ,t) = ∃Z ( Ω(X ,Z ,t − )1 ∧ Ω(Z ,Y ,t − ))1 ItdoesnotworkbecauseΩ(X ,Y , f (| x isbuildof|)) 2 f (| x|) Ψ formulas T (X ,Y ) Thereareuniversalquantifierstodothejob! Ω(X ,Y ,t) = ∃Z ∀(U ,V ) (((( U ,V ) = ( X ,Z )) ∨ (( U ,V ) = (Z ,Y ))) ∧ Ω(U ,V ,t − ))1 ThelengthofthisformulaisO( f (| x |) g(| x |)) 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us