Transcript Lecture 19

Lecture 19
• NFA’s
– nondeterministic transition functions
• computations are trees, not paths
– L(M) and LNFA
• LFSA subset of LNFA
– Comparing computational models
1
Nondeterministic Finite State
Automata
NFA’s
2
Change: d is a relation
• For an FSA M, d(q,a) results in one and
only one state for all states q and characters
a.
– That is, d is a function
• For an NFA M, d(q,a) can result in a set of
states
– That is, d is now a relation
– Next step is not determined (nondeterministic)
3
Example NFA
a,b
a,b
a
a
b
a
•Why is this only an NFA and not an FSA?
•Out of the first state, there are 2 transitions on a
•Out of the second state, there are 0 transitions on b
•Out of the third state, there are 0 transitions on a
•Out of the fourth state, there are 0 transitions on b
4
Computing with NFA’s
• Configurations: same as they are for FSA’s
• Computations are different
– Initial configuration is identical
– However, there may be several next configurations or
there may be none.
• Computation is no longer a “path” but is now a “graph” (often
a tree) rooted at the initial configuration
– Definition of halting, accepting, and rejecting
configurations is identical
– Definition of acceptance must be modified
5
a,b
Computation
Graph (Tree)
a,b
a
a
b
a
Input string aaaaba
(1, aaaaba)
(1, aaaba)
(2, aaaba)
(1, aaba)
(2, aaba)
(3, aaba)
(1, aba)
(2, aba)
(3, aba)
(1, ba)
(2, ba)
(1, a)
(1, l)
crash
(3, ba)
(4, a)
(2, l)
(5, l)
6
a,b
Definition of |unchanged
a
a
b
a
Input string aaaaba
(1, aaaaba)
(1, aaaba)
a,b
(1, aaaaba) |- (1, aaaba)
(1, aaaaba) |- (2, aaaba)
(2, aaaba)
(1, aaaaba) |-3 (1, aba)
(1, aaba)
(2, aaba)
(3, aaba)
(1, aaaaba) |-3 (3, aba)
(1, aaaaba) |-* (2, aba)
(1, aba)
(2, aba)
(1, ba)
(2, ba)
(3, aba)
crash
(1, aaaaba) |-* (3, aba)
(1, aaaaba) |-* (1, l)
(3, ba)
(1, aaaaba) |-* (5, l)
(1, a)
(1, l)
(4, a)
(2, l)
(5, l)
7
a,b
a
Acceptance and
Rejection
(1, aaba)
(1, aba)
(2, aba)
(1, ba)
(2, ba)
(1, a)
(1, l)
b
a
M accepts string x if one of the
configurations reached is an
accepting configuration
(2, aaaba)
(2, aaba)
a
Input string aaaaba
(1, aaaaba)
(1, aaaba)
a,b
(q0, x) |-* (f, l),f in A
(3, aaba)
(3, aba)
crash
(3, ba)
M rejects string x if all
configurations reached are
either not halting
configurations or are rejecting
configurations
(4, a)
(2, l)
(5, l)
8
Comparison
b
a
a
a
a,b
b
a
b
b
FSA
a,b
a,b
a
a
b
a
NFA
9
Defining L(M) and LNFA
• M accepts string x if one
of the configurations
reached is an accepting
configuration
– (q0, x) |-* (f, l),f in A
• M rejects string x if all
configurations reached are
either not halting
configurations or are
rejecting configurations
• L(M) (or Y(M))
– The set of strings accepted by M
• N(M)
– The set of strings rejected by M
• LNFA
– Language L is in language class
LNFA iff there exists an NFA M
such that L(M) = L
10
Comparing language classes
LFSA subset of LNFA
11
LFSA subset LNFA
• Let L be an arbitrary language in LFSA
• Let M be the FSA such that L(M) = L
– M exists by definition of L in LFSA
•
•
•
•
Construct an NFA M’ such that L(M’) = L
Argue L(M’) = L
There exists an NFA M’ such that L(M’) = L
L is in LNFA
– By definition of L in LNFA
12
Visualization
•Let L be an arbitrary language in LFSA
•Let M be an FSA such that L(M) = L
•M exists by definition of L in LFSA
•Construct NFA M’ from FSA M
•Argue L(M’) = L
•There exists an NFA M’ such that L(M’)
=L
•L is in LNFA
L
LFSA
M
FSA’s
L
LNFA
M’
NFA’s
13
Construction
• We need to make M into an NFA M’ such
that L(M’) = L(M)
• How do we accomplish this?
– Trivial
– Every FSA already IS an NFA
14