4

Can a two-stack PDA accept language $L=\{a^nb^mc^nd^m \mid n \geq m\}$, which has no context-free grammar?

I don't believe this has a context-free grammar, but please correct me if I'm wrong.

Raphael
  • 73,212
  • 30
  • 182
  • 400
Iancovici
  • 675
  • 3
  • 14
  • 26

2 Answers2

6

A two-stack PDA is equivalent in computing power to a Turing machine. Since a Turing machine can accept that language (stated without proof), a two-stack PDA can as well. The actual definition of such a machine is left as an exercise :)

Patrick87
  • 12,924
  • 1
  • 45
  • 77
2

You don't even need to know about the equivalence to a Turing Machine to decide this language and if it was the intention of this exercise to come up with the equivalence, the language is (IMHO) to easy to motivate this.

A simple two-stack PDA for this language works like this:

  1. Put $n$ on both counters, while counting $a$s.
  2. Use counter one to check the $b$s.
  3. Count up on counter one and down on counter two to check the $c$s.
  4. Check the $d$s.

I left out some details, but filling them should be easy.

By the way: You should not believe that this language is not context free, but prove it (it should be obvious which word to choose as a counter example using the pumping lemma).

frafl
  • 2,339
  • 1
  • 17
  • 32