Ch-2 Equivalence of FA & NFA With - Transition
Ch-2 Equivalence of FA & NFA With - Transition
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Equivalence of DFA and NDFA
NFA with null transition
3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
4
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
p in s
5
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
δD 0 1 δD 0 1
δN 0 1
Ø Ø Ø {q0} {q0,q1} {q0}
q0 {q0,q1} {q0}
{q0} {q0,q1} {q0} {q0,q1} {q0,q1} {q0,q2}
q1 Ø {q2}
{q1} Ø {q2} *{q0,q2} {q0,q1} {q0}
*q2 Ø Ø
*{q2} Ø Ø
0. Enumerate all possible subsets
{q0,q1} {q0,q1} {q0,q2}
1. Determine
*{q0,q2} {q0,q1} {q0}
transitions
2. Retain only those states
*{q1,q2} Ø {q2}
reachable from {q0}
*{q0,q1,q2} {q0,q1} {q0,q2}
6
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
δN 0 1 δD 0 1
q0 {q0,q1} {q0} {q0} {q0,q1} {q0}
q1 Ø {q2} {q0,q1} {q0,q1} {q0,q2}
*q2 Ø Ø *{q0,q2} {q0,q1} {q0}
Main Idea: Introduce
states as you go(on a
need basis)
7
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
8
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Applications
• Text indexing
– inverted indexing
– For each unique word in the database, store all locations
that contain it using an NFA or a DFA
• Find pattern P in text T
– Example: Google querying
• Extensions of this idea:
– PATRICIA tree, suffix tree
10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FA with -Transitions
• We can allow explicit -transitions in finite
automata
– i.e., a transition from one state to another state without
consuming any additional input symbol
– Makes it easier sometimes to construct NFAs
12
University Institute of Engineering (UIE)
Example of an -NFA
0 1
• -closure of a state q,
q0 q1 q2 ECLOSE(q), is the set of
all states (including
start q’0 itself) that can be
δE 0 1
reached from q by
*q’0 Ø Ø {q’0,q0} repeatedly making an
q0 {q0,q1} {q0} {q0} arbitrary number of -
q1 Ø {q2} {q1} transitions.
*q2 Ø Ø {q2}
0 1
Simulate for w=101:
q0 q1 q2
q0’
start q’0
q0’ q0
1 1
δE 0 1
Ø q0
*q’0 Ø Ø {q’0,q0} x 0
ECLOSE(q’0)
q0 {q0,q1} {q0} {q0} q1
ECLOSE(q0) 1
q1 Ø {q2} {q1}
q2
*q2 Ø Ø {q2}
0 1
q0 q1 q2
1
start q’0 q3
δE 0 1
*q’0 Ø Ø {q’0,q0,q3}
q0 {q0,q1} {q0} {q0,q3}
q1 Ø {q2} {q1}
*q2 Ø Ø {q2}
q3 Ø {q2} {q3}
15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• Implication:
– DFA ≡ NFA ≡ -NFA
– (all accept Regular Languages)
16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Eliminating -transitions
Let E = {QE,∑,δE,q0,FE} be an -NFA
Goal: To build DFA D={QD,∑,δD,{qD},FD} s.t. L(D)=L(E)
Construction:
1. QD= all reachable subsets of QE factoring in -closures
2. qD = ECLOSE(q0)
3. FD=subsets S in QD s.t. S∩FE≠Φ
4. δD: for each subset S of QE and for each input symbol a∑:
• Let R= U δE(p,a) // go to destination states
p in s
• δD(S,a) = U ECLOSE(r) // from there, take a union
of all their
-closures r in R
17
University Institute of Engineering (UIE)
Example: -NFA DFA
0 1
q0 q1 q2
start q’0
δE 0 1
δD 0 1
*q’0 Ø Ø {q’0,q0}
*{q’0,q0}
q0 {q0,q1} {q0} {q0}
…
q1 Ø {q2} {q1}
*q2 Ø Ø {q2}
Summary
• Equivalency of DFA & NFA
• Removal of redundant states and including dead states
• -transitions in NFA
• Pigeon hole principles
• Text searching applications
19
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
References
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• http://studentsfocus.com/
• http://www.francisxavier.ac.in/