Professional Documents
Culture Documents
Lecture 4: NFA
Course Leader:
P.Padma Priya Dharishini
padmapriya.cs.et@msruas.ac.in
1
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Session Objectives
2
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Session Topics
3
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Non Deterministic Automata
4
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
Alphabet = {a}
q1 a q2
a
q0
a
q3
5
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
Alphabet = {a}
Two choices
q1 a q2
a
q0
a
q3
6
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
Alphabet ={a}
Two choices
q1 a q2 No transition
a
q0
a
q3 No transition
7
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a
q1 a q2
a
q0
a
q3
8
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a
q1 a q2
a
q0
a
q3
9
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a
q1 a q2
a
q0
a
q3
10
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a
All input is consumed
q1 a q2 “accept”
a
q0
a
q3
11
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a
q1 a q2
a
q0
a
q3
12
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a
q1 a q2
a
q0
a
q3
13
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a
q1 a q2
a
q0
a
No transition:
q3 the automaton hangs
14
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a
Input cannot be consumed
q1 a q2
a
q0
a
q3 “reject”
15
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
• An NFA accepts a string: When there is a computation of
the NFA that accepts the string
16
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Example
aa is accepted by the NFA:
“accept”
q1 a q2 q1 a q2
a a
q0 q0
a a
q3 q3 “reject”
q1 a q2
a
q0
a
q3
18
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a
q1 a q2
a
q0
a
q3
19
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a
“reject”
q1 a q2
a
q0
a
q3
20
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a
q1 a q2
a
q0
a
q3
21
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a
q1 a q2
a
q0
a
q3
22
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a
q1 a q2
a
q0
a
q3 “reject”
23
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
An NFA rejects a string: When there is no computation of
the NFA that accepts the string
• All the input is consumed and the automaton is in a non
final state
• The input cannot be consumed
24
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Example
a is rejected by the NFA:
“reject”
q1 a q2 a
q1 q2
a a
q0 q0
a a
q3 “reject” q3
a a a
q1 a q2
a
q0
a
q3
26
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a a
q1 a q2
a
q0
a
q3
27
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a a
q1 a q2
a
q0 No transition:
a the automaton hangs
q3
28
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
First Choice
a a a
Input cannot be consumed
q1 a q2 “reject”
a
q0
a
q3
29
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a a
q1 a q2
a
q0
a
q3
30
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a a
q1 a q2
a
q0
a
q3
31
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a a
q1 a q2
a
q0
a
No transition:
q3 the automaton hangs
32
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Second Choice
a a a
Input cannot be consumed
q1 a q2
a
q0
a
q3 “reject”
33
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Nondeterministic Finite Accepter (NFA)
aaa is rejected by the NFA:
“reject”
q1 a q2 q1 a q2
a a
q0 q0
a a
q3 q3 “reject”
q1 a q2
a
q0
a
q3
35
Faculty of Engineering & Technology Ramaiah University of Applied Sciences
Summary
36
Faculty of Engineering & Technology Ramaiah University of Applied Sciences