Session 6: �Regular Expression and Regular Languages
By
Dr. Ashok Kumar
Amity School of Engineering & Technology
REGULAR EXPRESSION
Amity School of Engineering & Technology
Let Σ be an alphabet. The regular expressions over Σ and the sets that they denote are defined recursively as follows.
r + s denotes R U S
rs denotes RS
r* denotes R*
Amity School of Engineering & Technology
REGULAR EXPRESSION - operations
are regular expressions
Given regular expressions r1 and r2
Union
Concatenation
Star Closure
Amity School of Engineering & Technology
Amity School of Engineering & Technology
REGULAR EXPRESSION - example
A regular expression:
Not a regular expression:
Amity School of Engineering & Technology
Equivalence of Regular Expressions - example
= { all strings without two consecutive 0 }
and
are equivalent regular expr.
L (r1) = { ε, 0, 1, 10, 01, 11, 110, 0101,…. }
L (r2) = { ε, 0, 1, 10, 01, 11, 110, 0101,…. }
Amity School of Engineering & Technology
Equivalence of Regular Expressions
Amity School of Engineering & Technology
Identity Rules for Regular Expression
The two regular expression’s P and Q are equivalent (denoted as P=Q) if and only if P represents the same set of strings as Q does.
For showing the equivalence of two regular expressions we need to show some identities of regular expression’s
Amity School of Engineering & Technology
Identity Rules for Regular Expression
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Language & REGULAR EXPRESSION
Amity School of Engineering & Technology
REGULAR EXPRESSION & Language
Regular Expression | Language |
0* | Set of all strings of the form 0n (n>=0) L = {ε, 0, 00, 000, 0000, 00000, . . . } |
1+0 | Set of 0 and 1 L = { 0, 1 } |
01 | L = { 01 } |
(01)* | Set of all strings containing n ‘01’s ( n >= 0 ) L = {ε , 01, 0101, 010101, 01010101, . . . } |
(1+0)* | Set of all strings containing 1 and 0 L = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, …. } |
01* | Set of all strings start with 0 followed by n 1s ( n>=0 ) L = { 0, 01, 011, 0111, 01111, 011111, … } |
(0+1)00 | L = {000, 100} |
Amity School of Engineering & Technology
More Examples
R = 1 (0+1)* 0
R = a b* a
R = {a + ab}*
Amity School of Engineering & Technology
More Examples
R = a* b* c*
R = (00)*
R = (1* 0*)
Amity School of Engineering & Technology
More Examples
R = (011 + 1)*
Amity School of Engineering & Technology