Recap from Last Time

Size: px
Start display at page:

Download "Recap from Last Time"

Transcription

1 Regular Expressions

2 Recap from Last Time

3 Regular Languages A language L is a regular language if there is a DFA D such that L( D) = L. Theorem: The following are equivalent: L is a regular language. There is a DFA for L. There is an NFA for L.

4 Language Concatenation If w Σ* and x Σ*, then wx is the concatenation of w and x. If L₁ and L₂ are languages over Σ, the concatenation of L₁ and L₂ is the language L₁L₂ defined as L₁L₂ = { wx w L₁ and x L₂ } Example: if L₁ = { a, ba, bb } and L₂ = { aa, bb }, then L₁L₂ = { aaa, abb, baaa, babb, bbaa, bbbb }

5 New Stuff!

6 Lots and Lots of Concatenation Consider the language L = { aa, b } LL is the set of strings formed by concatenating pairs of strings in L. { aaaa, aab, baa, bb } LLL is the set of strings formed by concatenating triples of strings in L. { aaaaaa, aaaab, aabaa, aabb, baaaa, baab, bbaa, bbb} LLLL is the set of strings formed by concatenating quadruples of strings in L. { aaaaaaaa, aaaaaab, aaaabaa, aaaabb, aabaaaa, aabaab, aabbaa, aabbb, baaaaaa, baaaab, baabaa, baabb, bbaaaa, bbaab, bbbaa, bbbb}

7 Language Exponentiation We can define what it means to exponentiate a language as follows: L 0 = {ε} The set containing just the empty string. Idea: Any string formed by concatenating zero strings together is the empty string. L n+1 = LL n Idea: Concatenating (n+1) strings together works by concatenating n strings, then concatenating one more. Question: Why define L 0 = {ε}?

8 The Kleene Closure An important operation on languages is the Kleene Closure, which is defined as L* = { w Σ* n N. w L n } Mathematically: w L* iff n N. w L n Intuitively, all possible ways of concatenating zero or more strings in L together, possibly with repetition.

9 The Kleene Closure If L = { a, bb }, then L* = { ε, a, bb, aa, abb, bba, bbbb, aaa, aabb, abba, abbbb, bbaa, bbabb, bbbba, bbbbbb, } Think Think of of L L * * as as the the set set of of strings strings you you can can make make if if you you have have a a collection collection of of stamps stamps one one for for each each string string in in L L and and you you form form every every possible possible string string that that can can be be made made from from those those stamps. stamps.

10 Reasoning about Infinity If L is regular, is L* necessarily regular? A Bad Line of Reasoning: L 0 = { ε } is regular. L 1 = L is regular. L 2 = LL is regular L 3 = L(LL) is regular Regular languages are closed under union. So the union of all these languages is regular.

11 Reasoning about Infinity

12 Reasoning about Infinity x x

13 Reasoning about Infinity x x

14 Reasoning about Infinity x x

15 Reasoning about Infinity x x

16 Reasoning about Infinity x x

17 Reasoning about Infinity x x

18 Reasoning about Infinity 2x x x

19 Reasoning about Infinity 0.9 < 1

20 Reasoning about Infinity 0.99 < 1

21 Reasoning about Infinity < 1

22 Reasoning about Infinity < 1

23 Reasoning about Infinity < 1

24 Reasoning about Infinity < 1

25 Reasoning about Infinity 0 is finite

26 Reasoning about Infinity 1 is finite

27 Reasoning about Infinity 2 is finite

28 Reasoning about Infinity 3 is finite

29 Reasoning about Infinity 4 is finite

30 Reasoning about Infinity is finite

31 Reasoning about Infinity is finite ^ not

32 Reasoning About the Infinite If a series of finite objects all have some property, the limit of that process does not necessarily have that property. In general, it is not safe to conclude that some property that always holds in the finite case must hold in the infinite case. (This is why calculus is interesting).

33 Idea: Can we directly convert an NFA for language L to an NFA for language L*?

34 The Kleene Star start Machine for L

35 The Kleene Star start ε Machine for L

36 The Kleene Star start ε Machine for L

37 The Kleene Star ε ε start ε Machine for L

38 The Kleene Star ε ε start ε Machine for L

39 The Kleene Star ε ε start ε Machine for L Machine for L*

40 The Kleene Star ε ε start ε Question: Question: Why Why add add the the new new state state out out front? front? Why Why not not just just make make the the old old start start state state accepting? accepting? Machine for L Machine for L*

41 Closure Properties Theorem: If L₁ and L₂ are regular languages over an alphabet Σ, then so are the following languages: L₁ L₁ L₂ L₁ L₂ L₁L₂ L₁* These properties are called closure properties of the regular languages.

42 Another View of Regular Languages

43 Rethinking Regular Languages We currently have several tools for showing a language is regular. Construct a DFA for it. Construct an NFA for it. Apply closure properties to existing languages. We have not spoken much of this last idea.

44 Constructing Regular Languages Idea: Build up all regular languages as follows: Start with a small set of simple languages we already know to be regular. Using closure properties, combine these simple languages together to form more elaborate languages. A bottom-up approach to the regular languages.

45 Constructing Regular Languages Idea: Build up all regular languages as follows: Start with a small set of simple languages we already know to be regular. Using closure properties, combine these simple languages together to form more elaborate languages. A bottom-up approach to the regular languages.

46 Regular Expressions Regular expressions are a way of describing a language via a string representation. Used extensively in software systems for string processing and as the basis for tools like grep and flex. Conceptually, regular languages are strings describing how to assemble a larger language out of smaller pieces.

47 Atomic Regular Expressions The regular expressions begin with three simple building blocks. The symbol Ø is a regular expression that represents the empty language Ø. For any a Σ, the symbol a is a regular expression for the language {a}. The symbol ε is a regular expression that represents the language {ε}. Remember: {ε} Ø! Remember: {ε} ε!

48 Compound Regular Expressions If R1 and R 2 are regular expressions, R 1 R 2 is a regular expression for the concatenation of the languages of R 1 and R 2. If R1 and R 2 are regular expressions, R 1 R 2 is a regular expression for the union of the languages of R 1 and R 2. If R is a regular expression, R* is a regular expression for the Kleene closure of the language of R. If R is a regular expression, (R) is a regular expression with the same meaning as R.

49 Operator Precedence Regular expression operator precedence: (R) R* R 1 R 2 R 1 R 2 So ab*c d is parsed as ((a(b*))c) d

50 Regular Expression Examples The regular expression trick treat represents the regular language { trick, treat }. The regular expression booo* represents the regular language { boo, booo, boooo, }. The regular expression candy!(candy!)* represents the regular language { candy!, candy!candy!, candy!candy!candy!, }.

51 Regular Expressions, Formally The language of a regular expression is the language described by that regular expression. Formally: L(ε) = {ε} L(Ø) = Ø L(a) = {a} L(R1 R 2 ) = L( R 1 ) L( R 2 ) L(R1 R 2 ) = L( R 1 ) L( R 2 ) L(R*) = L( R)* L((R)) = L( R) Worthwhile Worthwhile activity: activity: Apply Apply this this recursive recursive definition definition to to a(b c)((d)) and and see see what what you you get. get.

52 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring }

53 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*

54 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*

55 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*

56 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*

57 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } Σ*00Σ*

58 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 }

59 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 }

60 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } The The length of of a string w is is denoted w w

61 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 }

62 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ

63 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ

64 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ

65 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ

66 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } Σ

67 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w = 4 } Σ

68 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 }

69 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*

70 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*

71 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*

72 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*

73 Designing Regular Expressions Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*0?1*

74 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses.

75 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

76 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

77 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

78 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

79 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

80 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

81 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@ cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

82 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@ cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

83 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@aa*.aa* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

84 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@aa*.aa* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

85 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@aa*.aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

86 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. aa*(.aa*)*@aa*.aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

87 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.aa*)*@aa*.aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

88 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.aa*)*@aa*.aa*(.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

89 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

90 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

91 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

92 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

93 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a + (.a + ) + cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

94 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + a + (.a + ) + cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

95 A More Elaborate Design Let Σ = { }, where a represents some letter. Let's make a regex for addresses. a + (.a + )*@ a + (.a + ) + cs103@cs.stanford.edu first.middle.last@mail.site.org dot.at@dot.com

96 Regular Expressions are Awesome a + (.a + )*@a + (.a + ) q 2 q 8 q a start q 0 a q q 3 a q 4. q 5 a q 6 a a a

97 Shorthand Summary R n is shorthand for RR R (n times). Edge case: define R 0 = ε. Σ is shorthand for any character in Σ. R? is shorthand for (R ε), meaning zero or one copies of R. R+ is shorthand for RR*, meaning one or more copies of R.

98 Time-Out for Announcements!

99 Problem Sets Problem Set Five was due at the start of today s lecture. Need more time? Use your 24-hour late days! Problem Set Six goes out today. It s due next Friday at the start of class. Design DFAs and NFAs for various languages! Explore properties of formal language theory! See applications of the concepts!

100 Problem Set Four Problem Set Four is now graded. Here s the score distribution: As always, feel free to stop by office hours to discuss your problem sets or the feedback. We re happy to help out!

101 Your Questions

102 what do the numberings of the handouts mean They re They re numbered numbered sequentially. sequentially. Anything Anything ending ending in in an an S S is is a a solutions solutions set, set, anything anything in in C C is is a a checkpoint checkpoint solutions solutions set, set, and and anything anything in in an an R R is is a a regrade regrade form. form.

103 Why did you delete a top-ranking question about handout numbers? Oops. Oops. I I didn t didn t mean mean to to do do that. that. Sorry! Sorry!

104 What is Stanford CS doing increase faculty diversity? (in terms of gender, race, class, etc.) We ve We ve significantly significantly stepped stepped up up efforts efforts to to address address this this recently. recently. I ll I ll take take this this one one in in class. class.

105 Back to CS103!

106 The Power of Regular Expressions Theorem: If R is a regular expression, then L( R) is regular. Proof idea: Use induction! The atomic regular expressions all represent regular languages. The combination steps represent closure properties. So anything you can make from them must be regular!

107 Thompson s Algorithm In practice, many regex matchers use an algorithm called Thompson's algorithm to convert regular expressions into NFAs (and, from there, to DFAs). Read Sipser if you re curious! Fun fact: the Thompson here is Ken Thompson, one of the co-inventors of Unix!

108 The Power of Regular Expressions Theorem: If L is a regular language, then there is a regular expression for L. This is not obvious! Proof idea: Show how to convert an arbitrary NFA into a regular expression.

109 Generalizing NFAs q₂ Σ b start q₀ a q₁ ε q₃ Σ b q₄

110 Generalizing NFAs q₂ Σ b start q₀ a q₁ ε q₃ Σ b q₄

111 Generalizing NFAs q₂ Σ b start q₀ ε q₃ a Σ b q₁ q₄ These These are are all all regular regular expressions! expressions!

112 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃

113 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ Note: Note: Actual Actual NFAs NFAs aren't aren't allowed allowed to to have have transitions transitions like like these. these. This This is is just just a a thought thought experiment. experiment.

114 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

115 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

116 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

117 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

118 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

119 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

120 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

121 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

122 Generalizing NFAs start ab b q₀ q₁ a ab* q₂ a*b?a* q₃ a a a b a a b b b

123 Key Idea 1: Imagine that we can label transitions in an NFA with arbitrary regular expressions.

124 Generalizing NFAs start ab b q₀ q₁

125 Generalizing NFAs start ab b q₀ q₁ Is Is there there a a simple simple regular regular expression expression for for the the language language of of this this generalized generalized NFA? NFA?

126 Generalizing NFAs start ab b q₀ q₁ Is Is there there a a simple simple regular regular expression expression for for the the language language of of this this generalized generalized NFA? NFA?

127 Generalizing NFAs start a q₀ + (.a + )*@a + (.a + ) + q₁

128 Generalizing NFAs start a q₀ + (.a + )*@a + (.a + ) + q₁ Is Is there there a a simple simple regular regular expression expression for for the the language language of of this this generalized generalized NFA? NFA?

129 Generalizing NFAs start a q₀ + (.a + )*@a + (.a + ) + q₁ Is Is there there a a simple simple regular regular expression expression for for the the language language of of this this generalized generalized NFA? NFA?

130 Key Idea 2: If we can convert an NFA into a generalized NFA that looks like this... start q₀ some-regex q₁...then we can easily read off a regular expression for that NFA.

131 From NFAs to Regular Expressions R 11 R 22 R 12 start q 1 R q 21 2

132 From NFAs to Regular Expressions R 11 R 22 R 12 start q 1 R q 21 2 Here, Here, R ₁₁ ₁₁,, R ₁₂ ₁₂,, R ₂₁ ₂₁,, and and R ₂₂ ₂₂ are are arbitrary arbitrary regular regular expressions.

133 From NFAs to Regular Expressions R 11 R 22 R 12 start q 1 R q 21 2 Question: Question: Can Can we we get get a clean clean regular regular expression from from this this NFA? NFA?

134 From NFAs to Regular Expressions R 11 R 22 R 12 start q 1 R q 21 2 Key Key Idea Idea 3: 3: Somehow Somehow transform this this NFA NFA so so that that it it looks looks like like this: this: start some-regex q₀ q₁

135 From NFAs to Regular Expressions R 11 R 22 R 12 start q 1 R q 21 2 The The first first step step is is going going to to be be a bit bit weird. weird.

136 From NFAs to Regular Expressions R 11 R 22 R 12 start q s q 1 q 2 R 21 q f

137 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

138 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

139 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

140 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f Could Could we we eliminate this this state state from from the the NFA? NFA?

141 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

142 From NFAs to Regular Expressions R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

143 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f Note: Note: We're We're using using concatenation concatenation and and Kleene Kleene closure closure in in order order to to skip skip this this state. state.

144 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

145 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

146 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f

147 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f R 21 R 11 * R 12

148 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 start ε ε q s q 1 q 2 R 21 q f R 21 R 11 * R 12

149 From NFAs to Regular Expressions ε R 11 * R 12 R 22 start q s q 2 ε q f R 21 R 11 * R 12

150 From NFAs to Regular Expressions R 11 * R 12 R 22 start q s q 2 ε q f R 21 R 11 * R 12

151 From NFAs to Regular Expressions R 11 * R 12 start q s q 2 ε q f R 22 R 21 R 11 * R 12 Note: Note: We're We're using using union union to to combine combine these these transitions transitions together. together.

152 From NFAs to Regular Expressions start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

153 From NFAs to Regular Expressions start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

154 From NFAs to Regular Expressions start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

155 From NFAs to Regular Expressions start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

156 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

157 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε start q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12

158 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε start q s q f

159 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* start q s q f

160 From NFAs to Regular Expressions start q s R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q f

161 From NFAs to Regular Expressions start q s R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q f R 11 R 22 R 12 start q 1 R q 21 2

162 The Construction at a Glance Start with an NFA N for the language L. Add a new start state qs and accept state q f to the NFA. Add an ε-transition from qs to the old start state of N. Add ε-transitions from each accepting state of N to qf, then mark them as not accepting. Repeatedly remove states other than qs and q f from the NFA by shortcutting them until only two states remain: q s and q f. The transition from qs to q f is then a regular expression for the NFA.

163 Eliminating a State To eliminate a state q from the automaton, do the following for each pair of states q₀ and q₁, where there's a transition from q₀ into q and a transition from q into q₁: Let R in be the regex on the transition from q₀ to q. Let R out be the regex on the transition from q to q₁. If there is a regular expression R stay on a transition from q to itself, add a new transition from q₀ to q₁ labeled (R in (R stay )*R out ). If there isn't, add a new transition from q₀ to q₁ labeled (R in R out ) If a pair of states has multiple transitions between them labeled R₁, R₂,, Rₖ, replace them with a single transition labeled R₁ R₂ Rₖ.

164 Our Transformations direct conversion state elimination DFA NFA Regexp subset construction Thompson's algorithm

165 Theorem: The following are all equivalent: L is a regular language. There is a DFA D such that L( D) = L. There is an NFA N such that L( N) = L. There is a regular expression R such that L( R) = L.

166 Why This Matters The equivalence of regular expressions and finite automata has practical relevance. Tools like grep and flex that use regular expressions capture all the power available via DFAs and NFAs. This also is hugely theoretically significant: the regular languages can be assembled from scratch using a small number of operations!

167 Next Time Applications of Regular Languages Answering so what? Intuiting Regular Languages What makes a language regular? The Myhill-Nerode Theorem The limits of regular languages.

Concatenation. The concatenation of two languages L 1 and L 2

Concatenation. The concatenation of two languages L 1 and L 2 Regular Expressions Problem Problem Set Set Four Four is is due due using using a late late period period in in the the box box up up front. front. Concatenation The concatenation of two languages L 1

More information

Recap from Last Time

Recap from Last Time Regular Expressions Recap from Last Time Regular Languages A language L is a regular language if there is a DFA D such that L( D) = L. Theorem: The following are equivalent: L is a regular language. There

More information

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

FABER Formal Languages, Automata. Lecture 2. Mälardalen University CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010 1 Content Languages, g Alphabets and Strings Strings & String Operations Languages & Language Operations

More information

Chapter 4. Regular Expressions. 4.1 Some Definitions

Chapter 4. Regular Expressions. 4.1 Some Definitions Chapter 4 Regular Expressions 4.1 Some Definitions Definition: If S and T are sets of strings of letters (whether they are finite or infinite sets), we define the product set of strings of letters to be

More information

Nonregular Languages

Nonregular Languages Nonregular Languages Recap from Last Time Theorem: The following are all equivalent: L is a regular language. There is a DFA D such that L( D) = L. There is an NFA N such that L( N) = L. There is a regular

More information

How do regular expressions work? CMSC 330: Organization of Programming Languages

How do regular expressions work? CMSC 330: Organization of Programming Languages How do regular expressions work? CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata What we ve learned What regular expressions are What they can express, and cannot

More information

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

Nondeterministic Finite Automata and Regular Expressions

Nondeterministic Finite Automata and Regular Expressions Nondeterministic Finite Automata and Regular Expressions CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite

More information

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

The assignment is not difficult, but quite labour consuming. Do not wait until the very last day.

The assignment is not difficult, but quite labour consuming. Do not wait until the very last day. CAS 705 CAS 705. Sample solutions to the assignment 1 (many questions have more than one solutions). Total of this assignment is 129 pts. Each assignment is worth 25%. The assignment is not difficult,

More information

Finite Automata Part One

Finite Automata Part One Finite Automata Part One Computability Theory What problems can we solve with a computer? What problems can we solve with a computer? What kind of computer? Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm

More information

CMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata

CMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC330 Spring 2018 1 How do regular expressions work? What we ve learned What regular expressions are What they

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC 330 Spring 2017 1 How do regular expressions work? What we ve learned What regular expressions are What they

More information

Finite Automata Part One

Finite Automata Part One Finite Automata Part One Computability Theory What problems can we solve with a computer? What kind of computer? Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm We need a simpler

More information

Author: Vivek Kulkarni ( )

Author: Vivek Kulkarni ( ) Author: Vivek Kulkarni ( vivek_kulkarni@yahoo.com ) Chapter-3: Regular Expressions Solutions for Review Questions @ Oxford University Press 2013. All rights reserved. 1 Q.1 Define the following and give

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013 CMPSCI 250: Introduction to Computation Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013 Finishing Kleene s Theorem A Normal Form for λ-nfa s Building λ-nfa s by Induction Why

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

CS 133 : Automata Theory and Computability

CS 133 : Automata Theory and Computability CS 133 : Automata Theory and Computability Lecture Slides 1 Regular Languages and Finite Automata Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University

More information

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science CSCI 340: Computational Models Regular Expressions Chapter 4 Department of Computer Science Yet Another New Method for Defining Languages Given the Language: L 1 = {x n for n = 1 2 3...} We could easily

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages Finite Automata and Regular Languages Topics to be covered in Chapters 1-4 include: deterministic vs. nondeterministic FA, regular expressions, one-way vs. two-way FA, minimization, pumping lemma for regular

More information

Text Search and Closure Properties

Text Search and Closure Properties Text Search and Closure Properties CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2017 1/30 Text Search 2/30 grep program grep -E regexp file.txt Searches

More information

CS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach

CS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach CS311 Computational Structures Regular Languages and Regular Expressions Lecture 4 Andrew P. Black Andrew Tolmach 1 Expressions Weʼre used to using expressions to describe mathematical objects Example:

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

Text Search and Closure Properties

Text Search and Closure Properties Text Search and Closure Properties CSCI 330 Formal Languages and Automata Theory Siu On CHAN Fall 208 Chinese University of Hong Kong /28 Text Search grep program grep -E regex file.txt Searches for an

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Finite Automata Part Two

Finite Automata Part Two Finite Automata Part Two DFAs A DFA is a Deterministic Finite Automaton A DFA is defined relative to some alphabet Σ. For each state in the DFA, there must be exactly one transition defined for each symbol

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Determine if a language is regular Apply closure properties to conclude

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries Harry Lewis September 5, 2013 Reading: Sipser, Chapter 0 Sets Sets are defined by their members A = B means that for every x, x A iff

More information

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed HKN CS/ECE 374 Midterm 1 Review Nathan Bleier and Mahir Morshed For the most part, all about strings! String induction (to some extent) Regular languages Regular expressions (regexps) Deterministic finite

More information

Finite Automata Part Two

Finite Automata Part Two Finite Automata Part Two Recap from Last Time Old MacDonald Had a Symbol, Σ-eye-ε-ey, Oh! You may have noticed that we have several letter- E-ish symbols in CS103, which can get confusing! Here s a quick

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main

More information

1 Alphabets and Languages

1 Alphabets and Languages 1 Alphabets and Languages Look at handout 1 (inference rules for sets) and use the rules on some examples like {a} {{a}} {a} {a, b}, {a} {{a}}, {a} {{a}}, {a} {a, b}, a {{a}}, a {a, b}, a {{a}}, a {a,

More information

In English, there are at least three different types of entities: letters, words, sentences.

In English, there are at least three different types of entities: letters, words, sentences. Chapter 2 Languages 2.1 Introduction In English, there are at least three different types of entities: letters, words, sentences. letters are from a finite alphabet { a, b, c,..., z } words are made up

More information

CS 121, Section 2. Week of September 16, 2013

CS 121, Section 2. Week of September 16, 2013 CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,

More information

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages Do Homework 2. What Is a Language? Grammars, Languages, and Machines L Language Grammar Accepts Machine Strings: the Building Blocks of Languages An alphabet is a finite set of symbols: English alphabet:

More information

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem and Informatics 2A: Lecture 5 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 25 September, 2014 1 / 26 1 More closure properties of regular languages Operations on languages

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2018 http://cseweb.ucsd.edu/classes/sp18/cse105-ab/ Today's learning goals Sipser Section 1.1 Prove closure properties of the class of regular languages Apply closure

More information

CS Automata, Computability and Formal Languages

CS Automata, Computability and Formal Languages Automata, Computability and Formal Languages Luc Longpré faculty.utep.edu/longpre 1 - Pg 1 Slides : version 3.1 version 1 A. Tapp version 2 P. McKenzie, L. Longpré version 2.1 D. Gehl version 2.2 M. Csűrös,

More information

TDDD65 Introduction to the Theory of Computation

TDDD65 Introduction to the Theory of Computation TDDD65 Introduction to the Theory of Computation Lecture 2 Gustav Nordh, IDA gustav.nordh@liu.se 2012-08-31 Outline - Lecture 2 Closure properties of regular languages Regular expressions Equivalence of

More information

10. The GNFA method is used to show that

10. The GNFA method is used to show that CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Theory of Regular Expressions DFAs and NFAs Reminders Project 1 due Sep. 24 Homework 1 posted Exam 1 on Sep. 25 Exam topics list posted Practice homework

More information

COMP4141 Theory of Computation

COMP4141 Theory of Computation COMP4141 Theory of Computation Lecture 4 Regular Languages cont. Ron van der Meyden CSE, UNSW Revision: 2013/03/14 (Credits: David Dill, Thomas Wilke, Kai Engelhardt, Peter Höfner, Rob van Glabbeek) Regular

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Regular Expressions and Language Properties

Regular Expressions and Language Properties Regular Expressions and Language Properties Mridul Aanjaneya Stanford University July 3, 2012 Mridul Aanjaneya Automata Theory 1/ 47 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),

More information

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem and Kleene s theorem Informatics 2A: Lecture 5 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 29 September 2016 1 / 21 1 More closure properties of regular languages Operations

More information

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission. CSE 5 Homework Due: Monday October 9, 7 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in this

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

Automata Theory CS F-08 Context-Free Grammars

Automata Theory CS F-08 Context-Free Grammars Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of

More information

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free

More information

The Binomial Theorem.

The Binomial Theorem. The Binomial Theorem RajeshRathod42@gmail.com The Problem Evaluate (A+B) N as a polynomial in powers of A and B Where N is a positive integer A and B are numbers Example: (A+B) 5 = A 5 +5A 4 B+10A 3 B

More information

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More information

CSC173 Workshop: 13 Sept. Notes

CSC173 Workshop: 13 Sept. Notes CSC173 Workshop: 13 Sept. Notes Frank Ferraro Department of Computer Science University of Rochester September 14, 2010 1 Regular Languages and Equivalent Forms A language can be thought of a set L of

More information

UNIT II REGULAR LANGUAGES

UNIT II REGULAR LANGUAGES 1 UNIT II REGULAR LANGUAGES Introduction: A regular expression is a way of describing a regular language. The various operations are closure, union and concatenation. We can also find the equivalent regular

More information

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Finite Automata and Formal Languages TMV26/DIT32 LP4 22 Lecture 7 Ana Bove March 27th 22 Overview of today s lecture: Regular Expressions From FA to RE Regular Expressions Regular expressions (RE) are

More information

Foundations of

Foundations of 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu d with some modifications by Prof. Karen Daniels, Spring 2012

More information

Finite Automata Part One

Finite Automata Part One Finite Automata Part One Computability Theory What problems can we solve with a computer? What kind of computer? Computers are Messy http://en.wikipedia.org/wiki/file:eniac.jpg Computers are Messy That

More information

Finite Automata and Formal Languages

Finite Automata and Formal Languages Finite Automata and Formal Languages TMV26/DIT32 LP4 2 Lecture 6 April 5th 2 Regular expressions (RE) are an algebraic way to denote languages. Given a RE R, it defines the language L(R). Actually, they

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

Regular Expressions. Definitions Equivalence to Finite Automata

Regular Expressions. Definitions Equivalence to Finite Automata Regular Expressions Definitions Equivalence to Finite Automata 1 RE s: Introduction Regular expressions are an algebraic way to describe languages. They describe exactly the regular languages. If E is

More information

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Before we show how languages can be proven not regular, first, how would we show a language is regular? CS35 Proving Languages not to be Regular Before we show how languages can be proven not regular, first, how would we show a language is regular? Although regular languages and automata are quite powerful

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions TAFL 1 (ECS-403) Unit- II 2.1 Regular Expression: 2.1.1 The Operators of Regular Expressions: 2.1.2 Building Regular Expressions 2.1.3 Precedence of Regular-Expression Operators 2.1.4 Algebraic laws for

More information

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010 University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,

More information

Turing Machines Part One

Turing Machines Part One Turing Machines Part One What problems can we solve with a computer? Regular Languages CFLs Languages recognizable by any feasible computing machine All Languages That same drawing, to scale. All Languages

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation   Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Announcement & Reminders HW 2: Grades not available yet, will be soon Solutions posted, read even if you did well

More information

1 More finite deterministic automata

1 More finite deterministic automata CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.

More information

Non-deterministic Finite Automata (NFAs)

Non-deterministic Finite Automata (NFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel

More information

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

More information

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

Theory of Computation

Theory of Computation Theory of Computation Lecture #2 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 1 Lecture 2: Overview Recall some basic definitions from Automata Theory.

More information

FLAC Context-Free Grammars

FLAC Context-Free Grammars FLAC Context-Free Grammars Klaus Sutner Carnegie Mellon Universality Fall 2017 1 Generating Languages Properties of CFLs Generation vs. Recognition 3 Turing machines can be used to check membership in

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

Closure under the Regular Operations

Closure under the Regular Operations Closure under the Regular Operations Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have

More information

Exam 1 CSU 390 Theory of Computation Fall 2007

Exam 1 CSU 390 Theory of Computation Fall 2007 Exam 1 CSU 390 Theory of Computation Fall 2007 Solutions Problem 1 [10 points] Construct a state transition diagram for a DFA that recognizes the following language over the alphabet Σ = {a, b}: L 1 =

More information

Regular Expressions Kleene s Theorem Equation-based alternate construction. Regular Expressions. Deepak D Souza

Regular Expressions Kleene s Theorem Equation-based alternate construction. Regular Expressions. Deepak D Souza Regular Expressions Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 16 August 2012 Outline 1 Regular Expressions 2 Kleene s Theorem 3 Equation-based

More information

Lecture 1 09/08/2017

Lecture 1 09/08/2017 15CS54 Automata Theory & Computability By Harivinod N Asst. Professor, Dept of CSE, VCET Puttur 1 Lecture 1 09/08/2017 3 1 Text Books 5 Why Study the Theory of Computation? Implementations come and go.

More information

Formal Languages. We ll use the English language as a running example.

Formal Languages. We ll use the English language as a running example. Formal Languages We ll use the English language as a running example. Definitions. A string is a finite set of symbols, where each symbol belongs to an alphabet denoted by. Examples. The set of all strings

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

Formal Languages, Automata and Models of Computation

Formal Languages, Automata and Models of Computation CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)

More information

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata. Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Theory (CS21004) Announcements The slide is just a short summary Follow the discussion and the boardwork Solve problems (apart from those we dish out in class) Table of Contents 1 2 3 Patterns A Pattern

More information

Lecture 4: More on Regexps, Non-Regular Languages

Lecture 4: More on Regexps, Non-Regular Languages 6.045 Lecture 4: More on Regexps, Non-Regular Languages 6.045 Announcements: - Pset 1 is on piazza (as of last night) - If you don t have piazza access but are registered for 6.045, send email to TAs with

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.

More information