Académique Documents
Professionnel Documents
Culture Documents
CS2Ah 22.10.04
is a regular expressions.
is a regular expression.
Every symbol a in
and
is a regular expression.
.
If and are regular expressions then so is .
If is a regular expression then so is
.
To define the language described by a regular expression , we first define
the language associated to each of the basic expressions , and then describe
how to interpret the operations +, concatenation, and (often referred to as
If
CS2Ah 22.10.04
.
.
a a .
!
" $# ,
&%('*)&%,+ '-+ ,
. #/&%0)1%*+ #2&%435%(67)&%43 %(6+ #2898:8
;<%43=898:8>%@?A)1BC+CDE %43 8:898 %@?F+ &G(8
(the language consisting of all concatenations of finitely many strings from
).
I
H
K6L
MN
KO-
>P
73J
>
3M ab abc
K6Q consists of all strings of even length having an a at all even positions
and either a b or a c at all odd positions, that is,
CS2Ah 22.10.04
W
We first show how to construct NFAs for the basic regular expressions
and
a for a
. Recall that
,
, and a
a . Figure 1 shows three
simple NFAs recognising these three languages.
+C
3X
K6
V
V,Y
ZV 3 V76
VF3>Y
VF3
V76
V76
V
and a
7 3 K 6
3M 7V 6QY 6Q
V
[:E
V
VL3
[13
[96
VF3
q1
N1
q2
N2
[13
[96
V76
\3$ 6
[96
VZ3
[13
^3
[96
CS2Ah 22.10.04
[_3
all states in
with
by an -transition. The starting state of
is , and the
final states are all final states of
. Figure 3 gives a schematic picture of .
V\6
N1
q1
N2
`
3
3
V
VF3M*V "/
3M 1[ 3
ZV 3
V
[
[S3
\3>6
^ 3
^3
[
[
U[
VL3
VZ3
N1
q1
3
ab 8
4
such that
CS2Ah 22.10.04
b
a
b
a
a
a
b
b
Figure 5: A DFA
obtain the NFA with transitions displayed in Figure 6, which obviously accepts
the same language as . Now we start eliminating states and obtain the automata displayed in Figures 7. All these automata recognise the same language.
The language of the last automaton of Figures 7 can easily be seen to be
for
the regular expression
c M a
M a
ba b
ba a
M a
bb b a
ba
$ b
Kleenes Theorem
Putting results of the previous sections together, we obtain Kleenes Theorem,
first proved by S.C. Kleene, one of the founders of modern mathematical logic.
5
CS2Ah 22.10.04
b
a
b
a
a
a
b
b
Figure 6: Normalisation
CS2Ah 22.10.04
a+ba
bb
a
(a+ba)b
(a+ba)+b
(a+ba)a+bb
b
(a+ba)b+((a+ba)a+bb)b*a
(a+ba)+b
CS2Ah 22.10.04
Exercises
1. Convert the following regular expressions to NFAs.
d d N
(b) d W>
M
ef
(c) d e d
(a)
1
0
0
0
3. Convert the DFAs from lecture notes 1 and 2 into regular expressions.
Don Sannella