This ppt is the work by Dr. Costas Busch, used with permission, and available from http://csc.lsu.edu/~busch/courses/theorycomp/fall2008/ 1
Regular Expressions
Regular expressions describe regular languages
Example:
(a b c) * describes the language
a, bc * , a, bc, aa, abc, bca,...
2
Recursive Definition
Primitive regular expressions: , ,
Given regular expressionsr1
r2 and r1 r2 r1 r2 r1 *
Are regular expressions
r1
3
Examples
A regular expression:
a b c * (c )
Not a regular expression:
a b
4
Languages of Regular Expressions
L r
r
: language of regular expression
Example
L (a b c) * , a, bc, aa, abc, bca,...
5
Definition
For primitive regular expressions:
L
L
L a a
6
Definition (continued)
For regular expressionsr1
andr2
L r1 r2 L r1 L r2
L r1 r2 L r1 L r2
L r1 * L r1 *
L r1 L r1
7
Example
Regular expression: a b a *
L a b a * L a b L a *
L a b L a *
L a L b L a *
a b a *
a, b , a, aa, aaa,...
a, aa, aaa,..., b, ba, baa,...
8
Example
Regular expression
r a b * a bb
L r a, bb, aa, abb, ba, bbb,...
9
Example
Regular expression
r aa * bb * b
2n 2m
L r {a b
b : n, m 0}
10
Example
Regular expression
r (0 1) * 00 (0 1) *
L(r ) = { all strings containing substring 00
11
Example
Regular expression r
(1 01) * (0 )
L(r ) = { all strings without substring 00 }
12
Equivalent Regular Expressions
Definition:
Regular expressions r1
andr2
are equivalent ifL( r1 ) L( r2 )
13
Example
L
= { all strings without substring 00 }
r1 (1 01) * (0 ) r2 (1* 011*) * (0 ) 1* (0 )
L(r1 ) L(r2 ) L
r1
and r2 are equivalent regular expressions
14
Regular Expressions and Regular Languages
15
Theorem
Languages
Generated by