I'm aware that the halting problem is solvable for PDAs, but I have recently discovered that I am wrong about how to actually do it. I used to think that you could detect an infinite loop by meeting these four conditions:

  1. arrive at the same state as you were in previously
  2. with the same top symbol as you had last time
  3. without consuming anything on the stack, and
  4. without consuming any input.

...but this appears to actually be untrue for nondeterministic PDAs. Consider this machine:

enter image description here

It accepts the empty string, but it matches all of my infinite-loop detecting criteria in the first state before it can do so.

The following version even contains infinite paths to accepting the empty string:

enter image description here

I am coding a NPDA simulator in Scheme, and while I am happy to accept that the halting problem is solvable for a PDA, I am clearly wrong about how it is accomplished. How can it actually be done?

  • $\begingroup$ Infinitely many paths, but most (i.e., all but a finite number) of them are equivalent. $\endgroup$ – dkaeae May 9 '19 at 7:18
  • $\begingroup$ @dkaeae True! But since my original 4 rules are insufficient, how would you actually detect an equivalence? That's the crux of the question. $\endgroup$ – Ben I. May 9 '19 at 13:55
  • $\begingroup$ You could convert your NPDA to a context-free grammar and then check whether the empty string is generated by this grammar $\endgroup$ – Andrei Kh Sep 6 '19 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.