You are on page 1of 17

Theory of Automata –

Introduction
1
Lecture 4
Amna Iftikhar

Amna Iftikhar Spring 23


Week 3

2
Non Deterministic Finite Automata
NFA’s
8 A non-deterministic finite automaton (NFA) over an alphabet Σ is a
finite directed graph with each node having zero or more edges,

8 Each edge is labelled either with a letter from Σ or with .

8 Multiple edges may be emitted from the same node with the same
label.

8 Some letters may not have an edge associated with them. Strings
following such paths are not recognised.
Non-determinism
8 If an edge is labelled with the empty string , then we can travel
the edge without consuming an input letter. Effectively we could
be in either state, and so the possible paths could branch.

8 If there are two edges with the same label, we can take either path.

8 NFA’s recognise a string if any one of its many possible states


following it is a final state

8 Otherwise, it rejects it.


NFA’s versus DFA’s

NFA for a*a :

DFA for a*a :

Why is the top an NFA while the bottom is a DFA?


From a Regular Expression to an ε-NFA
Algorithm: (Thompson's construction):
Input: a regular expression R over alphabet ∑.
Output: NFA N accepting L(R).
1- BASIS
For , construct the NFA
From a Regular Expression to an ε-NFA
2- BASIS
For a in ∑, construct the NFA
From a Regular Expression to an ε-NFA
 3- UNION
 For the regular expression a | b construct the following composite NFA N(a
| b).
From a Regular Expression to an ε-NFA
4- CLOSURE
For the regular expression a* construct the following composite NFA N(a*).
From a Regular Expression to an ε-NFA
 5- CONCATENATION
 RE = (ab)*
From a Regular Expression to an ε-NFA
RE = (a | b)*a
From a Regular Expression to an ε-NFA
RE = a* (a | b)
13 EXAMPLE 1

Convert a(a+b)*b to NFA-ε.


14 EXAMPLE 1

Convert a(a+b)*b to NFA-ε.


15 EXAMPLE 2

Convert aa*bb* to NFA-ε.


16 EXAMPLE 3

Convert a(b*+ba*+(a+b)*)* to NFA-ε.


17

You might also like