Knowing that $C$ is a context-free language and $R$ is a regular language, how to prove that $C / R = \{w| \exists x \in R: wx \in C\}$ is also a context-free language?
2 Answers
Let me prove the following more general statement:
Every full trio is closed under right quotient by a regular language.
Let $\mathcal{L}$ be the full trio, let $L \in \mathcal{L}$ be a language over $\Sigma$, and let $R$ be a regular language over $\Sigma$. Let $\Sigma' = \{ \sigma' : \sigma \in \Sigma \}$. Define the homomorphism $h\colon \Sigma \cup \Sigma' \to \Sigma$ by $h(\sigma) = h(\sigma') = \sigma$, and define the homomorphism $k\colon \Sigma \cup \Sigma' \to \Sigma$ by $k(\sigma') = \sigma$, $k(\sigma) = \epsilon$. Then $$ L/R = k(h^{-1}(L) \cap \Sigma^{\prime *} R). $$
- 280,205
- 27
- 317
- 514
There is a simple proof uses PDAs. Start with a PDA for $C$. Add an $\epsilon$ transition to a copy of the PDA, multiplied by an NFA for $R$. Instead of reading characters from the input, this part guesses them and advances the NFA. The new machine accepts if both the PDA and the NFA accept. Details left to you.
- 280,205
- 27
- 317
- 514