Chapter 4: Regular Expressions

Topics
Introduction
Three operations on languages
Regular expressions
Definition of regular expression
Some common regular expressions and their languages


Introduction

We have the means to describe some languages:

We need some more operations on languages that will allow us to create more interesting languages


Three operations on languages

Operations on numbers:

Operations on languages (the analogy with numbers is complete): For the purposes of our goal, we will use three set operations:

Operation *: Kleene closure

Operation È: set union Operation: set product Definition: In addition to the operations, we will use parentheses for grouping, as for arithmetic expressions.


Now we are ready to construct a language expression:
({a}{ab, a})È({a, b}{a, cd})
which stands for:
{aab, aa, acd, ba, bcd }

 



Regular expressions Note: we will now be using Kleene * in two ways!!
a* Þ {a}* = {l, a, aa, aaa, …}
 
Some examples (assume a and b are characters in an alphabet): Grouping operation ( "()" ): Operator precedence:
Definition of regular expression

Given a vocabulary a, b, c, …

Rule 1: l is a regular expression: L(l) = Æ
Rule 2: a, b, c, … are regular expressions: L(a) = {a}, L(b) = {b}, …
Rule 3: If R and S are regular expressions, then:

Some common regular expressions and their languages
 
r.e. language
a* strings of 0 or more a's
aa*  strings of 1 or more a's
a+               "
an a string of n a's (not in the definition, but sometimes used, for brevity)
(a + b)* {a, b}* = strings of 0 or more a's and b's
a*b* any # a's followed by any # of b's
(ab)* strings of any number of ab's
b*ab* strings with exactly one a
(a + b)*a(a + b)* strings with at least one a
a(a + b)* strings beginning with a
Hosted by www.Geocities.ws

1