1 a single final state for finite accepters. 2 observation any finite accepter (nfa or dfa) can be...
Post on 22-Dec-2015
221 views
TRANSCRIPT
![Page 1: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/1.jpg)
1
A Single Final Statefor Finite Accepters
![Page 2: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/2.jpg)
2
ObservationAny Finite Accepter (NFA or DFA)
can be converted to an equivalent NFA
with a single final state
![Page 3: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/3.jpg)
3
Example
a
b
b
aNFA
Equivalent NFA
a
b
b
a
![Page 4: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/4.jpg)
4
In GeneralNFA
Equivalent NFA
Singlefinal state
![Page 5: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/5.jpg)
5
Extreme Case
NFA without final state
Add a final state
![Page 6: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/6.jpg)
6
Properties of Regular Languages
![Page 7: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/7.jpg)
7
PropertiesTake any regular languages andWe will prove:
1L 2L
21 LL
21LL
*1L
Union:
Concatenation:
Star:Are regularLanguages
Complement:
Intersection: 21 LL
1L
![Page 8: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/8.jpg)
8
We SayRegular Languages are closedclosed:
– Under union:
– Under concatenation:
– Under the star operation:
– Under complement:
– Under intersection:
21 LL
21LL
*1L
21 LL
1L
![Page 9: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/9.jpg)
9
For regular languages and take NFAs and with
1M 2M
22
11
LML
LML
1M 2M
Single final state
1L 2L
![Page 10: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/10.jpg)
10
Example
baL n1
baL 2
a
b
ab
1M
2M
![Page 11: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/11.jpg)
11
UnionNFA for
1M
2M
21 LL
![Page 12: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/12.jpg)
12
Example
a
b
ab
baL n1
baL 2
abbaLL n ,21 NFA for
![Page 13: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/13.jpg)
13
ConcatenationNFA for 21LL
1M 2M
![Page 14: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/14.jpg)
14
Example NFA for
a
b ab
baL n1 baL 2
bbaababaLL nn 21
![Page 15: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/15.jpg)
15
Star OperationNFA for *1L
1M
![Page 16: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/16.jpg)
16
ExampleNFA for *1* baL n
a
b
baL n1
![Page 17: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/17.jpg)
17
ComplementFor the complement of regular language :
Take the DFA that accepts
Construct such that: – Each final state of is nonfinal in nonfinal final
We have:
LL
LM
M M M
LMLML
![Page 18: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/18.jpg)
18
Example
a
b ba,
ba, baL n
a
b ba,
ba, baL n
![Page 19: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/19.jpg)
19
IntersectionFor regular languages and : 1L 2L
21
2121
LL
LLLL
1Lregular
1L
regular
2L 2L
21 LL
regular
21 LL
21 LL regular
regular
![Page 20: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/20.jpg)
20
ExampleRegular languages:
lkbaL 1 babL m2
bbLL m 21The language
0,, mlk
is regular
![Page 21: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/21.jpg)
21
Regular Expressions
![Page 22: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/22.jpg)
22
Regular ExpressionsRegular expressionsare another way of expressing regular languages
Example:
Stands for the language
*)( cba
,...,,,,,*, bcaabcaabcabca
![Page 23: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/23.jpg)
23
Recursive DefinitionRegular Expressions:
• Primitive regular expressions:
• Given regular expressions and
,,
2r1r
11
21
21
*
r
r
rr
rr
Are regular expressions
![Page 24: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/24.jpg)
24
ExamplesA regular expression
Not a regular expression
)(* ccba
ba
![Page 25: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/25.jpg)
25
Languages of Regular Expressions : language of regular expression
Example
rL r
,...,,,,,*)( bcaabcaabcacbaL
![Page 26: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/26.jpg)
26
Definition
For primitive regular expressions:
aaL
L
L
![Page 27: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/27.jpg)
27
Definition (continued)For regular expressions and
1r 2r
11
11
2121
2121
**
rLrL
rLrL
rLrLrrL
rLrLrrL
![Page 28: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/28.jpg)
28
ExampleRegular expression: *aba
*abaL
,...,,,...,,,
,...,,,,
*
*
*
*
baababaaaaaa
aaaaaaba
aba
aLbLaL
aLbaL
aLbaL
![Page 29: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/29.jpg)
29
Example
Regular expression bbabar *
,...,,,,, bbbbaabbaabbarL
![Page 30: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/30.jpg)
30
Example
Regular expression bbbaar **
0,:22 mnbbarL mn
![Page 31: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/31.jpg)
31
Example
Regular expression *)10(00*)10( r
)(rL = { all strings with at least two consecutive 0 }
![Page 32: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/32.jpg)
32
Example
Regular expression )0(*)011( r
)(rL = { all strings without two consecutive 0 }
![Page 33: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/33.jpg)
33
Equivalent Regular Expressions
Definition:
Regular expressions and
are equivalent if
1r 2r
)()( 21 rLrL
![Page 34: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/34.jpg)
34
Example L= { all strings with at least
two consecutive 0 }
)0(*)011(1 r
)0(*1)0(**)011*1(2 r
LrLrL )()( 211r 2rand
are equivalentregular expr.
![Page 35: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/35.jpg)
35
Regular Expressionsand
Regular Languages
![Page 36: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/36.jpg)
36
Theorem
The class of languages described by Regular expressionsis identical to the Regular languages
![Page 37: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/37.jpg)
37
In Other Words
• For any regular expression the language is regular
• For any regular language there is a regular expression with
r
)(rL
L
r LrL )(
![Page 38: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/38.jpg)
38
ProofFirst we prove:
• For any regular expression the language is regular
r)(rL
![Page 39: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/39.jpg)
39
Induction BasisPrimitive Regular Expressions: ,,
NFAs
)()( 1 LML
)(}{)( 2 LML
)(}{)( 3 aLaML
regularlanguages
![Page 40: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/40.jpg)
40
Inductive Hypothesis
Assume for regular expressions andthat and are regular languages
1r 2r
)( 1rL )( 2rL
![Page 41: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/41.jpg)
41
Inductive StepWe will prove that:
1
1
21
21
*
rL
rL
rrL
rrL
Are regular Languages
![Page 42: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/42.jpg)
42
By definition of regular expressions:
11
11
2121
2121
**
rLrL
rLrL
rLrLrrL
rLrLrrL
![Page 43: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/43.jpg)
43
By inductive hypothesis and are regular languages
We know:
)( 1rL )( 2rL
Regular languagesare closed under union concatenation star operation
*1
21
21
rL
rLrL
rLrL
![Page 44: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/44.jpg)
44
Therefore:
** 11
2121
2121
rLrL
rLrLrrL
rLrLrrL
Are regularlanguages
![Page 45: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/45.jpg)
45
And trivially:
))(( 1rL is a regular language
![Page 46: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/46.jpg)
46
Proof - Second PartNow we want to prove:
• For any regular language there is a regular expression with
L
r LrL )(
![Page 47: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/47.jpg)
47
Since is regular take the NFA that accepts it
LM
LML )(
Single final state
![Page 48: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/48.jpg)
48
From Construct the equivalentGeneralized Transition Graph
labels of transitions are regular expressions
M
Example:
a
ba,
cM
a
ba
c
![Page 49: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/49.jpg)
49
Another Example:
ba a
b
b
0q 1q 2q
ba,a
b
b
0q 1q 2q
b
b
![Page 50: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/50.jpg)
50
Reducing the states:
ba a
b
b
0q 1q 2q
b
0q 2q
babb*
)(* babb
![Page 51: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/51.jpg)
51
Resulting Regular Expression:
0q 2q
babb*
)(* babb
*)(**)*( bbabbabbr
LMLrL )()(
![Page 52: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/52.jpg)
52
In GeneralRemoving states:
iq q jqa b
cde
iq jq
dae* bce*dce*
bae*
![Page 53: 1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d7e5503460f94a619f2/html5/thumbnails/53.jpg)
53
Obtaining the final regular expression:
0q fq
1r
2r
3r4r
*)*(* 213421 rrrrrrr
LMLrL )()(