140 likes | 151 Views
Savitch and Immerman-Szelepcsènyi Theorems. Space Compression. For every k-tape S(n) space bounded offline (with a separate read-only input tape) TM and a constant c>0, there exists a 1-tape c·S(n) space bounded offline TM such that L(M)=L(N). If M is deterministic then so is N.
E N D
Space Compression • For every k-tape S(n) space bounded offline (with a separate read-only input tape) TM and a constant c>0, there exists a 1-tape c·S(n) space bounded offline TM such that L(M)=L(N). If M is deterministic then so is N. • The idea is to encode the k tapes into 1 with extra symbols(1 symbol of N represents kxd matrix of d cells for each tape of M • SPACE(S(n))=SPACE(O(S(n)))
Linear Speedup • L is accepted by a k-tape T(n) time bounded TM M. If n є o(T(n)), then for any c>0, L is accepted by a k-tape c·T(n) time bounded TM N. If M is deterministic then so is N. • Same idea we enlarge the alphabet of M. Also N simulates m moves of M in 8 moves, with mc≥16. • TIME(T(n))=TIME(O(T(N))) • TIME(O(n))=TIME((1+e)n)
Time and Space Constructible Functions • f(n) is time(space) constructible if there is a f(n) time(space) bounded TM M such that for each n there is some input of length n on which uses exactly f(n) steps(cells). • Fully time(space) constructible if it holds for all inputs of length n • Logn only space constructible • nk, 2n, n! : time and space constructible • f1(n)·f2(n), 2f1(n), f1(n)f2(n)
Loop Detection in space bounded TM’s • Length of configuration I of TM M is the length of the work tape of M in cofiguration I • M is a S(n) TM, S(n)≥logn. There exists a constant k such that for each n and l, logn≤l≤S(n), the number of different configurations of M with length l on any input of length n is at most kl. The number of different configurations of M on any input of length n is at most kS(n)
Proof • If M has s states and t alphabet symbols then I consists of • Input head position (at most n+1) • Tape head position (at most l) • Current state (at most s) • Tape contents (at most tl) • M has at most (n+1)sltl different configs • There exists a k such that for all n≥1 and logn≤l≤S(n), kl ≥ (n+1)sltl • For c,d constants ncdl ≤ kl
Savitch’s Theorem • NSPACE(S(n)) DSPACE(S2(n)) if S is fully space construct and S(n)≥logn • Let M be a S(n) tape NDTM with s states and t tape symbols. L=L(M). • From lemma on input w, |w|=n the max No of configurations is cS(n). If M accepts w there exists an accepting computation with length ≤ cS(n) wich in binary representation has length at most logcS(n) =mS(n) • If M accepts w then there exists a sequence of at most 2mS(n)≥mS(n)moves from I0 to If of length at most S(n) (wich is the length limit of each intermediate configuration).
The Algorithm (1) • Function TEST(I1,I2,i): Boolean • Var I’: configuration • If i=0 and (I1=I2 or I1 I2) • Return true; • If i≥1 • then for each I’ of length at most S(n) do • if TEST(I1,I’,i-1) and TEST(I’,I2,i-1) • then return true; • Return False; • End
The Algorithm (2) • For each accepting config If of length at most S(n) do • If test (I0,If,mS(n)) • accept; • Reject;
S(n)2 Space bound achieved • The active variables in a call to TEST take O(n) space • Each of the configurations I1, I2, I’ require no more than O(n) space • logn≤S(n), so the input head position can be written in binary in S(n) space • i≤mS(n), i in binary takes ≤ O(S(n)) space • TEST uses a tape as a stack. Initial call of TEST uses depth of stack i≤mS(n)=O(S(n)) and it decreases with each recursion. • Stack size O(S2(n)), can be compressed to S2(n) space
The Immerman-Szelepcsényi theorem • For any S(n)≥logn, NSPACE(S(n))=co-NSPACE(S(n)) • For input x on M (a S(n)≥logn bounded TM) define COUNTM(x)= the number or configurations of M that are reachable from Ix0, the initial configuration of M on input x. • We will first prove it for S(n) fully space-constructible
There is a NDTM transducer that computes COUNTM in space S(n) • The No of different configurations of M on any input of length n is ≤kS(n) so COUNTM(x) can be written in space O(S(n)) • REACHM(x,I,d)=I is reachable from Ix0 in at most d steps.(d ≤ kS(n)) • It can be accepted nondet in S(n) space. • N(x,d)=the # of configs that are reachable from Ix0 • By induction on d we show that N(x,d) can be computed nondet in space S(n). • COUNTM(x)=N(x, kS(n))
There is a S(n) NDTM N’ that given x and COUNTM(x), accepts iff M doesn’t accept x • Cycle through the configs that use space S(n) • For each such config I determine if REACHM(x,I,kS(n)) • If an accepting config is found halt and reject • Every time the procedure finds an I such that REACHM(x,I,kS(n)) is true iterates a counter • When counter reaches COUNTM(x) with no config accepting it accepts.
For any function S(n)≥logn (not only constructible) • We initialize a counter S for space bound to logn and increment the space bound as needed • N(x,S,d) the number of configs that are reachable within space S and d steps. It is nondet calculated • Nondet compute N(x,S+1,d+1) and N(x,S,d+1) (if N(x,S,d)≠0) • If difference is nonzero continue with N(x,S+1,d+1) else don’t increase S. • We never exceed S(n) space (except by a constant) • If our algorithm claims that no reachable computation is accepting then x is not in L(M) • For all S≤S(n) and all d≤kS(n) all configurations are checked