-1

I am doing an exercise from Models Of Computation - Ch - 5, Q-1(r).

Design a grammar that generates this context-free language

$\{ x\space\$\space y^R \,|\, x, y \in\{0, 1\}^* \text{ and } x \ne y\}$

Any hint will be nice.

(My try: I can't seem to come up with a grammar. The pushdown automaton that can accept this language seems easy though. First push all of x into the stack, which can be identified on seeing the $. Keep matching y's characters one by one with top of stack character and pop until the first mismatch. If no mismatch is encountered and the stack is empty as well as y is exhausted, then reject. If a mismatch is encountered, or if the stack becomes empty before y is exhausted, or y is exhausted and stack is still not empty, then accept.)

Raphael
  • 72,336
  • 29
  • 179
  • 389
slnsoumik
  • 317
  • 3
  • 9
  • 1
  • If you can come up with a pushdown automaton, you should be essentially done. Any decent textbook will describe how to convert a PDA to a context-free grammar, so just apply that algorithm by hand. 2. See also http://cs.stackexchange.com/q/307/755
  • – D.W. Mar 22 '16 at 00:26