Prove that if $\mathcal L$ is context-free so $\mathcal L_{\text{even}}$ is context-free

137 Views Asked by At

Let $\mathcal L$ be a language. Denote by $\mathcal L_{\text{even}}$ the language consisting of all words in $\mathcal L$ whose length is even.

Prove that if $\mathcal L$ is context-free over the alphabet $\{0,1\}$ then $\mathcal L_{\text{even}}$ is also context-free.


Here is my idea:

All the words that belong to $\mathcal L_{\text{even}}$ are joined from words in $\mathcal L$, e.g. given the word $\color{green}{011}\in \mathcal L$ and the word $\color{blue}{10100}\in \mathcal L$, we can join them: $\color{green}{011}\color{blue}{10100}\in \mathcal L_{\text{even}}$.

I think that since the context-free languages are closed under junction, it follows that $\mathcal L_{\text{even}}$ is context-free, and that's it.

But it looks too simple so I'm suspicious.

2

There are 2 best solutions below

12
On BEST ANSWER

You are misinterpreting the definition of $\mathcal{L}_\mathrm{even}$: it consists of those words in $\mathcal{L}$ which have even length. For example, if $\mathcal{L} = \{ a^n b^n, a^n b^{n+1} : n \geq 0 \}$ then $\mathcal{L}_\mathrm{even} = \{ a^n b^n : n \geq 0 \}$.

For the proof, use the fact that the context-free languages are closed under intersection with regular languages.

0
On

After using @YuvalFilmus's hint

Let's denote $\mathcal L'$ to be the language of all the even words above the alphabe $\{0,1\}$.

$\mathcal L'$ is regular because we can write a regular expression for it: $\big((0+1)(0+1)\big)^*$, we can see that $\mathcal L_{\text{even}}=\mathcal L \cap \mathcal L'$ since the context-free languages are closed under intersection with regular languages so $\mathcal L_{\text{even}}$ is context free $\square$