View
33
Download
0
Category
Tags:
Preview:
DESCRIPTION
NFAs accept the Regular Languages. Equivalence of Machines. Definition: Machine is equivalent to machine if. Example of equivalent machines. NFA. DFA. Theorem:. Languages accepted by NFAs. Regular Languages. Languages accepted by DFAs. - PowerPoint PPT Presentation
Citation preview
Prof. Busch - LSU 1
NFAs accept the Regular Languages
Prof. Busch - LSU 2
Equivalence of Machines
Definition:
Machine is equivalent to machine
if
1M 2M
21 MLML
Prof. Busch - LSU 3
0q 1q
0
1
0q 1q 2q
0
11
0
1,0
NFA
DFA
*}10{1 ML
*}10{2 ML
1M
2M
Example of equivalent machines
Prof. Busch - LSU 4
Theorem:
Languages acceptedby NFAs
RegularLanguages
NFAs and DFAs have the same computation power,accept the same set of languages
Languages acceptedby DFAs
Prof. Busch - LSU 5
Languages acceptedby NFAs
RegularLanguages
Languages acceptedby NFAs
RegularLanguages
we only need to showProof:
AND
Prof. Busch - LSU 6
Languages acceptedby NFAs
RegularLanguages
Proof-Step 1
Every DFA is trivially an NFA
Any language accepted by a DFAis also accepted by an NFA
L
Prof. Busch - LSU 7
Languages acceptedby NFAs
RegularLanguages
Proof-Step 2
Any NFA can be converted to anequivalent DFA
Any language accepted by an NFAis also accepted by a DFA
L
Prof. Busch - LSU 8
Conversion NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q
M
M
Prof. Busch - LSU 9
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
M
M
},{),( 210* qqaq
Prof. Busch - LSU 10
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
M
M
),( 0* bq empty set
trap state
Prof. Busch - LSU 11
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
a
M
M
},{),( 211* qqaq
),( 2* aq
21,qq
union
Prof. Busch - LSU 12
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
M
M
}{),( 01* qbq
}{),( 02* qbq
0q
union
Prof. Busch - LSU 13
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
trap state
Prof. Busch - LSU 14
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
END OF CONSTRUCTION
Fq 1
Fqq 21,
Prof. Busch - LSU 15
General Conversion Procedure
Input: an NFA
Output: an equivalent DFAwith
M
M )(MLML
Prof. Busch - LSU 16
The NFA has states
The DFA has states from the power set
,...,, 210 qqq
....,,,,,,,, 3211010 qqqqqqq
Prof. Busch - LSU 17
1. Initial state of NFA:
Initial state of DFA:
0q
,, 00* qq
Conversion Procedure Steps
step
,0q
Prof. Busch - LSU 18
a
b
a
0q 1q 2q
NFA
DFA
0q
M
M
Example 00* , qq
Prof. Busch - LSU 19
2. For every DFA’s state
compute in the NFA
add transition to DFA
},...,,{ mji qqq
aq
aq
aq
m
j
i
,*
...
,*
,*
},...,,{ nlk qqq
},...,,{},,...,,{ nlkmji qqqaqqq
Union
step
Prof. Busch - LSU 20
a
b
a
0q 1q 2q
NFA
0q 21,qqa
DFA
},{),(* 210 qqaq
210 ,, qqaq
M
M
Example
Prof. Busch - LSU 21
3. Repeat Step 2 for every state in DFA and symbols in alphabet until no more states can be added in the DFA
step
Prof. Busch - LSU 22
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
Example
Prof. Busch - LSU 23
4. For any DFA state
if some is accepting state in NFA
Then, is accepting state in DFA
},...,,{ mji qqq
jq
},...,,{ mji qqq
step
Prof. Busch - LSU 24
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
Fq 1
Fqq 21,
M
M
Example
Prof. Busch - LSU 25
If we convert NFA to DFAthen the two automata are equivalent:
M
MLML
M Lemma:
Proof:
MLML
MLML AND
We only need to show:
Prof. Busch - LSU 26
MLML First we show:
)(MLw
We only need to prove:
)(MLw
Prof. Busch - LSU 27
)(MLw
w
kw 21
0q fq
0q fq1 2 k
symbols
Consider
NFA
Prof. Busch - LSU 28
i
i
denotes a possible sub-path like
iq jq
iq jq
symbol
symbol
Prof. Busch - LSU 29
0q fq
kw 211 2 k
:M
},{ 0 q
1 2 k:M
},{ fq
)(MLw
)(MLw
We will show that if
then
NFA
DFA
state label
state label
Prof. Busch - LSU 30
0q mq
naaav 211a 2a na:M
1a 2a na:M },{ iq
iq jq lq
},{ jq },{ lq },{ mq
More generally, we will show that if in :M
(arbitrary string)
then
NFA
DFA},{ 0 q
Prof. Busch - LSU 31
0q 1a:M
1a:M },{ iq
iq
Proof by induction on
Induction Basis: 1av
|| v
is true by construction of M
NFA
DFA
1|| v
},{ 0 q
Prof. Busch - LSU 32
Induction hypothesis: kv ||1
0q dq1a 2a ka:M iq jq cq
1a 2a ka:M },{ iq },{ jq },{ cq },{ dq
kaaav 21
NFA
DFA
Suppose that the following hold
},{ 0 q
Prof. Busch - LSU 33
Induction Step: 1|| kv
0q dq1a 2a ka:M iq jq cq
1a 2a ka:M },{ iq },{ jq },{ cq },{ dq
1121
kk
v
k avaaaav
v
v
eq1ka
1ka
},{ eq
NFA
DFA
Then this is true by construction ofM
},{ 0 q
Prof. Busch - LSU 34
0q fq
kw 211 2 k
:M
1 2 k:M
},{ fq
)(MLw
)(MLw
Therefore if
NFA
DFA
then
},{ 0 q
Prof. Busch - LSU 35
We have shown: MLML
With a similar proof we can show: MLML
END OF LEMMA PROOF
MLML Therefore:
Recommended