THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY

Size: px
Start display at page:

Download "THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY"

Transcription

1 THEORY OF FORMAL LANGUAGES EXERCISE BOOK A Suite of Exerises with Solutions DRAFT COPY Lu Breveglieri ollortors Gimpolo Agost Alessndro Brenghi Ann Beletsk Stefno Crespi Reghizzi Bernrdo Dl Seno Vinenzo Mrten Angelo Morzenti Lii Sttell Mrtino Sykor 21st Jnury 2008

2 Contents 1 Introdution 1 2 Regulr Lnguges Regulr Expression Finite Stte Automton Context-Free Lnguges Grmmr Trnsformtion Grmmr Synthesis Tehnil Grmmr Pushdown Automton Syntx Anlysis Reursive Desent Shift nd Redution Erley Algorithm Trnsdution nd Semnti Syntx Trnsdution Attriute Grmmr Stti Flow Anlysis Live Vriles Rehing Definitions i

3 Chpter 1 Introdution 1

4 2 CHAPTER 1. INTRODUCTION

5 Chpter 2 Regulr Lnguges 2.1 Regulr Expression Exerise 1 Consider the two following regulr expressions R 1 nd R 2 over lphet {, }: R 1 = R 2 = ( ) These expressions generte regulr lnguges L 1 nd L 2, respetively. Answer the following questions: 1. List ll the strings of length 4 elonging to set differenes L 1 \L 2 nd L 2 \L 1 (sometimes lso written L 1 L 2 nd L 2 L 1 respetively). 2. Write the regulr expression R 3 generting lnguge L 3 = L 1 (set omplement of L 1 ) nd use only union, ontention, str nd ross opertors. Solution of (1) In order to ompute quikly the required set differenes one n proeed intuitively nd notie wht follows: in the regulr expression R 1 only one sequene of letters of ritrry length 1 my our, in ny position in the regulr expression R 2 one or more sequenes of letters of ritrry length 1 my our, seprted y t lest one letter, internlly to or t n end of the string, with the exeption tht if sequene is positioned t the eginning of the string then it hs to e of even length 3

6 4 CHAPTER 2. REGULAR LANGUAGES Therefore the set differenes re hrterised s follows: the phrses ontined in the lnguge L 1 ut not in the lnguge L 2 re those of L 1 tht egin with n odd numer of letters the phrses ontined in the lnguge L 2 ut not in the lnguge L 1 re those of L 2 tht ontin t lest two letters seprted y t lest one letter As onsequene, here re the strings elonging to lnguge L 1 ut not to lnguge L 2 (on the left), nd to L 2 ut not to L 1 (on the right), limited to the se of length 4: L 1 \ L 2 L 2 \ L 1 The strings re ordered lexiogrphilly, ssuming <. One sees soon tht the listed strings stisfy preisely the two intuitive hrteristions stted ove. Oservtion As n lterntive one n otin the requested set differenes in purely lgorithmi wy, first y listing ll the strings of length 4 of lnguges L 1 nd L 2, respetively, nd then y determining the two differene sets. The reder is left this tsk, perhps little oring ut not long nd surely t ll trivil. Solution of (2) As is hs een oserved efore, the phrses of lnguge L 1 re hrterised y not ontining ny pir of letters tht re not djent. More expliitly, phrse of L 1 is s follows: either it does not ontin ny letter or it ontins extly one letter or it ontins two or more letters, ut not seprted y ny letter As onsequene, the phrses of lnguge L 3 = L 1 (set omplement of L 1 ) re hrterised so s to ontin t lest two letters seprted y t lest one letter, s follows: L 3 = { x x Σ ontins t lest two hrters tht re not djent } Therefore lnguge L 3 is generted y the following regulr expression R 3 : R 3 = ( ) + ( ) If one prefers, the expression n e rewritten s R 3 = Σ + Σ, where the role of the universl lnguge Σ is put into evidene.

7 2.1. REGULAR EXPRESSION 5 Oservtion Notie tht the given regulr expression R 3 is highly indeterministi (tully it is even miguous), nd s suh it is very elegnt nd ompt in desriing lnguge L 3 without unuseful detils. If one prefers version tht is not miguous, here it is: R 3 = + + Σ. Suh formultion speifies tht the neessry pir of seprted letters generted y omponent + + is the leftmost one, while the other suh pirs (if ny) re generted y omponent Σ. Of ourse one ould otin lgorithmilly, without the need of intuition, regulr expression tht genertes lnguge L 3 = L 1, s follows: uild the deterministi utomton equivlent to regulr expression R 1, y mens of the MNughton-Ymd lgorithm or of the Thompson modulr onstrution followed y deterministion with the suset onstrution uild the omplement utomton, whih is deterministi s well otin regulr expression R 3 equivlent to the omplement utomton, y mens of the Brozozowski node elimintion lgorithm or of the lgorithm of liner equtions In suh stritly lgorithmi wy no intuition is needed, ut the whole proess is presumly longer. The reder is left the tsk of pplying the ove desried pproh. Exerise 2 Eh of the two following tles A nd B onsists of two rows, nd eh row ontins two regulr expressions: the former is in olumn L 1, the ltter in L 2. Answer the following questions: 1. In eh row, list y inresing length the three shortest strings elonging to the lnguge defined y set differene L 1 \ L 2 (or L 1 L 2 ). Tle A L 1 L 2 write the three shortest strings of L 1 \ L 2 (( )) + () (() ) ( () ) (() ) 2. In eh row, write regulr expression generting the lnguge L 1 \ L 2 (or L 1 L 2 ) nd use only union, ontention, str nd ross opertors.

8 6 CHAPTER 2. REGULAR LANGUAGES Tle B L 1 L 2 write regulr expression of L 1 \ L 2 (( )) + () (() ) ( () ) (() ) Write the nswers to the questions in the rightmost olumn of Tles A nd B. Solution of (1) nd (2) For etter onveniene, here the nswers to questions (1) nd (2) re given together for the two rows of the tles (top nd ottom). Top row In the top row the two lnguges L 1 nd L 2 re hrterised in the following wy: set L 1 ontins strings of length 3, eh of whih is list of two or more elements seprted y only one letter or two onseutive letters, indifferently set L 2 ontins strings of two different types: the short string, of length 2 strings of length 4, eh of whih is list of two or more elements seprted y only one letter, exept tht etween the seond lst (penultimte) nd lst element the seprtor is lwys the pir of onseutive letters As onsequene, list of elements elongs to lnguge L 1, ut not to lnguge L 2, in the following two ses: se () the lst seprtor is letter (nd the others re or indifferently) se () the lst seprtor is the pir of onseutive letters nd the string ontins somewhere t lest nother seprtor, or even more thn one, or s limit se ll the seprtors my e (this se implies however tht there re t lest three elements ) L 1 L 2 the three shortest strings nd the regexp of L 1 \ L 2 (( ) ) + ( ) ( ( )) ( ( )) ( ( )) The three shortest strings (ll relted to se () ove) nd the regulr expression re otined s onsequene. Sping isoltes nd puts into evidene the groups of letters.

9 2.1. REGULAR EXPRESSION 7 Oservtion For ompleteness, notie tht there re two shortest strings in the fourth position, nmely nd, nd tht the ltter string is relted to the se () ove. Bottom row In the ottom row letters nd n e interpreted s open nd lose prenthesis, respetively. Then the following holds: set L 1 ontins ll nd only the strings of prentheses tht hve nesting depth 2 nd stisfy one of the following two onstrints: they re well formed Dyk strings (ses (1) nd (3) elow) they hve extly one exeeding open prenthesis, with respet to well formed Dyk strings (se (2) elow) set L 2 ontins ll nd only the Dyk strings tht hve nesting depth 2 Therefore the strings elonging to set differene L 1 \ L 2 re those tht re of Dyk type with nesting depth 2 nd hve extly one exeeding open prenthesis, tht is se (2) of lnguge L 1. L 1 L 2 three shortest strings nd regexp of L 1 \L 2 ( () ) (}{{} () }{{} se 1 se 2 }{{} se 3 ) ( () ) ( ( ) ) ( ) The three shortest strings nd the regulr expression re otined s onsequene. Sping isoltes nd puts into evidene the groups of letters. Oservtion As n lterntive, one n notie tht in lnguge L 1 se (3) is ontined in the se (1), tht se (2) is disjoint from se (1) (nd therefore lso from se (3)) nd tht lnguge L 2 oinides with se (1) of L 1. There follows tht set differene L 1 \ L 2 oinides with se (2) of L 2, whih is the sme onlusion s tht otined y the previous resoning. Oservtion As n lterntive, one n list the three shortest strings first y writing few short strings of lnguges L 1 nd L 2, nd then y omputing the set differene of these two sulists of strings. Oservtion The ltter regulr expression n e further simplified s follows: ( ( ) ) ( ) = ( )

10 8 CHAPTER 2. REGULAR LANGUAGES Suh simplifition is esily justified y exmining few smple strings, short enough not to spend too long time for the exmintion. However one n otin the sme simplifition lso y refleting on the ft tht Dyk string with nesting depth 2 nd extly one exeeding open prenthesis, is neessrily strutured s follows: it ertinly egins with letter, s it my not egin with letter if it hs to e of Dyk type nd moreover to ontin somewhere n exeeding letter fter the initil hrter it ontinues with letters nd in equl numer, suh tht t the end it ontins extly one exeeding letter (it is the initil letter tht unlnes the mth though the exeeding open prenthesis my e one of the internl letters ) ut it does not ontin nywhere s ftor either string or (three or more onseutive letters or ), suh tht it never hs nesting depth > 2 (in ft oth foridden ftors would imply to hve nesting depth of t lest 3 if not higher) Suh is preisely the ehviour of the simplified regulr expression on the right, whih egins with letter nd ontinues with mix of letters nd, in ny order nd in equl numer, ut never ontins foridden ftors euse it never juxtposes more thn two identil letters. By the wy, this shows tht the lnguge is of lol type nd tht n e expressed lso in the following wy (where Σ = {, } nd overlining indites set omplement): ( ) = ( Σ 2 ) Σ {, } Σ Suh simplifition (whih my look like somewht unexpeted) shows tht there my exist notly different lines of resoning tht however reh the sme trget. 2.2 Finite Stte Automton Exerise 3 Consider the following regulr expression over lphet {,, }: R = ( + ) Answer the following questions: Construt n indeterministi utomton A tht reognises the lnguge generted y regulr expression R. Construt deterministi utomton A equivlent to utomton A. If neessry, onstrut the miniml utomton A equivlent to utomton A.

11 2.2. FINITE STATE AUTOMATON 9 First solution of (1) Sine n indeterministi utomton A equivlent to regulr expression R is requested, possiility is to use the Thompson or modulr onstrution, whih usully produes n indeterministi result. Here is the struture tree of R, whih will e useful lter for the onstrution, nd ll the strings of length 5 generted y R (to view intuitively the wy R works): struture tree of regulr expression R = ( + ) + short ( 5) strings generted y R... And here is the Thompson or modulr onstrution, rrnged step y step snning ottom-up the struture tree of regulr expression R, nd in suh wy s to hve unique initil nd finl sttes t eh step. Below eh intermedite utomton produed y the onstrution, there is the orresponding frgment of R to whih the utomton is equivlent

12 10 CHAPTER 2. REGULAR LANGUAGES ( + ) ( ( + )) ( ( + )) indeterministi utomton A

13 2.2. FINITE STATE AUTOMATON 11 The finl utomton A is indeterministi euse it hs severl spontneous trnsitions. The reder n hek the orretness of A using the smple short strings listed t the eginning. First solution of (2) To determinise utomton A (whih lredy hs unique initil stte), one hs first to ut spontneous trnsitions (first phse) nd then to use the suset onstrution (seond phse). Here is the first phse. Cut -trnsitions 7 3, 7 5 nd 8 11, nd duplite on the soure stte the r outgoing from the destintion stte of the trnsition (k-propgtion rule): Sttes 3, 5 nd 11 eome unrehle nd n e removed, s follows: Now ut -trnsitions 10 7, 4 1 nd 6 8, nd duplite on the destintion stte the r inoming into the soure stte of the trnsition (forwrd-propgtion rule):

14 12 CHAPTER 2. REGULAR LANGUAGES Sttes 10, 4 nd 6 eome indefinite nd n e removed, s follows: Now ut -trnsition 2 1 nd duplite on the destintion stte the r inoming into the soure stte of the trnsition (forwrd-propgtion rule): Now ut -trnsition 2 8 nd duplite on the destintion stte the r inoming into the soure stte of the trnsition (forwrd-propgtion rule):

15 2.2. FINITE STATE AUTOMATON Stte 2 eomes indefinite nd n e removed, s follows: Now, notie tht sttes 7 nd 8 onstitute n -loop, hene they n e ollpsed into one stte (temporrily nmed 7 8 for lrity), s follows: Now the utomton does not hve ny spontneous trnsition left. However it is still indeterministi, s stte 7 8 hs two outgoing rs oth leled y letter (one is self-loop). The reder my hve notied tht the forwrd nd kwrd propgtion rules for utting spontneous trnsitions hve een interleved, for the purpose of minimising t eh step the

16 14 CHAPTER 2. REGULAR LANGUAGES numer of rs to duplite, nd tht the -loop hs een ollpsed only t the end not to rete stte ssoited with mny trnsitions. The seond phse is the suset onstrution. Sttes nd trnsitions of the utomton n e renmed nd redisplyed more onveniently s follows (see elow on the left), nd the suessor tle is written onsequently (see elow on the right): A B D group finl? A B no B B C D no B C B C B C D no C D yes B C D B C B C D yes suessor tle Sttes nd trnsitions of the resulting deterministi utomton A n e more onveniently renmed nd redisplyed s follows: stte finl? α β no α β δ β γ δ no γ γ no δ yes γ γ yes stte tle deterministi utomton A Therefore deterministi utomton A with five sttes hs een otined. It my e not in miniml form, nywy (see the next nswer). First solution of (3) Normlly to minimise the deterministi utomton A one should resort to the stndrd minimistion lgorithm, sed on the tringulr implition tle. Here however it is possile to onlude more speedily in n intuitive wy. Rememer tht finl sttes re lwys distinguishle from those tht re not finl. Then one hs the following dedutions: Sttes δ nd re distinguishle euse they ehve differently s for the error stte. Stte α is distinguishle from oth stte β nd γ, euse α ehves differently from β nd γ s for the error stte.

17 2.2. FINITE STATE AUTOMATON 15 For sttes β nd γ to e indistinguishle, it would e neessry tht sttes δ nd were indistinguishle s well. However indistinguishility δ does not hold (see efore), nd therefore β nd γ re distinguishle. In onlusion ll the sttes of utomton A re distinguishle from one nother. Therefore A is lredy in miniml form nd the requested miniml utomton A oinides with A. Seond solution of (1) As n lterntive, one n resort to the Berri-Seti lgorithm for otining n indeterministi utomton A equivlent to regulr expression R. Here is the struture tree of R leled with strt nd follow sets t the root nd for ll genertors, respetively (see elow on the left), nd the tle with the strt nd ll the follow sets (see elow on the right): struture tree of regulr expression R = 1 ( ) 4 5 strt nd follow sets 1 strt genertor follow The indeterministi utomton A is then the following: 1: 1 2: : 3: 4 4: The indeterministi utomton A is in redued form nd hs five sttes, somewht fewer thn those otined with the Thompson or modulr onstrution. The utomton is indeterministi s it hs multiple rs with identil lels outgoing from the sme stte.

18 16 CHAPTER 2. REGULAR LANGUAGES Seond solution of (2) It is possile to determinise the ove indeterministi utomton A diretly y mens of the suset onstrution (s there re not ny spontneous trnsitions), s follows: group finl? 1 2 no no no 5 yes yes suessor tle stte finl? A B no B C D no C C E no D yes E C E yes stte tle On the left there is the suessor tle nd on the right the stte tle, with more ompt stte nmes. Here is the stte-trnsition grph of the deterministi utomton A : A B D C E The deterministi utomton is lso in redued form (sine the suessor tle produes redued result if the originl utomton is so), ut my e not in miniml form, nywy. Seond solution of (3) It is reltively strightforwrd to onlude tht the deterministi utomton A is lredy in miniml form. Rememer tht finl stte is lwys distinguishle from stte tht is not finl. Then one hs the following dedutions: Sttes D nd E re distinguishle euse they ehve differently s for the error stte. Stte A is distinguishle from oth stte B nd C, euse it ehves differently from them s for the error stte. For sttes B nd C to e indistinguishle, it would e neessry tht sttes D nd E were indistinguishle s well. But equivlene D E does not hold (see efore), hene B nd C re distinguishle.

19 2.2. FINITE STATE AUTOMATON 17 Therefore one onludes tht utomton A is lredy in miniml form nd tht the requested utomton A oinides with A. Of ourse, the utomton A here otined oinides with tht designed y mens of the Thompson or modulr onstrution efore (the reder n hek y himself), s the miniml form is unique. Oservtion If the exerise hd not requested expliitly to produe n indeterministi utomton A equivlent to regulr expression R, one ould hve resorted to the MNughton-Ymd lgorithm to otin diretly deterministi utomton equivlent to R. Agin, the resulting utomton my e not in miniml form. Oservtion One my wish to notie tht regulr expression R n e simplified s follows: R = ( + ) = ( ( + ) ) = ( ) whih my e slightly simpler to del with for otining n equivlent utomton. Exerise 4 The two following regulr expressions R 1 nd R 2 re given: R 1 = ( () ) R 2 = ( () ) Answer the following questions: 1. Chek intuitively whether the two expressions R 1 e R 2 re equivlent (if they re not show string elonging to either one). 2. Chek in n lgorithmi wy whether the two expressions R 1 nd R 2 re equivlent. Solution of (1) Tht the two regulr expressions R 1 nd R 2 re not equivlent, should e lmost evident y intuition: the strings generted y R 1 (exept ) neessrily end with t lest one letter, while those generted y R 2 my end with one letter (esides ending with ). For instne, string is generted y R 2 ut not y R 1. Solution of (2) However here it is requested to provide n lgorithmi proof of the inequivlene of expressions R 1 nd R 2. One wy to do so is to find the deterministi miniml reogniser utomt

20 18 CHAPTER 2. REGULAR LANGUAGES equivlent to R 1 nd R 2, nd verify whether suh utomt re identil or not (s the miniml form is unique). Here the two deterministi utomt re otined y mens of the MNughton-Ymd lgorithm. Automton of R 1 = (( 1 2 ) 3 ) : strt genertor follow Clerly the utomton is miniml s sttes 2 nd 1 3 re ertinly distinguishle, euse the ltter hs n outgoing r leled y while the former does not, nd the finl stte is oviously distinguishle from the other two sttes, whih re not finl. Automton of R 2 = ( 1 ( 2 3 ) ) : strt 1 2 genertor follow Agin, lerly the utomton is miniml s the two sttes re one finl nd the other one not, hene they re neessrily distinguishle. Sine the two deterministi miniml utomt re different (s they hve three nd two sttes respetively), they re not equivlent nd therefore the two regulr expressions R 1 nd R 2 re not equivlent either. Exerise 5 Consider the strings over lphet Σ = {,, } nd the two following onstrints: 1. if the string ontins two or more letters, they re not djent 2. if the string ontins one or more letters, t lest one of them is followed y t lest one letter, t whtever distne Answer the following questions: 1. Write the two regulr expressions (no mtter if miguous) tht generte the strings orresponding to the former nd ltter onstrint, respetively (tht is one expression for eh onstrint) nd use only ontention, union nd str (or ross).

21 2.2. FINITE STATE AUTOMATON By pplying n lgorithmi method design the deterministi utomton tht reognizes the lnguge, the strings of whih stisfy oth onstrints (not one s efore). 3. Minimise the numer of sttes of the previously designed deterministi utomton. Solution of (1) Here is regulr expression R 1, not miguous, stisfying the former onstrint: R 1 = ( ) ( ( ) +) ( ) If there is letter in the string, expression R 1 mndtorily inserts soon fter suh letter new letter or, unless letter is the end of the string. The string n egin optionlly y sequene of letters nd. In this wy ll the strings re generted, ut those ontining two djent letters. Here is regulr expression R 2, strongly miguous, stisfying the ltter onstrint: R 2 = ( ) Σ Σ Σ For t lest one instne of letter in the string, expression R 2 neessrily inserts into the string letter t some distne (unless the string lks ompletely letters ). Suh formultion is very simple ut lerly is strongly miguous s well, s it does not speify whih will e followed y (see elow). For instne, string is generted miguously y R 2. In ft, suppose to numer s Σ 1 2 Σ 3 4 Σ 5, then lerly string ould e generted in three wys: , or However, if one prefers version tht is not miguous, here it is: R 2 = ( ) ( ( ) ( ) ) Expression R 2 speifies tht the instne of letter (if ny) neessrily followed (t some distne) y letter, is ( )... (see the pointing drt), tht is the leftmost one. This removes miguity ut does not use ny loss of generlity, s if some instne of must e followed y sooner or lter, then lso the leftmost instne of must e so. Solution of (2) One n proeed first y designing the deterministi utomt of lnguges L 1 nd L 2, nd then y omputing the intersetion lnguge y mens of the onstrution of the rtesin produt of utomt. Automton A 1 is very esy to design intuitively in deterministi form. It n e otined soon y exmining regulr expression R 1. Here it is:

22 20 CHAPTER 2. REGULAR LANGUAGES, Automton A 1 1 2, If one follows the sme pproh dopted for otining regulr expression R 2, the resulting utomton A 2 is indeterministi (rememer tht R 2 is miguous) nd for this reson esier nd more nturl to design. Here it is, derived from R 2 in the nturl wy, tht is y pplying the Thompson or modulr onstrution (with some simplifitions):, 1 Automton A ,,,,,, Automton A 2 n however e esily determinised first y utting spontneous trnsitions (-trnsition) nd then y pplying the suset onstrution:, 1 A 2 fter uts ,,,,,, Here spontneous trnsitions 0 1 nd 0 2 re ut nd the rs inoming into the soure node of the trnsition re duplited on the destintion node. This uses oth sttes 1 nd 2 to eome initil, while stte 0 remins indefinite (unonneted to ny finl node) nd hene n e removed (in the grph it is dshed). Here is the suset onstrution (the initil stte group is 1 2):

23 2.2. FINITE STATE AUTOMATON 21 group finl?,,,, yes no yes suessor tle deterministi form of utomton A 3 On the right side there is the stte-trnsition grph of the determinised utomton. By the wy, it is preisely wht is otined y using regulr expression R 2 s model to strt from. Now the rtesin produt of utomt A 1 nd A 2 (in determinised form) n e omputed. First it is onvenient redrw A 1 nd renme the sttes of A 2, s follows:,,,,, A A 2 A B C, The rtesin produt utomton A 3 = A 1 A 2 is then the following:, 1A 2A 1C 2C, Automton A 3 1B 2B Notie tht ll the six produt sttes of A 3 = A 1 A 2 hppen to e useful, tht is oth rehle nd definite. As oth utomt A 1 nd A 2 re deterministi (one would suffie), A 3 is ertinly deterministi s well. It my e not in miniml form, nywy. Solution of (3) In order to minimise the deterministi utomton A 3, first it is onvenient to renme more shortly the sttes nd to write the stte-trnsition tle of A 3, s follows:

24 22 CHAPTER 2. REGULAR LANGUAGES, α γ ι, β δ stte finl? α γ α yes β δ β no γ β α yes δ β no ι yes ι yes utomton A 3 stte tle In priniple to mimimise one should pply the lssil stte redution ostrution sed on the tringulr implition tle, ut sometimes it is possile to ome to onlusion more quikly, s it hppens here. Rememer tht finl stte is lwys distinguishle from stte tht is not finl. Thus the following onsidertions pply: of the sttes tht re not finl (β nd δ), stte β is distinguishle form stte δ s for input letter the ltter goes into the error stte while the former does not of the finl sttes (α γ nd ι), only sttes γ nd ι might e indistinguishle s the other pirs go into the error stte for different input letters, ut the equivlene γ ι would hold if nd only if oth equivlenes β nd α held, whih y trnsitivity would imply equivlene α β, whih in turn is impossile for α is finl while β is not, nd hene γ nd ι re distinguishle Therefore there re not ny pirs of indistinguishle sttes nd the onlusion is tht utomton A 3 is lredy in miniml form. Exerise 6 Lnguge L over lphet {,, } is defined y mens of the following three onditions (every string of L must stisfy ll of them): 1. phrses strt with letter nd 2. phrses end with letter nd 3. phrses my not ontin ny of the following four two-letter ftors:

25 2.2. FINITE STATE AUTOMATON 23 For exmple, the following string: is phrse of L, while the string: }{{} foridden is invlid (nd is not phrse of L), euse the middle ftor is not dmittle. Answer the following questions: 1. Write regulr expression of lnguge L y using only union, ontention nd str (or ross) opertors. 2. Define lnguge L, the omplement of lnguge L, y modifying suitly the three onditions (1, 2, 3) ove. First solution of (1) In order to otin the regulr expression of lnguge L, first one n onstrut the utomton of L nd then derive from it the expression. As lnguge L elongs to the fmily known s lol lnguges, the utomton hs sttes leled y lphet letters, plus one initil stte. Suh n utomton need only reord the lst red letter nd hek whether the input string egins nd ends with the letters presried y onditions (1, 2). Here is the utomton: q 0 q q q Stte nmes (i.e. q, q nd q ) re in one-to-one orrespondene with lphet letters (ut the initil stte q 0 ). Outgoing rs represent initil nd finl hrters, nd the dmittle pirs of djent hrters. In order to find regulr expression R equivlent to the utomton (nd ontining only union, ontention nd str or ross opertors), one n for instne resort to the Brozozowski lgorithm, lso lled node elimintion lgorithm. Here it is (q nd q re the dditionl initil nd finl nodes required y the lgorithm respetively): Preprtion of the utomton (dd unique initil nd finl nodes): q q 0 q q q q

26 24 CHAPTER 2. REGULAR LANGUAGES Remove node q 0 (former initil node): q q q q q Remove node q : + q + q q q Remove node q : + q q q Remove node q : + q ( + + ) ( ) q Finlly the following regulr expression R is otined: R = ( + + ) ( ) = + ( ) + ( ) = + ( ) ( ) = + ( ) + ( ) + Here suh n expression R is displyed in four different ut equivlent forms. The fourth form is otined from the seond one y oserving tht the identity () = () holds true. Seond solution of (1) As n lterntive, one n otin regulr expression R tht genertes lnguge L, y mens of the method of linguisti liner equtions. The first step is the sme s efore nd onsists of onstruting the finite stte utomton of lnguge L. Here it is gin: q 0 q q q

27 2.2. FINITE STATE AUTOMATON 25 Then one onverts suh n utomton into system of right-liner linguisti equtions. Let L 0, L, L nd L e the lnguges reognised y the utomton when ssuming stte q 0, q, q nd q s initil, respetively. The system of equtions is then the following (on the left), long with the solution proess (follow the hin of implitions nd red the ptions): L 0 L L L = L = L L L = L = L L 0 = L L = L L L L = ( L ) = L = L = = ( ) (Arden rule) = L eqution system reple eq. L into eq. L nd use Arden rule L 0 L L = L = L L L = ( ) L = ( ) = = ( ) + = = ( ) L 0 = L L = L ( ) ( ) = = L ( ) + ( ) = = ( ( ) + ( ) ) (Arden rule) L L = ( ) = ( ) reple eq. L into eq. L reple eq.s L nd L into eq. L, nd use Arden rule L 0 = ( ( ) + ( ) ) = = + ( ( ) + ( ) ) L = ( ( ) + ( ) ) L L = ( ) = ( ) R = L 0 = + ( ( ) + ( ) ) = = + ( ) + + ( ) reple eq. L into eq. L 0 regulr expression of lnguge L To solve the system ove, it is suffiient to sustitute equtions nd use Arden rule to eliminte reursion. If possile, intermedite expressions re simplified y resorting to known properties of regulr opertors: for instne the ovious property tht ( ) =... = ( ) +, nd so on. Thus one otins eventully regulr expression R, whih is the solution of eqution L 0 orresponding to the originl initil stte of the utomton. Expression R is of ourse equivlent to the expression R otined efore; just notie tht ( ) = ( ) holds. Solution of (2) Rememer tht L is lol lnguge, defined s the logil onjuntion (nd) of the three onditions (1, 2, 3). Therefore the omplement lnguge L is defined s the logil disjuntion

28 26 CHAPTER 2. REGULAR LANGUAGES (or) of the sme three onditions (1, 2, 3) in negted form (ording to De Morgn theorem). One then otins the following: phrse of L does not egin with letter (i.e. egins with or ) or phrse of L does not end with letter (i.e. ends with or ) or phrse of L does not hppen not to ontin some (i.e. hs to ontin t lest one) of the following ftors: Moreover, it is evident tht the omplement lnguge L ontins the empty string, s lnguge L is -free. Py ttention to tht now the three onditions ove re disjoint, not onjoint, tht is it suffies tht the string stisfies one of them to elong to L (of ourse the string my stisfy two or even ll the three of them). Oservtion One my wish to explore the question little more in depth. Sine lnguge L is of the lol type, generlised regulr expression R (ontining lso the opertor of set differene or those of set intersetion nd set omplement) tht genertes L is the following: R = Σ (Σ {,,, }Σ ) = Σ Σ {,,, }Σ Clerly suh n expression R is equivlent to the regulr expression R previously found, lthough it is formulted differently. An ordinry regulr expression R (with only union, ontention nd str or ross) tht genertes the omplement lnguge L is then the following: R = R = Σ Σ {,,, }Σ = Σ Σ {,,, }Σ = (Σ Σ ) Σ {,,, }Σ = Σ Σ Σ {,,, }Σ = {, }Σ Σ {, } Σ {,,, }Σ = {, }Σ Σ {, } Σ {,,, }Σ Clerly it holds L = L(R ). As it seems resonle, expression R hs struture onformnt to the three onditions ove (plus the empty string ), where the opertor of union represents logil disjuntion (or). If one prefers to use the usul symology, regulr expression R n e rewritten s follows: R = ( ) ( ) ( ) ( ) ( ) ( ) ( )

29 2.2. FINITE STATE AUTOMATON 27 Oservtion One ould otin regulr expression R lso in the following wy: first tke the deterministi utomton of L tht hs een found efore nd onstrut the omplement utomton thereof, whih reognises the omplemet lnguge L, then derive from the ltter utomton the equivlent regulr expression, for instne y mens of the Brozozowski or node elimintion lgorithm gin. The reder is left the tsk of ompleting this lterntive pproh. Exerise 7 Consider the following regulr expression R over lphet {,, }: R = ( ) ( ) ( ) Answer the following questions: 1. List ll the strings of length 2 generted y expression R nd sy whih miguity degree they hve (tht is in how mny different wys eh string is generted y R). 2. Design the indeterministi utomton A of expression R (hoose the method to follow). 3. Design the deterministi utomton A of expression R, otined from the previous one y mens of the suset onstrution. 4. If neessry, design the miniml utomton A of expression R. Solution of (1) The strings of length 2 generted y regulr expression R re the following: Of these strings, nd hve miguity degree 2, tht is they re generted y expression R in two different wys. In ft, numer the genertors in the expression R s follows: R = ( 1 2 ) ( 3 4 ) ( ) Then expression R n generte oth 1 3 nd 7 8, nd oth 3 4 nd 5 6. Therefore strings nd hve miguity degree 2. Solution of (2) Sine n indeterministi utomton A equivlent to regulr expression R is wnted, one n uild it esily y mens of the Thompson or modulr onstrution. Here it is, step y step ut with some shortuts to speed it up:

30 28 CHAPTER 2. REGULAR LANGUAGES ( ) 1 2, 5 ( ) 4 ( ) 3 6 Then the omplete (indeterministi) utomton A is otined y ontenting the three suutomt ove y mens of spontneous trnsitions (-trnsition), s follows: 5, Automton A Automton A is indeterministi minly euse it hs few spontneous trnsitions (trnsitions). Solution of (3) To determinise utomton A, one must ut spontneous trnsitions nd pply the suset onstrution. First ut -trnsition 2 3 nd replite on destintion stte 3 the rs ingoing into soure stte 2, s follows on the left:

31 2.2. FINITE STATE AUTOMATON , , ut trnsition 2 3 remove undefined stte 2 One sees soon tht stte 2 eomes indefinite (no pth from stte 2 to finl stte 4) nd tht therefore it n e removed; see the figure ove on the right. Next one n ut -trnsition 1 3 nd replite on destintion stte 3 the rs inoming into soure stte 1 (nmely the initil mrker drt), s follows on the left. 5 5,, ut trnsition 1 2 ut trnsition 3 4 Finlly one n ut -trnsition 3 4 nd replite on soure stte 3 the rs outgoing from destintion stte 4 (inluding the finl mrker drt); see the figure ove on the right. Now there re not ny spontneous trnsitions left. However the utomton is still indeterministi, s there re two multiple initil sttes (1 nd 3) nd duplite rs (on stte 3). The suset onstrution hs to e pplied, s follows (the initil stte group is 1 3):

32 30 CHAPTER 2. REGULAR LANGUAGES group finl? yes yes yes yes 6 4 no yes yes yes 5 4 no suessor tle The suset onstrution produes deterministi utomton A with nine sttes. Here is the stte-trnsition grph: deterministi utomton A - stte-trnsition grph The error stte is not shown expliitly, ut of ourse is present nywy. The otined deterministi utomton A is not neessrily in miniml form. Solution of (4) It is pretty evident tht the otined deterministi utomton A is not in miniml form, s the stte tle ontins identil rows. First it is onvenient to renme sttes in more ompt wy, s follows on the left:

33 2.2. FINITE STATE AUTOMATON 31 stte finl? A B C D yes B E F D yes C E C G yes D E C D yes E H no F E C G yes G E C D yes H E K yes K H no stte tle stte finl? A B C D yes B E C D yes C E C D yes D E C D yes E H no H E K yes K H no stte tle Now notie tht rows C, F nd D, G re identil, hene sttes C, F nd D, G re indistinguishle, nd the equivlenes C F nd D G hold. One n then remove rows F nd G, nd reple F nd G y C nd D, respetively; see the figure ove on the right. Removl nd replement use other rows to eome identil, nmely rows B, C nd D. Suh sttes re therefore indistinguishle nd onstitute n equivlene lss. One n then remove rows C nd D, nd reple oth C nd D y B, s follows on the left: stte finl? A B B B yes B E B B yes E H no H E K yes K H no,, A B E H K, stte tle miniml utomton A Now, to identify other potentil equivlenes one should resort to the stndrd minimistion lgorithm sed on the tringulr implition tle. Here however it is possile to onlude more quikly. Rememer tht finl sttes re lwys distinguishle from the sttes tht re not finl. Notie lso tht the utomton is in redued form (s ll the sttes re useful). Then the following resoning pplies: Sttes E nd K re distinguishle, s they ehve differently s for the error stte. Stte H is distinguishle from oth sttes A nd B, s with letter stte H goes into the error stte while sttes A nd B do not. Stte A is distinguishle from stte B s their equivlene would imply tht of sttes B nd E, whih tully does not hold. Therefore ll the sttes A, B, E, H nd K re distinguishle. Minimistion ends here nd the stte-trnsition grph of the miniml utomton A is shown ove on the right.

34 32 CHAPTER 2. REGULAR LANGUAGES Oservtion Alterntively, one ould minimise the deterministi utomton A diretly y mens of the stndrd lgorithm sed on the tringulr implition tle. Here it is, on the left: B BE CF C BE DG CF DG D BE CF DG E F BE DG CF DG DG G BE CF DG DG H K A B C D E F G H implition tle B BE C BE D BE E F BE G BE H K A B C D E F G H Sine there re immedite distinguishle nd indistinguishle stte pirs, propgtion is neessry. In the tle on the right ove, distinguishle stte pirs re rred through nd oloured in red, while the indistinguishle ones re repled y. Rememer tht for pir of sttes to e indistinguishle, ll the implitions it hs must e. Then one otins the following finl tle, on the left: B C D E E D C B F G H K A B C D E F G H F G H K A finl implition tle equivlene reltion The tle does not ontin irulr implitions nd is fully solved. The equivlene reltion is shown on the right ove. The equivlene lsses re {A}, {B, C, D, F, G}, {E}, {H} nd {K}, whih of ourse is the sme result s efore. Exerise 8 Consider the following finite stte utomton A:

35 2.2. FINITE STATE AUTOMATON Automton A 3 2 Answer the following questions: 1. Design deterministi utomton A equivlent to A (use method of hoie). 2. Minimize the numer of sttes of the deterministi utomton A otined efore. Solution of (1) Notie tht utomton A is in redued form (every stte is oth rehle nd defined). In order to determinise A one hd etter strt utting spontneous trnsitions (-trnsition). It is onvenient first to ut r 3 0 nd duplite from sttes 0 to 3 the r outgoing from 0, nd then to ut r 2 3 nd duplite from sttes 2 to 3 the r inoming into 2 (of ourse without removing the originl rs nd ). Suh uts minimise the numer of rs to duplite nd do not introdue ny new initil or finl sttes. In this wy one otins the following utomton A, whih is still indeterministi (stte 1 hs three outgoing rs leled with letter ): Automton A The two dshed rs leled with letters nd re the replited ones nd their funtion is to reonstrut the leled pths tht re interrupted on utting the two spontneous trnsitions. Then one n otin deterministi utomton A equivlent to utomton A y mens of the lssil suset onstrution (rried out with the suessor tle lgorithm):

36 34 CHAPTER 2. REGULAR LANGUAGES group finl? no no yes yes no suessor tle Automton A The suset onstrution leds to the deterministi utomton A drwn on the right, whih still hs four sttes (s usul in drwing deterministi utomt the error stte is omitted). The deterministi utomton A is in redued form (ll the sttes re oth rehle nd definite). In ft if the originl indeterministi utomton is in redued form, the suset onstrution rried out y mens of the suessor tle lgorithm neessrily produes redued deterministi utomton. Notie tht the utomton my e not in miniml form. Solution of (2) In generl to minimise the numer of sttes of deterministi utomton one should use the lssil stte minimistion lgorithm, sed on the tringulr implition tle. Sometimes however one n reh onlusion more quikly, s it is here the se. As finl stte is lwys distinguishle from stte tht is not finl, to hek whether the deterministi utomton A is in miniml form it suffies to exmine pirs of sttes whih re oth finl or not finl. Then one otins the following results: sttes 0 nd 1 re distinguishle, s from 1, ut not from 0, there is n outgoing r leled with letter sttes nd 1 3 re distinguishle, s from the r leled with letter goes into finl stte, while from 1 3 the r leled in the sme wy goes into stte tht is not finl Therefore the deterministi utomton A is lredy in miniml form nd, s verified efore, is in redued form s well. This lso implies tht A is unique. In onlusion it is definitely impossile to further redue the numer of sttes of A under four. Oservtion Rememer tht if determinism is not required, there my exist n indeterministi utomton equivlent to utomton A with fewer thn four sttes. The reder my wish to investigte y himself whether suh n utomton exists (existene is not grnted).

37 2.2. FINITE STATE AUTOMATON 35 Exerise 9 Given deterministi finite stte utomton M tht reognizes lnguge L(M), onsider the following onstrutions (orderly listed): i. trnsform M into n utomton N R tht reognizes the mirror lnguge L(M) R ii. trnsform N R into deterministi utomton M R equivlent to N R iii. trnsform M R into n utomton M RR tht reognizes the mirror lnguge L(M R ) R Answer the following questions: 1. Strt from the utomton M shown elow, perform the ove mentioned onstrutions (i), (ii) nd (iii) (in the speified order), nd drw the stte-trnsition grphs of the requested utomt N R, M R nd M RR Compre the two utomt M nd M RR, explin wht mkes them different from eh other nd why. Solution of (1) Automton M reognises lists (not empty) of type () : suh strings lwys egin with one element nd (possily) ontinue only with elements ; the elements ( or ) re lwys seprted y extly one letter. The utomt onstruted fter eh trnsformtion re listed s follows. Here is the (indeterministi) utomton N R, otined s the mirror imge of utomton M (it hs the two initil sttes 2 nd 4): Automton N R Suh n utomton is indeterministi euse of stte 3, whih hs two outgoing rs oth leled with the sme letter, nd euse of the two initil sttes 2 nd 4. Here is the deterministi utomton M R (equivlent to N R ), whih is otined from N R y pplying the suset onstrution. Sine there re multiple initil sttes the tle of stte groups

38 36 CHAPTER 2. REGULAR LANGUAGES egins with the suset of initil sttes {2, 4}, whih onstitutes the unique initil stte of the deterministi resulting utomton M R : group finl? no no 1 yes no suessor tle Automton M R stte-trnsition grph On the right side there is the stte-trnsition grph of utomton M R, where s usul the error stte is omitted. Finlly here is utomton M RR, otined s the mirror imge of utomton M R : Automton M RR The deterministi utomton M RR is in redued form (every stte is rehle from stte 1 nd rehes finl stte 2 4), nd it is esy to verify tht it is miniml s well: t the est stte 1 nd 3 might e indistinguishle, ut this is flse s they do not hve outgoing rs leled in the sme wy. Solution of (2) Clerly the lnguge reognised y utomton M RR is nothing else ut the lnguge L itself, s it holds (L R ) R = L. Therefore utomton M RR is equivlent to the originl utomton M nd differs from M euse of the lower numer of sttes. In ft, it will e proved soon tht M RR is neessrily in miniml form. In other words, trnsformtions (i), (ii) nd (iii) onstitute stte minimistion proedure, s one n esily see from the following resoning. Two sttes p nd q of utomton M re indistinguishle if nd only if the two sets of strings y tht lel the pths onneting p nd q to the finl sttes, respetively, re equl. Consider lel string y of length 1 suh tht: p y f q y g where f nd g re finl sttes (no mtter wether different or oinident). In the determinised mirror utomton M R, the mirrored string y R lels pth from the initil stte (neessiily unique) to suset {...,p,...,q,...}, surely uilt y the deterministion lgorithm, ontining oth sttes p nd q (esides possily other sttes).

39 2.2. FINITE STATE AUTOMATON 37 When utomton M RR is otined s the mirror imge of utomton M R (y simply flipping the diretion of rs nd swpping initil nd finl sttes), sttes do not hnge, hene the indistinguishle sttes p nd q hppen to e grouped together in the suset {...,p,...,q,...}, nd therefore the result is the sme s wht would hve een otined with the lssil stte minimistion lgorithm (sed on the tringulr implition tle). Oservtion There re t lest three well known stte minimistion lgorithms: the stndrd one, redited to Nerode nd sed on the tringulr implition tle; tht seen ove, redited to Brozozowski; nd third one, redited to Hoproft. The stndrd or Nerode stte minimistion lgorithm hs worst se qudrti time omplexity, i.e. O ( n 2) where n is the numer of sttes of the originl utomton to minimise. The Brozozowski stte minimistion lgorithm onsists of pplying to the utomton first mirror, seond deterministion, third gin mirror nd fourth gin deterministion (unless the finl utomton is lredy deterministi). Suh n lgorithm is ineffiient nywy, euse the intermedite nd finl utomt otined fter deterministion my e not in redued form nd exhiit n exponentil explosion of the numer of sttes. One need hek whether suh utomt hve unuseful sttes nd, if so, one need put them in redued form, whih in the worst se my tke n exponentil time with respet to the numer of sttes of the originl utomton, i.e. O (exp(n)) where n is the numer of sttes. The Hoproft stte minimistion lgorithm is insted sed on the ide of repetedly splitting the stte set of the utomton so s to otin finlly the equivlene lsses of indistinguishle sttes. Suh n lgorithm is deidedly more sophistited thn the Nerode nd Brozozowski ones, nd oneptully is more diffiult to understnd, ut in return it is more effiient, s its worst se time omplexity is of type O (n log n), where n is the numer of sttes of the originl utomton to minimise. Exerise 10 The following regulr expression R is given (in generlised form s it ontins the intersetion opertor), over lphet {,, }: R = ( ) ( ) ( + ) Answer the following questions: 1. Design in systemti wy reogniser utomton equivlent to R (tht is design it s the intersetion of utomt). 2. If neessry, put the designed reogniser in deterministi form. Solution of (1) Intuitively the intersetion is expressed y the following regulr expression R : R = ( ( + + ) )

40 38 CHAPTER 2. REGULAR LANGUAGES Expression R is equivlent to the regulr expression R given in the exerise. In order to find the intersetion in systemti wy, first the two utomt of the two suexpressions ( ) nd ( ) ( + ) n e otined y mens of the Berri-Sethi or MNughton-Ymd lgorithm, nd then they should e interseted y mens of the rtesin produt onstrution. Atully the two utomt re rther esy to find intuitively. For suexpression ( ) one soon hs the following utomton: One designs the utomton quikly y oserving tht ( ) = ( ) holds, s ( ) genertes the empty string or generi string eginning with letter. For suexpression ( ) ( + ) one soon hs the following utomton: A B D C Both utomt re lredy deterministi nd in redued form (s ll the sttes re useful). Should the ltter utomton seem somewht omplex to design in n intuitive wy, here is how to otin it systemtilly y mens of the MNughton-Ymd lgorithm, whih is sed on reful exmintion of the follow hrters of the expression genertors: ( 1 2 ) ( strt 1, 2 genertor follow ) 1, 2 3, 4, 5, 4, , 4, strt nd follow tle MNughton-Ymd lgorithm

41 2.2. FINITE STATE AUTOMATON 39 By the wy, the onstruted utomton oinides with the intuitive version shown efore. It is deterministi (y onstrution) nd hppens to e miniml (s it n e verified esily). And here is the intersetion utomton (otined y mens of the rtesin produt of utomt), where unrehle nd indefinite sttes re skipped: 1A 2B 3D 3B rtesin produt utomton The resulting produt utomton is evidently deterministi nd miniml: sttes 1A (not finl) nd 2B (finl) ould e indistinguishle only from sttes 3B (not finl) nd 3D (finl), respetively, ut oth 1A nd 2B do not hve outgoing r leled with, while 3B nd 3D do. The utomton genertes the regulr expression R of the intersetion tht is given ove; the reder is left the tsk of verifying so (for instne y mens of the Brozozowski or node elimintion lgorithm). Solution of (2) The produt utomton ove is lredy deterministi, therefore nothing else is needed. Exerise 11 Consider the two following lnguges (notie tht the lphets re different): L 1 = { x {,} the seond hrter of x is } L 2 = {x {,,} the seond lst (i.e. penultimte) hrter of x is } Answer the following questions: 1. Construt the miniml deterministi utomton tht reognises the lnguge L 1 L 2 nd explin the dopted resoning. 2. Construt the miniml deterministi utomton tht reognises the lnguge L 1 L 2 nd explin the dopted resoning. 3. Construt the miniml deterministi utomton tht reognises the lnguge L 1 L R 2 (L R 2 is the mirror imge of L 2) nd explin the dopted resoning.

42 40 CHAPTER 2. REGULAR LANGUAGES Solution of (1) If one wishes to proeed in n lgorithmi wy, first one ought to design in n intuitive wy the two utomt A 1 nd A 2 tht reognise the two lnguges L 1 nd L 2, respetively (suh utomt my e indeterministi), then one should unite A 1 nd A 2 (indeterministilly), determinise the resulting utomton nd eventully minimise it. Here re the two utomt to strt with: Automton of L 1 = ( ) ( ) :,, Automton A 1 : Automton A 1 is lredy deterministi. Automton of L 2 = ( ) ( ): Automton A 2 : 0 1 2,,,, Automton A 2 is indeterministi (in the stte 0). If one wishes, one n give lgoritmilly the two utomt A 1 nd A 2, for instne y mens of the Berri-Sethi or MNughton-Ymd lgorithm (in the ltter se oth utomt would e deterministi). Here the two intuitive utomt re used. Union utomton (indeterministi) A 3 :,, Automton A 3 : 0 4 5,, 6,, Automton A 3 is indeterministi in the sttes 0 nd 4. Stte 0 hs outgoing spontneous trnsitions (-trnsitions).

43 2.2. FINITE STATE AUTOMATON 41 Elimintion of spontneous trnsitions (yields utomton A 4 ):,, 2 3 Automton A 4 : 0,, 4 5,, 6,, Automton A 4 is still indeterministi in the sttes 0 nd 4 (ut without spontneous trnsitions). Suset onstrution (yields utomton A 5 ): Automton A 5 group finl? no no no no yes yes yes no yes yes yes stte finl? A B C D no B E F F no C G D D no D H D D no E E I F yes F H D D yes G E I F yes H L F F no I G M D yes L L F F yes M G M D yes suessor tle stte tle Minimistion of utomton A 5. As rows I nd M oinide, s well s rows E nd G, the respetive indexing sttes re indistinguishle nd one immeditely finds the stte equivlenes I M nd E G. Therefore one otins the utomton A 6 :

44 42 CHAPTER 2. REGULAR LANGUAGES Automton A 6 stte finl? A B C D no B E F F no C E D D no D H D D no E E I F yes F H D D yes H L F F no I E I D yes L L F F yes stte tle It is not diffiult to sertin intuitively tht the remining sttes re ll distinguishle from one nother. Therefore utomton A 6 is in the miniml form. Here is its stte-trnsition grph: Automton A 6 : B E I,, C A F L, D,, H, stte-trnsition grph

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their

More information

CS 573 Automata Theory and Formal Languages

CS 573 Automata Theory and Formal Languages Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple

More information

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6 CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized

More information

NON-DETERMINISTIC FSA

NON-DETERMINISTIC FSA Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is

More information

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton:

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)

More information

= state, a = reading and q j

= state, a = reading and q j 4 Finite Automt CHAPTER 2 Finite Automt (FA) (i) Derterministi Finite Automt (DFA) A DFA, M Q, q,, F, Where, Q = set of sttes (finite) q Q = the strt/initil stte = input lphet (finite) (use only those

More information

Nondeterministic Automata vs Deterministic Automata

Nondeterministic Automata vs Deterministic Automata Nondeterministi Automt vs Deterministi Automt We lerned tht NFA is onvenient model for showing the reltionships mong regulr grmmrs, FA, nd regulr expressions, nd designing them. However, we know tht n

More information

Finite State Automata and Determinisation

Finite State Automata and Determinisation Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions

More information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 6: Minigoals Towards Simplifying and Rewriting Expressions MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy

More information

Regular languages refresher

Regular languages refresher Regulr lnguges refresher 1 Regulr lnguges refresher Forml lnguges Alphet = finite set of letters Word = sequene of letter Lnguge = set of words Regulr lnguges defined equivlently y Regulr expressions Finite-stte

More information

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Siene Deprtment Compiler Design Spring 7 Lexil Anlysis Smple Exerises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sienes Institute 47 Admirlty Wy, Suite

More information

6.5 Improper integrals

6.5 Improper integrals Eerpt from "Clulus" 3 AoPS In. www.rtofprolemsolving.om 6.5. IMPROPER INTEGRALS 6.5 Improper integrls As we ve seen, we use the definite integrl R f to ompute the re of the region under the grph of y =

More information

Chapter 4 State-Space Planning

Chapter 4 State-Space Planning Leture slides for Automted Plnning: Theory nd Prtie Chpter 4 Stte-Spe Plnning Dn S. Nu CMSC 722, AI Plnning University of Mrylnd, Spring 2008 1 Motivtion Nerly ll plnning proedures re serh proedures Different

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. 1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

System Validation (IN4387) November 2, 2012, 14:00-17:00

System Validation (IN4387) November 2, 2012, 14:00-17:00 System Vlidtion (IN4387) Novemer 2, 2012, 14:00-17:00 Importnt Notes. The exmintion omprises 5 question in 4 pges. Give omplete explntion nd do not onfine yourself to giving the finl nswer. Good luk! Exerise

More information

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points: Eidgenössishe Tehnishe Hohshule Zürih Eole polytehnique fédérle de Zurih Politenio federle di Zurigo Federl Institute of Tehnology t Zurih Deprtement of Computer Siene. Novemer 0 Mrkus Püshel, Dvid Steurer

More information

Introduction to Olympiad Inequalities

Introduction to Olympiad Inequalities Introdution to Olympid Inequlities Edutionl Studies Progrm HSSP Msshusetts Institute of Tehnology Snj Simonovikj Spring 207 Contents Wrm up nd Am-Gm inequlity 2. Elementry inequlities......................

More information

2.4 Theoretical Foundations

2.4 Theoretical Foundations 2 Progrmming Lnguge Syntx 2.4 Theoretil Fountions As note in the min text, snners n prsers re se on the finite utomt n pushown utomt tht form the ottom two levels of the Chomsky lnguge hierrhy. At eh level

More information

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b CS 294-2 9/11/04 Quntum Ciruit Model, Solovy-Kitev Theorem, BQP Fll 2004 Leture 4 1 Quntum Ciruit Model 1.1 Clssil Ciruits - Universl Gte Sets A lssil iruit implements multi-output oolen funtion f : {0,1}

More information

Lecture 6: Coding theory

Lecture 6: Coding theory Leture 6: Coing theory Biology 429 Crl Bergstrom Ferury 4, 2008 Soures: This leture loosely follows Cover n Thoms Chpter 5 n Yeung Chpter 3. As usul, some of the text n equtions re tken iretly from those

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

Bisimulation, Games & Hennessy Milner logic

Bisimulation, Games & Hennessy Milner logic Bisimultion, Gmes & Hennessy Milner logi Leture 1 of Modelli Mtemtii dei Proessi Conorrenti Pweł Soboiński Univeristy of Southmpton, UK Bisimultion, Gmes & Hennessy Milner logi p.1/32 Clssil lnguge theory

More information

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α Disrete Strutures, Test 2 Mondy, Mrh 28, 2016 SOLUTIONS, VERSION α α 1. (18 pts) Short nswer. Put your nswer in the ox. No prtil redit. () Consider the reltion R on {,,, d with mtrix digrph of R.. Drw

More information

Computational Biology Lecture 18: Genome rearrangements, finding maximal matches Saad Mneimneh

Computational Biology Lecture 18: Genome rearrangements, finding maximal matches Saad Mneimneh Computtionl Biology Leture 8: Genome rerrngements, finding miml mthes Sd Mneimneh We hve seen how to rerrnge genome to otin nother one sed on reversls nd the knowledge of the preserved loks or genes. Now

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata

@#? Text Search ] { ! Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata g Text Serh @#? ~ Mrko Berezovský Rdek Mřík PAL 0 Nondeterministi Finite Automt n Trnsformtion NFA to DFA nd Simultion of NFA f Text Serh Using Automt A B R Power of Nondeterministi Approh u j Regulr Expression

More information

TOPIC: LINEAR ALGEBRA MATRICES

TOPIC: LINEAR ALGEBRA MATRICES Interntionl Blurete LECTUE NOTES for FUTHE MATHEMATICS Dr TOPIC: LINEA ALGEBA MATICES. DEFINITION OF A MATIX MATIX OPEATIONS.. THE DETEMINANT deta THE INVESE A -... SYSTEMS OF LINEA EQUATIONS. 8. THE AUGMENTED

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite! Solutions for HW9 Exerise 28. () Drw C 6, W 6 K 6, n K 5,3. C 6 : W 6 : K 6 : K 5,3 : () Whih of the following re iprtite? Justify your nswer. Biprtite: put the re verties in V 1 n the lk in V 2. Biprtite:

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL:

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL: PYTHAGORAS THEOREM 1 WHAT S IN CHAPTER 1? 1 01 Squres, squre roots nd surds 1 02 Pythgors theorem 1 03 Finding the hypotenuse 1 04 Finding shorter side 1 05 Mixed prolems 1 06 Testing for right-ngled tringles

More information

CS241 Week 6 Tutorial Solutions

CS241 Week 6 Tutorial Solutions 241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

Symmetrical Components 1

Symmetrical Components 1 Symmetril Components. Introdution These notes should e red together with Setion. of your text. When performing stedy-stte nlysis of high voltge trnsmission systems, we mke use of the per-phse equivlent

More information

Arrow s Impossibility Theorem

Arrow s Impossibility Theorem Rep Voting Prdoxes Properties Arrow s Theorem Arrow s Impossiility Theorem Leture 12 Arrow s Impossiility Theorem Leture 12, Slide 1 Rep Voting Prdoxes Properties Arrow s Theorem Leture Overview 1 Rep

More information

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4. Mth 5 Tutoril Week 1 - Jnury 1 1 Nme Setion Tutoril Worksheet 1. Find ll solutions to the liner system by following the given steps x + y + z = x + y + z = 4. y + z = Step 1. Write down the rgumented mtrix

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

Lesson 2: The Pythagorean Theorem and Similar Triangles. A Brief Review of the Pythagorean Theorem.

Lesson 2: The Pythagorean Theorem and Similar Triangles. A Brief Review of the Pythagorean Theorem. 27 Lesson 2: The Pythgoren Theorem nd Similr Tringles A Brief Review of the Pythgoren Theorem. Rell tht n ngle whih mesures 90º is lled right ngle. If one of the ngles of tringle is right ngle, then we

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

Section 1.3 Triangles

Section 1.3 Triangles Se 1.3 Tringles 21 Setion 1.3 Tringles LELING TRINGLE The line segments tht form tringle re lled the sides of the tringle. Eh pir of sides forms n ngle, lled n interior ngle, nd eh tringle hs three interior

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals AP Clulus BC Chpter 8: Integrtion Tehniques, L Hopitl s Rule nd Improper Integrls 8. Bsi Integrtion Rules In this setion we will review vrious integrtion strtegies. Strtegies: I. Seprte the integrnd into

More information

Part I: Study the theorem statement.

Part I: Study the theorem statement. Nme 1 Nme 2 Nme 3 A STUDY OF PYTHAGORAS THEOREM Instrutions: Together in groups of 2 or 3, fill out the following worksheet. You my lift nswers from the reding, or nswer on your own. Turn in one pket for

More information

The Word Problem in Quandles

The Word Problem in Quandles The Word Prolem in Qundles Benjmin Fish Advisor: Ren Levitt April 5, 2013 1 1 Introdution A word over n lger A is finite sequene of elements of A, prentheses, nd opertions of A defined reursively: Given

More information

Polynomials. Polynomials. Curriculum Ready ACMNA:

Polynomials. Polynomials. Curriculum Ready ACMNA: Polynomils Polynomils Curriulum Redy ACMNA: 66 www.mthletis.om Polynomils POLYNOMIALS A polynomil is mthemtil expression with one vrile whose powers re neither negtive nor frtions. The power in eh expression

More information

Discrete Structures Lecture 11

Discrete Structures Lecture 11 Introdution Good morning. In this setion we study funtions. A funtion is mpping from one set to nother set or, perhps, from one set to itself. We study the properties of funtions. A mpping my not e funtion.

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Model Reduction of Finite State Machines by Contraction

Model Reduction of Finite State Machines by Contraction Model Reduction of Finite Stte Mchines y Contrction Alessndro Giu Dip. di Ingegneri Elettric ed Elettronic, Università di Cgliri, Pizz d Armi, 09123 Cgliri, Itly Phone: +39-070-675-5892 Fx: +39-070-675-5900

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

12.4 Similarity in Right Triangles

12.4 Similarity in Right Triangles Nme lss Dte 12.4 Similrit in Right Tringles Essentil Question: How does the ltitude to the hpotenuse of right tringle help ou use similr right tringles to solve prolems? Eplore Identifing Similrit in Right

More information

Transition systems (motivation)

Transition systems (motivation) Trnsition systems (motivtion) Course Modelling of Conurrent Systems ( Modellierung neenläufiger Systeme ) Winter Semester 2009/0 University of Duisurg-Essen Brr König Tehing ssistnt: Christoph Blume In

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II 2 ottom-up Prsing Prt II 1 Cnonil Colletion of LR(0) items CC_LR(0)_I items(g :ugmented_grmmr){ C = {CLOURE({ })} ; repet{ foreh(i C) foreh(grmmr symol X) if(goto(i,x) && GOTO(I,X) C) C = C {GOTO(I,X)};

More information

Thoery of Automata CS402

Thoery of Automata CS402 Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

More information

A Lower Bound for the Length of a Partial Transversal in a Latin Square, Revised Version

A Lower Bound for the Length of a Partial Transversal in a Latin Square, Revised Version A Lower Bound for the Length of Prtil Trnsversl in Ltin Squre, Revised Version Pooy Htmi nd Peter W. Shor Deprtment of Mthemtil Sienes, Shrif University of Tehnology, P.O.Bo 11365-9415, Tehrn, Irn Deprtment

More information

Prefix-Free Regular-Expression Matching

Prefix-Free Regular-Expression Matching Prefix-Free Regulr-Expression Mthing Yo-Su Hn, Yjun Wng nd Derik Wood Deprtment of Computer Siene HKUST Prefix-Free Regulr-Expression Mthing p.1/15 Pttern Mthing Given pttern P nd text T, find ll sustrings

More information

CSE 401 Compilers. Today s Agenda

CSE 401 Compilers. Today s Agenda CSE 401 Compilers Leture 3: Regulr Expressions & Snning, on?nued Mihel Ringenurg Tody s Agend Lst?me we reviewed lnguges nd grmmrs, nd riefly strted disussing regulr expressions. Tody I ll restrt the regulr

More information

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic Chpter 3 Vetor Spes In Chpter 2, we sw tht the set of imges possessed numer of onvenient properties. It turns out tht ny set tht possesses similr onvenient properties n e nlyzed in similr wy. In liner

More information

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix tries Definition of tri mtri is regulr rry of numers enlosed inside rkets SCHOOL OF ENGINEERING & UIL ENVIRONEN Emple he following re ll mtries: ), ) 9, themtis ), d) tries Definition of tri Size of tri

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

Alpha Algorithm: Limitations

Alpha Algorithm: Limitations Proess Mining: Dt Siene in Ation Alph Algorithm: Limittions prof.dr.ir. Wil vn der Alst www.proessmining.org Let L e n event log over T. α(l) is defined s follows. 1. T L = { t T σ L t σ}, 2. T I = { t

More information

p-adic Egyptian Fractions

p-adic Egyptian Fractions p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design nd Anlysis LECTURE 5 Supplement Greedy Algorithms Cont d Minimizing lteness Ching (NOT overed in leture) Adm Smith 9/8/10 A. Smith; sed on slides y E. Demine, C. Leiserson, S. Rskhodnikov,

More information

Arrow s Impossibility Theorem

Arrow s Impossibility Theorem Rep Fun Gme Properties Arrow s Theorem Arrow s Impossiility Theorem Leture 12 Arrow s Impossiility Theorem Leture 12, Slide 1 Rep Fun Gme Properties Arrow s Theorem Leture Overview 1 Rep 2 Fun Gme 3 Properties

More information

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs Isomorphism of Grphs Definition The simple grphs G 1 = (V 1, E 1 ) n G = (V, E ) re isomorphi if there is ijetion (n oneto-one n onto funtion) f from V 1 to V with the property tht n re jent in G 1 if

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18 Computt onl Biology Leture 18 Genome Rerrngements Finding preserved genes We hve seen before how to rerrnge genome to obtin nother one bsed on: Reversls Knowledge of preserved bloks (or genes) Now we re

More information

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

Proving the Pythagorean Theorem

Proving the Pythagorean Theorem Proving the Pythgoren Theorem W. Bline Dowler June 30, 2010 Astrt Most people re fmilir with the formul 2 + 2 = 2. However, in most ses, this ws presented in lssroom s n solute with no ttempt t proof or

More information

April 8, 2017 Math 9. Geometry. Solving vector problems. Problem. Prove that if vectors and satisfy, then.

April 8, 2017 Math 9. Geometry. Solving vector problems. Problem. Prove that if vectors and satisfy, then. pril 8, 2017 Mth 9 Geometry Solving vetor prolems Prolem Prove tht if vetors nd stisfy, then Solution 1 onsider the vetor ddition prllelogrm shown in the Figure Sine its digonls hve equl length,, the prllelogrm

More information

Lecture Notes No. 10

Lecture Notes No. 10 2.6 System Identifition, Estimtion, nd Lerning Leture otes o. Mrh 3, 26 6 Model Struture of Liner ime Invrint Systems 6. Model Struture In representing dynmil system, the first step is to find n pproprite

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014 S 224 DIGITAL LOGI & STATE MAHINE DESIGN SPRING 214 DUE : Mrh 27, 214 HOMEWORK III READ : Relte portions of hpters VII n VIII ASSIGNMENT : There re three questions. Solve ll homework n exm prolems s shown

More information

MAT 403 NOTES 4. f + f =

MAT 403 NOTES 4. f + f = MAT 403 NOTES 4 1. Fundmentl Theorem o Clulus We will proo more generl version o the FTC thn the textook. But just like the textook, we strt with the ollowing proposition. Let R[, ] e the set o Riemnn

More information

Bases for Vector Spaces

Bases for Vector Spaces Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything

More information

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3 2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

2.4 Linear Inequalities and Interval Notation

2.4 Linear Inequalities and Interval Notation .4 Liner Inequlities nd Intervl Nottion We wnt to solve equtions tht hve n inequlity symol insted of n equl sign. There re four inequlity symols tht we will look t: Less thn , Less thn or

More information

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata Desriptionl Complexity of Non-Unry Self-Verifying Symmetri Differene Automt Lurette Mris 1,2 nd Lynette vn Zijl 1 1 Deprtment of Computer Siene, Stellenosh University, South Afri 2 Merk Institute, CSIR,

More information

CS 491G Combinatorial Optimization Lecture Notes

CS 491G Combinatorial Optimization Lecture Notes CS 491G Comintoril Optimiztion Leture Notes Dvi Owen July 30, August 1 1 Mthings Figure 1: two possile mthings in simple grph. Definition 1 Given grph G = V, E, mthing is olletion of eges M suh tht e i,

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Comparing the Pre-image and Image of a Dilation

Comparing the Pre-image and Image of a Dilation hpter Summry Key Terms Postultes nd Theorems similr tringles (.1) inluded ngle (.2) inluded side (.2) geometri men (.) indiret mesurement (.6) ngle-ngle Similrity Theorem (.2) Side-Side-Side Similrity

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information