0% found this document useful (0 votes)
35 views

Decidable Regular Context Free

The document discusses decidable problems for regular and context-free languages. For regular languages, it describes how to check if a string is in a language, if a language is empty, if it is finite, and if two languages are equal using deterministic finite automata. For context-free languages, it describes algorithms to check membership, if a language is empty, and if it is infinite by analyzing the context-free grammar.

Uploaded by

tariqravian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Decidable Regular Context Free

The document discusses decidable problems for regular and context-free languages. For regular languages, it describes how to check if a string is in a language, if a language is empty, if it is finite, and if two languages are equal using deterministic finite automata. For context-free languages, it describes algorithms to check membership, if a language is empty, and if it is infinite by analyzing the context-free grammar.

Uploaded by

tariqravian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

Decidable Problems

of
Regular Languages

Fall 2003 Costas Busch - RPI 1


Membership Question
Question: Given regular language L
and string w
how can we check if w  L?

Answer: Take the DFA that accepts L


and check if w is accepted

Fall 2003 Costas Busch - RPI 2


DFA
w
w L

DFA
w
w L

Fall 2003 Costas 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
Fall 2003 Costas Busch - RPI 4
DFA

L

DFA

L

Fall 2003 Costas Busch - RPI 5


Question: Given regular language L
how can we check
if L is finite?

Answer: Take the DFA that accepts L

Check if there is a walk with cycle


from the initial state to a final state
Fall 2003 Costas Busch - RPI 6
DFA

L is infinite

DFA

L is finite

Fall 2003 Costas Busch - RPI 7


Question: Given regular languages L1 and L2
how can we check if L1  L2 ?

Answer: Find if ( L1  L2 )  ( L1  L2 )  

Fall 2003 Costas Busch - RPI 8


( L1  L2 )  ( L1  L2 )  

L1  L2   and L1  L2  

L1 L2 L L2 L1 L1
2
L1  L2 L2  L1

L1  L2
Fall 2003 Costas Busch - RPI 9
( L1  L2 )  ( L1  L2 )  

L1  L2   or L1  L2  

L1 L2 L2 L1

L1  L2 L2  L1

L1  L2
Fall 2003 Costas Busch - RPI 10
Decidable Problems
of
Context-Free Languages

Fall 2003 Costas Busch - RPI 11


Membership Question:

for context-free grammar G


find if string w L(G )

Membership Algorithms: Parsers

• Exhaustive search parser

• CYK parsing algorithm

Fall 2003 Costas Busch - RPI 12


Empty Language Question:

for context-free grammar G


find if L(G )  

Algorithm:

1. Remove useless variables

2. Check if start variable S is useless


Fall 2003 Costas Busch - RPI 13
Infinite Language Question:
for context-free grammar G
find if L (G ) is infinite

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
Fall 2003 Costas Busch - RPI 14
Example: S  AB
A  aCb | a
B  bB | bb
C  cBS
Dependency graph Infinite language

A C
S
B
Fall 2003 Costas Busch - RPI 15
S  AB
A  aCb | a
B  bB | bb
C  cBS

S  AB  aCbB  acBSbB  acbbSbbb


 
2 2
S  acbbSbbb (acbb) S (bbb)

i i
(acbb) S (bbb)
Fall 2003 Costas Busch - RPI 16

You might also like