Turing Machine
Turing Machine
Turing Machine
s5 : move right until 0, 1, or ⊔; accept if ⊔; reject if 0, 1. s1 (a): move right until #; if no # before ⊔, reject;
δ(s5 , x) = hs5 , x, Ri, δ(s5 , ⊔) = hsa , ⊔, Li δ(s1 (a), 0) = hs1 (a), 0, Ri, δ(s1 (a), 1) =
hs1 (a), 1, Ri, δ(s1 (a), #) = hs2 (a), #, Ri
s2 (a): move right until 0 or 1; if the current symbol is the
same as a, then replace it by x; else reject;
δ(s2 (a), x) = hs2 (a), x, Ri, δ(s2 (0), 0) =
hs3 , x, Li, δ(s2 (1), 1) = hs3 , x, Li;
Note:looping does not mean that machine repeats the same steps over
and over again; looping may entail any simple or complex behavior that
never leads to a halting state.
Question: is this real? I.e., can you indicate a computation that takes infinite
the symbols under the virtual heads. Then S makes the second pass ?
b a ⊔ ...
over the tape to update it according to the way M ’s transition function
?
dictates.
3. If at any time S moves one of the virtual heads to the right of # it
S •
# 0 1 • # • a #
0 1 0 # b a b
...
means that M has moved on the corresponding tape onto the unread
blank portion of that tape. So, S writes a ⊔ on this tape cell and shifts Figure 1: Multitape machine simulation
the tape contents from this cell until the rightmost #, one unit to the
right. Then it continues to simulates as before".
The root of N (w) is the start configuration Note: in this simulation D tries all possible branches of N ’s
computation. If D ever finds the accept state on one of these
Note: D searches N (w) for an accepting configuration
branches then it accepts. Otherwise D simulation will not
terminate
This strategy explores all branches at the same depth before A depth-first search goes all the way down on one branch
going to explore any branch at the next depth. Hence, this before backing up to explore next branch. Hence, D could
method guarantees that D will visit every node of N (w) until go forever down on an infinite branch and miss an accepting
it encounters an accepting configuration configuration on an other branch
input tape
D has three tapes, Figure ??:
...
0 0 1 0 ⊔ 1. Tape 1 always contains the input (and the code of N )
6 simulation tape and is never altered.
-x
D x # 1 x ⊔ ...
2. Tape 2 (called simulation tape) maintains a copy of the
? address tape
N ’s tape on some branch of its nondeterministic
1 2 3 3 2 3 1 2 1 1 3 ⊔ ...
computation
3. Tape 3 (called address tape) keeps track of D’s location
Figure 2: Deterministic TM D simulating N in N ’s nondeterministic computation tree
Note: Some people use the term recursively enumerable language for lan-
A TM deciding A Example TM
M = “On input hGi, the encoding of G Let A be the language consisting of all strings
representing undirected graphs that are connected.
1. Select the first node of G and mark it.
Recall:a graph is connected if every node can be reached from
2. Repeat the following stage until no new nodes are marked.
every other node.
3. For each node in G, mark it if it is attached by an edge to a node
Notation: A = {hGi | G is a connected undirected graph}
that is already marked.
4. Scan all the nodes of G to determine whether they all are marked. If
they are accept; otherwise reject."
.
Note: element distinctness problem can be used to formate the lists and to