Professional Documents
Culture Documents
In Mathematics…
• An automaton is an abstract machine, ie a mathematical
model.
• In particular, a finite-state machine or finite state automaton,
is a mathematical model of computer hardware and software,
mostly used for compilers (cf. programming languages) and
natural language processing (NLP) and computational
linguistics.
Automaton
Automata Theory:
• Study of abstract computing devices, or
“machines”
• Automaton = an abstract computing
device
Note: A “device” need not even be a
phyasical hardware.
Deterministic Finite State Automata (DFA)
……..
0 1 1 0 0
Finite
Control
• One-way, infinite tape, broken into cells
• One-way, read-only tape head.
• Finite control, i.e.,
– finite number of states, and
– transition rules between them, i.e.,
– a program, containing the position of the read head, current symbol being
scanned, and the current “state.”
• A string is placed on the tape, read head is positioned at the left end,
and the DFA will read the string one symbol at a time until all symbols
have been read. The DFA will then either accept or reject the string.
3
• The finite control can be described by a transition diagram or table:
• Example #1:
0
q0 q1 1
0
1 0 0 1 1
q0 q0 q1 q0 q0 q0
M1 M2 …. M-inf
1 1
q3 q2
1 0 0 0
q0 0 q1 1
1 0 0 1 1
q0 q3 q1 q2 q2 q2 accept string
a a a/b/c
c c
q0 q1 q2
b b
a c c c b accepted
q0 q0 q1 q2 q2 q2
a a c rejected
q0 q0 q0 q1
7
a a a/
q c q c qb/
0 1 2c
b b
Inductive Proof (sketch): that the machine correctly accepts strings with at least two c’s
Proof goes over the length of the string.
Inductive steps: Each case for symbol p, for string xp (|xp| = k+1), the last symbol p = a, b or c
xa xb xc
• A DFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
9
• Revisit example #1:
1
Q = {q0, q1}
Σ = {0, 1} 0
Start state is q0 q0 q1 1
F = {q0} 0
δ:
0 1
q0 q1 q0
q1 q0 q1
10
• Revisit example #2:
a a a/b/c
Q = {q0, q1, q2}
Σ = {a, b, c} c c q
q0 q1
Start state is q0 2
F = {q2} b
b
δ: a b c
q0 q0 q0 q1
q1 q1 q1 q2
q2 q2 q2 q2
• Let M = (Q, Σ, δ,q0,F) be a DFA. Then the language accepted by M is the set:
• Let M1 = (Q1, Σ1, δ1, q0, F1) and M2 = (Q2, Σ2, δ2, p0, F2) be DFAs. Then M1 and
M2 are equivalent iff L(M1) = L(M2).
12
Nondeterministic Finite State
Automata (NFA)
• An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
13
• Example #1: one or more 0’s followed by one or more 1’s
0 1 0/1
Q = {q0, q1, q2}
Σ = {0, 1} 0 1 q
q0 q1
Start state is q0 2
F = {q2}
δ: 0 1
q0
{q0, q1} {}
q1 {} {q1, q2}
{q2} {q2}
q2
14
• Example #2: pair of 0’s or pair of 1’s as substring
0/1 0/1
Q = {q0, q1, q2 , q3 , q4}
Σ = {0, 1} 0 0 q
q0 q3
Start state is q0 4
δ: 0 1 1 q
q1
q0 2
{q0, q3} {q0, q1}
q1 {} {q2}
q2 {q2} {q2}
q3 {q4} {}
{q4} {q4}
q4
15
• Notes:
– δ(q,s) may not be defined for some q and s (what does that mean?)
– δ(q,s) may map to multiple q’s
– A string is said to be accepted if there exists a path from q0 to some state
in F
– A string is rejected if there exist NO path to any state in F
– The language accepted by an NFA is the set of all accepted strings
q0 0 q0 q0 0 q0 1
q3 q3 q1
q4 q4 accepted
0/1 0/1
q 0 q 0 q
0 1 3 40/1
q 1 q
1 2
17
• Another example (010):
q0 0q q0 1 q0 0
0
q3 q1 q3
not accepted
• All paths have been explored, and none lead to an accepting state.
0/1
q 0 q 0 q
0 1 3 4
q 1 q
1 2
18
• Question: Why non-determinism is useful?
– Non-determinism = Backtracking
– Compressed information
– Non-determinism hides backtracking
– Programming languages, e.g., Prolog, hides backtracking => Easy to
program at a higher level: what we want to do, rather than how to do it
– Useful in algorithm complexity study
– Is NDA more “powerful” than DFA, i.e., accepts type of languages that any
DFA cannot?
19
• Let Σ = {a, b, c}. Give an NFA M that accepts:
a/b/c a/b/c
a b q
q0 q1
2
20
• Let Σ = {a, b}. Give an NFA M that accepts:
a/b
b a/b a/b q
q0 q1 q2
3
Is L a subset of L(M)?
Is L(M) a subset of L?
21
Definitions for NFAs
22
Equivalence of DFAs and NFAs
23
• Consider the following DFA: 2 or more c’s
a a a/b/c
Q = {q0, q1, q2}
Σ = {a, b, c} c c q
q0 q1
Start state is q0 2
F = {q2} b
b
δ: a b c
q0 q0 q0 q1
q1 q1 q1 q2
q2 q2 q2 q2
24
• An Equivalent NFA:
a a a/b/c
Q = {q0, q1, q2}
Σ = {a, b, c} c c q
q0 q1
Start state is q0 2
F = {q2} b
b
δ: a b c
q0 {q0} {q0} {q1}
25
• Example of creating a DFA out of an NFA (as per the constructive
proof): 0/1
0
q q1
0 0
-->q0
δ for DFA: 0 1 q1
->q0 {q } {}
1
write as write as
[q1] []
[q1]
[]
26
• Example of creating a DFA out of an NFA (as per the constructive
proof): 0/1
0
q q1
0 0
δ: 0 1
->q0 {q } {}
1
write as
[q1]
{q0,q1} {q1}
[q1] write as
[q01]
[]
[q01]
27
• Example of creating a DFA out of an NFA (as per the constructive
proof): 0/1
0
q q1
0 0
δ: 0 1
->q0 {q } {}
1
write as
[q1]
{q0,q1} {q1}
[q1] write as
[q01]
[] []
[]
[q01]
28