Beruflich Dokumente
Kultur Dokumente
By…
Sukanta behera
Reg. No.
07SBSCA048
OUTLINE
INTRODUCTION
DFA
NFA WITH ε- MOVES
REGULAR EXPRESSION
DFA FROM R.E
NFA FROM R.E
INTRODUCTION
A Finite automaton is a mathematical
model of a with discrete inputs and
outputs
E.g.: A switch circuit
1
q0 q
1
0
A finite automaton(FA) consists of a finite
set of states and a set of transistors from
one state to another state that occur on
an input symbol from alphabet ‘Z’.
Deterministic Finite
Automata(DFA)
For each input symbol there is exactly one
transition out of each state such a finite
automaton is otherwise called Deterministic
Finite Automata(DFA).
We formally define a finite automata by a 5-
tuple represented as
M=[Q,Σ,δ,q0,F] where
Q is a finite set of states
Σ is a finite input alphabet.
q0 in Q is the initial state
F C Q : where F is a set of final states; and
δ is the transition function that maps QXΣ to
Q.
NONDETERMINISTIC FINITE
AUTOMATON WITH ε-MOVES
This NFA is modeled to include transitions on
the empty input ‘ε’.
Nondeterministic finite automaton with ε-
moves is defined to be a
quintuple(Q,Σ,δ,q0,F) where Q is a set of
states
Σ is a set of input symbols
q0 is the initial state
F is the Final state
The difference lies only in δ1 the transition
function that maps QX(ΣU{ε}) to 2^Q
i.e; δ(q,a) will consists of a set of states P
such that there is a transition labeled ‘a’ from
q to p where ‘a’ is either ‘ε’ or a symbol in Σ.
REGULAR EXPRESSION
The language accepted by finite
automata can be simple expressions
called regular expressions
The union of two languages L and M ,
denoted LUM, is the set of strings that
are in either L or M or both.
The concatenation of languages L and M
is the set of strings that can be formed by
taking any string in L and concatenating it
with any string in M.
The closure (or star, or Kleene closure) of
a language L is denoted L* and represent
the set of those strings that can be
formed by taking any number of strings
More Regular Expressions
All strings of 1s and 0s ending in a 1
( 0 | 1 )* 1
Cons → (b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|
z)
Cons* a Cons* e Cons* i Cons* o Cons* u Cons*
Construction
Key idea
NFA pattern for each symbol & each operator
Join them with ε moves in precedence order
a
S0 S1 a ε b
S0 S1 S3 S4
NFA for
a NFA for ab
S1
a
S2 ε
ε ε
S0 S5 S0 ε S1
a
S3 ε S4
ε b ε ε
S3 S4
NFA for a*
NFA for a | b
Example of Construction
Let’s try a ( b | c )*
1. a, b, & c
a b c
S0 S1 S0 S1 S0 S1
2. b | c S1
b
S2
ε ε
S0 S5
ε c ε
S3 S4
3. ( b | c )* ε S2
b
S3 ε
S0 ε S1 S6 ε S7
ε c ε
S4 S5
ε
Example of Construction
(con’t)
4. a ( b | c )* ε
b
ε S4 S5 ε
S0
a
S1 ε ε ε
S2 S3 S8 S9
ε c ε
S6 S7
ε
a
S0 S1
with Subset
NFA →DFA
Construction
Need to build a simulation of the NFA
The algorithm:
Start state derived from s0 of the NFA
Take its ε-closure S0 = ε-closure(s0)
Take the image of S0, Move(S0, α) for each α
∈ Σ, and take its ε-closure
Iterate until no more states are added
NFA →DFA with Subset Construction
a ( b | c )* :
b q5
ε q4 ε
q0 a q1 ε q2 ε q3 q8 ε q9
ε q6 c q7 ε
ε
Final states
with Subset
NFA →DFA
Construction
The DFA for a ( b | c )*
b
δ a b c
s2
b s0 s1 - -
a
s0 s1 b c s1 - s2 s3
c s2 - s2 s3
s3
c
s3 - s2 s3