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

Size: px
Start display at page:

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

Transcription

1 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, / 35

2 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 on n input w y keeping trck of ll possile sttes the NFA could e in We cn convert n NFA to DFA y letting ech stte of the DFA represent set of sttes in the NFA 2 / 35

3 Building new lnguges using regulr opertion Use regulr opertions to uild new lnguges A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } D = C E = A (B C) F = (D C) (B E) 3 / 35

4 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } 4 / 35

5 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} 4 / 35

6 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} = {} ({} {}) ({} {} {}) 4 / 35

7 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} = {} ({} {}) ({} {} {}) B = {} {} {} 4 / 35

8 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} = {} ({} {}) ({} {} {}) B = {} {} {} A = {} {} ({} Σ {}) ({} Σ {}) 4 / 35

9 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} = {} ({} {}) ({} {} {}) B = {} {} {} A = {} {} ({} Σ {}) ({} Σ {}) = {} {} ({} ({} {}) {}) ({} ({} {}) {}) 4 / 35

10 Descriing complex lnguges using simpler ones Use regulr opertions to rek complex lnguges down into simpler ones A = {w w strts nd ends with the sme symols} B = { k k 1} C = {,, } C = {} {} {} = {} ({} {}) ({} {} {}) B = {} {} {} A = {} {} ({} Σ {}) ({} Σ {}) = {} {} ({} ({} {}) {}) ({} ({} {}) {}) We roke ech lnguge down into lnguges contining {}, {}, or {} nd comined them using the three regulr opertions,, nd 4 / 35

11 Regulr expressions The rces ren t dding nything since ll of our sets re singletons; let s drop them Similrly, let s drop the much s how we drop multipliction symols Let s lso replce with (which we red s or ) This gives us regulr expressions (regex) A = {} {} ({} ({} {}) {}) ({} ({} {}) {}) = B = {} {} {} = C = {} ({} {}) ({} {} {}) = 5 / 35

12 Regulr expressions The rces ren t dding nything since ll of our sets re singletons; let s drop them Similrly, let s drop the much s how we drop multipliction symols Let s lso replce with (which we red s or ) This gives us regulr expressions (regex) A = {} {} ({} ({} {}) {}) ({} ({} {}) {}) = ( ) ( ) B = {} {} {} = C = {} ({} {}) ({} {} {}) = 5 / 35

13 Regulr expressions The rces ren t dding nything since ll of our sets re singletons; let s drop them Similrly, let s drop the much s how we drop multipliction symols Let s lso replce with (which we red s or ) This gives us regulr expressions (regex) A = {} {} ({} ({} {}) {}) ({} ({} {}) {}) = ( ) ( ) B = {} {} {} = C = {} ({} {}) ({} {} {}) = 5 / 35

14 Regulr expressions The rces ren t dding nything since ll of our sets re singletons; let s drop them Similrly, let s drop the much s how we drop multipliction symols Let s lso replce with (which we red s or ) This gives us regulr expressions (regex) A = {} {} ({} ({} {}) {}) ({} ({} {}) {}) = ( ) ( ) B = {} {} {} = C = {} ({} {}) ({} {} {}) = 5 / 35

15 Regulr expressions The rces ren t dding nything since ll of our sets re singletons; let s drop them Similrly, let s drop the much s how we drop multipliction symols Let s lso replce with (which we red s or ) This gives us regulr expressions (regex) A = {} {} ({} ({} {}) {}) ({} ({} {}) {}) = ( ) ( ) B = {} {} {} = C = {} ({} {}) ({} {} {}) = Order of opertion:,, Prentheses used for grouping We underline the expression to differentite the string from the regulr expression 5 / 35

16 Regulr expressions Six types of regulr expressions: three se types, three recursive types Regex Lnguge (very rrely used) {} t {t} for ech t Σ R 1 R 2 L(R 1 ) L(R 2 ) R 1 nd R 2 re regex R 1 R 2 L(R 1 ) L(R 2 ) R 1 nd R 2 re regex R L(R) R is regex As shorthnd, we ll use Σ to men (or similr for other lphets) A = Σ Σ 6 / 35

17 Techniclities Techniclly, regulr expression genertes or descries (regulr) lnguge, it is not lnguge itself Given regulr expression R, the lnguge L(R) is the set of strings generted y R E.g., R = genertes strings,,,... L(R) = { k k 0} A DFA M recognizes (regulr) lnguge L(M) ut we don t identify M with its lnguge Similrly, we shouldn t identify regulr expression R with its lnguge L(R); however it is customry to do so Still, even if we let {} =, tht doesn t men is the sme s! 7 / 35

18 Kleene str = { k k 0} 8 / 35

19 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} 8 / 35

20 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} ( ) = {w w is the conctention of 0 or more or } 8 / 35

21 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} ( ) = {w w is the conctention of 0 or more or } = { m n m, n 0} 8 / 35

22 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} ( ) = {w w is the conctention of 0 or more or } = { m n m, n 0} = {} = 8 / 35

23 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} ( ) = {w w is the conctention of 0 or more or } = { m n m, n 0} = {} = = {} = 8 / 35

24 Kleene str = { k k 0} ( c) = {w w contins ny numer of,, or c in ny order} ( ) = {w w is the conctention of 0 or more or } = { m n m, n 0} = {} = = {} = Σ = Σ = {w w is string over Σ} 8 / 35

25 Regulr expression exmples ΣΣ = {w w = 2} 9 / 35

26 Regulr expression exmples ΣΣ = {w w = 2} (ΣΣ) = {w w is even} 9 / 35

27 Regulr expression exmples ΣΣ = {w w = 2} (ΣΣ) = {w w is even} ( ) = {w every in w is followed y t lest one } 9 / 35

28 Regulr expression exmples ΣΣ = {w w = 2} (ΣΣ) = {w w is even} ( ) = {w every in w is followed y t lest one } ( ) = 9 / 35

29 Regulr expression exmples ΣΣ = {w w = 2} (ΣΣ) = {w w is even} ( ) = {w every in w is followed y t lest one } ( ) = = {w w contins exctly one } 9 / 35

30 Question 1 Wht strings re in the lnguge given y the regulr expression ( )( )? 10 / 35

31 Question 1 Wht strings re in the lnguge given y the regulr expression ( )( )?,,, 10 / 35

32 Question 2 True or flse. If lnguges A nd B ech contin 2 strings, then A B contins 4 strings. 11 / 35

33 Question 2 True or flse. If lnguges A nd B ech contin 2 strings, then A B contins 4 strings. Flse. Counter exmple: A = B = {, }. A B = {,, } Another counter exmple A = {, } nd B = {, }. A B = {,, } 11 / 35

34 Question 3 Is in the lnguge given y ( )? 12 / 35

35 Question 3 Is in the lnguge given y ( )? Yes. = 12 / 35

36 Question 4 Write regex for the lnguge {w is sustring of w} 13 / 35

37 Question 4 Write regex for the lnguge {w is sustring of w} Σ Σ 13 / 35

38 Question 5 Write regex for the lnguge {w the second symol of w is or the third to lst symol of w is } 14 / 35

39 Question 5 Write regex for the lnguge {w the second symol of w is or the third to lst symol of w is } ΣΣ Σ ΣΣ 14 / 35

40 Question 6 Let Σ = {0, 1,..., 9, } nd D = Wht strings re generted y the following regulr expression? ((1 )DDD )DDD DDD 15 / 35

41 Question 6 Let Σ = {0, 1,..., 9, } nd D = Wht strings re generted y the following regulr expression? ((1 )DDD )DDD DDD U.S. phone numers. We cn rewrite this regex s 1 DDD DDD DDDD DDD DDD DDDD DDD DDDD 15 / 35

42 Question 7 If R is regulr expression, then the lnguge generted y R is either infinite or contins exctly one string. Under wht condition on R is R infinite? When R contins exctly one string, wht is the string nd wht is R? 16 / 35

43 Question 7 If R is regulr expression, then the lnguge generted y R is either infinite or contins exctly one string. Under wht condition on R is R infinite? When R contins exctly one string, wht is the string nd wht is R? R is infinite if R contins t lest one nonempty string R contins exctly one string, nmely, when R = or R = 16 / 35

44 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 17 / 35

45 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 17 / 35

46 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 (R 1 R 2 )R 3 = R 1 R 3 R 2 R 3 17 / 35

47 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 (R 1 R 2 )R 3 = R 1 R 3 R 2 R 3 R 1 (R 2 R 3 ) = R 1 R 2 R 1 R 3 17 / 35

48 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 (R 1 R 2 )R 3 = R 1 R 3 R 2 R 3 R 1 (R 2 R 3 ) = R 1 R 2 R 1 R 3 (R1 ) = R1 17 / 35

49 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 (R 1 R 2 )R 3 = R 1 R 3 R 2 R 3 R 1 (R 2 R 3 ) = R 1 R 2 R 1 R 3 (R1 ) = R1 (R 1 R 2 ) = (R1 R2 ) 17 / 35

50 Regulr expression mnipultion Let R 1, R 2, nd R 3 e regulr expressions R 1 = R 1 R 1 = R 1 (R 1 R 2 )R 3 = R 1 R 3 R 2 R 3 R 1 (R 2 R 3 ) = R 1 R 2 R 1 R 3 (R1 ) = R1 (R 1 R 2 ) = (R1 R2 ) Theorem Every regulr expression R cn e rewritten s n equivlent regulr expression R 1 R 2 R k such tht none of the R i contin n or ( ) 17 / 35

51 Converting regulr expressions to NFAs Theorem Every regulr expression R cn e converted to n equivlent NFA N. I.e., L(N) = L(R) Proof ide Induction on the structure of the regex We need to construct NFAs directly for the three se cses,, nd t for t Σ Then, we hndle the three inductive cses, R 1 R 2, R 1 R 2, nd R 1 For the inductive cses, we ssume there exist NFAs for R 1 nd R 2 nd use them to uild NFAs for the three inductive cses 18 / 35

52 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 19 / 35

53 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 2 R = 19 / 35

54 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 2 R = 3 R = t t for t Σ 19 / 35

55 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 2 R = 3 R = t Inductive cses. 4 R = R 1 R 2 5 R = R 1 R 2 6 R = R 1 t for t Σ 19 / 35

56 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 2 R = 3 R = t Inductive cses. 4 R = R 1 R 2 5 R = R 1 R 2 6 R = R 1 t for t Σ By the inductive hypothesis, there exist NFAs N 1 nd N 2 such tht L(N 1 ) = L(R 1 ) nd L(N 2 ) = L(R 2 ). 19 / 35

57 Converting regulr expressions to NFAs Proof. Bse cses. 1 R = 2 R = 3 R = t Inductive cses. 4 R = R 1 R 2 5 R = R 1 R 2 6 R = R 1 t for t Σ By the inductive hypothesis, there exist NFAs N 1 nd N 2 such tht L(N 1 ) = L(R 1 ) nd L(N 2 ) = L(R 2 ). Since regulr lnguges re closed under union, conctention, nd Kleene str, L(R) is regulr so there exists some NFA N such tht L(N) = L(R). 19 / 35

58 Converting regulr expressions to NFAs The proof of the inductive cses pplied previous theorems to show tht some NFA exists But we know how to perform the constructions explicitly: N 1 N 1 N 2 N 2 N 1 20 / 35

59 Regulr expressions descrie regulr lnguges The lnguge of regulr expression is regulr This follow directly from the previous theorem: Regulr expression NFA DFA regulr lnguge 21 / 35

60 Regulr expression to NFA: R = () () 1 22 / 35

61 Regulr expression to NFA: R = () () / 35

62 Regulr expression to NFA: R = () () / 35

63 Regulr expression to NFA: R = () () () 22 / 35

64 Regulr expression to NFA: R = () () () 5 () 22 / 35

65 Regulr expression to NFA: R = () () () 5 () 6 () 22 / 35

66 Regulr expression to NFA: R = () () () 5 () 6 () 7 R 22 / 35

67 Not the smllest possile NFA 23 / 35

68 Not the smllest possile NFA 23 / 35

69 Not the smllest possile NFA 23 / 35

70 Not the smllest possile NFA 23 / 35

71 Not the smllest possile NFA 23 / 35

72 Not the smllest possile NFA "Accepted 23 / 35

73 Not the smllest possile NFA "Accepted 24 / 35

74 Not the smllest possile NFA "Accepted 24 / 35

75 Not the smllest possile NFA "Accepted 24 / 35

76 Not the smllest possile NFA "Accepted 24 / 35

77 Not the smllest possile NFA "Accepted $Rejected 24 / 35

78 Not the smllest possile NFA "Accepted $Rejected 25 / 35

79 Not the smllest possile NFA "Accepted $Rejected 25 / 35

80 Not the smllest possile NFA "Accepted $Rejected 25 / 35

81 Not the smllest possile NFA "Accepted $Rejected $Rejected 25 / 35

82 Converting from NFAs to regex Theorem Every NFA (nd thus every DFA) cn e converted to n equivlent regulr expression. Proof ide 1 Convert the NFA to new type of finite utomton whose edges re leled with regulr expressions 2 Remove sttes nd updte trnsitions one t time from the new utomton to produce n equivlent utomton 3 When only the strt nd (single) ccept stte remin, the trnsition etween them is the regulr expression 26 / 35

83 Generlized NFA (GNFA) A GNFA is finite utomton with single ccept stte, no trnsitions to the strt stte, no trnsitions from the ccept stte, nd ech trnsition is leled with regulr expression q 1 q 0 q q 2 27 / 35

84 GNFA cceptnce A GNFA trnsitions from one stte to the next y reding lock of input symols generted y the regex q 1 q 0 q q 2 28 / 35

85 GNFA cceptnce A GNFA trnsitions from one stte to the next y reding lock of input symols generted y the regex q 1 q 0 q q 2 28 / 35

86 GNFA cceptnce A GNFA trnsitions from one stte to the next y reding lock of input symols generted y the regex q 1 q 0 q q 2 28 / 35

87 GNFA cceptnce A GNFA trnsitions from one stte to the next y reding lock of input symols generted y the regex q 1 q 0 q q 2 28 / 35

88 GNFA cceptnce A GNFA trnsitions from one stte to the next y reding lock of input symols generted y the regex q 1 q 0 q q 2 "Accepted 28 / 35

89 Removing sttes in GNFA 1 Select stte to remove r other thn the strt or ccept sttes (r Q {q 0, q }) 2 For ech q, s Q {r} we hve R 2 R 1 R 3 q r s R 4 If trnsition is missing from the GNFA, then the corresponding regex is Remove stte r nd replce regex R 4 with R 1 R 2 R3 R 4 q R 1 R 2 R 3 R 4 s 29 / 35

90 Removing sttes in GNFA 1 Select stte to remove r other thn the strt or ccept sttes (r Q {q 0, q }) 2 For ech q, s Q {r} we hve R 2 R 4 R 2 R 1 R 3 R 1 q r s q r R 4 If trnsition is missing from the GNFA, then the corresponding regex is Remove stte r nd replce regex R 4 with R 1 R 2 R3 R 4 R 3 q R 1 R2 R 3 R 4 s q R 1 R2 R 3 R 4 29 / 35

91 Remove stte q 1 q 1 q 0 q q 2 q 0 q q 2 30 / 35

92 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = q 2 q 0 q q 2 30 / 35

93 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q q 2 30 / 35

94 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q q 2 30 / 35

95 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q ( )( ) q 2 30 / 35

96 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q ( )( ) q 2 30 / 35

97 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q ( )( ) q 2 ( ) 30 / 35

98 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q ( )( ) q 2 ( ) 30 / 35

99 Remove stte q 1 R 1 = q 1 R 2 = R 3 = q 0 q R 4 = ( )( ) q 2 q 0 q ( )( ) q 2 ( ) ( ) 30 / 35

100 Remove stte q 2 ( )( ) q 0 q ( )( ) q 2 ( ) ( ) (( )( ) )(( ) ) (( ) ) (( )( ) ) q 0 q 31 / 35

101 Converting GNFA to regulr expression Remove sttes one t time until only the strt nd ccept remin The one remining trnsition is n equivlent regex G: q 1 q 0 q q 2 L(G) = (( )( ) )(( ) ) (( ) ) (( )( ) ) 32 / 35

102 Converting n NFA (or DFA) to GNFA 1 Add new strt stte with n epsilon trnsition to the originl strt stte 2 Add new ccept stte with epsilon trnsitions from the originl ccept sttes 3 Convert multiple trnsitions etween pir of nodes to single regex using to seprte them, 33 / 35

103 Converting n NFA (or DFA) to regulr expression Theorem Every NFA (nd thus every DFA) cn e converted to n equivlent regulr expression. Proof. Given n NFA N, convert it to n equivlent GNFA G. Convert G to n equivlent regulr expression. (Some detils missing, ut see the ook.) 34 / 35

104 Exmple, q 1 q 2 First, convert to GNFA. q 0 q 1 q 2 q 35 / 35

105 Exmple, q 1 q 2 First, convert to GNFA. q 0 q 1 q 2 q ( ) Next, remove q 1 q 0 ( ) q 2 q 35 / 35

106 Exmple, q 1 q 2 First, convert to GNFA. q 0 q 1 q 2 q ( ) Next, remove q 1 q 0 ( ) q 2 q ( )(( )) Next, remove q 2 q 0 q 35 / 35

107 Exmple, q 1 q 2 First, convert to GNFA. q 0 q 1 q 2 q ( ) Next, remove q 1 q 0 ( ) q 2 q ( )(( )) Next, remove q 2 q 0 q Equivlent regulr expression ( )(( )) 35 / 35

108 Exmple, q 1 q 2 First, convert to GNFA. q 0 q 1 q 2 q ( ) Next, remove q 1 q 0 ( ) q 2 q ( )(( )) Next, remove q 2 q 0 q Equivlent regulr expression ( )(( )) = Σ(Σ) 35 / 35

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

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

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

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

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

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

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

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

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

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

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

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3. Finite utomt nd regulr

More information

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun: CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

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

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

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

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

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES nd REGULAR EXPRESSIONS TUESDAY Jn 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w hs equl numer of

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

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

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

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

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

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

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

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

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

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

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

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010 CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

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

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

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

Languages & Automata

Languages & Automata Lnguges & Automt Dr. Lim Nughton Lnguges A lnguge is sed on n lphet which is finite set of smols such s {, } or {, } or {,..., z}. If Σ is n lphet, string over Σ is finite sequence of letters from Σ, (strings

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

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

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

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

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

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

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

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

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

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

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

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

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

ɛ-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

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

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

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

Lecture 6 Regular Grammars

Lecture 6 Regular Grammars Lecture 6 Regulr Grmmrs COT 4420 Theory of Computtion Section 3.3 Grmmr A grmmr G is defined s qudruple G = (V, T, S, P) V is finite set of vribles T is finite set of terminl symbols S V is specil vrible

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

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

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

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

Today s Topics Automata and Languages

Today s Topics Automata and Languages Tody s Topics Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn DFA to Regulr Expression GFNA DFAèGNFA GNFA è RE DFA è RE Exmples 2 DFA è RE NFA DFA -NFA REX GNFA 3 Definition

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Tody s Topics DFA to Regulr Expression GFNA DFAèGNFA GNFA è RE DFA è RE Exmples 2 DFA è RE NFA DFA -NFA REX GNFA 3 Definition

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

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

GNFA GNFA GNFA GNFA GNFA

GNFA GNFA GNFA GNFA GNFA DFA RE NFA DFA -NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with in-egree, n unique finl stte with

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages of Regulr Lnguges Dr. Neil T. Dntm CSCI-561, Colordo School of Mines Fll 2018 Dntm (Mines CSCI-561) Closure Properties of Regulr Lnguges Fll 2018 1 / 50 Outline Introduction Closure Properties Stte Minimiztion

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

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

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, section 003, George Mson University, Fll 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 7 1. Prove (p q) (p q), () (5pts) using truth tles. p q

More information

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15 Models of Comput:on Lecture #8 Chpter 7 con:nued Any lnguge tht e defined y regulr expression, finite utomton, or trnsi:on grph cn e defined y ll three methods We prove this y showing tht ny lnguge defined

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

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 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

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

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

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q

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

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

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

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

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

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

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

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

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy: Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

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

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

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

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

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

Turing Machines Part One

Turing Machines Part One Turing Mchines Prt One Wht problems cn we solve with computer? Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges Tht sme drwing, to scle. All Lnguges The Problem Finite

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

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

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

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

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

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

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

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

In-depth introduction to main models, concepts of theory of computation:

In-depth introduction to main models, concepts of theory of computation: CMPSCI601: Introduction Lecture 1 In-depth introduction to min models, concepts of theory of computtion: Computility: wht cn e computed in principle Logic: how cn we express our requirements Complexity:

More information