Finite State Automata and Determinisation

Size: px
Start display at page:

Download "Finite State Automata and Determinisation"

Transcription

1 Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016

2 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 5 Deterministi Finite Stte Automt (df) 6 Deterministion Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

3 Lnguges fs nf re df Deterministion 3 Alphets An lphet Σ is set of tokens used y lnguge Σ = {0, 1} is the lphet for inry Σ = {., 0, 1,..., 9} is the lphet for deiml numer Σ = {mro, polo} is the lphet for the ommunitions protool in the gme Mro Polo 1 Wht lnguge(s) is this the lphet for? Σ = {x, 0, 1,..., 9, A, B,..., F} 1 A gme involving lling out Mro! nd Polo!, with n optionl swimming pool Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

4 Lnguges fs nf re df Deterministion 4 Strings A omintion 2 of elements from Σ is lled string 0, , 111 re ll strings of Σ = {0, 1} The set Σ is the infinite set of ll omintions of the elements of Σ For the inry lphet, Σ = {0, 1}, Σ is 3 Σ = {, (0), (1), (00), (01), (10), (11), (000), (001),...} 2 Oviously, ontiguous ordered tuple of elements, not set: 01 is different string from 10 3 Here the empty set will do to represent null or empty string Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

5 Lnguges fs nf re df Deterministion 5 Lnguges A lnguge L is set of items from Σ whih re deemed to e vlid (L Σ ) For hexdeiml, only the strings whih egin with 0x nd hve t lest one more non- x token re deemed vlid 0xF x0 0x 1xA (the empty string) A lnguge in this ontext is not set of rules, syntx, grmmr nd ll: it s just set of vlid strings Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

6 Lnguges fs nf re df Deterministion 6 Finite Stte Automt Finite Stte Automt re representtions of self-ontined finite set of sttes, with rules tht govern movement mong those sttes. Finite Stte Automt (fss) exist everywhere They re used to illustrte the possile sttes some proess n e in how the proess moves etween these sttes Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

7 Lnguges fs nf re df Deterministion 7 Finite Stte Automt E.g. stte mhine for PIN ode entry on your moile 4 : 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! 4 How mny people do you know who sy PIN Numer? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

8 Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

9 Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

10 Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

11 Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels fss hve strt node (entry point) Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

12 Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels fss hve strt node (entry point) fss hve epting nodes, denoted with the doule outline Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

13 Lnguges fs nf re df Deterministion 9 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! You re lwys on one of the nodes, i.e., in one of the sttes. You n trvel etween the nodes following the direted edges You n only trvel long n edge if you see the lel tht is on the edge Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

14 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

15 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

16 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

17 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

18 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

19 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

20 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

21 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

22 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

23 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

24 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 q 0 q 1 q 2 q 3 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

25 Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q q 0 0x0 q 0 q 1 q 2 q 3 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

26 Lnguges fs nf re df Deterministion 11 Non-deterministi Finite Stte Automt There re two min types of fss Deterministi Non-deterministi Wht we hve een looking t so fr re exmples of non-deterministi finite [stte] utomt (nf) E.g. nf for reognising hexdeiml numer: 0-9,A-F 0 x 0-9,A-F Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

27 Lnguges fs nf re df Deterministion 12 Properties of nfs Must hve strt node No restritions on the edge lels Allowed speil ε edge lels (we ll ome k to this) Allowed to e on multiple sttes simultneously non-determinism Bsilly n NFA is FSA tht isn t fully defined: in DFA (Deterministi Finite (Stte) Automton of ourse), everything hs to e determined: if there s n error ondition tht hs to e explined, there n t e ny miguity, nd so on. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

28 Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

29 Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

30 Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

31 Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } {q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

32 Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } {q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

33 Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

34 Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

35 Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

36 Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 1, q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

37 Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 1, q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

38 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

39 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

40 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

41 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

42 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

43 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } {q 1, q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

44 Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } {q 1, q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

45 Lnguges fs nf re df Deterministion 16 ε trnsitions nfs n hve speil trnsition lel ε ε llows trnsition without onsuming ny input tokens ϵ q4 In English, wht pttern does this nf therefore llow us to mth? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

46 Lnguges fs nf re df Deterministion 16 ε trnsitions nfs n hve speil trnsition lel ε ε llows trnsition without onsuming ny input tokens ϵ q4 In English, wht pttern does this nf therefore llow us to mth? Any string strting with, followed y one or more instnes of, followed y Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

47 Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

48 Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

49 Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s As ove, exept for one s insted of zero s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

50 Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s As ove, exept for one s insted of zero s Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

51 Lnguges fs nf re df Deterministion 18 Your turn Construt nf whih epts only inry numers with n even numer of zero s OR n even numer of one s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

52 Lnguges fs nf re df Deterministion 18 Your turn Construt nf whih epts only inry numers with n even numer of zero s OR n even numer of one s. 1 1 ϵ 0 0 ϵ q4 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

53 Lnguges fs nf re df Deterministion 19 Regulr Expressions (re) You rememer the power of regulr expressions? These things n sve the world! regex s rule.... nd it turns out they re muh etter interpreted nd delt with Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

54 Lnguges fs nf re df Deterministion 20 Regulr Expressions s nfs Regulr expressions n esily e represented using nfs We n group regulr expressions into 4 different omponents Chrter single hrter: // Contention two djent expressions: // Union two OR d expressions: / / Kleene str zero or more repetitions: /*/ /( d*)*e/ n e viewed s ont ont str union e ont str d Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

55 Lnguges fs nf re df Deterministion 21 And it relly does mtter Knowing the right wy to do regulr expressions, using good omputer siene, mens tht you don t hve to mke mjor errors leding to relly relly d performne, in hrdly-used it of softwre, like sy, Perl. This is the time tken to mth the sequene? n n ginst n where the supersript represents string repets, so? 2 2 =?? Soure: Russ Cox / rs@swth.om 5 5 For gret disussion of this, see Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

56 Lnguges fs nf re df Deterministion 22 re to nf: Chrter // Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

57 Lnguges fs nf re df Deterministion 23 re to nf: Contention // + eomes ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

58 Lnguges fs nf re df Deterministion 24 re to nf: Union / / + eomes q4 ϵ ϵ ϵ ϵ q5 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

59 Lnguges fs nf re df Deterministion 25 re to nf: Kleene Str /*/ eomes ϵ ϵ ϵ ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

60 Lnguges fs nf re df Deterministion 26 An exmple onversion /( d*)*e/ eomes ϵ ϵ ϵ ϵ q4 ϵ q5 q6 ϵ ϵ d ϵ q7 q8 ϵ q9 0 ϵ ϵ 1 ϵ 2 ϵ 3 e 4 ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

61 Lnguges fs nf re df Deterministion 27 DFAs vs NFAs How do dfs differ from nfs? Deterministi (not non-deterministi) No ε edges Every edge from node must hve unique lel (n t e in multiple sttes) Every node must hve n outwrd edge for eh token of the lphet (it is ompletely desried) Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

62 Lnguges fs nf re df Deterministion 28 dfs vs. nfs E.g. df for reognising hexdeiml numer: 0-9,A-F 0 x 1-9,A-F,x 0-9,A-F 0-9,A-F q4 x x 0-9,A-F,x q5 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

63 Lnguges fs nf re df Deterministion 29 Why do we need dfs? Wht s wrong with nfs? The non-deterministi spet of nfs mkes them d for modern-dy omputtion Computers nnot effiiently perform the e in multiple sttes t one In df, you n only e in one stte t time Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

64 Lnguges fs nf re df Deterministion 30 Your turn dfs n e hrder to mnully onstrut thn nfs, due to their restritions. Construt df over Σ = {, } epting strings ending in. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

65 Lnguges fs nf re df Deterministion 30 Your turn dfs n e hrder to mnully onstrut thn nfs, due to their restritions. Construt df over Σ = {, } epting strings ending in. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

66 Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

67 Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? multiple edges with the sme lel oming off node ε edges ility to e in multiple sttes t one Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

68 Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? multiple edges with the sme lel oming off node ε edges ility to e in multiple sttes t one In 1959, Rin nd Sott proved tht nfs nd dfs hve the sme expressive power The proof is surprisingly simple: we need to show tht for eh NFA there is DFA, nd vie-vers, tht ept preisely the sme lnguges. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

69 Lnguges fs nf re df Deterministion 32 Deterministion Algorithm This lgorithm onverts ny nf into n equivlent df ϵ 0 0 ϵ q into 0,1 {,,} 0,1 {,q4} 0 1 {,} 0 0 {q4} 1 {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

70 Lnguges fs nf re df Deterministion 33 Move nd Epsilon-Closure Move M(sttes, token) Given set of sttes nd n input token, wht set of sttes do you end up t Epsilon-Closure EC(sttes) Given set of sttes, wht set of sttes do you get y expnding ll ε trnsitions, ϵ, M({q 0, q 1 }, ) = {q 2, q 3 } EC({q 2, q 3 }) = {q 0, q 2, q 3 } Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

71 Lnguges fs nf re df Deterministion 34 Algorithm Ide We need to remove the onept of non-determinism in the df Ahieved y reting stte in the df for every possile set of sttes in the nf Q: If the nf hs n sttes, wht s the mximum numer of sttes its orresponding df ould hve? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

72 Lnguges fs nf re df Deterministion 34 Algorithm Ide We need to remove the onept of non-determinism in the df Ahieved y reting stte in the df for every possile set of sttes in the nf Q: If the nf hs n sttes, wht s the mximum numer of sttes its orresponding df ould hve? A: P(n) = 2 n Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

73 Lnguges fs nf re df Deterministion 35 Pseudoode Require: nf df new DFA ojet df.strt EC(nf.strt) todo [df.strt] while todo = do sttes = pop the next item off todo for ll σ Σ NFA \ {ε} do s = EC (M(sttes, σ)) if s = then Add the edge sttes Add s to todo if it s new end if end for end while return df σ s to df Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

74 Lnguges fs nf re df Deterministion 36 Exmple, todo {0} ϵ, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

75 Lnguges fs nf re df Deterministion 36 Exmple, todo {0} ϵ, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

76 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {,} {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

77 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {,} {,,} {,} {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

78 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {} {,} {,,} {,}, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

79 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,}, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

80 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,},, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

81 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,},, {} {},,,, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

82 Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3}, {} {,} {,,} {,,} {,},, {} {},,,, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

83 Lnguges fs nf re df Deterministion 37 Finish End of presenttion. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

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

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

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

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

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

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

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

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

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

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

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

NFA and regex. the Boolean algebra of languages. non-deterministic machines. regular expressions

NFA and regex. the Boolean algebra of languages. non-deterministic machines. regular expressions NFA nd regex l the Boolen lger of lnguges non-deterministi mhines regulr expressions Informtis The intersetion of two regulr lnguges is regulr Run oth mhines in prllel? Build one mhine tht simultes two

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

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ Running n NFA & the suset lgorithm (NFA->DFA) CS 350 Fll 2018 gilry.org/lsses/fll2018/s350/ 1 NFAs operte y simultneously exploring ll pths nd epting if ny pth termintes t n ept stte.!2 Try n exmple: L

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

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

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

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

= 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

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

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

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

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

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

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

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

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

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

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

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

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

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

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering Petri Nets Ree Alreht Seminr: Automt Theory Chir of Softwre Engeneering Overview 1. Motivtion: Why not just using finite utomt for everything? Wht re Petri Nets nd when do we use them? 2. Introdution:

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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

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

Worked out examples Finite Automata

Worked out examples Finite Automata Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will

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

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

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

State Complexity of Union and Intersection of Binary Suffix-Free Languages

State Complexity of Union and Intersection of Binary Suffix-Free Languages Stte Complexity of Union nd Intersetion of Binry Suffix-Free Lnguges Glin Jirásková nd Pvol Olejár Slovk Ademy of Sienes nd Šfárik University, Košie 0000 1111 0000 1111 Glin Jirásková nd Pvol Olejár Binry

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information

input tape head moves current state

input tape head moves current state CPS 140 - Mthemticl Foundtions of CS Dr. Susn Rodger Section: Finite Automt (Ch. 2) (lecture notes) Things to do in clss tody (Jn. 13, 2004): ffl questions on homework 1 ffl finish chpter 1 ffl Red Chpter

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

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

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

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Dt Strutures nd Algorithm Xioqing Zheng zhengxq@fudn.edu.n String mthing prolem Pttern P ours with shift s in text T (or, equivlently, tht pttern P ours eginning t position s + in text T) if T[s +... s

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

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

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

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

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

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

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

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

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

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

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

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

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

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

ɛ-closure, Kleene s Theorem,

ɛ-closure, Kleene s Theorem, DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene

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

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

More information

CSCI565 - Compiler Design

CSCI565 - Compiler Design CSCI565 - Compiler Deign Spring 6 Due Dte: Fe. 5, 6 t : PM in Cl Prolem [ point]: Regulr Expreion nd Finite Automt Develop regulr expreion (RE) tht detet the longet tring over the lphet {-} with the following

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive

More information

Java II Finite Automata I

Java II Finite Automata I Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression

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

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

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

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

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1 Non Deterministic Automt Forml Lnguges nd Automt - Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges

More information

State Minimization for DFAs

State Minimization for DFAs Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7 CS103 Hndout 32 Fll 2016 Novemer 11, 2016 Prolem Set 7 Wht cn you do with regulr expressions? Wht re the limits of regulr lnguges? On this prolem set, you'll find out! As lwys, plese feel free to drop

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

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

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

More on automata. Michael George. March 24 April 7, 2014

More on automata. Michael George. March 24 April 7, 2014 More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

More information

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

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

Automata and Regular Languages

Automata and Regular Languages Chpter 9 Automt n Regulr Lnguges 9. Introution This hpter looks t mthemtil moels of omputtion n lnguges tht esrie them. The moel-lnguge reltionship hs multiple levels. We shll explore the simplest level,

More information