1 CD5560 FABER Forml Lnguges, Automt nd Models of Computtion Exerise Mälrdlen University 007 NEXT WEEK! Midterm Exm 1 Regulr Lnguges Ple: U-114 Time: Tuesdy 007-04-4, 10:15-1:00 t is OPEN BOOK. This mens you re llowed to ring in one ook of your hoie. t will over letures 1 through 5 Regulr Lnguges. Tent 9 okt 1999; uppgift L Slling Construt nd explin },, { = wih strings ontin ll three symols!, L L A regulr expression over 4 Solution or
Construt nd explin A miniml DFA for lnguge L over = {,, } wih strings ontin ll three symols!, 5 1 4 6,, 7 5,, 8 6 Särskiljningslgoritm En reguljär grmmtik för L 5,,,, 1 7 8 4 6, { 1,,,4,5,6,7} {8} {1,,,4,5,6} {1,,4,6} { 7} {8} { } { 5} { 7} {8} { 1} { } { 4} { 6} { } { 5} { 7} {8} D, C,,, A S F G B E, S A B C A A E D B B F E C C D F D D D G E E E G F F F G G λ G G G 7 8
Tent 4 okt 1994; uppgift L Slling Reguljär? Språket över = {, } vrs strängr innehåller ett jämnt ntl :n! J, språket är reguljärt oh eskrivs med ett reguljärt uttryk: Tent 4 okt 1994; uppgift L Slling De välformde ritmetisk uttryken formde i lfetet = {,,, } Nej, språket är inte reguljärt: T följnde sträng: K K N styken dders Om språket vore reguljärt skulle det kunn pumps. Men de N vslutnde teknen estår enrt v höger- prenteser oh kn inte ändrs utn tt lnsen med vänsterprentesern förstörs. 9 10 Tent 15 mrs 1995; uppgift L Slling Tent 15 mrs 1995; uppgift L Slling Reguljär? Reguljär? { w {, } w hr ett prefix v längd som är en plindromsträng} { w {, } w hr ett som är en prefix v längd MNST plindroms träng } J, språket är reguljärt oh eskrivs med ett reguljärt uttryk: Nej. Strängen w = vrs end plindromprefix längre än är strängen själv, kn inte pumps någonstns inuti -lok utn tt fll ur språket. N N 11 1
Tent 15 mrs 1995; uppgift L Slling Reguljär? Nej. { w {, } w inget prefix v längd MNST som är en plindromsträng} Pumping Lemm is neessry ut not suffiient for RL OBS! The pumping lemm does not give suffiient ondition for lnguge to e regulr! You n not use it to show tht lnguge is regulr. For exmple, the lnguge R { uu v u, v {0,1} } strings over the lphet {0,1} onsisting of nonempty even plindrome followed y nother nonempty string is not regulr ut n still e "pumped" with m = 4: Om det vore reguljärt skulle även föregående språk vr det eftersom det är komplementspråk, oh regulriteten evrs under komplementildning. 1 Suppose w=uurv hs length t lest 4. f u hs length 1, then v nd we n tke y to e the first hrter in v. Otherwise, tke y to e the first hrter of u nd note tht yk for k strts with the nonempty plindrome yy. For prtil test tht extly hrterizes regulr lnguges, see the Myhill-Nerode theorem. The typil method for proving tht lnguge is regulr is to onstrut either Finite Stte Mhine or Regulr Expression for the lnguge. 14 Minimizing DFA s By Prtitioning Delmängdskonstruktion Minimizing DFA s Different methods All involve finding equivlent sttes: Sttes tht go to equivlent sttes under ll inputs We will use the Prtitioning Method 15 16
Minimizing DFA s y Prtitioning Consider the following DFA from Fores Louis: Aepting sttes re yellow Non-epting sttes re lue Are ny sttes relly the sme? S nd re relly the sme: Both Finl sttes Both go to S6 under input Both go to S under n S0 nd S5 relly the sme. Why? We sy eh pir is equivlent Are there ny other equivlent sttes? We n merge equivlent sttes into 1 stte 17 18 Prtitioning Algorithm Prtitioning Algorithm First Divide the set of sttes into Finl nd Non-finl sttes Prtition Prtition S Now See if sttes in eh prtition eh go to the sme prtition & re different from the rest of the sttes in Prtition ut like eh other We will move them to their own prtition S 4 S S S 4 S 4 S 7 S 6 19 0
Prtitioning Algorithm Prtitioning Algorithm S Now gin See if sttes in eh prtition eh go to the sme prtition n Prtition, goes to different prtition from, nd We ll move S to its own prtition S 4 S S S 6 1 Prtitioning Algorithm Prtitioning Algorithm Note hnges in, S nd S 4 S 4 S Now goes to different prtition on n from gets its own prtition. We now hve 5 prtitions Note hnges in S nd S 4 S 4 S S 6 S V 6 V 4
All sttes within eh of the 5 prtitions re identil. We might s well ll the sttes,, nd V. Prtitioning Algorithm S S V 6 V Here they re: * V V Prtitioning Algorithm V 5 6 Automt theory: forml lnguges nd forml grmmrs Chomsky Hierrhy Chomsky hierrhy Grmmrs Lnguges Miniml utomton Type-0 Unrestrited Reursively enumerle Turing mhine Type-1 Context-sensitive Context-sensitive Liner-ounded Type- Context-free Context-free Pushdown Type- Regulr Regulr Finite 7 8
Automt theory: forml lnguges nd forml grmmrs Grmmr Lnguges Automton Type-0 Type-1 Type- Reursively enumerle Context-sensitive Context-free Turing mhine Liner-ounded non-deterministi Turing mhine Non-deterministi pushdown utomton Type- Regulr Finite stte utomton Prodution rules No restritions nd n l n l { : n, l 0} Non-regulr lnguges Context-Free Lnguges n n { } ww } { R Regulr Lnguges {! : n n 0} 9 0