Lecture 2 - A 28022024 031156pm
Lecture 2 - A 28022024 031156pm
1 qj
qi … • Each transition function therefore
1 maps to a set of states
qk
4
Example
Example
w = 010110
Example
w = 010110
Non-deterministic Finite Automata (NFA)
• A Non-deterministic Finite Automaton (NFA) consists
of:
– Q ==> a finite set of states
– ∑ ==> a finite set of input symbols (alphabet)
– q0 ==> a start state
– F ==> set of accepting states
– δ ==> a transition function, which is a mapping between Q
x ∑ ==> subset of Q
• An NFA is also defined by the 5-tuple:
– {Q, ∑ , q0,F, δ }
9
How to use an NFA?
• Input: a word w in ∑*
• Question: Is w acceptable by the NFA?
• Steps:
– Start at the “start state” q0
– For every input symbol in the sequence w do
• Determine all possible next states from all current states, given the
current input symbol in w and the transition function
– If after all symbols in w are consumed and if at least one of the current
states is a final state then accept w;
– Otherwise, reject w.
10
NFA for strings containing 01
12
Class Activity
• Build an NFA for the following language:
L = { w | w contains a 1 on its 3rd last
position}
• Provide formal specification and transition
table as well.
13
Language of an NFA
• An NFA accepts w if there exists at least one
path from the start state to an accepting (or
final) state that is labeled by w
• L(N) = { w | δ(q0,w) ∩ F ≠ Φ }
14
References
• Book Chapter 2
• Lectures from Stanford University
– http://infolab.stanford.edu/~ullman/ialc/spr10/sp
r10.html#LECTURE%20NOTES
• Lectures from Washington State University
– http://www.eecs.wsu.edu/~ananth/CptS317/Lect
ures/