Title: COSC 3340: Introduction to Theory of Computation
1COSC 3340 Introduction to Theory of Computation
- University of Houston
- Dr. Verma
- Lecture 18
2Combining Turing Machines
- A Turing Machine can be a component of another
Turing Machine (subroutine) - We will develop a graphical notation to build
larger machines for more complex tasks easily.
The scheme is hierarchical. - Combination is possible since all TMs are
designed to be non-hanging so the first
machine can save something on the leftend of the
tape.
Reference Elements of the Theory of
Computation by H.R. Lewis and C.H.
Papadimitriou.
3Combining Turing Machines
- Assumptions, for convenience
- From now on, Turing machines can either write a
symbol or move head but not both in the same
move. - All TMs have only one alphabet ?, containing the
blank symbol - All machines start in this position w
- There are two types of basic machines
- Symbol-writing
- Head-moving
4Basic Machines Symbol-Writing
- There are ? symbol-writing machines, one for
each symbol in ?. Each TM simply writes a
specified symbol in the currently scanned tape
square and halts. - Formally, the TM which writes a is
- Wa (K, ?, ?, s), where
- K q for some arbitrarily chosen state q
- s q and
- ?(q, b) (h, a) for each b ? ?
Notation Wa
5Basic Machines Head-Moving
- The head-moving machines simply move the head one
square to the left or right, and then halt. - Formally, the TMs are
- VL (q, ?, ?L, q), where
- ?L(q, a) (h, L) for each a ? ?
- VR (q, ?, ?R, q), where
- ?R(q, a) (h, R) for each a ? ?
let q be some state
Notation L and R
let q be some state
6Rules for Combining Machines
- Machines may be connected just like a Finite
Automaton. - If two machine are connected, then the first
machine has to halt before the other machine
starts.
7Rules for Combining Machines
If M1 and M2 are any TM Start in the initial
state of M1 operate as M1 would operate until M1
would halt then initiate M2 and operate as M2
would operate
After M1 halts either M2 or M3 would start
depending on the symbol.
8Abbreviations
- L/R A TM that moves the head one cell to the
left/right - R? - A TM that moves to the Right seeking ?
- L? - A TM that moves to the Left seeking ?
- R? - A TM that moves to the Right seeking a
nonblank spot - L? - A TM that moves to the Left seeking nonblank
spot
9Example R?
Alphabet (?) a, b
M (q0, q1 , a, b, a, b, ?, ?, q0, )
a
State Symbol Next state action
q0 ? (q1, ?, R)
q0 a (q1, a, R)
q0 b (q1, b, R)
q1 ? halt
q1 a (q1, a, R)
q1 b (q1, b, R)
R?
R
b
L? is very similar to R?
10JFLAP SIMULATION
11JFLAP SIMULATION
12JFLAP SIMULATION
13JFLAP SIMULATION
14JFLAP SIMULATION
15Example Machine 1
16Example Machine 1 (contd.)
?abc?a ?ab??a ?ab??ab? ?a?c?abc ?ab??abc ?abc?abc
?abc?abc ?abc?abc?
?abc? ?abc? ??bc? ??bc?? ??bc?a ??bc?a ?abc?a
?abc?a ?a?c?a ?a?c?a? ?a?c?ab ?a?c?ab ?abc?ab
Let C be the TM, we say C transforms ?w? into
?w?w? (Copying Machine)
17Example Machine 2
? ? ?
gtL?
L?R
R
?
L?
18Example Machine 2 (contd.)
?ab? ?ab? ?ab? ?ab? aab? aab?
aab? aab? abb? abb? ab?
Let SL be the TM, we say SL transforms ?w? into
w? (Shift-Left Machine)
19Example Machine 3
I
gtaL?L
?
aRa?CaLa?
L
I
?
?
?
aRa?
IR