Exercises for Chapter 2
Summary for the Quiz Some numbers –199 less than 100 55 Conclusion –There are students who did read textbook at least for review; –Most submitted answers are actually correct; –Rethinks on teaching method
Explanations on RE A regular expression defines a set of strings(language); A regular expression states the common pattern(structure) of the strings that belong to its language; For the same set of strings, there could be several RE definitions for it; Explanation of three operations –( 顺序 ; 选择 ; 重复 );
Example of RE {a, b, c} Defining a set of strings, where each string should starts with “a” and ends with “c”; Defining a set of strings, if “a” appears in one string, “c” should appear right after “a”;
From RE to NFA The generated NFA could be different, but they are equivalent; –The only criteria for judging whether the generated NFA is correct: L(RE) = L(NFA) You can follow the general rules; There are some shortcuts;
Rules ■ is a regular expression , L( )={ } ■ is a regular expression , L( )={ } ■ for any c , c is a regular expression, L(c)={c} S0S0 S S0S0 S c
Rules ■ ( A ), L( (A) )= L(A), no change; ■ A B , L( A B )= L(A)L(B) NFA(A) NFA(B)
Rules ■ ( A ), L( (A) )= L(A), no change; ■ A | B , L( A | B )=L(A) L(B) NFA(A) NFA(B)
Rules ■ A* , L( A*)= L(A)* NFA(A)
Attention The rules introduced above are effective for those NFAs that have one start state and one terminal state; Any NFA can be extended to meet this requirement; …… NFA ……
Quiz (a|b)*abb(a|b)* Follow the rules a b a bb
Quiz (a|b)*abb(a|b)* Follow the process in the textbook (a|b)*abb(a|b)* (a|b)* abb (a|b)* bb b a a b a
Quiz (a|b)*abb(a|b)* The NFA without edge; 1 a b b a b b a
ab {1} 0 {1,2}{1} {1,2} {1,3} {1,2}{1,4}* {1,2,4}*{1,4}* {1,2,4}* {1,3,4}* {1,2,4}*{1,4}*
ab {1} 0 {1,2}{1} {1,2} {1,3} {1,2}{1,4}* {1,2,4}*{1,4}* {1,2,4}* {1,3,4}* {1,2,4}*{1,4}* {1} --- S0; {1,2} --- S1; {1,3} --- S2; {1,4} --- S3; {1,2,4} --- S4; {1,3,4} --- S5; ab S0 0 S1S0 S1 S2 S1S3* S4*S3* S4* S5* S4*S3*
Minimizing DFA Current groups:{S0,S1,S2}, {S3,S4,S5} Splitting {S0, S1,S2} {S0,S1},{S2} Current groups:{S0,S1},{S2}, {S3,S4,S5} Splitting {S0, S1} {S0},{S1} ab S0 0 S1S0 S1 S2 S1S3*
Minimizing DFA Current groups:{S0},{S1},{S2}, {S3,S4,S5} Splitting {S3, S4,S5} {S3,S4,S5} ab S3*S4*S3* S4* S5* S4*S3*
Minimized DFA ab S0 0 S1S0 S1 S2 S1S3* S4*S3* S4* S5* S4*S3* {S0},{S1},{S2}, {S3,S4,S5} {S0} ; {S1} ; {S2} ; {S3,S4,S5} --- 3; ab *
You should know how to do these problems!!!!