Download presentation
Presentation is loading. Please wait.
Published byΥγίνος Γερμανού Modified over 6 years ago
1
CSC312 Automata Theory Lecture # 4 Languages-III
2
Languages of Regular Expressions
Example: Consider the alphabet Σ={a} The language of all words containing even number of a’s can be defined by the following RE (aa)* Example: Language of all words containing only odd no. of a’s can be defined by the following RE 1. (aaa)* 2. a(aa)*+ 3. a+(aa)* 4. a+a* 5. a+(aa)*a correct but inefficient due to repetition 6. (aa)*a or a(aa)*
3
Languages of Regular Expressions
Example: The language of all words having all possible combinations of a’s followed be one b can be described by the following RE. 1. a+b 2. a*+b 3. a*b 4. (+a+)b 5. a+b+b Example: The language of all words in which all a’s (if any) comes before all the b’s (if any) can be defined the following RE (ab)* 2. a*b* 3. a+b+ + 4. a+b* + both are inefficient
4
Example:The language of all words of a’s & b’s that have atleast two letters, that begin & end with a’s & that have nothing but b’s inside (if any thing at all) can be defined by following RE. Σ = {a, b} (aba)* 2. ab*a ab+a 4. a+b*a+ all above are incorrect 5. ab*a
5
Example: Consider the alphabet Σ={a,b,c}
Example: Consider the alphabet Σ={a,b,c}. The language of all words that begins with either a or c, followed be any no. of b’s can be defined by following RE. (a+c)b* = ab* + cb* Example: The language of all words that ends with letter b can be defined be RE (a+b)*b
6
Note: All finite languages are regular whereas some infinite languages are regular & some are non-regular. In order to write RE for finite languages just include +’s between the words of finite languages. Consider the alphabet Σ={a,b}. The words of length 1 are two. Its RE will be a+b. Similarly the words of length 2 will be aa,ab,ba,bb. Its RE will be aa+ab+ba+bb or (a+b)(b+a). Similary the languages of all words whose length is 3 will be aaa,aab,aba,abb,bbb,bba,bab,baa. Thus we can conclude that all words of a’s and b’s of any length can be defined by (a+b)*.
7
Definition For regular expressions and
8
Example Regular expression:
9
Example Regular expression
10
Example = { all strings with at least two consecutive 0 }
= { all strings without two consecutive 0 }
11
Equivalent Regular Expressions
Definition: Regular expressions and are equivalent if
12
Examples (a+)* = (a*)+ = a* (a*+b)* = (a+b)*
(a+b)*ab(a+b)* = (a+b)*a(a+b)*b(a+b)* (a+b)*= (a*b*)* (a+b)*= (a*b*+b*a*)* (aa+ab*)* = (aa+ab)* a*a* = (aa)*
13
Regular Expressions and Regular Languages
14
Theorem Languages Generated by Regular Expressions Regular Languages
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.