Theory of Automata: Regular Expressions
Theory of Automata: Regular Expressions
Regular Expressions
Regular Expressions
Language Defining Symbols
Alternation, Either/OR, Disjunction, Plus Sign
Defining Languages by Another New Method
Formal Definition of Regular Expressions
Product Set
Languages Associated with Regular Expressions
Finite Languages Are Regular
How Hard It Is to Understand a Regular Expression
Introducing EVEN-EVEN
This language is the set of all words over the alphabet Σ = {a,
b} that have at least one a.
The only words left out are those that have only b’s and the
word Λ.
These left out words are exactly the language defined by the
expression b*.
If we combine this language, we should provide a language of
all strings over the alphabet Σ = {a, b}. That is,
(a + b)* = (a + b)*a(a + b)* + b*
Another expression that defines all the words with at least two
a’s is
b*ab*a(a + b)*
Since we know that either the a comes before the b or the b comes
before the a, we can define the language by the expression
Note that the only words that are omitted by the first term
(a + b)*a(a + b)*b(a + b)* are the words of the form some b’s followed by
some a’s. They are defined by the expression bb*aa*
The only words that do not contain both an a and a b are the
words of all a’s, all b’s, or Λ.
b* + ab*
where Λ is included in b*.
Alternatively, we could define V by
(Λ + a)b*
which means that in front of the string of some b’s, we have
either an a or nothing.
Hence,
(Λ + a)b* = b* + ab*
(a + aa + aaa)(bb + bbb)
= abb + abbb + aabb + aabbb + aaabb + aaabbb
language(r1r2) = L1L2
Rule 2 (cont.):
This is the set of strings of a’s and b’s that at some point
contain a double letter.
(Λ + b)(ab)*(Λ + a)
Note that
(a + b*)* = (a + b)*
since the internal * adds nothing to the language. However,
Since both the single letter a and the single letter b are words
of the form a*b*, this language contains all strings of a’s and
b’s. That is,
(a*b*)* = (a + b)*
This equation gives a big doubt on the possibility of finding a
set of algebraic rules to reduce one regular expression to
another equivalent one.
This expression represents all the words that are made up of syllables
of three types:
type1 = aa
type2 = bb
type3 = (ab + ba)(aa + bb)*(ab + ba)
All strings with an even number of a’s and an even number of b’s
belong to the language defined by E.
Algorithm 1: Keep two binary flags, the a-flag and the b-flag.
Every time an a is read, the a-flag is reversed (0 to 1, or 1 to 0),
and every time a b is read, the b-flag is reversed. We start both
flags at 0 and check to be sure they are both 0 at the end.