Sei sulla pagina 1di 29

Fall 2006 Costas Busch - RPI 1

Properties of
Regular Languages

Fall 2006 Costas Busch - RPI 2
1
L
2
L
2 1
L L
Concatenation:
*
1
L
Star:
2 1
L L Union:
Are regular
Languages
For regular languages and
we will prove that:
1
L
2 1
L L
Complement:
Intersection:
R
L
1
Reversal:
Fall 2006 Costas Busch - RPI 3
We say: Regular languages are closed under
2 1
L L
Concatenation:
*
1
L
Star:
2 1
L L Union:
1
L
2 1
L L
Complement:
Intersection:
R
L
1
Reversal:
Fall 2006 Costas Busch - RPI 4
a
b
b
a
NFA
Equivalent
NFA


a
b
b
a
A useful transformation: use one accept state
2 accept states
1 accept state
Fall 2006 Costas Busch - RPI 5
NFA
Equivalent NFA
Single
accepting
state

In General
Fall 2006 Costas Busch - RPI 6


NFA without accepting state
Add an accepting state
without transitions
Extreme case
Fall 2006 Costas Busch - RPI 7
1
L Regular language
( )
1 1
L M L =
1
M
Single accepting state
NFA
2
M
2
L
Single accepting state
( )
2 2
L M L =
Regular language
NFA
Take two languages
Fall 2006 Costas Busch - RPI 8
} {
1
b a L
n
=
a
b
1
M
{ } ba L =
2
a
b
2
M
0 > n
Example
Fall 2006 Costas Busch - RPI 9
Union
NFA for
1
M
2
M
2 1
L L

Fall 2006 Costas Busch - RPI 10



a
b
a
b

} {
1
b a L
n
=
} {
2
ba L =
} { } {
2 1
ba b a L L
n
=
NFA for
Example
Fall 2006 Costas Busch - RPI 11
Concatenation

NFA for
2 1
L L
1
M
2
M

Fall 2006 Costas Busch - RPI 12



NFA for
a
b
a
b
} {
1
b a L
n
=
} {
2
ba L =
} { } }{ {
2 1
bba a ba b a L L
n n
= =

Example
Fall 2006 Costas Busch - RPI 13
Star Operation
NFA for
*
1
L
1
M

*
1
L e


1
2 1
L w
w w w w
i
k
e
=
Fall 2006 Costas Busch - RPI 14

NFA for * } { *
1
b a L
n
=
a
b
} {
1
b a L
n
=

Example
Fall 2006 Costas Busch - RPI 15
Reverse
R
L
1
1
M
NFA for
'
1
M
1. Reverse all transitions
2. Make initial state accepting state
and vice versa
1
L
Fall 2006 Costas Busch - RPI 16
} {
1
b a L
n
=
a
b
1
M
} {
1
n R
ba L =
a
b
'
1
M
Example
Fall 2006 Costas Busch - RPI 17
Complement
1. Take the DFA that accepts
1
L
1
M
1
L
'
1
M
1
L
2. Make accepting states non-final,
and vice-versa
Fall 2006 Costas Busch - RPI 18
} {
1
b a L
n
=
a
b
1
M
b a,
b a,
} { * } , {
1
b a b a L
n
=
a
b
'
1
M
b a,
b a,
Example
Fall 2006 Costas Busch - RPI 19
Intersection
1
L
regular
2
L
regular
We show
2 1
L L
regular
Fall 2006 Costas Busch - RPI 20
DeMorgans Law:
2 1 2 1
L L L L =
2 1
, L L
regular
2 1
, L L
regular
2 1
L L
regular
2 1
L L
regular
2 1
L L
regular
Fall 2006 Costas Busch - RPI 21
Example
} {
1
b a L
n
=
} , {
2
ba ab L =
regular
regular
} {
2 1
ab L L =
regular
Fall 2006 Costas Busch - RPI 22
1
L for
for
2
L
DFA
1
M
DFA
2
M
Construct a new DFA that accepts
Machine
Machine
M
2 1
L L
M
simulates in parallel and
1
M
2
M
Another Proof for Intersection Closure
Fall 2006 Costas Busch - RPI 23
States in
M
j i
p q ,
1
M
2
M State in
State in
Fall 2006 Costas Busch - RPI 24
1
M
2
M
1
q
2
q
a
transition
1
p
2
p
a
transition
DFA DFA
1 1
, p q
a
New transition
M DFA
2 2
, p q
Fall 2006 Costas Busch - RPI 25
0
q
initial state
0
p
initial state
New initial state
0 0
, p q
1
M
2
M DFA DFA
M DFA
Fall 2006 Costas Busch - RPI 26
i
q
accept state
j
p
accept states
New accept states
j i
p q ,
k
p
k i
p q ,
1
M
2
M DFA DFA
M DFA
Both constituents must be accepting states
Fall 2006 Costas Busch - RPI 27
Example:
} {
1
b a L
n
=
a
b
1
M
0 > n
} {
2
m
ab L =
b
b
2
M
0
q
1
q
0
p
1
p
0 > m
2
q
2
p
a
a
b a,
b a,
b a,
Fall 2006 Costas Busch - RPI 28
0 0
, p q
Automaton for intersection
} { } { } { ab ab b a L
n n
= =
1 0
, p q
a
2 1
, p q
b
a
b
1 1
, p q
2 0
, p q
a
1 2
, p q
2 2
, p q
b
b a,
a
b
b a,
b
a
Fall 2006 Costas Busch - RPI 29
M simulates in parallel and
1
M
2
M
M
accepts string
w
if and only if:
accepts string
w
1
M
and accepts string
w
2
M
) ( ) ( ) (
2 1
M L M L M L =

Potrebbero piacerti anche