2. 2
RE’s: Introduction
• Regular expressions describe
languages by an algebra.
• They describe exactly the regular
languages.
• If E is a regular expression, then L(E)
is the language it defines.
• We’ll describe RE’s and their
languages recursively.
Courtesy: Costas/Ullman
3. 3
Operations on Languages
• RE’s use three operations: union,
concatenation, and Kleene star.
• The union of languages is the usual thing,
since languages are sets.
• Example: {01,111,10}{00, 01} =
{01,111,10,00}.
Courtesy: Costas/Ullman
4. 4
Concatenation
• The concatenation of languages L and
M is denoted LM.
• It contains every string wx such that
w is in L and x is in M.
• Example: {01,111,10}{00, 01} = {0100,
0101, 11100, 11101, 1000, 1001}.
Courtesy: Costas/Ullman
5. 5
Kleene Star
• If L is a language, then L*, the Kleene star
or just “star,” is the set of strings formed
by concatenating zero or more strings from
L, in any order.
• L* = {ε} L LL LLL …
• Example: {0,10}* = {ε, 0, 10, 00, 010, 100,
1010,…}
Courtesy: Costas/Ullman
6. 6
RE’s: Definition
• Basis 1: If a is any symbol, then a is a RE,
and L(a) = {a}.
– Note: {a} is the language containing one string,
and that string is of length 1.
• Basis 2: ε is a RE, and L(ε) = {ε}.
• Basis 3: ∅ is a RE, and L(∅) = ∅.
Courtesy: Costas/Ullman
7. 7
RE’s: Definition – (2)
• Induction 1: If E1 and E2 are regular
expressions, then E1+E2 is a regular
expression, and L(E1+E2) = L(E1)L(E2).
• Induction 2: If E1 and E2 are regular
expressions, then E1E2 is a regular
expression, and L(E1E2) = L(E1)L(E2).
• Induction 3: If E is a RE, then E* is a RE,
and L(E*) = (L(E))*.
Courtesy: Costas/Ullman
9. 9
Precedence of Operators
• Parentheses may be used wherever needed
to influence the grouping of operators.
• Order of precedence is * (highest), then
concatenation, then + (lowest).
Courtesy: Costas/Ullman
20. Courtesy: Costas/Ullman 20
Proof - Part 1
r
)(rL
For any regular expression
the language is regular
Languages
Generated by
Regular Expressions
Regular
Languages
Proof by induction on the size of r
25. Courtesy: Costas/Ullman 25
)( 1rL )( 2rL
By inductive hypothesis we know:
and are regular languages
Regular languages are closed under:
*1
21
21
rL
rLrL
rLrL Union
Concatenation
Star
We also know:
26. Courtesy: Costas/Ullman 26
Therefore:
** 11
2121
2121
rLrL
rLrLrrL
rLrLrrL
Are regular
languages
)())(( 11 rLrL is trivially a regular language
(by induction hypothesis)
End of Proof-Part 1
27. Courtesy: Costas/Ullman 27
Using the regular closure of operations,
we can construct recursively the NFA
that accepts
M
)()( rLML
Example: 21 rrr
)()( 11 rLML
)()( 22 rLML
)()( rLML
28. Courtesy: Costas/Ullman 28
For any regular language there is
a regular expression with
Proof - Part 2
Languages
Generated by
Regular Expressions
Regular
Languages
L
r LrL )(
We will convert an NFA that accepts
to a regular expression
L
30. Courtesy: Costas/Ullman 30
From construct the equivalent
Generalized Transition Graph
in which transition labels are regular expressions
M
Example:
a
ba,
c
M
a
ba
c
Corresponding
Generalized transition graph
35. Courtesy: Costas/Ullman 35
iq jq
dae* bce*
dce*
bae*
iq q jq
a b
cd
e
kq
f g
kq
fge*
dge*
fae*
bge*
fce*
This can be generalized
to arbitrary number
of neighbors to q
3-neighbors
36. Courtesy: Costas/Ullman 36
0q fq
1r
2r
3r
4r
*)*(* 213421 rrrrrrr
LMLrL )()(
The resulting regular expression:
By repeating the process until
two states are left, the resulting graph is
Initial graph Resulting graph
End of Proof-Part 2
38. Courtesy: Costas/Ullman 38
When we say: We are given
a Regular Language
We mean:
L
Language is in a standard
representation
L
(DFA, NFA, or Regular Expression)