Download presentation
Presentation is loading. Please wait.
36
What is it about? . . . . acba aaba M G Models of Language Recognition
Reminder What is it about? M aaba acba G Models of Language Recognition Models of Language Generation
37
Machine Models: Automata, that recognize (understand)
the languages
38
Deterministic Turing Machines
b 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.
39
Deterministic 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},
40
Deterministic 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}.
41
Example : Construct a deterministic Turing Machine which accepts {0n1n | n 1}. 1 q0 An idea : Traveling back and forth replace "1" by Y for each "0" replaced by X. The transition function is defined as follows.
42
Transition 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. X Y 1 q1 q2 q3 X Y q4 q5
43
Transition Table
44
Transition Graph (0,0,L) (Y,Y,L) (0,0,R) (Y,Y,R) (Y,Y,R) (1,Y,L) q2 q1
(X,X,R) (0,X,R) q4 (0,X,R) (B,B,N) q0 (Y,Y,R) start q3 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.
45
Restricted Turing Machines (cont’ed)
(1) Deterministic linear bounded automata (DLBA): [ a q0 b ] Two-way read/write 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.
46
Restricted Turing Machines (cont’ed)
(2) Deterministic pushdown automata (DPDA): a b Z0 q0 One-way read only Stack M = ( Q, , , , q0 , Z0, F ) : Q ( { } ) Q *
47
Restricted Turing Machines (cont’ed)
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.
48
Restricted Turing Machines (cont’ed)
Example: Two transitions ( p , a, Z ) = ( q,YX ) and ( q, b, Y ) = ( r, ) in sequence implies the following. …… Z a b c … p …… X Y a b c … q …… X a b c … r
49
Examples (a) Construct a DPDA which recognizes {aibi | i > 0 }
(input symbol, current stack top/stack top changed) a b Z0 q0 One-way read only Stack start (a, Z0/aZ0) (a, a/aa) (b, a/) (, Z0/Z0)
50
Examples (cont’ed) (b) Construct a DPDA which recognizes {aibj | i > j > 0 } start (a, Z0/aZ0) (a, a/aa) (b, a/) (, Z0/Z0) start (a, Z0/Z0) (a, a/aa) (b, a/) (a, Z0/aZ0)
51
Examples (cont’ed) (c) Construct a DPDA which recognizes {aibj | j > i > 0 } start (a, Z0/Z0) (a, a/aa) (b, a/) (a, Z0/aZ0) start (a, Z0/aZ0) (a, a/aa) (b, a/) (b, Z0/Z0)
52
Examples (cont’ed) (d) Construct a DPDA which recognizes
{aibkci | k, i > 0 } {aibkdk | k, i > 0 } start (a, Z0/aZ0) (a, a/aa) (b, a/ba) (b, b/bb) (c, b/) (, b/) (, a/) (c, a/) (d, b/) (, a/a) (, Z0/ Z0) Notice that this machine needs -move, i.e., takes a step without reading the input.
53
Restricted Turing Machines (cont’ed)
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.
54
Restricted Turing Machines (cont’ed)
(3) Deterministic finite state automata (DFA): a b q0 One-way read only One-way DFA a b [ ] q0 Two-way read only Two-way 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.
55
Example Construct a DFA which recognizes the following language;
{x | x is a binary number, i.e., x {0, 1}+, which is divisible by 3 } 1 2 start State id indicates current remainder.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.