4

Is the following problem decidable. "Given 2 CFL, $L_1$ and $L_2$. Is $L_1 \cap L_2$ a CFL?"

CFL is an abbreviation for "Context Free Language".

nickalh
  • 103
  • 2

1 Answers1

7

This is not decidable.

We can use the fact that it is undecidable whether $L_1\cap L_2=\varnothing$ for context-free languages $L_1,L_2$.

Take two (fixed) context-free languages $K_1,K_2$ such that $K_1\cap K_2$ is not context-free. Also take a symbol $\#$ which is not in the alphabet of any of the four languages.

Languages $L_1\cdot \# \cdot K_1$ and $L_2\cdot \# \cdot K_2$ are context-free. Their intersection $(L_1\cdot \# \cdot K_1) \cap (L_2\cdot \# \cdot K_2)$ equals $(L_1 \cap L_2) \cdot \# \cdot (K_1\cap K_2)$. This intersection is either empty and context-free (when $L_1\cap L_2 =\varnothing$) or it is not context-free (otherwise).

Deciding when one intersection is context-free is equivalent to deciding whether to other intersection is empty. Which we can't.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109