Lecture 4: Regular Expressions
David Dill
Department of Computer Science
1
Outline
•
Finish
±
NFAs
•
Introduction to Regular expressions
•
More Operations on Languages
•
Recursive Definition of Syntax and Semantics
•
Converting Regular Expressions to
±
NFAs
•
Converting NFAs to regular expressions.
2
Definition of
ECLOSE
Def:
S
is the least set satisfying property
P
if whenever
P
(
S
0
)
holds,
S
⊆
S
0
.
ECLOSE
(
q
)
is the least set satisfying:
•
q
∈
ECLOSE
(
q
)
•
δ
(
s, ±
)
⊆
ECLOSE
(
q
)
for all
s
∈
ECLOSE
(
q
)
Also,
ECLOSE
(
S
) =
S
{
ECLOSE
(
q
)

q
∈
S
}
(“Extend to sets” – this is overloading)
3
Acceptance by an
±
NFA
We can define
ˆ
δ
for an
±
NFA taking
ECLOSE
into account:
Base:
ˆ
δ
(
q, ±
) =
ECLOSE
(
q
)
Induction:
ˆ
δ
(
q, xa
) =
ECLOSE
(
S
s
∈
ˆ
δ
(
q,x
)
δ
(
s, a
))
(Same as
ˆ
δ
for NFA, with
ECLOSE
wrapped around state sets.)
Acceptance (same as before).
x
∈
L
(
E
)
if
ˆ
δ
(
q
0
, x
)
∩
F
6
=
∅
Example:
ˆ
δ
(
q
0
,
001) =
{
q
1
, q
2
}
– accepted because
q
2
∈
F
.
4
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentConverting an
±
NFA to an DFA
Theorem:
For every
±
NFA
E
, there exists an DFA
D
such that
L
(
D
) =
L
(
E
)
.
The proof uses a modified subset construction, where every subset is
±
closed.
Given
E
= (
Q,
Σ
, q
0
, δ
E
, F
E
)
, we can define
D
= (2
Q
,
Σ
,
ECLOSE
(
q
0
)
, δ
D
, F
D
)
as follows:
F
D
=
{
S
⊆
Q

S
∩
F
6
=
∅}
δ
D
(
S, a
) =
ECLOSE
(
S
s
∈
S
δ
E
(
s, a
))
Note:
δ
D
has no
±
transitions!
5
±
elimination example
q0
q1
1
q2
0
0
e
1
e
converts to the DFA:
{q0}
{q1,q2}
0,1
0,1
6
±
elimination Proof (not presented in lecture)
Lemma:
If
D
is the DFA obtained from the
±

NF A N
by the
±
elimination,
then
ˆ
δ
D
(
ECLOSE
(
q
0
)
, x
) =
ˆ
δ
E
(
q
0
, x
)
for all
x
∈
Σ
*
.
Proof:
By induction on strings:
Basis:
ˆ
δ
D
(
ECLOSE
(
q
0
)
, ±
)
=
ECLOSE
(
q
0
)
Def of
ˆ
δ
for DFA
=
ˆ
δ
E
(
q
0
, ±
)
def of
ˆ
δ
for
±
NFA
Induction:
ˆ
δ
D
(
ECLOSE
(
q
0
)
, xa
)
=
δ
D
(
ˆ
δ
D
(
ECLOSE
(
q
0
)
, x
)
, a
)
Def of
ˆ
δ
for DFA
=
δ
D
(
ˆ
δ
E
(
q
0
, x
)
, a
)
Ind. Hyp.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '08
 Motwani,R
 Regular expression, regular expressions, ECLOSE

Click to edit the document details