Decidable problems on Regular and Context

advertisement
Decidable Problems
of
Regular Languages
Prof. Busch - RPI
1
Membership Question
Question:
Answer:
Given regular language L
and string w
how can we check if w 
L?
Take the DFA that accepts L
and check if w is accepted
Prof. Busch - RPI
2
DFA
w
w L
DFA
w
w L
Prof. Busch - RPI
3
Question:
Given regular language L
how can we check
if L is empty: ( L  ) ?
Answer: Take the DFA that accepts
L
Check if there is any path from
the initial state to an accepting state
Prof. Busch - RPI
4
DFA
L
DFA
L
Prof. Busch - RPI
5
Question:
Given regular language
how can we check
if L is finite?
Answer: Take the DFA that accepts
L
L
Check if there is a walk with cycle
from the initial state to a final state
Prof. Busch - RPI
6
DFA
L is infinite
DFA
L is finite
Prof. Busch - RPI
7
Question: Given regular languages L1 and
how can we check if L1  L2 ?
Answer:
Find if
L2
( L1  L2 )  ( L1  L2 )  
Prof. Busch - RPI
8
( L1  L2 )  ( L1  L2 )  
and
L1  L2  
L1
L1  L2  
L2
L2 L
2
L1  L2
L1 L1
L2  L1
L1  L2
Prof. Busch - RPI
9
( L1  L2 )  ( L1  L2 )  
L1  L2  
L1
or
L1  L2  
L2
L2
L1  L2
L1
L2  L1
L1  L2
Prof. Busch - RPI
10
Decidable Problems
of
Context-Free Languages
Prof. Busch - RPI
11
Membership Question:
for context-free grammar
find if string w L(G )
G
Membership Algorithms: Parsers
• Exhaustive search parser
• CYK parsing algorithm
Prof. Busch - RPI
12
Empty Language Question:
for context-free grammar
find if L(G )  
G
Algorithm:
1. Remove useless variables
2. Check if start variable
Prof. Busch - RPI
S is useless
13
Infinite Language Question:
for context-free grammar
find if L(G ) is infinite
G
Algorithm:
1. Remove useless variables
2. Remove unit and

productions
3. Create dependency graph for variables
4. If there is a loop in the dependency graph
then the language is infinite
Prof. Busch - RPI
14
Example:
S  AB
A  aCb | a
B  bB | bb
C  cBS
Infinite language
Dependency graph
A
C
S
B
Prof. Busch - RPI
15
S  AB
A  aCb | a
B  bB | bb
C  cBS
S  AB  aCbB  acBSbB  acbbSbbb


S  acbbSbbb(acbb) S (bbb)

(acbb) S (bbb)
i
2
2
i
Prof. Busch - RPI
16
Download