{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

module3-print

# module3-print - Module 3 Regular languages and regular...

This preview shows pages 1–3. Sign up to view the full content.

Module 3 Regular languages and regular expressions What can a computer do with no memory? CS 360: Introduction to the Theory of Computing Daniel G. Brown, modified by Margareta Ackerman, University of Waterloo 3.1 Topics of Module 3 Regular languages Kleene’s theorem 3.2 1 Regular languages Regular languages Language L is regular if one of these is true: L = /0. L = { ε } L = { a } for some alphabet letter a L = L * 1 , for some regular language L 1 L = L 1 L 2 for regular languages L 1 , L 2 L = L 1 L 2 , for regular languages L 1 , L 2 No other languages are regular. Recursive definition. Remember that /0 6 = { ε } ! 3.3 Beginnings of regular languages First simple theorem: All one-word languages L are regular. Proof: Let L = { w } . Induction on | w | : Case 1: | w | = 0. Then L = { ε } , which is regular. Case 2: | w | = 1. Then L = { a } , for some letter a . That’s regular. Case 3: Suppose that the theorem is true for all one-word languages where the word is shorter than w . Let w = xa . Then L 1 = { x } is regular by induction. And L 2 = { a } is regular by rule. And L = L 1 L 2 , which is regular by rule. We’re done. 3.4 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Finite languages are regular Theorem: If L has a finite number of words, it is regular. Proof: By induction on | L | : Base case: | L | = 0. Then L = /0, which is regular. Inductive case: Suppose all finite languages with k members are regular, and that | L | = k + 1. Then L = { w 1 , w 2 ,..., w k + 1 } = { w 1 , w 2 ,..., w k }∪ w k + 1 . By hypothesis, the first language is regular. By the previous theorem, the second one is. So L is the union of two regular languages, and thus regular. 3.5 Are all languages regular? All languages are the union of a collection of one-word languages. Are all languages regular, using the proof model just shown? No! Finite unions are not infinite unions! Can’t do induction in that way! In fact, { ε , 01 , 0011 , 000111 , 00001111 , 0000011111 , 000000111111 ,... } is not regular, which we’ll see later. 3.6 Regular expressions Another way of representing regular languages: L = /0 /0 L = { ε } ε L = { a } a L = L * 1 r * 1 L = L 1 L 2 r 1 r 2 L = L 1 L 2 r 1 + r 2 (Yes, just like in grep . But you might have already known that.) If r is a regular expression, then L ( r ) is the language of r , defined as you’d expect.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}