Title: Deterministic%20Turing%20Machines
1Reminder
What is it about?
Models of Language Recognition
Models of Language Generation
2Machine Models Automata, that recognize
(understand) the languages
3 Deterministic Turing Machines
Read/write tape
q0
Two-way read/write head
Finite State Control
- The Turing machine (TM) is a computational model
which has a tape of infinite length divided into
cells and a finite control unit with a two-way
read/write head. In a move (i.e, a computational
step) the TM, depending upon the symbol scanned
by the head and current state of the control,
does the following - (1) Writes a symbol on the tape cell under the
head, replacing what was written, - (2) changes the state of its control, and
- (3) moves the head to the left, right or does not
move.
4Deterministic Turing Machines
- Formally a TM is defined as a 6-tuple M ( Q, ?
, ? , ? , q0 , F ), where - Q is the finite set of states,
- ? is the set of tape symbols (alphabet)
including the blank symbol, usually denoted by B
(a square box in the text), - ? is the set of input symbols, which is a subset
of ? , - q0 is the start state,
- F is the set of accepting states (F ? Q ), and
- ? is the transition function which maps Q ? ?
? Q ? ? ? L, N, R,
5Deterministic Turing Machines
- where L, N, and R denote a move to the left,
no move, and a move to the right, respectively.
The transition function ? may be undefined for
some arguments. In this case we assume that the
machine halts. It is assumed that initially an
input string x ? ? is written on the tape and
the machine is reading the leftmost symbol in the
start state q0. - Definition We say a string x is accepted by a
TM M if M, given x on the tape, enters an
accepting state after some finite number of
moves. - Definition The language recognized (or
accepted) by a TM M, denoted by L(M), is the set
of strings accepted by the machine, i.e., L(M)
x M accepts x.
6Example
Construct a deterministic Turing Machine which
accepts 0n1n n ? 1.
- An idea Traveling back and forth replace "1" by
Y for each "0" replaced by X. The transition
function ? is defined as follows.
7Transition Fuction
- ?(q0, 0) (q1, X, R) In q0 , reading 0, change
it to X, - ?(q1, 0) (q1, 0, R) move to the right
searching 1 in q1. - (q1, 1) (q2, Y, L) Reading 1, replace it by Y,
and - (q2, 0) (q2, 0, L) move to the left in q2
searching X. - ?(q2, X) (q3, X, R) Reading X, back up in q3 ,
and - ?(q3, 0) (q1, X, R) reading 0 repalce it by
X. - ?(q1, Y) (q1, Y, R) In q1 , move over Y to the
right. - ?(q2, Y) (q2, Y, L) In q2 , move over Y to the
left. - ?(q3, Y) (q4, Y, R) Reading Y, instead of 0,
enter q4, - ?(q4, Y) (q4, Y, R) and move over Y to the
right, till - ?(q4, B) (q5, B, N) there appears blank, and
accept in q5.
q4
q5
8Transition Table
9Transition Graph
(0,0,L) (Y,Y,L)
(0,0,R) (Y,Y,R)
(Y,Y,R)
q2
(1,Y,L)
q1
(X,X,R)
q4
(0,X,R)
(0,X,R)
(B,B,N)
q0
(Y,Y,R)
q3
start
q5
- Now, the machine is formally defined as follows
- M ( Q, ? , ? , ? , q0 , F ), where Q q0, q1,
q2, q3, q4, q5, ? 0, 1, - ? 0, 1, X, Y, B, F q5, and ? is given in
terms of one of the above forms, - i.e, state transition function, state transition
table or state transition graph.
10Restricted Turing Machines (conted)
(1) Deterministic linear bounded automata (DLBA)
- The head cannot cross the left and right boundary
markers ( and ), i.e., the computation must be
done within the range of the input string. Other
operations are the same as in the standard TM.
Formally a DLBA is defined as a tuple - M (Q, ? , ? , ? , q0, , ,
F), - where, excepts for the boundary markers ' and
', all the elements of the tuple are defined
the same way as for the Turing machines.
11Restricted Turing Machines (conted)
(2) Deterministic pushdown automata (DPDA)
- M ( Q, ? , ? , ? , q0 , Z0, F )
- ? Q ? ( ? ? ? ) ? ? ? Q ? ?
12Restricted Turing Machines (conted)
- Formally a DPDA is a tuple M ( Q, ? , ? , ? ,
q0 , Z0, F ), where Q, ? , ? , ? , q0 , Z0 and F
are the set of states, the input alphabet, the
stack alphabet, the start state, the bottom of
stack symbol and the set of accepting states,
respectively. The transition function ? is a
mapping - ? Q ? ( ? ? ? ) ? ? ? Q ? ?
- For example ? ( q , a, Z ) ( p, ? ), where q ,
p ? Q, a ?? , Z ? ? , and ? is a string of
stack symbols written on top of the stack
replacing Z. Conventionally, we assume that
either - ? 0, i.e., ? ? , means the machine pops
the stack top symbol, - ? 1, i.e., rewrites the stack top symbol, or
- ? 2, i.e., pushes a symbol on top of the
stack.
13Restricted Turing Machines (conted)
Example Two transitions ? ( p , a, Z ) ( q,YX
) and ? ( q, b, Y ) ( r, ? ) in sequence
implies the following.
14Examples
(a) Construct a DPDA which recognizes aibi i gt
0
15Examples (conted)
(b) Construct a DPDA which recognizes aibj i gt
j gt 0
16Examples (conted)
(c) Construct a DPDA which recognizes aibj j gt
i gt 0
17Examples (conted)
(d) Construct a DPDA which recognizes aibkci
k, i gt 0 ? aibkdk k, i gt 0
Notice that this machine needs ?-move, i.e.,
takes a step without reading the input.
18Restricted Turing Machines (conted)
- The input head should move to the right when
it reads the input. The ? in a - transition ? (q , ? , Z ) ( p, ? ) means the
machine does not read the input. We - call such transition ? -move. The input head
does not move when it does not - read. An important restriction is that a DPDA
cannot have both transitions ? (q , a, - Z ) and ? (q, ? ,Z) defined. Otherwise, it is a
nondeterministic PDA, which will be - discussed later. The language accepted by a DPDA
M is defined as - L(M)x M enters an accepting state some
time after reading the last symbol of - the input x.
- Notice that, for an input string x to be
accepted, the PDA should enter an - accepting state and the whole string must be
read.
19Restricted Turing Machines (conted)
(3) Deterministic finite state automata (DFA)
- A DFA is defined as a tuple M ( Q, ? , ? , ?
, q0 , F ). One-way DFA is a DFA whose head is
not allowed to move to the left. The language
accepted by a DFA M is defined as - L(M) x M enters an accepting state after
reading the last symbol of input x. - It is proven that one-way FA's and two-way FA's
are equivalent in the sense that they can accept
the same languages.
20Example
Construct a DFA which recognizes the following
language x x is a binary number, i.e., x ?
0, 1, which is divisible by 3
State id indicates current remainder.