340 likes | 498 Views
Book’s model. There is a unique reject state similar with the accept (when reached the computation stops). The tape can be infinitely extended only to the right. There is no stay move for the head. The two models are equivalent!. The two models are equivalent.
E N D
Book’s model • There is a unique reject state similar with the accept (when reached the computation stops). • The tape can be infinitely extended only to the right. • There is no stay move for the head. The two models are equivalent!
The two models are equivalent • There is a unique reject state similar with the accept (when reached the computation stops). → Add every outgoing missing arrow leading to a unique reject state. ← Remove every transition leading to the unique reject state together with the reject state.
The two models are equivalent • The tape can be infinitely extended only to the right. → Add a special symbol $ before the beginning of the input. When you see the dollar sign move right. ← A bit more complicated. You have to introduce an new blank space in the beginning in order to use it (part of this might appear on the homework).
Book’s model … … a a b a →b, L q q q' q' … b a b a →b, L q q'
… to our model … … a a b $ $ → $, R $ → $, R … … $ b a b a →b, L a →b, L q q q' q' $ → $, R $ → $, R a →b, L q q' … … $ b a b $ → $, R $ → $, R a →b, L q q'
The two models are equivalent • There is no stay move for the head. → The model that allows the stay move is at least as powerful as the one that doesn’t. ← Simulate the ‘stay’ move in the restrictive model using left and right moves (probably on the homework).
Multitape Turing Machines • As we saw, a 2-PDA (a PDA with 2 stacks) is much more powerful than a regular PDA. • This is not the case with Turing Machines as adding more tapes is not going to make the Turing Machine more powerful. • We can simulate a multitape Turing Machine M with a single tape TM S (the other direction is obvious).
Equivalence with single tape TM • First we have to simulate the k tapes of M into the tape of S. To do so we introduce a special separator symbol #. We then copy the contents of the k tapes consecutively into the unique tape of S and separate them with #. … … … … … … a a b a c b a b … … a c b a b # # # a a b #
Equivalence with single tape TM • We have to take care of the position of the head in each tape. To remember where the head is we introduce one new symbol â for each symbol a in the tape alphabet Γ. … … … … … … a a b a c b a b … … a ĉ b ̂ a b # # # â a b #
Equivalence with single tape TM • Each instruction of the form a →b, R ; c →a, L ; □ → c , S ; … is replaced by several instructions that implement the suggested changes. … … … … … … a a b a c b a b … … a ĉ b ̂ a b # # # â a b #
Equivalence with single tape TM • Each instruction of the form a →b, R ; c →a, L ; □ → c , S ; … is replaced by several instructions that implement the suggested changes. … … … … … … b a b a a b c a b … … â a b ĉ a b # # # a â b #
Non-Deterministic Turing Machines • Unlike the PDA, Non-Deterministic Turing Machines are equivalent with Deterministic ones. • Obviously a DTM is a restriction of an NTM (there exist only deterministic transitions). • For the other direction we have to simulate each NTM by an equivalent DTM.
Computation Tree • The computation of a DTM on input w forms a path: For every state and every symbol that is currently read in the tape there is a unique transition. • The current state of the Turing machine together with the contents of the tape and the current head positionis called the configuration of the TM. • In DTMs every configuration can only be followed be a unique next configuration.
Computation Tree • This is not the case with NTM, where the computation can be a tree: There might be more than one possible next configurations A b →a, S a →c, R a →b, L a →b, L a →c, R q1 q2 q3 B1 B2 b →c, R a a b a
Computation Tree • This is not the case with NTM, where the computation can be a tree: There might be more than one possible next transitions A b →a, S a →c, R a →b, L a →b, L a →c, R q1 q2 q3 B1 B2 b →c, R b →a, S b →c, R a c b a C1 C2
Computation Tree • This is not the case with NTM, where the computation can be a tree: There might be more than one possible next transitions A b →a, S a →c, R a →b, L a →b, L a →c, R q1 q2 q3 B1 B2 b →c, R b →a, S b →c, R a c b a C1 C2
Computation Tree • This is not the case with NTM, where the computation can be a tree: There might be more than one possible next transitions A b →a, S a →c, R a →b, L a →b, L a →c, R q1 q2 q3 B1 B2 b →c, R b →a, S b →c, R a c c a C1 C2
NTM – DTM equivalence • We simulate an NTM with a DTM having the DTM try all possible branches in the computation tree of the NTM searching for an accepting configuration. • We have to simulate the computation using breadth first search (depth first search might result in a search on an infinite branch if the NTM loops for that choice, thus failing to find accepting states in some other branches).
Bad Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a a b
Bad Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S C a b b
Bad Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S C a b b a →a, S C
Bad Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S C a b b a →a, S C …
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a a b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a b b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a a b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a b b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a a b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a b b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a b b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a a b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a b b
Good Simulation A a →b, R a →b, L a →a, S a →b, L q2 B1 B2 q1 q4 q3 b →b, S a →b, R a →a, S b →b, S C C a b b
NTM – DTM equivalence • It suffices to show how to build an equivalent DTM out of the NTM. • We create a TM with 3 tapes: • The first one will always contain the input string and is never changed. • The second simulates the contents of the tape of the NTM for the current configuration. • The third contains the address of the child under examination in the computation tree (for example the string 13 if we are currently examining the third child of the first child of the root).
Simulation of the equivalent DTM • Each time we examine a new configuration, we reset the second tape to the initial input (copy it from tape 1). • Following the address provided in tape 3 we follow the corresponding transitions of the NTM. • When this is done the DTM should check if this current configuration is an accepting one. • If it is then the DTM should accept. • If it is not then the DTM should update the address under examination on tape 3 and restart.