CSC 312 Automata Theory Lecture 5 Chapter 4

  • Slides: 13
Download presentation
CSC 312 Automata Theory Lecture # 5 Chapter # 4 Cont…

CSC 312 Automata Theory Lecture # 5 Chapter # 4 Cont…

Definition For regular expressions and 2

Definition For regular expressions and 2

Example Regular expression: 3

Example Regular expression: 3

Example Regular expression 4

Example Regular expression 4

Example = { all strings with at least two consecutive 0 } = {

Example = { all strings with at least two consecutive 0 } = { all strings without two consecutive 0 } 5

Regular Languages Definition: The language generated by any regular expression is called a regular

Regular Languages Definition: The language generated by any regular expression is called a regular language. Note: If r 1, r 2 are regular expressions, corresponding to the languages L 1 and L 2 then the languages generated by r 1+ r 2, r 1 r 2 (or r 2 r 1) and r 1*( or r 2*) are also regular languages. 6

Languages Generated by Regular Expressions Regular Languages 7

Languages Generated by Regular Expressions Regular Languages 7

Note: All finite languages are regular whereas some infinite languages are regular & some

Note: All finite languages are regular whereas some infinite languages are regular & some are nonregular. 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, 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)*. 8

EVEN-EVEN Language EVEN-EVEN = { aa bb aaaa aabb abab abba baab baba bbaa

EVEN-EVEN Language EVEN-EVEN = { aa bb aaaa aabb abab abba baab baba bbaa bbbb aaaaaa …} In this language we have following three types of strings type 1 = aa type 2 = bb type 3 = (ab+ba)(aa+bb)*(ab+ba) Thus the RE = (type 1 +type 2 +type 3)* = (aa + bb + (ab+ba)(aa+bb)*(ab+ba))* 9

Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 10

Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 10

Check Equality 1. (a+)* = (a*)+ = a* 2. (a*+b)* = (a+b)* 3. (a+b)*ab(a+b)*

Check Equality 1. (a+)* = (a*)+ = a* 2. (a*+b)* = (a+b)* 3. (a+b)*ab(a+b)* = (a+b)*a(a+b)*b(a+b)* 4. (a+b)*= (a*+b*)* 5. (a+b)*= (a*b*+b*a*)* 6. (a+b)*= a(a+b)*+b(a+b)*+ 7. (a+b)*= a(a+b)*ab(a+b)*+b*a* 8. (aa+ab*)* = (aa+ab)* 9. a*a* = (aa)* 10. (a+b)*= (a*b*)* 11

Check Equality 1. (a+)* = (a*)+ = a* Yes 2. (a*+b)* = (a+b)* Yes

Check Equality 1. (a+)* = (a*)+ = a* Yes 2. (a*+b)* = (a+b)* Yes 3. (a+b)*ab(a+b)* = (a+b)*a(a+b)*b(a+b)* Yes 4. (a+b)*= (a*+b*)* Yes 5. (a+b)*= (a*b*+b*a*)* Yes 6. (aa+ab*)* = (aa+ab)* No – what is missing 7. (a+b)*= a(a+b)*+b(a+b)*+ Yes 8. (a+b)*= a(a+b)*ab(a+b)*+b*a* No 9. a*a* = (aa)* No Yes 10. (a+b)*= (a*b*)* 12

Practice Questions See examples at p-37, 38, 39, 40, 46, 47 Ch # 4

Practice Questions See examples at p-37, 38, 39, 40, 46, 47 Ch # 4 Exercise p-49. Questions: 2, 3, 4, 5, 6, 7, 8, 9, 10 13