Presentation is loading. Please wait.

Presentation is loading. Please wait.

Converting Reg. Exps. To -NFAs: An Example

Similar presentations


Presentation on theme: "Converting Reg. Exps. To -NFAs: An Example"— Presentation transcript:

1 Converting Reg. Exps. To -NFAs: An Example
a•b+c* a b •  L ¢  c a b c c 004-01

2 What is Rijk ? In any DFA, xRijk  *(qi,x)=qj with the following properties: A similar relation holds also for –NFAs. 1) Whole x is consumed on the path going out of qi and entering qj ,and 2) The suffix of any state on the path (except for qi and qj) is at most k. •  L ¢  x qi qj 004-01

3 Converting DFAs To Reg. Exps: Example 1 (Based on the construction of the proof of the theorem)
R110={}, R120={a,b}, R130={c}, R210= , R220={}, R230=, R310= , R320=, R330={d,}, R111=R110R110(R110)*R110 ={}{}{}*{}={}, R121=R120R110(R110)*R120={a,b}, R131=R130R110(R110)*R130={c}, R211=, R221={}, R231=R311=R321= , R331={d,}, R112={} , R122={a,b}, R132={c}, R212=, R222={}, R232=, R312=R322=, R332={d,}, R113={}, R123={a,b}, R133=R132R132(R332)*R332={c}{c}{d,}*{d,}={c}{d}*, L(M)=R113 R133={}{c}{d}*. =||+cd*|| •  L ¢  q1 q2 a,b c d q3 004-01

4 Converting -NFAs To Reg. Exps: Example 2
Based on the meaning of Rijk R114=R113=R112=R111=R110={}, R124={a}, R130=R131={c}, R132={a,c}, R144=R143={,ab}, R444=R443={}, R434=R433=, R221={}, R231={e}, R321=, R332=R331=R330R310(R110)*R130={,d}, R133=R132R132(R332)*R332 ={a,c}{a,c}{,d}*{,d}={a,c}{d}*, R134=R133R143(R443)*R433 ={a,c}{d}*{,ab}{}*={a,c}{d}*. L(M)=R134 R144={a,c}{d}*{,ab} =||(a+c)d*++ab||. •  L ¢  q1 q2 q4 a b c d 004-01 q3

5 Regular Sets L is called a regular set if L=|||| for some reg. exp. ;  is said to denote L. If L and L’ are regular sets, then so are LL’, LL’, and L*. Why? THEOREM (S.C.Kleene) The class of regular sets, which we denote by R, is the smallest class of languages that contains all finite languages and closed under , •, and *. THEOREM R=L(DFA)=L(NFA)= L(-NFA)=L(Reg. Exp.). •  L ¢  004-01

6 Examples & Exercises =  ||||=|||| Examples Excercises
def =  ||||=|||| Examples 1. a*+a*=a*, 2. a*a*=a*, 3. (a*)*=a*, 4. (a+b)*=(b+a)*, 5. (ab)*=a(ba)*b+, 5. (ab*+a*b+)(a+)+a*b* =(ab*a+a*ba+ab*+a*b)+a*b* =ab*a+a*ba+a*b*a*b*(a+) ||ab*a+a*ba+a*b*|| is a proper subset of ||a*b*(a+)|| (Consider aabba). 6. ||a(b+c)+ab||=||a(b+c)||||ab||= ||a||•||b+c||||a||•||b||={a}(||b||||c||) {a}{b}={a}{b,c}{ab}={ab,ac}. Excercises 1. (a+b)*(b+a)*=(a+b)*? 2. (a+b)*(a+b)+=(a+b)*? 3. (ab+ba)*=(ab)*+(ba)*? 4. (a*+b*)*=(a*b*)*? 5. ||**+aa*||=?, 6. ||0*10*10*||=?, 7. Give reg. exps. for (a) the set of words over {0,1} containing 000 as a subword, (b) the set of odd nonnegative integers over {0,1,2,…,9}, (c) the set of words over {a,b} containing even number of a’s and b’s, (d) the set of integers which are multiples of 3, (e) the set of positive integers over {0,1,…,9} that are dividable by 10. •    L ¢  004-01


Download ppt "Converting Reg. Exps. To -NFAs: An Example"

Similar presentations


Ads by Google