Professional Documents
Culture Documents
November 2002
Introduction
an abstract machine
a specification with many possible implementations
issues of functionality (power) and efficiency
hierarchy of automata corresponds to hierarchy of
grammars
languages generated by grammars are accepted by
automata
the computational tasks performed by an automaton are
very closely related to the structures & meanings modelled
by the corresponding grammar.
2
Computing power of automata:
3
Deterministic Finite Automaton DFA
DFA = (Q,T,F,g)
a
q q’
5
DFA
a1 a2
q q’ f
7
Teletext remote control example
text
tv text
tv
new
d = 0 … 9
tv tv tv page
d
d
• Pressing the text button followed by three digits causes the appropriate
page to be loaded and displayed.
• Pressing the tv button causes a return to the normal image. 8
DFA State Transition
10
Binary adder DFA example
Note that a DFA halts when its input string is exhausted (or
when no move is possible for a given (state, input) pair),
and not just because it has entered a final state. Some
machines can also generate an output for every move. Let
the output vocabulary be T*.
(0,0)→0 (1,1)→1 T = { ( 0 ,0), ( 0,1), (1,0), (1,1) }, T ′ = {0 ,1}
(1,1)→ 0
input: 0 1 1 0 1 0 1
q0 q1
input: 0 0 1 0 0 1 1
(0,0)→ 1 state: q 0 q1 q 1 q0 q 1 q1 q1 q 0
(0,1)→1 (1,0)→1 (0,1)→0 (1,0)→0 output: 1 0 0 1 0 0 0
The state diagram shows the output to the right of each arrow.
11
Binary Multiply by 3
0 →0 1→1
T = T ′ = {0 ,1}
1→1 1→0
q0 q1 q2 input: 0 0 1 1 0
0→1 0→0 state: q 0 q1 q 2 q1 q 0 q0
carry 0 carry 1 carry 2 output: 1 0 0 1 0
12
Nondeterministic Finite Automaton NFA
13
NFA
14
NFA
15
NFA to DFA conversion
The final states of the DFA are those states R for which
R∩F≠∅
16
NFA to DFA conversion
Example:
R0 R1 R4 b
b b
a {q1, q2}
a {q0} a {q1,q4}
q1
q0 b b b
a b
a a a R5 b
b q4
{q4}
{q3} R2 b a R6
b R3
q3 q2 {q2} {q1}
a a
NFA DFA a
17
18