3

I want to derive a context free grammar for the following language on alphabet $\Sigma=\{a,b\}$:

$\qquad\displaystyle \{ xax'yby'z \mid x,y,z\in\Sigma ^*, |x|=|x'|, |y|=|y'|, |z|=|x|+|y|\}$

I am convinced that this language is context-free because this is part of my proof to a theorem given in textbook, but haven't yet seen a context-free grammar for it.

Raphael
  • 73,212
  • 30
  • 182
  • 400
sjtufs
  • 91
  • 2

1 Answers1

1

Hint: you want to measure size of $x$ and $y$, and still have the sum of the two in the end. so when you read them, you will need twice their size: one for $x'$, and one for $z$. Start with designing a PDA, it seems easier than a grammar. Then you can use a PDA-to-grammar translation to get the wanted grammar.

Denis
  • 1,387
  • 6
  • 9