250 likes | 274 Views
DSPACE. Slides By: Alexander Eskin, Ilya Berdichevsky (From the Course “Computational Complexity” by Ely Porat). Agenda. Definition of DSPACE DSPACE(s(n)) DTIME(2 O(s(n)) ) DSPACE(O(1)) = DFA DSPACE( o (logn)) DSPACE(O(1)) DSPACE(o(loglogn)) = DSPACE(O(1)).
E N D
DSPACE Slides By: Alexander Eskin, Ilya Berdichevsky (From the Course “Computational Complexity” by Ely Porat) DSPACE
Agenda • Definition of DSPACE • DSPACE(s(n)) DTIME(2O(s(n))) • DSPACE(O(1)) =DFA • DSPACE(o(logn)) DSPACE(O(1)) • DSPACE(o(loglogn)) = DSPACE(O(1)) DSPACE
Definition of DSPACE • Let M be a deterministic Turing Machine with 3 tapes: Input, Space (work)and Output. • DSPACE ( s(n) ) := { L | M M(x) = L(X) n |Space(M)| s(n) } DSPACE
Explanation • Input tape is read-only. • Work tape is read-write. • |Space(M)| is measured by the bounds of the machine’s position on this tape. • Output tape is write-only. • DSPACE ( s(n) ) is the class of all the languages that can be decided deterministically using s(n) work space. DSPACE
Theorem:DSPACE(s(n)) DTIME(2O(s(n))) Proof: • Let M be a Turing Machine s.t. L(M) DSPACE(s(n)) |Space(M)| = s(n) • = {0, 1, #} number of states for the work tape is || |Space| =3 s(n) • The number of possible head positions in the work tape is s(n). • The number of possible head positions in the input tape is n. • The number of the states of M is |QM|. DSPACE
This entails: • The number of the possible configurations of M is s(n) 3s(n) n |QM| = 2O(s(n)) • Claim: M cannot do more than 2O(s(n)) steps • Otherwise, M will go through the same configuration at least twice, entering an infinite loop. • Therefore, M has to run in time 2O(s(n)) DSPACE
Explanation • If M will go through the same configuration twice, it will enter an infinite loop, since: • The same configuration Ci the same head position in the input tape and the same state. • But M is deterministic, so in both cases it will move to the same configuration Ci+1 etc. • Since after the first time M entered Ci ,it returned there one more time, it would do so after the second time and so on. DSPACE
Theorem:DSPACE(O(1)) =DFA Proof: • Claim: DSPACE(O(1)) = TWA (Two way automata) • Claim: TWA = DFA Claims 1, 2 entail: DSPACE(O(1)) =DFA DSPACE
Explanation • Proof of Claim 1: • Let M be a Turing machine. |Space(M)| = O(1) there is constant number of possible contents of the work tape, say y. There are |Q| states M can be simulated by TWA with |Q|y states (still constant # of states). • The proof of Claim 2 is beyond the scope of this course. DSPACE
Theorem:DSPACE(o(logn)) DSPACE(O(1)) Proof: • We will show: • DSPACE(log log(n)) DSPACE(O(1)) • Let L be a language: • (L) = {0, 1, $} • L = {w = 0…0$0…01$0…010$…$1…1 | k N the l-th substring of w delimited by $ has length k and is the binary representation of l-1, 0 l < 2k} • Claim: L is not regular. DSPACE
Lemma: L DSPACE(log log(n)) • Proof: Let M be a Turing Machine, doing the following: • Check that every block delimited by $ is k-length. This takes log(k) space. • Check the 1st block is all 0’s and the last block is all 1’s. This takes O(1) space. • For each two consecutive sub-strings, verify that they are x$x+1. DSPACE
Explanation • The claim that L is not regular can be easily proved by the Pumping Lemma • Step 3 above (for each two consecutive sub-strings, verify that they are x$x+1) is done as follows: • Start from the LSB (right-to-left) • Check: every 1 in Xm 0 in Xm+1 • Check: the 1st0 in Xm 1 in Xm+1 DSPACE
Back to the proof of the lemma: • Verifying that each two consecutive sub-strings are x$x+1 (step 3)takes log(k) space, since each time we compare 1 bit only, and need a log(k) counter to count k bits forward • Steps 1-3 take together O(log(k))space, which is O( log log(n) ) • We have shown: L DSPACE(log log(n)) • But L is not regular DSPACE(log log(n)) DSPACE(O(1)) DSPACE(o(log(n)) DSPACE(O(1)) DSPACE
Theorem:DSPACE(o(loglogn)) = DSPACE(O(1)) Proof: • Claim: DSPACE(o(loglogn)) DSPACE(O(1)) • Lemma: DSPACE(o(loglogn)) DSPACE(O(1)) • DSPACE(o(loglogn)) = DSPACE(O(1)) (entailed by 1. and 2. above) DSPACE
Explanation Claim: DSPACE(o(loglogn)) DSPACE(O(1)) Proof: o(loglogn)) O(1) DSPACE(o(loglogn)) DSPACE(O(1)) DSPACE
Claim: • Given input x : |x| = n such that M accepts x, then M can be on every cell on the input tape at most k times k = 2S(n) S(n) |QM| = O(2S(n)) Proof: • k is number of possible different configuration of the machine. • If M were on the cell more than k times then it would be in the same configuration twice and thus never terminate. DSPACE
Explanation • k is the number of possible different configurations of the machine • 2S(n) – number of possible contents of the work-tape. • S(n) – number of possible locations for the r/w head on the work-tape. • |QM| - set of states of M. • If M were on the cell more than k times then it would be in the same configuration twice. • The second time in the same configuration the machine will perform exactly as the first time endless loop. DSPACE
Lemma:DSPACE(o(loglogn)) DSPACE(O(1)) Proof: • Definition: • semi-configuration is a configuration with position on the input tape replaced by the symbol at the current input tape position configuration of the machine • For every location i on the input tape we consider all possible semi-configuration of M when passing location I • The sequence of such a configurations is Ci= Ci1,Ci2… Cir then it length is bounded by O(2S(n)) r DSPACE
Proof of Lemma (contd.): The number of possible different sequences of semi-configurations of M, associated with any position on input tape is bounded by • S(n) = o(log log n) • n0N such that n n0, • We’ll show that n n0 S(n) = S(n0), thus LDSPACE(S(n0)) DSPACE(S(1)) proving the theorem. DSPACE
Proof of Lemma (contd.): • Assume to the contrary that there exists n` such that S(n`) > S(n0) • Let and let x1{0,1}n1 be such that SpaceM(x1) > S(n0) • x1 is the shortest input on which M uses more space then S(n0). • The number of sequences of semi-configurations at any position in the input tape is • Labeling n1 positions on the input tape by at most sequences means there must be at least three positions with the same sequence of semi-configurations. DSPACE
Without loss of generality say x1= aaa • Each of the position with symbol a has the same sequence of semi-configurations attached. Claim: • The machine produces the same final semi-configuration with either a or a eliminated from the input. DSPACE
Explanation Proof of the Claim: • Consider cutting a, leaving x1` = aa • On x1` M proceeds on the input exactly as with x1 until it first reaches the a. • M will make the same decision to go right or left on x1` as it did on x1 since all the information stored in the machine at the current head position is identical. • If the machine goes left then its computation will proceed identically because it still did not see difference on both inputs. DSPACE
Explanation (contd.) Proof of the claim (contd.): If the machine goes right: • Say this is the ith time at the first a. • Since the semi-configuration is the same in both cases then on input x1 the machine M also went right on the ith time seeing the second a. • The machine proceeded and either terminated or came back for the (i+1)th time to the second a. • In either case on input x`1 the machine M is going to do the same thing but now on the first a. DSPACE
Explanation (contd.) Proof of the claim (contd.): • As the machine proceeds through the sequence of semi-configurations we see that the final semi-configuration on x`1 will be same as for x1 • arguing each time that on x`1 we will have the same sequence of semi-configurations. • The case in which a is eliminated is identical. DSPACE
Proof of the Lemma (contd.): • Let x2 = aa and x3 = aa • If the worst case of space usage processing x1 was in a then WM(x1)= WM(x2)= WM(x3) • If the worst case of space usage was in a then WM(x1)= WM(x2)WM(x3) • If the worst case of space usage was in a then WM(x1)= WM(x3)WM(x2) • Chose x1`{x2,x3} to maximize WM(x1`) WM(x1`) = WM(x1) and | x1`| < | x1| • Contradiction to assumption that x1 is minimal length string using more then S(n0) space no such x1 exists. DSPACE