1

Consider the language below, on the alphabet $\Sigma = \{a,b,\$\}$: $$L = \left\{ x$y \mid x,y\in\{a,b\}^* \land \left|x\right| \ne \left|y\right| \right\}$$

I need to define a CFG for this language. I've tried couple of CFGs but they all failed in one way or another.

I'd be glad for help.

babou
  • 19,445
  • 40
  • 76
Elimination
  • 389
  • 4
  • 13
  • 3
    Could you show us what you have tried? – Jake May 02 '15 at 16:39
  • 2
    What have you tried? ...Try to simplify your problem. Start with only $a$ and $$$. That should be easier. Then modify your solution to add the $b$. Why do I say that? Because only length matters, not the difference between $a$ and $b$. So I am taking advantage of it. Many problems are quite simple if you stop to analyze what matters and what does not. – babou May 02 '15 at 17:03
  • I'm sure this was asked before on this site. Did you try to look it up? – Ran G. May 12 '15 at 01:05

1 Answers1

4

Hint: $$ L = \{ \Sigma^{m+1} \Sigma^n \$ \Sigma^n : n,m \geq 0 \} \cup \{ \Sigma^n \$ \Sigma^n \Sigma^{m+1} \}, $$ where $\Sigma = \{a,b\}$.

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