Sie sind auf Seite 1von 22

UNIVERSITY INSTITUTE OF TECHNOLOGY

COMPUTER SCIENCE & ENGINEERING


Bachelor of Engineering (Computer Science & Engineering)-CSBS
FORMAL LANGUAGE AND AUTOMATA THEORY
CSJ-231
Dr. Sheetal Kundra(E7460)

ε-NFA DISCOVER . LEARN . EMPOWER


ε-NFA
Course Outcome
CO Title Level
Number
CO1 Students will be able to understand the powers and Understand
limitations of the language.  
CO2 Students will be able to learn the concepts of Create
unsolvable problems  
CO3 Students will be able to demonstrate and apply the Apply
relationship between various formal languages and
learn the characteristics properties of the languages

2
Contents Outline
• Epsilon NFA
• Closure of states
• Conversion of Epsilon NFA to DFA

3
NFA’s With ε-Transitions
• We can allow state-to-state transitions on ε input.
• These transitions are done spontaneously, without looking at
the input string.
• A convenience at times, but still only regular languages are
accepted.
Formal Definition of ε-NFA

• A finite set of states, typically Q.


• An input alphabet, typically Σ.
• A transition function, typically δ, that takes a state in Q and an input
symbol in Σ U {ε} as argument and return a subset of Q.
• A start state in Q, typically q0.
• A set of final states F ⊆ Q.
Example of NFA’s With ε-Transitions
Closure of States
• CL(q) = set of states you can reach from state q following only
arcs labelled ε.
• Example: CL(A) = {A}; CL(E) = {B, C, D, E}.
• Closure of a set of states = union of the closure of each state.
Equivalence of NFA, ε-NFA
• Every NFA is an ε-NFA. It just has no transitions on ε.
• Converse requires us to take an ε-NFA and construct an NFA
that accepts the same language.
• We do so by combining ε–transitions with the next transition on
a real input.
Equivalence of NFA, ε-NFA
• Start with an ε-NFA with states Q, inputs Σ, start state q0, final
states F, and transition function δE.
• Construct an “ordinary” NFA with states Q, inputs Σ, start state
q0, final states F’, and transition function δN.
• Compute δN(q, a) as follows:
1. Let S = CL(q).
2. δN(q, a) is the union over all p in S of δE(p, a).
• F’ = the set of states q such that CL(q) contains a state of F.
Example of ε-NFA to NFA
Eliminating ε transition ε-NFA to DFA
•Let E=(QE, Σ, δE, q0, FE ) be the ε-NFA . Then equivalent DFA
D =(QD, Σ, δD, qD, FD) is defined as follows:
1.QD is the set of subsets of QE. More precisely, we shall find that all
accessible states of D are ε-closed subsets of QE, that is , sets S is a
subset of QE such that S=ECLOSE(S).
2.qD= ECLOSE(q0 ); that is we get start state of D by closing the set
consisting of only start state of E.
3.FD is those set of states that contain at least one accepting state of E
4.δD (S, a) is computed , for all a in Σ and sets S in QD by:
a.Let S= {p1, p2,…….., pk }
b.Compute ;let this set be {r1, r2,…….., rk }.
c.Then δD (S, a) =ECLOSE({r1, r2,…….., rk }).
Example: ε-NFA to DFA
Example:ε-NFA accepts decimal numbers consisting of:
1. An optional + or – sign
2. A string of digits,
3. A decimal point, and
4. Another string of digits. Either this string of digits, or string in 2 can be empty,
but at least one of the two strings of digits must be non empty.

ε-NFA
ε +,- . 0,1,..........9
q0 {q1} {q1} Ø Ø
q1 Ø Ø {q2} {q1,q4}
q2 Ø Ø Ø {q3}
q3 {q5} Ø Ø {q3}
q4 Ø Ø {q3} Ø
q5 Ø Ø Ø Ø
Example: ε-NFA to DFA

• ECLOSE(q0)={q0,q1}
• ECLOSE(δD ({q0,q1},+))=ECLOSE({q1})={q1}
• ECLOSE(δD ({q0,q1},-))=ECLOSE({q1})={q1}
• ECLOSE(δD ({q0,q1},.))=ECLOSE({q2})={q2}
• ECLOSE(δD ({q0,q1},0..9))=ECLOSE({q1,q4})=
{q1,q4}
Example: ε-NFA to DFA

• ECLOSE(q1)={q1}
• ECLOSE(δD ({q1},+))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q1},-))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q1},.))=ECLOSE({q2})={q2}
• ECLOSE(δD ({q1},0..9))=ECLOSE({q1,q4})=
{q1,q4}
Example: ε-NFA to DFA

• ECLOSE(q2)={q2}
• ECLOSE(δD ({q2},+))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q2},-))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q2},.))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q2},0..9))=ECLOSE({q3})={q3,q5}
Example: ε-NFA to DFA

• ECLOSE({q1,q4})={q1,q4}
• ECLOSE(δD ({q1,q4},+))=ECLOSE(Ø)= Ø
• ECLOSE(δD ({q1,q4},-))=ECLOSE(Ø)= Ø
• ECLOSE(δD ({q1,q4},.))=ECLOSE({q2,q3})
={q2,q3,q5}
• ECLOSE(δD ({q1,q4},0..9))=ECLOSE({q1,q4})=
{q1,q4}
Example: ε-NFA to DFA

• ECLOSE(q3)={q3,q5}
• ECLOSE(δD ({q3,q5},+))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q3,q5},-))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q3,q5},.))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q3,q5},0..9))=ECLOSE({q3})
• ={q3,q5}
Example: ε-NFA to DFA

• ECLOSE({q2,q3,q5})={q2,q3,q5}
• ECLOSE(δD ({q2,q3,q5},+))=ECLOSE(Ø)= Ø
• ECLOSE(δD ({q2,q3,q5},-))=ECLOSE(Ø)= Ø
• ECLOSE(δD ({q2,q3,q5},.))=ECLOSE(Ø)=Ø
• ECLOSE(δD ({q2,q3,q5},0..9))=ECLOSE({q3}) ={q3,q5}
Example: ε-NFA to DFA
+,- . 0..9
{q0,q1} {q1} {q2} {q1,q4}
{q1} Ø {q2} {q1,q4}
{q2} Ø Ø {q3,q5}
{q1,q4} Ø {q2,q3,q5} {q1,q4}
{q3,q5} Ø Ø {q3,q5}
{q2,q3,q5} Ø Ø {q3,q5}
An Application: Text Search
•A common problem in the age of the web and other on-
line text repositories is the following. Given a set of words,
find all documents that contain one (or all) of those words.
E.g. Search engine.

e b
2 3 4
Σ w
1

e 5 6 7 8
b a y
References
• Hopcroft J.E. and Ullman J.D., “Introduction to Automata Theory Languages and Computation”, Narosa Publications.
• https://en.wikipedia.org
• http://www.eecs.wsu.edu/

21
THANK YOU

For queries
Email: sheetal.ait@cumail.in

22

Das könnte Ihnen auch gefallen