Is this language context-free, and how to prove it

95 Views Asked by At

Consider the following language (sorry, I am new here, I don't know how to make the 'element of' symbol):

$$L = \{w_1 \in L_1 : \exists w_2 \in L_2 : |w_1|=|w_2|\}$$

so it is all strings in $L_1$ for which there exists a string in $L_2$ of equal length.

I know that if $L_1$ and $L_2$ are regular, then $L$ is also regular. The proof requires that $L_2$ has a DFA.

I want to know now whether L is also context-free if $L_1$ and $L_2$ are context-free? I don't really know how to prove or disprove that.

1

There are 1 best solutions below

2
On BEST ANSWER

Proof outline:

  1. If $L$ is a context-free language with alphabet $\Sigma$, then the image of $L$ under $H_a$, the homomorphism mapping every element of $\Sigma$ to $a$, is regular. So $H_a(L_2)$ is regular. (CFLs with a unary alphabet are regular.)

  2. Regular languages are closed under inverse homomorphism. So $H^{-1}_a(H_a(L_2))$ is regular.

  3. The intersection of a context-free language and a regular language is context-free. So $L_1 \cap H^{-1}_a(H_a(L_2))$ is context-free.

  4. But that's $L$.