Professional Documents
Culture Documents
(Automata) lecture 12
cl •
•
•
a simple form of computation
used widely
1
A current
A B C D
D B
B C D A
C
next
2
Application Fields
Industry
• real-time control, vending machines, cash dispensers, etc.
Electronic circuits
• data path / control path
• memory / cache handling
• protocols, USB, etc.
Communication protocols
• initiation and maintenance of communication links
• error detection and handling, packet retransmission
Language analysis
• natural languages
001
• programming languages
• search engines
3
Finite State Machines
start
d d end
alternative paths repetition
Each path from start to end, with a choice of sta
one of the labels for each edge traversal, gives a decimal number.
d = {"0","1","2","3","4","5","6","7","8","9"}
+⎮− = { "+","-" } ε = "" . = "."
5
This gives us a new way of defining sets by rules.
ε
+⎮− d
d . d
6
This gives us a new way of defining sets by rules.
ε
+⎮− d
d . d
8
finite state machines
A labelled directed graph
nodes
edges
with
R a set of start nodes
and
a set of end nodes
start
d d end
alternative paths repetition
sta
The language defined by this machine
is the set of all decimal numerals
10
finite state machines
R S
R S
RS = { r ++ s | r ∈ R ∧ s ∈ S }
12
alternation R | S
R S
R|S=R∪S
13
iteration R*
ε
R ε
"" ∈ R*
x ∈ R*, r ∈ R x ++ r ∈ R*
14
finite state spaghetti
A language is a set of
finite sequences of words.
A language is a set of
finite sequences of symbols.
15
State Three states
2
Six transitions
Start state b a,b a,b
Accepting state
0 1
a,b a
s t Transitions
Strings that
begin with b and are of even length or
begin with a and are of odd length
Three states
State
Two start states
One accepting 2
Start state Four transitions
b
Accepting state b a
a,b 0 1
s t Transitions a
This machine is non-deterministic
some strings have more than one trace
some strings have no traces
a,b 0 1
s t Transitions a
This machine is non-deterministic
some strings have more than one trace
some strings have no traces
a,b 0 1
s t Transitions a
This machine is non-deterministic
some strings have more than one trace
some strings have no traces
aεL
Which of these strings are accepted? ba ε L
abba abab baba aba bab ab ba a b x ε L → x ba ε L
KISS – DFA
Deterministic Finite Automaton
22
This machine has four states,
Q = { s0, s1, s2, s3 }
Its alphabet has three symbols
Σ = { 0, 1, 2 }
For each
(state, symbol) pair, (q,s)
there is exactly one transition
from q with label s
q
s qʹ
q
s qʹ
q
s qʹ
qʹ is determined by (q,s)
It has only one start state
This is a
Every DFA has a deterministic finite-
next-state function state automaton,
qʹ = F(q,s) DFA
DFA ⊂ NFA Every DFA has a
A DFA has only one start state next-state function
For each (state, symbol) pair, (q,s) qʹ = F(q,s)
there is exactly one transition
any input string
from q with label s determines
qʹ is determined by q and s a sequence of states.
26
Every DFA has a
next-state function
qʹ = F(q,s)
s
q qʹ
Since we have
finitely many symbols and states
This can be given by a table
This is a
0 1 2 deterministic finite-
s0 s0
s1 s2
state automaton,
s2 s3 DFA
s3 s1
Every DFA has a
next-state function
qʹ = F(q,s)
s
q qʹ
Since we have
finitely many symbols and states
This can be given by a
next-state table
This is a
q\s 0 1 2 deterministic finite-
s0 s0 s1 s2
s1 s3 s0 s1
state automaton,
s2 s2 s3 s0 DFA
s3 s1 s2 s3
Every DFA has a
next-state function
qʹ = F(q,s)
s
q qʹ
input path
000 s0 s0 s0 s0
021 s0 s0 s2 s3
120 s0 s1 s1 s3
11
12
This is a
21
22 deterministic finite-
111 state automaton,
110 DFA
212
For every DFA, any input string
determines a path
input path
000 s0 s0 s0 s0
021 s0 s0 s2 s3
120 s0 s1 s1 s3
11 s0 s1 s0
12 s0 s1 s1
This is a
21 s0 s2 s3
22 s0 s2 s0 deterministic finite-
111 s0 s1 s0 s1 state automaton,
110 s0 s1 s0 s0 DFA
212 s0 s2 s3 s3
Which paths
end in an accepting state?
input path
000 s0 s0 s0 s0
021 s0 s0 s2 s3
120 s0 s1 s1 s3
11 s0 s1 s0
12 s0 s1 s1
This is a
21 s0 s2 s3
22 s0 s2 s0 deterministic finite-
111 s0 s1 s0 s1 state automaton,
110 s0 s1 s0 s0 DFA
212 s0 s2 s3 s3
Which paths
end in an accepting state?
input path
0 000 s0 s0 s0 s0
7 021 s0 s0 s2 s3
15 120 s0 s1 s1 s3
4 11 s0 s1 s0
5 12 s0 s1 s1
This is a
7 21 s0 s2 s3
8 22 s0 s2 s0 deterministic finite-
13 111 s0 s1 s0 s1 state automaton,
12 110 s0 s1 s0 s0 DFA
23 212 s0 s2 s3 s3
What is the meaning of each state?
0
This machine counts
1
ternary
2
mod 4
3
4
F(q, s) = 3 * q + s (mod 4)
5
This is a
6
7
deterministic finite-
8 state automaton,
9 DFA