03 Regular Expression
03 Regular Expression
Faryal Shamsi
Lecturer Computer Science
2
Formal Definition of RE
Algebra for Languages
Previously we discussed these operators:
• Union
• Concatenation
• Kleene Star
Example of Regular Expression
• Example
L
L
La a
• For regular expressions r1 and r2
Lr1 r2 Lr1 Lr2
Lr1 Lr1
Example 1
a b a *
La b a * La b La *
La b La *
La Lb La *
a b a*
a, b , a, aa, aaa,...
a, aa, aaa,..., b, ba, baa,...
Example 2
• Regular expression r a b * a bb
Lr {a b
2n 2m
b : n, m 0}
Example 4
• Regular expression r (0 1) * 00 (0 1) *
• Note that R+ε may or may not equal R (we are adding ε to the language)
• Note that RØ will only equal R if R itself is the empty set.
Equivalent Regular Expressions
r1 and r2
L(r1 ) L(r2 ) L
are equivalent
regular expr.