2

Given that $\#\notin \Sigma$ and $L\subseteq \Sigma^*\#\Sigma^*$, prove that if $L$ is context-free language then $L' = \{w_2\#w_1 \mid w_1\#w_2\in L\}$ is context-free. I'm trying to prove this in this way:

  1. because $L$ is context-free then $G$ is context-free grammar for $L$, then $L(G)=L$.
  2. by showing that the reversed grammar $F$ of $G$ is the same grammar of $L$ and because $G$ is context-free then $F$ is context-free then $L(F)=L'$ is also context-free. but can't figure out a way to prove this, so I need help to do this.
Nathaniel
  • 18,309
  • 2
  • 30
  • 58
Black Hat
  • 21
  • 1

1 Answers1

1

There is a unique path in the derivation tree that leads from the axiom $S$ to the terminal symbol $\#$. An idea would be to turn this tree upside down along that path.

This solution follows the construction for the closure under cyclic shift for context-free languages, as suggested in the book by Hopcroft and Ullman.

derivation trees

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109