✂ � ✁ � ✂ � ✁ � ✄ ✆ ✄ ☎ ✁ ✂ � ✄ ✄ ✂ � ✂ � ✂ � � ☎ � ✂ Precedence relation Denoting the rule describing the order of ops in the evaluation of arithmetic and regular expressions we have: ✁ ✂✁ Arithmetic expressions: Regular expressions: ✁ ✁� Note: denotes expressions enclosed in parentheses Regular Expressions (REs) – p.7/37
� � � Formal definitions Consider an alphabet. A regular expression (RE) over is defi ned recursivelyby the rules: Regular Expressions (REs) – p.8/37
� � � Formal definitions Consider an alphabet. A regular expression (RE) over is defi ned recursivelyby the rules: Recursion basis: Regular Expressions (REs) – p.8/37
✂ ✄ � ✂ � � � ✁ ☎ ✂ � ✁ � � � Formal definitions Consider an alphabet. A regular expression (RE) over is defi ned recursivelyby the rules: Recursion basis: 1. For any , is a RE describing the language Regular Expressions (REs) – p.8/37
� ✝ � ✁ ☎ ✂ ✄ � ✄ � � ✂ ✝ ✁ � ✂ ☎ ✁ � ✝ � ✂ � ✂ Formal definitions Consider an alphabet. A regular expression (RE) over is defi ned recursivelyby the rules: Recursion basis: 1. For any , is a RE describing the language 2. is a RE describing the language Regular Expressions (REs) – p.8/37
✂ ✄ ✝ � ✄ ✁ ✝ ✝ ✂ � ✁ ☎ ✂ � � � ☎ � ✄ ✂ ✁ � � � ✂ � ☎ � � � ✂ Formal definitions Consider an alphabet. A regular expression (RE) over is defi ned recursivelyby the rules: Recursion basis: 1. For any , is a RE describing the language 2. is a RE describing the language 3. is a RE describing the empty language . Regular Expressions (REs) – p.8/37
� ☎ ☎ ✂ � ✂ � � ✄ � ✄ � Formal definitions, continutation Recursion body: If and are REs evaluating to the � ✁� languages and then: Regular Expressions (REs) – p.9/37
� � ✂ ✂ ✂ � ✁ ✁ � � � ✂ ☎ ✂ � � ✄ ✁ ☎ � � � ✄ ✂ ✁ ✂ � ✄ � ✄ Formal definitions, continutation Recursion body: If and are REs evaluating to the � ✁� languages and then: 1. is a RE evaluating to Regular Expressions (REs) – p.9/37
� � ✂ ✁ ✄ � � ✁ ✂ ✁ ✄ � � ✂ ✂ � � � ✁ ✂ � ✂ ✂ ✁ ✄ � ✂ ✂ � ✂ � � ✄ � � ☎ ✁ ✄ ✄ � � ✂ ☎ ✂ ✂ � � ✂ Formal definitions, continutation Recursion body: If and are REs evaluating to the � ✁� languages and then: 1. is a RE evaluating to 2. is a RE evaluating to Regular Expressions (REs) – p.9/37
✂ � ✄ ✁ ✆ � � ✂ ✂ � ✄ ✂ ✂ � ✁ � � ✄ ✁ ✂ ✂ ✄ � ✁ ✂ ✁ � � ✄ ☎ � ✂ � ✄ � ✄ ✁ � ✂ ✁ � � ✂ ✂ ☎ � � ☎ ✂ � � ✄ ✁ ☎ � � � ✄ ✂ ✄ ✂ � ☎ ✝ � � ✁ ✁ � � ✂ ✂ ✂ � � ✄ ✂ ✁ ✁ � � ✄ ✄ ✂ ✂ � ✁ � Formal definitions, continutation Recursion body: If and are REs evaluating to the � ✁� languages and then: 1. is a RE evaluating to 2. is a RE evaluating to 3. is a RE evaluating to ✁ ✁� where and . Regular Expressions (REs) – p.9/37
Note A defi nition of the form expressed by rule (4) above is called an inductive defi nition Regular Expressions (REs) – p.10/37
� � ✁ Potential confusions Do not confuse the REs and ; Regular Expressions (REs) – p.11/37
� � ✁ ✝ Potential confusions Do not confuse the REs and ; 1. represents the language containing just the empty string Regular Expressions (REs) – p.11/37
� � ✁ ✝ � Potential confusions Do not confuse the REs and ; 1. represents the language containing just the empty string 2. is the RE that represents the the empty language Regular Expressions (REs) – p.11/37
✄ � � ☎ � � ☎ � � ✄ � � � � ✝ ✁ � Potential confusions Do not confuse the REs and ; 1. represents the language containing just the empty string 2. is the RE that represents the the empty language Note the distinction between and . is an expression and is the set of strings specifi ed by Regular Expressions (REs) – p.11/37
� ✆ ✄ � ✆ Example REs 1. , Regular Expressions (REs) – p.12/37
✄ � ✁ ☎ ✂ ✆ � � ✆ � ✁ ✄ ✂ ✆ � ✄ ✆ � � Example REs 1. , contains exactly a single 1 Regular Expressions (REs) – p.12/37
✂ � ✂ ✄ � ✁ � ✁ ☎ ✂ ✆ ✄ ✂ ✆ � � ✄ ✆ ✆ � ✄ ✆ � ✆ Example REs 1. , contains exactly a single 1 2. , Regular Expressions (REs) – p.12/37
✁ ✆ ✂ ✁ ✂ ✆ ✄ ✂ ✂ � ✄ � ✂ ✆ ✄ ✂ ✆ � ✁ ☎ � � ✆ ✄ � ✆ � ✄ � � ✆ ✄ � ✆ ✂ ☎ ✁ ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 Regular Expressions (REs) – p.12/37
✂ ✆ ✆ ✄ � ✆ � ✄ � ✂ ✄ ✄ ✂ ✆ ✂ ☎ ✁ � ✁ � ✆ ✂ ✂ ✂ � � ✆ ✄ � ✆ ✆ ✄ � ✆ ✂ ✄ � ✆ ✂ ☎ ✁ � ✁ � ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , Regular Expressions (REs) – p.12/37
☎ � ✂ ✆ ✂ � ✁ � ✁ � ✁ ✂ � ✂ ✆ � ✆ ✄ ✂ ✆ ✁ ✄ � ✂ ✆ � � ✄ ✂ ✆ ✄ ✂ ☎ ✂ � ✆ ✄ � ✆ ✂ ✄ � � ✆ ✄ � ✆ ☎ � ✁ � ✁ � ✄ ✂ � ✂ ✆ ✄ ✂ ✆ � ✄ ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring Regular Expressions (REs) – p.12/37
✁ ✂ ✂ ☎ ✁ � � � ✂ ✂ ✄ ✂ ✆ � � ✄ ✆ ✂ ✂ ✁ � ✁ ☎ ✂ ✆ ✄ � � � ✆ ✂ � ✄ ✆ ✄ � ☎ � ✆ ✄ � ✆ ✆ ✄ � � ✆ ✄ � ✆ ✂ ✁ ✆ ✄ ✂ � ✄ ✂ ✆ ✂ ✆ � ✂ ✂ ✂ ✂ � ✁ � Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , Regular Expressions (REs) – p.12/37
� ✂ � ✆ ✂ � ✄ ✂ ✆ ✄ ✄ � ✆ ✆ ✂ ☎ ✂ ✁ � ✂ ✁ ✄ ✂ ✂ ✂ � � ✂ ✂ � ✆ � ✂ � ✁ � ✁ ☎ ✂ � � ✄ � ✁ ☎ ✂ ✆ � ✄ ✆ � ✁ ✄ ✂ ✆ � ✄ ✆ � � � ✁ � ☎ ✂ ✆ ✂ ✄ ✆ ✂ ✄ � � ✆ ✂ ✄ ✆ ✂ ✁ ✂ ✆ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length Regular Expressions (REs) – p.12/37
✆ � ✂ ✆ ✂ ✄ � � ✆ ✂ ✄ ✁ � ✂ ✂ ✄ � � ✆ ✂ ☎ � ✂ ✂ ✂ ✂ � ✄ ☎ ✆ ✂ ✂ � ✁ ✁ ✂ � ✄ � � ✁ � � ✂ ✆ ✆ ✁ � ✁ ☎ ✂ ✆ � ✄ � ✂ � ✄ ✆ ✆ � ✄ ✆ � � ✂ � ✆ ✁ � ✁ ☎ ✂ ✆ ✂ ✄ ✂ ✂ � ✄ ✂ ✆ ✂ ✄ ✆ ✂ ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , Regular Expressions (REs) – p.12/37
� ☎ ✂ ✄ � � ✂ � ✁ � ✁ ✂ ✂ ✆ ✂ ✄ ✂ � ✆ ✂ � ✄ ✆ ✂ � ✂ ✁ ✂ ✂ � ✆ ✂ ✄ � ✁ � ☎ ✂ ✆ ✂ ✂ ✂ � ✄ � ✆ ✂ ✂ ✆ ✄ ✂ � ✂ � � ✁ � ✁ ☎ ✂ ✆ ✄ ✂ ✆ � � ✄ ✂ ✆ � ✄ ✆ � ✁ ✆ � ☎ � ✆ ✂ ☎ ✂ ✁ � ✁ � ✁ ✂ ✄ ✆ ✂ ✄ ✆ ✂ � ✄ � ✆ ✂ ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three Regular Expressions (REs) – p.12/37
✂ � � ☎ ✂ ✁ ✄ � � � � ✁ ✁ ✂ ☎ ✁ ✆ ✂ ✄ � � ✆ ✂ � ✂ ✂ � ✂ ✄ ✂ ✆ ✂ ✂ ✂ ✂ � ✂ ✂ � ✆ ✁ � ✁ ☎ ✆ ✂ ✂ ✂ � ✄ ✆ ✄ ✆ ✂ � ✁ ✂ � � ✁ � ✁ ☎ ✂ ✆ ✄ ✆ ✆ � � ✄ ✄ ✆ � ✄ ✆ � ✂ ✄ ✂ � ✄ � � ✆ ✂ ✂ ✂ � � ✁ ✁ ✂ ☎ ✂ ✆ ✂ ✄ ✆ ✂ � ✄ ✄ ✆ � Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , Regular Expressions (REs) – p.12/37
� � ☎ ✆ ✂ ✂ ✂ � ✄ ✁ ✆ ✂ ✂ ✂ � � ✂ ✄ ✄ ✂ � ☎ � ✁ � ✁ ☎ ✂ ✁ ✁ ✂ ✂ � � ✂ ✄ � ✄ ✁ � ✁ ☎ ✆ ✂ ✂ � ✂ � ✄ � ✆ ✂ ✂ ✂ ✂ � � ✂ ✄ ✆ ✄ ✁ ✂ ✂ ✄ ✆ ✂ � ✂ ✄ � ✁ � ✁ ☎ ✆ ✄ � ✄ ✆ � � ✄ ✂ ✆ � ✄ ✆ � ✆ ✄ � ✂ � ✆ ✂ � ✄ ✁ ✆ ✂ ✄ � � ✆ � � ✂ ✄ � ✁ � ✁ ☎ ✂ ✆ ✂ ✄ ✆ ✂ ✄ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , Regular Expressions (REs) – p.12/37
✂ ✂ ✂ ✂ � ✂ ✂ � � ✁ � ✁ ☎ ✆ ✂ ✂ ✂ � ✄ ✂ ✆ ✂ ✆ ✂ � � ✂ ✁ ✄ � � ✂ ✆ � ✄ ✂ ✄ � ✁ ✄ � � ✄ � ✄ � ✁ ✄ � ✂ ✄ ✄ � � ✁ � ✁ ☎ ✆ ✂ ✂ ✂ ✂ � ✄ ✄ ✁ ✁ ✁ � ✄ ✁ ✆ ✂ ✄ ✆ ✂ � ✂ ✁ � ✁ � ☎ ✆ ✂ ✆ � ✄ ✆ � � ✄ ✄ ✆ � ✄ ✆ � ✂ ✄ � ✂ ✁ ☎ ✂ ✆ ✂ ✄ � � ✆ ✂ � ✄ ✂ ✆ ✄ ✂ � � ✆ ✂ ✆ ✂ ✄ � ✁ � ✁ ☎ ✂ ✆ ☎ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , 7. , Regular Expressions (REs) – p.12/37
� ✂ ✆ ✄ ✄ � ✂ ✂ ✂ ✂ ✆ ☎ ✁ � ✁ ✁ � ✂ ✂ ✂ ☎ ✁ ✄ � ✂ ✂ ✂ ✆ ✁ ✂ ✄ ✁ � ✆ ✂ ✂ � � ✆ ✂ ✁ ✂ � � ✂ ✆ � ✄ � ✂ ✆ ✄ ✁ � ✁ ✄ ✄ ✄ � � ✄ ✁ � ✄ ✂ ✄ � ✄ ✄ ✁ � ✄ ✂ ☎ ✁ � ✆ ✂ ✄ ✆ ✂ ✁ ✂ ✆ ✄ ✂ � � ✄ � ✂ ✆ ✄ ✂ ✆ � ✁ ☎ � � ✆ ✄ � ✆ ✂ ✄ � � ✆ ✄ � ✆ ✂ ☎ ✁ ✂ ✁ ✂ � ✂ ✆ ✂ ☎ ✁ � ✁ ✄ � � � ✄ ✁ ✂ � � ✄ � � � ✁ � ✁ ✂ ☎ ✂ ✆ � ✆ ✄ ✂ ✆ ✂ ✄ � ✂ � Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , 7. , starts and ends with the same symbol Regular Expressions (REs) – p.12/37
� � ✄ � ✂ ✂ ✝ � ✄ ✁ ✄ � ✁ ✄ � � ✄ ✁ � ✄ ✁ ✁ ☎ ✂ � ✁ � ✂ � ✂ ✂ ✂ ✆ ☎ ✆ ✄ � ✂ ✂ ✂ ✂ ✆ ✂ ✁ ✂ ✄ � ✂ ✆ � ✁ ✄ ✂ ✆ ✁ ✄ � ✁ ✄ ✂ ☎ ✁ � ✁ � � � ✆ ✄ ✄ � ✄ ✂ � � ✂ � ✄ ✁ ✄ ✂ ✆ ✄ ✁ � ✁ ✁ ☎ ✆ ✁ ✂ ✆ ✂ ☎ ✁ � � ✆ � ✂ ✂ ✂ ✆ � � ✄ ✂ ✂ ✂ ☎ ✁ � ✁ � � ✄ � ✂ ✆ ✄ ✂ ✆ ✆ ✄ ✄ ✆ ✆ ✂ ✆ ✂ � � ✂ ✂ ✆ � ✄ ✆ ✄ � � ✂ ✂ ✄ � � ✄ ✄ � ✂ ✆ � � ✂ ✄ ✆ ✂ ☎ ✁ � ✁ � ✂ Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , 7. , starts and ends with the same symbol 8. , Regular Expressions (REs) – p.12/37
� ✄ ✂ � � ✄ ✁ � ✄ ✄ � � � ✄ ✁ � ✄ ✂ ☎ ✁ � � ✄ ✝ ✂ ✂ � ✂ ✂ ✂ ✂ ✆ ✄ ✁ ✁ ✂ ✂ ✂ ✂ ✆ ☎ ✁ � � ✄ � ✄ ✁ ✄ ✂ ✆ ✄ ✁ � ✁ ✂ ✆ ☎ ✁ � ✁ � ✂ ✝ ✂ ✁ � ✂ � ✄ ✄ ✂ ✆ � ✂ ✆ � ✁ ✂ � ✆ ✄ ✁ � ✁ ✄ ✄ ✄ � ✄ ✁ � ✆ ✆ ✄ ✂ ✆ ✁ ✄ � ✂ ✄ ✄ ✂ ✆ ✂ ☎ ✁ � ✁ � ✆ ✂ ✂ ✄ � � ✆ ✄ � ✆ ✂ ✄ � ✆ ✆ ✄ � ✆ ✂ ☎ ✁ � ✁ � ✂ ✂ � ✂ � ✄ ☎ ✂ ✂ � ✂ ✂ ✆ ✁ ✆ ✄ � ✂ ✂ ✂ ✆ ☎ ✁ � � ✆ ✂ � � ✄ ✂ ✆ � ✄ � ✆ ✁ � � ✄ ✂ ✆ ✂ ☎ ✁ � � Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , 7. , starts and ends with the same symbol 8. , Regular Expressions (REs) – p.12/37
☎ ✂ ✄ ☎ ✄ � � ✄ ✁ � ✄ ☎ ✁ ✁ � ✄ ✄ � ✄ ✂ ✂ � � ✄ ✆ ✂ ✂ ✂ ✆ ✁ ✄ � ✂ ✂ ✂ ✆ � ✆ ✁ � ✁ ✄ � � ✂ ✁ ✂ � ✂ ✝ ✂ ☎ ✁ � ✁ � ✄ ✂ ✂ � ✁ � ✁ ✝ ✂ ✄ ✆ ✁ ✄ � ✄ � ✁ ✄ ✄ ✂ ✆ ✄ ✁ � ✁ ✄ ✆ � ✁ � ✂ ✆ � ✁ ✄ ✂ ✆ ✄ ✂ � � ✂ ✄ ✂ ✆ ✄ ✄ � ✂ ✆ ✄ ✆ ✂ ✂ ☎ ✁ � ✁ � � ✂ ✂ ✆ ✁ ✆ ✆ � ✆ ✄ � ✆ ✂ ✄ � � ✄ ✂ � ✆ ✂ ☎ ✁ � ✁ � ✝ ✂ � ✄ ✂ � � ✂ ✂ ✂ ✆ ✂ ✄ � ✂ � ✂ ✆ ☎ ✁ � ✁ � ✆ ✂ ✂ ✄ � � ✄ ✂ ✆ ✝ ✄ � ✂ ✆ � ✄ � ✂ ✆ ✂ ☎ ✁ � ✁ � ✁ � � Example REs 1. , contains exactly a single 1 2. , contains at least one 1 3. , contains as a substring 4. , is a string of even length 5. , the length of is a multiple of three 6. , 7. , starts and ends with the same symbol 8. , 9. , Regular Expressions (REs) – p.12/37
Regular Expressions (REs) – p.12/37 ✂ � ✁ ✄ ✄ � � ✂ ✆ � ✁ ✄ ✆ ✄ ✄ ✁ � ✁ ✄ ✂ ☎ ✁ � ✁ � ✂ ✁ ✆ � ☎ ✄ ✁ ✄ ✄ � � ✄ ✁ � ✄ ✂ ✁ ✂ � ✄ ✄ � ✄ ✂ � ✂ ✆ � ✁ ✄ � ✁ ✂ ✄ ✁ ✝ ✂ ✄ � � � ✁ ✝ ✂ � ✁ � ✝ ✂ ✂ ☎ ✁ ✝ ✄ ✄ ✄ � ✄ ✂ ✄ ✂ ✝ ✆ ✂ ✄ ✆ ✄ � � � ✁ ✝ ✂ ✄ ✂ ✝ ☎ ✁ � ✄ ✆ ✁ ✄ ✆ ✂ � � ✁ � � ✁ ✂ ✆ � � ✄ ✂ ✆ ✄ ✆ ✄ � ✆ � � � � ✄ ✂ ✆ ✂ ☎ ✁ � ✂ ✂ � ✄ � ✂ ✁ ☎ ✂ ✆ ✄ ✂ ✆ ✂ � � ✂ ✆ ✆ ✄ ✂ ✆ ✂ ☎ ✁ � ✁ � ✁ ✂ ✂ � � � ✆ ✁ ✆ � ✂ ✂ ✂ � ✆ � ✄ � ✂ ✂ ✂ ✂ ✆ ✁ ✁ ✄ ✂ � ✄ � ✂ � � ✁ ✂ ✂ ☎ ✆ � ✄ ✄ � ✂ ✂ ✂ ✆ ☎ starts and is a multiple of three as a substring contains exactly a single 1 contains at least one 1 is a string of even length contains the length of � ☎✄ ends with the same symbol Example REs , , , , , , , , , 1. 2. 3. 4. 5. 6. 7. 8. 9.
✁ ✁ ✂ ✄ ✁ ✁ ✄ � ✂ ✄ ✁ ☎ � More example 10. , ; Note: concatenating to any set yields Regular Expressions (REs) – p.13/37
✁ � � � � ☎ ✄ ✁ � ✄ � ✄ ✁ ✁ ✁ ✄ ✄ ✂ ✁ ✄ � ☎ ✁ ✁ ✂ � More example 10. , ; Note: concatenating to any set yields 11. , ; by defi nition, is in the star operation applied on any language; if the language is empty becomes the one element Regular Expressions (REs) – p.13/37
� Identities If is a RE then the following identities take place: Regular Expressions (REs) – p.14/37
✁ � � ☎ � ✄ � � ✁ � ☎ � ✄ Identities If is a RE then the following identities take place: ; adding the empty language to any other language will not change that language Regular Expressions (REs) – p.14/37
� � ✄ � ☎ � � � � ✄ � ☎ ☎ � � ✄ � ☎ ✁ ✁ � � ✄ � � Identities If is a RE then the following identities take place: ; adding the empty language to any other language will not change that language ; concatenating any string with the empty string does not change that string Regular Expressions (REs) – p.14/37
✄ � � ☎ � ✁ � � ✄ ✁ � � ☎ � � � � � � ✄ � � ✁ � ☎ � � ✄ � � ☎ ✁ � � Note . Example: if then ; Regular Expressions (REs) – p.15/37
✁ � � � � ✄ � � � ✁ ☎ � � ✄ � ☎ � ✁ � � � � ✄ � � ☎ � � � ✁ � ✁ � � � ✄ � � ✁ � ☎ � � ✄ � � ☎ ✁ � � � � ✄ � � ☎ � � ☎ ✄ � � ✁ � ☎ ✄ Note . Example: if then ; . Example: if then but Regular Expressions (REs) – p.15/37
� Application REs are useful tools for the design of compilers Regular Expressions (REs) – p.16/37
� � Application REs are useful tools for the design of compilers Language lexicon is described by REs. Regular Expressions (REs) – p.16/37
✟ ✝ ✁ � � � � ✆ ✂ � � ☎ ✁ � ✄ ✄ ✄ ✄ ✆ ✆ ✟ ✄ ✄ ✂ � ✟ ✄ ✁ ☎ ✄ ✆ ✝ ✆ ✂ � � � ✆ ✁ � � ✄ Application REs are useful tools for the design of compilers Language lexicon is described by REs. Example: numerical constants can be described by: where ✁ ☎✄ ✂ ☎✄ ☎ ☎✄ ✞ ☎✄ Regular Expressions (REs) – p.16/37
� � ✁ � ✟ � � ✆ ✂ ✄ ☎ � ✁ � ✄ ✄ ✄ ✝ ✄ ✄ ✆ ✟ ✆ ✄ � � ✂ ✟ ✁ ☎ ✄ ✆ ✝ ✆ ✂ � � � ✆ ✁ � � ✄ Application REs are useful tools for the design of compilers Language lexicon is described by REs. Example: numerical constants can be described by: where ✁ ☎✄ ✂ ☎✄ ☎ ☎✄ ✞ ☎✄ From the lexicon description by REs one can generate automatically lexical analyzers Regular Expressions (REs) – p.16/37
� ✄ � � ☎ ✄ � � ☎ New terminology A RE that evaluates to the language is further said that specifi es the language Regular Expressions (REs) – p.17/37
� Equivalence with FA REs and fi nite automata are equivalentin their descriptive power Regular Expressions (REs) – p.18/37
� � � � Equivalence with FA REs and fi nite automata are equivalentin their descriptive power Any RE can be converted into a fi nite automaton, ✁✄✂ , that recognizes the language specifi ed by Regular Expressions (REs) – p.18/37
� � ✁ ✁ � � � Equivalence with FA REs and fi nite automata are equivalentin their descriptive power Any RE can be converted into a fi nite automaton, ✁✄✂ , that recognizes the language specifi ed by Vice-versa, any fi nite automaton recognizing a language can be converted into a RE that � ✁� specifi es the language Regular Expressions (REs) – p.18/37
Theorem 1.54 Language is regular iff some RE specifi es it Regular Expressions (REs) – p.19/37
Theorem 1.54 Language is regular iff some RE specifi es it Proof idea: this proof has two parts: Regular Expressions (REs) – p.19/37
� Theorem 1.54 Language is regular iff some RE specifi es it Proof idea: this proof has two parts: First part: we show that a language specified by a RE is regular, i.e., there is a finite automaton that recognizes it. Regular Expressions (REs) – p.19/37
� � Theorem 1.54 Language is regular iff some RE specifi es it Proof idea: this proof has two parts: First part: we show that a language specified by a RE is regular, i.e., there is a finite automaton that recognizes it. Second part: we show that if a language is regular then there is a RE that specifies it Regular Expressions (REs) – p.19/37
Lemma 1.55 If a language is specifi ed by a RE, then it is regular. Regular Expressions (REs) – p.20/37
✁ � Lemma 1.55 If a language is specifi ed by a RE, then it is regular. Proof idea: Assume that we have a RE that evaluate to the language . Regular Expressions (REs) – p.20/37
✁ � � � Lemma 1.55 If a language is specifi ed by a RE, then it is regular. Proof idea: Assume that we have a RE that evaluate to the language . 1. We will show how to convert into an NFA that recognizes . Regular Expressions (REs) – p.20/37
� ✁ � � � � Lemma 1.55 If a language is specifi ed by a RE, then it is regular. Proof idea: Assume that we have a RE that evaluate to the language . 1. We will show how to convert into an NFA that recognizes . 2. Then by corollary 1.40, if an NFA recognizes then is regular Regular Expressions (REs) – p.20/37
� � Proof Convert into an NFA by the following six-steps proce- dure: Regular Expressions (REs) – p.21/37
✄ ✁ ✂ ✁ ✄ ✂ ✂ ☎ � � ☎ ✁ � � � ✄ � � ☎ � � ✄ ✂ � ✁ � � � � Step 1: If , then and the NFA recognizing is in Figure 1 Figure 1: NFA recognizing Regular Expressions (REs) – p.22/37
� ✁ ✂ ✁ ✄ ✂ ✂ ☎ � ☎ ✄ ✁ � � � ✄ � � ☎ � � ✄ ✂ � ✁ � � � � Step 1: If , then and the NFA recognizing is in Figure 1 Figure 1: NFA recognizing Note: this is an NFA but not a DFA because it has states with no exiting arrow for each possible input symbol Regular Expressions (REs) – p.22/37
� ✁ � � ✁ � ☎ � � � ✂ ☎ ✂ ✂ � ✁ ☎ ☎ � ✁ � ✄ � � � ✁ � � � � � ✁ � ✂ ✁ � ☎ ✁ ✂ ✁ � � ✁ � � ✂ ✁ � Formal construction � ✁� Formally where: , � ✁✄ , for and Regular Expressions (REs) – p.23/37
☎ ✁ ✝ ✁ � ✂ ✂ ☎ � � ✄ � ✁ � � � ☎ � � ✄ � � � Step 2: If then and the NFA that recognizes is in Figure 2 Figure 2: The NFA recognizing Regular Expressions (REs) – p.24/37
� � ☎ ✁ ✁ ✂ ✄ ☎ ✁ ☎ ✁ ✁ � � ✁ ✂ ✁ � ✁ ✁ � � � � � ☎ Formal construction � ✁� � ✁� Formally where: � ✁✄ for any and Regular Expressions (REs) – p.25/37
� ☎ ✄ ☎ ✂ ☎ ✁ � � � � ✄ � ✁ � � � Step 3: If then , and the NFA that recognizes is in Figure 3 Figure 3: he NFA recognizing Regular Expressions (REs) – p.26/37
✁ ✁ ✁ � ✂ ✁ ☎ ✄ ✁ � ✂ ☎ ✁ � ✁ ✁ ☎ � � � ☎ Formal construction � ✁� Formally where: � ✁✄ for any and Regular Expressions (REs) – p.27/37
☎ � ✁ ☎ � � ✄ � ✂ � ✄ � ☎ ✂ � ✁ � � � � ✄ Step 4: If then . � ✁� Regular Expressions (REs) – p.28/37
✄ � ✄ ✁ ☎ ✂ � ☎ � ☎ � � ✄ � ✂ � ✁ � � � � � Step 4: If then . � ✁� Note: in view with the inductive nature of we may assume that: Regular Expressions (REs) – p.28/37
� � � � ✄ ✂ ✁ ☎ ✁ ☎ � ✂ ✁ ✄ ✂ ✄ ✁ ✁ ✄ ✄ ✁ ☎ � ✂ ✄ � � � � ✁ � ✂ ✂ � � � ☎ � ✄ � ✁ ☎ ✁ ✄ ✄ Step 4: If then . � ✁� Note: in view with the inductive nature of we may assume that: 1. is an NFA recognizing Regular Expressions (REs) – p.28/37
✁ � ✂ ✄ ✁ ✂ ✄ ✄ ✁ ✄ ✂ ✁ ✂ ✂ ✄ � ✁ ✁ ✂ ✄ ☎ ✂ ☎ � � ✂ ✄ ✂ ✄ ✁ ✂ ✄ ✄ � ✂ � � � � � ✁ � ✂ ✂ ✄ � � ☎ � ✄ ✂ � � ☎ ✁ ☎ ✂ ✄ � � ☎ ☎ ✂ � � ✄ ✁ ✄ Step 4: If then . � ✁� Note: in view with the inductive nature of we may assume that: 1. is an NFA recognizing 2. is an NFA recognizing Regular Expressions (REs) – p.28/37
✁ ✄ ☎ � ✂ ✁ � � ✄ ☎ ✂ � ✂ ✄ ✁ ✄ ✄ ✂ � ✁ ✂ � ✄ ✂ ✂ ✂ ✂ ✄ ✄ � ✄ ✂ ✁ ✄ ✂ ✄ ✂ ✁ ✄ ✂ ✄ � ✄ � ☎ � � ☎ ☎ ✂ � ✁ � � � � ✂ ✁ ✂ � ✄ ✁ � � ☎ ✁ ☎ � ✄ � ✁ � ☎ ✂ � � � Step 4: If then . � ✁� Note: in view with the inductive nature of we may assume that: 1. is an NFA recognizing 2. is an NFA recognizing The NFA recognizing is given in Figure 4 Regular Expressions (REs) – p.28/37
✝ ✂ � � ✄ � ☎ ✂ ✄ ✄ ✄ ✄ ✄ ✄ � ✝ ✂ ✁ ✂ ✂ ✄ ✄ ✄ ✂ ✂ ✄ ✄ ✄ ✂ ✁ ✂ ✁ ✁ NFA recognizing ✂✆☎ Figure 4: Construction of to recognize Regular Expressions (REs) – p.29/37
✂ ✁ ☎ ✂ ☎ ✄ ✄ � ✁ � ☎ ✁ ✂ ✄ ✄ ✁ ☎ � ✁ Construction procedure 1. : That is, the states of are all states on and with the addition of a new state Regular Expressions (REs) – p.30/37
Recommend
More recommend