SlideShare a Scribd company logo
1 of 32
Subset construction algorithm
Input: An NFA 𝑁.
Output: A DFA D accepting the same language.
Method: Algorithm construct a transition table π·π‘‘π‘Ÿπ‘Žπ‘› for D. We use the following operation:
OPERATION DESCRIPTION
οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑠) Set of NFA states reachable from NFA state 𝑠 on
οƒŽβ€“ transition alone.
οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑇) Set of NFA states reachable from some NFA state
𝑠 in 𝑇 on οƒŽβ€“ transition alone.
𝑴𝒐𝒗𝒆 (𝑇, π‘Ž) Set of NFA states to which there is a transition on
input symbol π‘Ž from some NFA state 𝑠 in 𝑇.
Subset construction algorithm
initially οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑠0) be the only state in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  and it is unmarked;
while there is unmarked states T in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  do begin
mark 𝑇;
for each input symbol π‘Ž do begin
π‘ˆ = πœ– βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’ π‘šπ‘œπ‘£π‘’ 𝑇, π‘Ž ;
if π‘ˆ is not in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  then
add π‘ˆ as unmarked state to π·π‘ π‘‘π‘Žπ‘‘π‘’π‘ ;
π·π‘‘π‘Ÿπ‘Žπ‘›[ 𝑇, π‘Ž ] = π‘ˆ
end
end
Conversion from NFA to DFA
1
(a|b)*abb
2
5
3
4
6 7 8 9
0 10
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Conversion from NFA to DFA
1
2
5
3
4
6 7 8 9
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
10
{0, 1, 7, 2, 4}
---- A
πœ–- Closure(0)=
= {0,1,2,4,7}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8 9
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
A= {0, 1, 2, 4, 7}
Move(A,a) = {3,8}
πœ–- Closure(Move(A,a)) = {3, 6, 7, 1, 2, 4, 8}
---- B
= {1,2,3,4,6,7,8}
10
States a b
A = {0,1,2,4,7} B
B = {1,2,3,4,6,7,8}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
A= {0, 1, 2, 4, 7}
Move(A,b) = {5}
πœ–- Closure(Move(A,b)) = {5, 6, 7, 1, 2, 4}
---- C
= {1,2,4,5,6,7}
{5}
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8}
C = {1,2,4,5,6,7}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
B = {1, 2, 3, 4, 6, 7, 8}
Move(B,a) = {3,8}
πœ–- Closure(Move(B,a)) = {3, 6, 7, 1, 2, 4, 8}
---- B
= {1,2,3,4,6,7,8}
b
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B
C = {1,2,4,5,6,7}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
B= {1, 2, 3, 4, 6, 7, 8}
Move(B,b) = {5,9}
πœ–- Closure(Move(B,b)) = {5, 6, 7, 1, 2, 4, 9}
---- D
= {1,2,4,5,6,7,9}
b
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7}
D = {1,2,4,5,6,7,9}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(C,a) = {3,8}
πœ–- Closure(Move(C,a)) = {3, 6, 7, 1, 2, 4, 8}
---- B
= {1,2,3,4,6,7,8}
C= {1, 2, 4, 5, 6 ,7}
b
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B
D = {1,2,4,5,6,7,9}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(C,b) = {5}
πœ–- Closure(Move(C,b))= {5, 6, 7, 1, 2, 4}
---- C
= {1,2,4,5,6,7}
C= {1, 2, 4, 5, 6, 7}
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
D = {1,2,4,5,6,7,9}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(D,a) = {3,8}
πœ–- Closure(Move(D,a)) = {3, 6, 7, 1, 2, 4, 8}
---- B
= {1,2,3,4,6,7,8}
D= {1, 2, 4, 5, 6, 7, 9}
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
D = {1,2,4,5,6,7,9} B
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(D,b) = {5,10}
πœ–- Closure(Move(D,b)) = {5, 6, 7, 1, 2, 4, 10}
---- E
= {1,2,4,5,6,7,10}
D= {1, 2, 4, 5, 6, 7, 9}
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
D = {1,2,4,5,6,7,9} B E
E = {1,2,4,5,6,7,10}
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(E,a) = {3,8}
πœ–- Closure(Move(E,a)) = {3, 6, 7, 1, 2, 4, 8}
---- B
= {1,2,3,4,6,7,8}
E= {1, 2, 4, 5, 6, 7, 10}
10
9
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
D = {1,2,4,5,6,7,9} B E
E = {1,2,4,5,6,7,10} B
Conversion from NFA to DFA
1
2
5
3
4
6 7 8
0
πœ–
a
b
πœ– a b b
πœ–
πœ– πœ–
πœ–
πœ–
πœ–
Move(E,b)= {5}
πœ–- Closure(Move(E,b))= {5,6,7,1,2,4}
---- C
= {1,2,4,5,6,7}
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
E= {1, 2, 4, 5, 6, 7, 10}
D = {1,2,4,5,6,7,9} B E
E = {1,2,4,5,6,7,10} B C
10
9
Conversion from NFA to DFA
A
B
C
a
b
a
b
a
D
E
b
a
b
b
a
Transition Table
DFA
Note:
β€’ Accepting state in NFA is 10
β€’ 10 is element of E
β€’ So, E is acceptance state in DFA
States a b
A = {0,1,2,4,7} B C
B = {1,2,3,4,6,7,8} B D
C = {1,2,4,5,6,7} B C
D = {1,2,4,5,6,7,9} B E
E = {1,2,4,5,6,7,10} B C
DFA optimization
1. Construct an initial partition Ξ  of the set of states with two groups: the
accepting states 𝐹 and the non-accepting states 𝑆 βˆ’ 𝐹.
2. Apply the repartition procedure to Ξ  to construct a new partition Π𝑛𝑒𝑀.
3. If Ξ  𝑛𝑒𝑀 = Ξ , let Ξ π‘“π‘–π‘›π‘Žπ‘™ = Ξ  and continue with step (4). Otherwise, repeat
step (2) with Ξ  = Π𝑛𝑒𝑀.
for each group 𝐺 of Π do begin
partition 𝐺 into subgroups such that two states 𝑠 and 𝑑
of 𝐺 are in the same subgroup if and only if for all
input symbols π‘Ž, states 𝑠 and 𝑑 have transitions on π‘Ž
to states in the same group of Ξ .
replace 𝐺 in Π𝑛𝑒𝑀 by the set of all subgroups formed.
end
DFA optimization
4. Choose one state in each group of the partition Ξ π‘“π‘–π‘›π‘Žπ‘™ as the representative for
that group. The representatives will be the states of 𝑀′. Let s be a
representative state, and suppose on input a there is a transition of 𝑀 from 𝑠 to
𝑑. Let π‘Ÿ be the representative of 𝑑′s group. Then 𝑀′ has a transition from 𝑠 to π‘Ÿ
on π‘Ž. Let the start state of 𝑀′ be the representative of the group containing start
state 𝑠0 of 𝑀, and let the accepting states of 𝑀′ be the representatives that are
in 𝐹.
5. If 𝑀′ has a dead state 𝑑, then remove 𝑑 from 𝑀′. Also remove any state not
reachable from the start state.
DFA optimization
β€’ Now no more splitting is possible.
β€’ If we chose A as the representative for
group (AC), then we obtain reduced
transition table
A B C
B B D
C B C
D B E
E B C
States a b
{𝐴, 𝐡, 𝐢, 𝐷, 𝐸}
Nonaccepting States
{𝐴, 𝐡, 𝐢, 𝐷}
Accepting States
{𝐸}
{𝐴, 𝐡, 𝐢} {𝐷}
{𝐡}
A B A
B B D
D B E
E B A
States a b
Optimized
Transition Table
{𝐴, 𝐢}
Rules to compute nullable, firstpos, lastpos
β€’ nullable(n)
β€’ The subtree at node 𝑛 generates languages including the empty string.
β€’ firstpos(n)
β€’ The set of positions that can match the first symbol of a string generated by the subtree at node 𝑛.
β€’ lastpos(n)
β€’ The set of positions that can match the last symbol of a string generated be the subtree at node 𝑛.
β€’ followpos(i)
β€’ The set of positions that can follow position 𝑖 in the tree.
Rules to compute nullable, firstpos, lastpos
Node n nullable(n) firstpos(n) lastpos(n)
A leaf labeled by ο₯ true βˆ… βˆ…
A leaf with
position 𝐒
false {i} {i}
nullable(c1)
or
nullable(c2)
firstpos(c1)
οƒˆ
firstpos(c2)
lastpos(c1)
οƒˆ
lastpos(c2)
nullable(c1)
and
nullable(c2)
if (nullable(c1))
thenfirstpos(c1) οƒˆ
firstpos(c2)
else firstpos(c1)
if (nullable(c2))
then lastpos(c1) οƒˆ
lastpos(c2)
else lastpos(c2)
true firstpos(c1) lastpos(c1)
|
n
c1 c2
n
βˆ—
n
.
c1 c2
c1
Rules to compute followpos
1. If n is concatenation node with left child c1 and right child c2 and i is a position
in lastpos(c1), then all position in firstpos(c2) are in followpos(i)
2. If n is * node and i is position in lastpos(n), then all position in firstpos(n) are in
followpos(i)
Conversion from regular expression to DFA
π‘Ž 𝑏
|
βˆ—
.
𝟏 𝟐
π‘Ž
.
.
.
𝑏
𝑏
#
(a|b)* abb
πŸ’
πŸ‘
πŸ“
πŸ”
#
Step 2: Nullable node
Here, * is only nullable node
Step 1: Construct Syntax Tree
Conversion from regular expression to DFA
π‘Ž 𝑏
|
βˆ—
.
{1} {2}
{1,2}
{1,2} π‘Ž
{3}
{1,2,3}
.
{4}
{1,2,3}
.
{5}
{1,2,3}
.
{6}
{1,2,3}
𝑏
𝑏
#
Step 3: Calculate firstpos
Firstpos
A leaf with position π’Š = {π’Š}
|
n
c1 c2
firstpos(c1) οƒˆ firstpos(c2)
βˆ—
n
c1
firstpos(c1)
.
n
c1 c2
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
if (nullable(c1))
thenfirstpos(c1) οƒˆ
firstpos(c2)
else firstpos(c1)
Conversion from regular expression to DFA
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 3: Calculate lastpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
Lastpos
A leaf with position π’Š = {π’Š}
|
n
c1 c2
if (nullable(c2)) then
lastpos(c1) οƒˆ lastpos(c2)
else lastpos(c2)
βˆ—
n
c1
lastpos(c1)
.
n
c1 c2
lastpos(c1) οƒˆ lastpos(c2)
Conversion from regular expression to DFA
Position followpos
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 4: Calculate followpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
5 6
{1,2,3} {5}
.
{6} {6}
π’„πŸ π’„πŸ
𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {5}
π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 6
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  5 = 6
Firstpos
Lastpos
Conversion from regular expression to DFA
Position followpos
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 4: Calculate followpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
5 6
{1,2,3} {4}
.
{5} {5}
π’„πŸ π’„πŸ
𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {4}
π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 5
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  4 = 5
4 5
Conversion from regular expression to DFA
Position followpos
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 4: Calculate followpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
5 6
{1,2,3} {3}
.
{4} {4}
π’„πŸ π’„πŸ
𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {3}
π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 4
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  3 = 4
4 5
3 4
Firstpos
Lastpos
Conversion from regular expression to DFA
Position followpos
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 4: Calculate followpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
5 6
{1,2} {1,2}
.
{3} {3}
π’„πŸ π’„πŸ
4 5
3 4
2 3
1 3
Firstpos
Lastpos
𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {1,2}
π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 3
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  1 = 3
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  2 = 3
Conversion from regular expression to DFA
Position followpos
π‘Ž 𝑏
|
βˆ—
.
{1} {1} {2} {2}
{1,2} {1,2}
{1,2} {1,2} π‘Ž
{3} {3}
{1,2,3} {3}
.
{4} {4}
{1,2,3} {4}
.
{5} {5}
{1,2,3} {5}
.
{6} {6}
{1,2,3} {6}
𝑏
𝑏
#
Step 4: Calculate followpos
𝟏 𝟐
πŸ’
πŸ‘
πŸ“
πŸ”
5 6
𝒏
4 5
3 4
2 3
1 3
{1,2} {1,2}
*
1,2,
1,2,
Firstpos
Lastpos
𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑛) = {1,2}
π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑛 = 1,2
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  1 = 1,2
π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  2 = 1,2
Conversion from regular expression to DFA
Initial state = π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  of root = {1,2,3} -----
A
State A
Ξ΄( (1,2,3),a) = followpos(1) U followpos(3)
=(1,2,3) U (4) = {1,2,3,4} ----- B
Ξ΄( (1,2,3),b) = followpos(2)
=(1,2,3) ----- A
Position followpos
5 6
4 5
3 4
2 1,2,3
1 1,2,3
States a b
A={1,2,3} B A
B={1,2,3,4}
Conversion from regular expression to DFA
State B
Ξ΄( (1,2,3,4),a) = followpos(1) U followpos(3)
=(1,2,3) U (4) = {1,2,3,4} ----- B
Ξ΄( (1,2,3,4),b) = followpos(2) U followpos(4)
=(1,2,3) U (5) = {1,2,3,5} ----- C
State C
Ξ΄( (1,2,3,5),a) = followpos(1) U followpos(3)
=(1,2,3) U (4) = {1,2,3,4} ----- B
Ξ΄( (1,2,3,5),b) = followpos(2) U followpos(5)
=(1,2,3) U (6) = {1,2,3,6} ----- D
Position followpos
5 6
4 5
3 4
2 1,2,3
1 1,2,3
States a b
A={1,2,3} B A
B={1,2,3,4} B C
C={1,2,3,5} B D
D={1,2,3,6}
Conversion from regular expression to DFA
State D
Ξ΄( (1,2,3,6),a) = followpos(1) U followpos(3)
=(1,2,3) U (4) = {1,2,3,4} ----- B
Ξ΄( (1,2,3,6),b) = followpos(2)
=(1,2,3) ----- A
Position followpos
5 6
4 5
3 4
2 1,2,3
1 1,2,3
States a b
A={1,2,3} B A
B={1,2,3,4} B C
C={1,2,3,5} B D
D={1,2,3,6} B A
A B C D
a b b
b
a
a
b
a
DFA

More Related Content

Similar to 4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2023.pptx

Atomata assignment 1 solution
Atomata  assignment 1 solutionAtomata  assignment 1 solution
Atomata assignment 1 solutionahsaniftikhar19
Β 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monadskenbot
Β 
Automata theory
Automata theoryAutomata theory
Automata theoryPardeep Vats
Β 
Guaranteeing Consensus in Distriubuted Systems with CRDTs
Guaranteeing Consensus in Distriubuted Systems with CRDTsGuaranteeing Consensus in Distriubuted Systems with CRDTs
Guaranteeing Consensus in Distriubuted Systems with CRDTsSun-Li Beatteay
Β 
1.Determine whether the relation is a function.{(-.docx
1.Determine whether the relation is a function.{(-.docx1.Determine whether the relation is a function.{(-.docx
1.Determine whether the relation is a function.{(-.docxfredellsberry
Β 
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1zukun
Β 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfaAbdul Aziz
Β 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA Rebaz Najeeb
Β 
Skiena algorithm 2007 lecture17 edit distance
Skiena algorithm 2007 lecture17 edit distanceSkiena algorithm 2007 lecture17 edit distance
Skiena algorithm 2007 lecture17 edit distancezukun
Β 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaRushabh2428
Β 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsRushabh2428
Β 
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-eFernandoDanielMamani1
Β 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimizationguest5873b2d
Β 
Ch06
Ch06Ch06
Ch06Hankyo
Β 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
Β 
LexBFS-Minimal VertexSeparators Final Presentation
LexBFS-Minimal VertexSeparators Final PresentationLexBFS-Minimal VertexSeparators Final Presentation
LexBFS-Minimal VertexSeparators Final Presentationnazlitemu
Β 

Similar to 4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2023.pptx (20)

Atomata assignment 1 solution
Atomata  assignment 1 solutionAtomata  assignment 1 solution
Atomata assignment 1 solution
Β 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
Β 
Lex analysis
Lex analysisLex analysis
Lex analysis
Β 
Automata theory
Automata theoryAutomata theory
Automata theory
Β 
Guaranteeing Consensus in Distriubuted Systems with CRDTs
Guaranteeing Consensus in Distriubuted Systems with CRDTsGuaranteeing Consensus in Distriubuted Systems with CRDTs
Guaranteeing Consensus in Distriubuted Systems with CRDTs
Β 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
Β 
1.Determine whether the relation is a function.{(-.docx
1.Determine whether the relation is a function.{(-.docx1.Determine whether the relation is a function.{(-.docx
1.Determine whether the relation is a function.{(-.docx
Β 
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 1
Β 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
Β 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA
Β 
Skiena algorithm 2007 lecture17 edit distance
Skiena algorithm 2007 lecture17 edit distanceSkiena algorithm 2007 lecture17 edit distance
Skiena algorithm 2007 lecture17 edit distance
Β 
Lecture4 lexical analysis2
Lecture4 lexical analysis2Lecture4 lexical analysis2
Lecture4 lexical analysis2
Β 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Β 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
Β 
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
Β 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
Β 
Homework1
Homework1Homework1
Homework1
Β 
Ch06
Ch06Ch06
Ch06
Β 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
Β 
LexBFS-Minimal VertexSeparators Final Presentation
LexBFS-Minimal VertexSeparators Final PresentationLexBFS-Minimal VertexSeparators Final Presentation
LexBFS-Minimal VertexSeparators Final Presentation
Β 

More from venkatapranaykumarGa

9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPT9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPTvenkatapranaykumarGa
Β 
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptxvenkatapranaykumarGa
Β 
10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptxvenkatapranaykumarGa
Β 
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...13-Applications of Syntax Directed Translation - Syntax Directed Translation ...
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...venkatapranaykumarGa
Β 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.pptvenkatapranaykumarGa
Β 
15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdfvenkatapranaykumarGa
Β 
11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docxvenkatapranaykumarGa
Β 
8-Practice problems on operator precedence parser-24-05-2023.docx
8-Practice problems on operator precedence parser-24-05-2023.docx8-Practice problems on operator precedence parser-24-05-2023.docx
8-Practice problems on operator precedence parser-24-05-2023.docxvenkatapranaykumarGa
Β 
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...venkatapranaykumarGa
Β 
6-Practice Problems - LL(1) parser-16-05-2023.pptx
6-Practice Problems - LL(1) parser-16-05-2023.pptx6-Practice Problems - LL(1) parser-16-05-2023.pptx
6-Practice Problems - LL(1) parser-16-05-2023.pptxvenkatapranaykumarGa
Β 
1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptxvenkatapranaykumarGa
Β 
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docxvenkatapranaykumarGa
Β 
7-Operator Precedence Parser-23-05-2023.pptx
7-Operator Precedence Parser-23-05-2023.pptx7-Operator Precedence Parser-23-05-2023.pptx
7-Operator Precedence Parser-23-05-2023.pptxvenkatapranaykumarGa
Β 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
Β 

More from venkatapranaykumarGa (14)

9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPT9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPT
Β 
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
Β 
10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx
Β 
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...13-Applications of Syntax Directed Translation - Syntax Directed Translation ...
13-Applications of Syntax Directed Translation - Syntax Directed Translation ...
Β 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
Β 
15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf
Β 
11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx
Β 
8-Practice problems on operator precedence parser-24-05-2023.docx
8-Practice problems on operator precedence parser-24-05-2023.docx8-Practice problems on operator precedence parser-24-05-2023.docx
8-Practice problems on operator precedence parser-24-05-2023.docx
Β 
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
Β 
6-Practice Problems - LL(1) parser-16-05-2023.pptx
6-Practice Problems - LL(1) parser-16-05-2023.pptx6-Practice Problems - LL(1) parser-16-05-2023.pptx
6-Practice Problems - LL(1) parser-16-05-2023.pptx
Β 
1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx
Β 
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
Β 
7-Operator Precedence Parser-23-05-2023.pptx
7-Operator Precedence Parser-23-05-2023.pptx7-Operator Precedence Parser-23-05-2023.pptx
7-Operator Precedence Parser-23-05-2023.pptx
Β 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
Β 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
Β 
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdfssuser54595a
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
Β 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
Β 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
Β 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
Β 
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈcall girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ9953056974 Low Rate Call Girls In Saket, Delhi NCR
Β 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
Β 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
Β 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
Β 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
Β 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
Β 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Β 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
Β 
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAΠ‘Y_INDEX-DM_23-1-final-eng.pdf
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
Β 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
Β 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Β 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
Β 
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈcall girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
Β 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
Β 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
Β 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Β 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
Β 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Β 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Β 

4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2023.pptx

  • 1. Subset construction algorithm Input: An NFA 𝑁. Output: A DFA D accepting the same language. Method: Algorithm construct a transition table π·π‘‘π‘Ÿπ‘Žπ‘› for D. We use the following operation: OPERATION DESCRIPTION οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑠) Set of NFA states reachable from NFA state 𝑠 on οƒŽβ€“ transition alone. οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑇) Set of NFA states reachable from some NFA state 𝑠 in 𝑇 on οƒŽβ€“ transition alone. 𝑴𝒐𝒗𝒆 (𝑇, π‘Ž) Set of NFA states to which there is a transition on input symbol π‘Ž from some NFA state 𝑠 in 𝑇.
  • 2. Subset construction algorithm initially οƒŽ βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’(𝑠0) be the only state in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  and it is unmarked; while there is unmarked states T in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  do begin mark 𝑇; for each input symbol π‘Ž do begin π‘ˆ = πœ– βˆ’ π‘π‘™π‘œπ‘ π‘’π‘Ÿπ‘’ π‘šπ‘œπ‘£π‘’ 𝑇, π‘Ž ; if π‘ˆ is not in π·π‘ π‘‘π‘Žπ‘‘π‘’π‘  then add π‘ˆ as unmarked state to π·π‘ π‘‘π‘Žπ‘‘π‘’π‘ ; π·π‘‘π‘Ÿπ‘Žπ‘›[ 𝑇, π‘Ž ] = π‘ˆ end end
  • 3. Conversion from NFA to DFA 1 (a|b)*abb 2 5 3 4 6 7 8 9 0 10 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ–
  • 4. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 9 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– 10 {0, 1, 7, 2, 4} ---- A πœ–- Closure(0)= = {0,1,2,4,7}
  • 5. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 9 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– A= {0, 1, 2, 4, 7} Move(A,a) = {3,8} πœ–- Closure(Move(A,a)) = {3, 6, 7, 1, 2, 4, 8} ---- B = {1,2,3,4,6,7,8} 10 States a b A = {0,1,2,4,7} B B = {1,2,3,4,6,7,8}
  • 6. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– A= {0, 1, 2, 4, 7} Move(A,b) = {5} πœ–- Closure(Move(A,b)) = {5, 6, 7, 1, 2, 4} ---- C = {1,2,4,5,6,7} {5} 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} C = {1,2,4,5,6,7}
  • 7. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b πœ– πœ– πœ– πœ– πœ– πœ– B = {1, 2, 3, 4, 6, 7, 8} Move(B,a) = {3,8} πœ–- Closure(Move(B,a)) = {3, 6, 7, 1, 2, 4, 8} ---- B = {1,2,3,4,6,7,8} b 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B C = {1,2,4,5,6,7}
  • 8. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b πœ– πœ– πœ– πœ– πœ– πœ– B= {1, 2, 3, 4, 6, 7, 8} Move(B,b) = {5,9} πœ–- Closure(Move(B,b)) = {5, 6, 7, 1, 2, 4, 9} ---- D = {1,2,4,5,6,7,9} b 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} D = {1,2,4,5,6,7,9}
  • 9. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b πœ– πœ– πœ– πœ– πœ– πœ– Move(C,a) = {3,8} πœ–- Closure(Move(C,a)) = {3, 6, 7, 1, 2, 4, 8} ---- B = {1,2,3,4,6,7,8} C= {1, 2, 4, 5, 6 ,7} b 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B D = {1,2,4,5,6,7,9}
  • 10. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– Move(C,b) = {5} πœ–- Closure(Move(C,b))= {5, 6, 7, 1, 2, 4} ---- C = {1,2,4,5,6,7} C= {1, 2, 4, 5, 6, 7} 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C D = {1,2,4,5,6,7,9}
  • 11. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– Move(D,a) = {3,8} πœ–- Closure(Move(D,a)) = {3, 6, 7, 1, 2, 4, 8} ---- B = {1,2,3,4,6,7,8} D= {1, 2, 4, 5, 6, 7, 9} 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C D = {1,2,4,5,6,7,9} B
  • 12. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– Move(D,b) = {5,10} πœ–- Closure(Move(D,b)) = {5, 6, 7, 1, 2, 4, 10} ---- E = {1,2,4,5,6,7,10} D= {1, 2, 4, 5, 6, 7, 9} 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C D = {1,2,4,5,6,7,9} B E E = {1,2,4,5,6,7,10}
  • 13. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– Move(E,a) = {3,8} πœ–- Closure(Move(E,a)) = {3, 6, 7, 1, 2, 4, 8} ---- B = {1,2,3,4,6,7,8} E= {1, 2, 4, 5, 6, 7, 10} 10 9 States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C D = {1,2,4,5,6,7,9} B E E = {1,2,4,5,6,7,10} B
  • 14. Conversion from NFA to DFA 1 2 5 3 4 6 7 8 0 πœ– a b πœ– a b b πœ– πœ– πœ– πœ– πœ– πœ– Move(E,b)= {5} πœ–- Closure(Move(E,b))= {5,6,7,1,2,4} ---- C = {1,2,4,5,6,7} States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C E= {1, 2, 4, 5, 6, 7, 10} D = {1,2,4,5,6,7,9} B E E = {1,2,4,5,6,7,10} B C 10 9
  • 15. Conversion from NFA to DFA A B C a b a b a D E b a b b a Transition Table DFA Note: β€’ Accepting state in NFA is 10 β€’ 10 is element of E β€’ So, E is acceptance state in DFA States a b A = {0,1,2,4,7} B C B = {1,2,3,4,6,7,8} B D C = {1,2,4,5,6,7} B C D = {1,2,4,5,6,7,9} B E E = {1,2,4,5,6,7,10} B C
  • 16. DFA optimization 1. Construct an initial partition Ξ  of the set of states with two groups: the accepting states 𝐹 and the non-accepting states 𝑆 βˆ’ 𝐹. 2. Apply the repartition procedure to Ξ  to construct a new partition Π𝑛𝑒𝑀. 3. If Ξ  𝑛𝑒𝑀 = Ξ , let Ξ π‘“π‘–π‘›π‘Žπ‘™ = Ξ  and continue with step (4). Otherwise, repeat step (2) with Ξ  = Π𝑛𝑒𝑀. for each group 𝐺 of Ξ  do begin partition 𝐺 into subgroups such that two states 𝑠 and 𝑑 of 𝐺 are in the same subgroup if and only if for all input symbols π‘Ž, states 𝑠 and 𝑑 have transitions on π‘Ž to states in the same group of Ξ . replace 𝐺 in Π𝑛𝑒𝑀 by the set of all subgroups formed. end
  • 17. DFA optimization 4. Choose one state in each group of the partition Ξ π‘“π‘–π‘›π‘Žπ‘™ as the representative for that group. The representatives will be the states of 𝑀′. Let s be a representative state, and suppose on input a there is a transition of 𝑀 from 𝑠 to 𝑑. Let π‘Ÿ be the representative of 𝑑′s group. Then 𝑀′ has a transition from 𝑠 to π‘Ÿ on π‘Ž. Let the start state of 𝑀′ be the representative of the group containing start state 𝑠0 of 𝑀, and let the accepting states of 𝑀′ be the representatives that are in 𝐹. 5. If 𝑀′ has a dead state 𝑑, then remove 𝑑 from 𝑀′. Also remove any state not reachable from the start state.
  • 18. DFA optimization β€’ Now no more splitting is possible. β€’ If we chose A as the representative for group (AC), then we obtain reduced transition table A B C B B D C B C D B E E B C States a b {𝐴, 𝐡, 𝐢, 𝐷, 𝐸} Nonaccepting States {𝐴, 𝐡, 𝐢, 𝐷} Accepting States {𝐸} {𝐴, 𝐡, 𝐢} {𝐷} {𝐡} A B A B B D D B E E B A States a b Optimized Transition Table {𝐴, 𝐢}
  • 19. Rules to compute nullable, firstpos, lastpos β€’ nullable(n) β€’ The subtree at node 𝑛 generates languages including the empty string. β€’ firstpos(n) β€’ The set of positions that can match the first symbol of a string generated by the subtree at node 𝑛. β€’ lastpos(n) β€’ The set of positions that can match the last symbol of a string generated be the subtree at node 𝑛. β€’ followpos(i) β€’ The set of positions that can follow position 𝑖 in the tree.
  • 20. Rules to compute nullable, firstpos, lastpos Node n nullable(n) firstpos(n) lastpos(n) A leaf labeled by ο₯ true βˆ… βˆ… A leaf with position 𝐒 false {i} {i} nullable(c1) or nullable(c2) firstpos(c1) οƒˆ firstpos(c2) lastpos(c1) οƒˆ lastpos(c2) nullable(c1) and nullable(c2) if (nullable(c1)) thenfirstpos(c1) οƒˆ firstpos(c2) else firstpos(c1) if (nullable(c2)) then lastpos(c1) οƒˆ lastpos(c2) else lastpos(c2) true firstpos(c1) lastpos(c1) | n c1 c2 n βˆ— n . c1 c2 c1
  • 21. Rules to compute followpos 1. If n is concatenation node with left child c1 and right child c2 and i is a position in lastpos(c1), then all position in firstpos(c2) are in followpos(i) 2. If n is * node and i is position in lastpos(n), then all position in firstpos(n) are in followpos(i)
  • 22. Conversion from regular expression to DFA π‘Ž 𝑏 | βˆ— . 𝟏 𝟐 π‘Ž . . . 𝑏 𝑏 # (a|b)* abb πŸ’ πŸ‘ πŸ“ πŸ” # Step 2: Nullable node Here, * is only nullable node Step 1: Construct Syntax Tree
  • 23. Conversion from regular expression to DFA π‘Ž 𝑏 | βˆ— . {1} {2} {1,2} {1,2} π‘Ž {3} {1,2,3} . {4} {1,2,3} . {5} {1,2,3} . {6} {1,2,3} 𝑏 𝑏 # Step 3: Calculate firstpos Firstpos A leaf with position π’Š = {π’Š} | n c1 c2 firstpos(c1) οƒˆ firstpos(c2) βˆ— n c1 firstpos(c1) . n c1 c2 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” if (nullable(c1)) thenfirstpos(c1) οƒˆ firstpos(c2) else firstpos(c1)
  • 24. Conversion from regular expression to DFA π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 3: Calculate lastpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” Lastpos A leaf with position π’Š = {π’Š} | n c1 c2 if (nullable(c2)) then lastpos(c1) οƒˆ lastpos(c2) else lastpos(c2) βˆ— n c1 lastpos(c1) . n c1 c2 lastpos(c1) οƒˆ lastpos(c2)
  • 25. Conversion from regular expression to DFA Position followpos π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 4: Calculate followpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” 5 6 {1,2,3} {5} . {6} {6} π’„πŸ π’„πŸ 𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {5} π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 6 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  5 = 6 Firstpos Lastpos
  • 26. Conversion from regular expression to DFA Position followpos π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 4: Calculate followpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” 5 6 {1,2,3} {4} . {5} {5} π’„πŸ π’„πŸ 𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {4} π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 5 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  4 = 5 4 5
  • 27. Conversion from regular expression to DFA Position followpos π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 4: Calculate followpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” 5 6 {1,2,3} {3} . {4} {4} π’„πŸ π’„πŸ 𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {3} π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 4 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  3 = 4 4 5 3 4 Firstpos Lastpos
  • 28. Conversion from regular expression to DFA Position followpos π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 4: Calculate followpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” 5 6 {1,2} {1,2} . {3} {3} π’„πŸ π’„πŸ 4 5 3 4 2 3 1 3 Firstpos Lastpos 𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑐1) = {1,2} π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑐2 = 3 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  1 = 3 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  2 = 3
  • 29. Conversion from regular expression to DFA Position followpos π‘Ž 𝑏 | βˆ— . {1} {1} {2} {2} {1,2} {1,2} {1,2} {1,2} π‘Ž {3} {3} {1,2,3} {3} . {4} {4} {1,2,3} {4} . {5} {5} {1,2,3} {5} . {6} {6} {1,2,3} {6} 𝑏 𝑏 # Step 4: Calculate followpos 𝟏 𝟐 πŸ’ πŸ‘ πŸ“ πŸ” 5 6 𝒏 4 5 3 4 2 3 1 3 {1,2} {1,2} * 1,2, 1,2, Firstpos Lastpos 𝑖 = π‘™π‘Žπ‘ π‘‘π‘π‘œπ‘ (𝑛) = {1,2} π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  𝑛 = 1,2 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  1 = 1,2 π‘“π‘œπ‘™π‘™π‘œπ‘€π‘π‘œπ‘  2 = 1,2
  • 30. Conversion from regular expression to DFA Initial state = π‘“π‘–π‘Ÿπ‘ π‘‘π‘π‘œπ‘  of root = {1,2,3} ----- A State A Ξ΄( (1,2,3),a) = followpos(1) U followpos(3) =(1,2,3) U (4) = {1,2,3,4} ----- B Ξ΄( (1,2,3),b) = followpos(2) =(1,2,3) ----- A Position followpos 5 6 4 5 3 4 2 1,2,3 1 1,2,3 States a b A={1,2,3} B A B={1,2,3,4}
  • 31. Conversion from regular expression to DFA State B Ξ΄( (1,2,3,4),a) = followpos(1) U followpos(3) =(1,2,3) U (4) = {1,2,3,4} ----- B Ξ΄( (1,2,3,4),b) = followpos(2) U followpos(4) =(1,2,3) U (5) = {1,2,3,5} ----- C State C Ξ΄( (1,2,3,5),a) = followpos(1) U followpos(3) =(1,2,3) U (4) = {1,2,3,4} ----- B Ξ΄( (1,2,3,5),b) = followpos(2) U followpos(5) =(1,2,3) U (6) = {1,2,3,6} ----- D Position followpos 5 6 4 5 3 4 2 1,2,3 1 1,2,3 States a b A={1,2,3} B A B={1,2,3,4} B C C={1,2,3,5} B D D={1,2,3,6}
  • 32. Conversion from regular expression to DFA State D Ξ΄( (1,2,3,6),a) = followpos(1) U followpos(3) =(1,2,3) U (4) = {1,2,3,4} ----- B Ξ΄( (1,2,3,6),b) = followpos(2) =(1,2,3) ----- A Position followpos 5 6 4 5 3 4 2 1,2,3 1 1,2,3 States a b A={1,2,3} B A B={1,2,3,4} B C C={1,2,3,5} B D D={1,2,3,6} B A A B C D a b b b a a b a DFA