2

R is a regular language over $\Sigma=\{0,1\}$
$Sub(R)=\{0^i1^j \mid \exists w\in R.|w|=i-j \}$
I need to prove that Sub(R) is context free.

I know that the quotient of a context free language with a regular language is context free but I can't seem to continue for there..

Raphael
  • 72,336
  • 29
  • 179
  • 389
Lee
  • 217
  • 2
  • 8

1 Answers1

3

Let $\phi(R) \subseteq 0^*$ result from $R$ by substituting $0$ for $1$. Alternatively, $\phi(R) = \{ 0^{|w|} : w \in R \}$. The previous description makes it clear that $\phi(R)$ is also regular. Now $$ \operatorname{Sub}(R) = \phi(R) \{ 0^j 1^j \}, $$ the concatenation of the regular language $\phi(R)$ and the context-free language $\{0^j 1^j\}$.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503