Example - Piazza

Download Report

Transcript Example - Piazza

Properties of
Regular Languages
Prof. Busch - LSU
1
For regular languages
we will prove that:
Union:
Concatenation:
L1
and
L2
L1  L2
L1L2
Star:
L1 *
Reversal:
R
L1
Complement:
L1
Intersection:
L1  L2
Prof. Busch - LSU
Are regular
Languages
2
We say: Regular languages are closed under
Union:
Concatenation:
L1  L2
L1L2
Star:
L1 *
Reversal:
R
L1
Complement:
L1
Intersection:
L1  L2
Prof. Busch - LSU
3
A useful transformation: use one accept state
NFA
a
2 accept states
b
a
b
Equivalent
NFA
a
b
1 accept state
a
b


Prof. Busch - LSU
4
NFA
In General
Equivalent NFA



Prof. Busch - LSU
Single
accepting
state
5
Extreme case
NFA without accepting state
Add an accepting state
without transitions
Prof. Busch - LSU
6
Take two languages
Regular language
L1
Regular language
LM1   L1
NFA
LM 2   L2
NFA
M1
Single accepting state
L2
M2
Single accepting state
Prof. Busch - LSU
7
Example
n0
L1  {a b}
n
M1
a
b
M2
L2  ba
b
Prof. Busch - LSU
a
8
NFA for
L1  L2
Union
M1


M2
Prof. Busch - LSU
9
NFA for
Example
n
L1  L2  {a b}  {ba}
L1  {a b}
n
a


b
L2  {ba}
b
a
Prof. Busch - LSU
10
Concatenation
NFA for
L1L2
M1
M2

Prof. Busch - LSU
11
Example
NFA for
L1L2  {a b}{ba}  {a bba}
n
L1  {a b}
n
n
L2  {ba}
a
b

b
Prof. Busch - LSU
a
12
Star Operation
NFA for L1 *
w  w1w2  wk

wi  L1
M1


  L1 *

Prof. Busch - LSU
13
Example
NFA for
L1*  {a b} *
n

L1  {a b}
n
a


b

Prof. Busch - LSU
14
Reverse
R
NFA for L1
L1

M1
M1
1. Reverse all transitions
2. Make initial state accepting state
and vice versa
Prof. Busch - LSU
15
Example
M1
a
L1  {a b}
n
b
a
R
L1
 {ba }
n

M1
b
Prof. Busch - LSU
16
Complement
L1
M1
L1
1. Take the DFA that accepts

M1
L1
2. Make accepting states non-final,
and vice-versa
Prof. Busch - LSU
17
Example
M1
a, b
a
L1  {a b}
n
b
L1  {a, b} * {a b}
n
a, b

M1
a, b
a
b
Prof. Busch - LSU
a, b
18
Intersection
L1
regular
We show
L2
regular
L1  L2
regular
Prof. Busch - LSU
19
DeMorgan’s Law:
L1  L2  L1  L2
L1 , L2
regular
L1 , L2
regular
L1  L2
regular
L1  L2
regular
L1  L2
regular
Prof. Busch - LSU
20
Example
L1  {a b} regular
n
L2  {ab, ba} regular
Prof. Busch - LSU
L1  L2  {ab}
regular
21
Another Proof for Intersection Closure
Machine
M1
Machine
M2
DFA for
L1
DFA for
L2
Construct a new DFA
M that accepts L1  L2
M simulates in parallel M1 and M 2
Prof. Busch - LSU
22
States in M
qi , p j
State in
M1
State in
Prof. Busch - LSU
M2
23
DFA
q1
DFA
M1
a
q2
a
p1
transition
M2
p2
transition
DFA
q1, p1
M
a
q2 , p2
New transition
Prof. Busch - LSU
24
DFA
DFA
M1
M2
q0
p0
initial state
initial state
DFA
M
q0 , p0
New initial state
Prof. Busch - LSU
25
DFA M1
DFA
pj
qi
accept state
M2
pk
accept states
DFA
M
qi , p j
qi , pk
New accept states
Both constituents must be accepting states
Prof. Busch - LSU
26
Example:
n0
m0
L1  {a b}
L2  {ab }
M1
M2
n
a
q0
b
q2
m
q1
p0
a, b
b
a, b
a
b
p1
a
p2
a, b
Prof. Busch - LSU
27
Automaton for intersection
L  {a n b }  {abm }  {ab }
a, b
q0 , p0
a
b
q1, p2
q0 , p1
b
q1, p1
a
b
a
a
b
q0 , p2
q2 , p2
q2 , p1
a
b
a, b
Prof. Busch - LSU
28
M
simulates in parallel
M1
and
M2
M accepts string w if and only if:
and
M1
accepts string
w
M2
accepts string
w
L( M )  L( M1)  L( M 2 )
Prof. Busch - LSU
29