# Is the halting problem solvable for NPDAs?

After the total silence in response to my last question, I am rethinking my assumptions. DPDAs are, of course, solvable, and I believe that their loops can be found in the manner I described in my prior question:

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 is my last question actually unanswerable because we cannot, in fact, determine whether a NPDA will halt? Is the halting problem even solvable for NPDAs?

• What is "the halting problem for NPDAs". Is it $A:=\{\langle N,w\rangle\mid N$ is an NPDA such that on input $w$, $N$ can be transitioned to a halt state$\}$? Is it $B:=\{\langle N,w\rangle\mid N$ is an NPDA such that on input $w$, $N$ will be transitioned to a halt state regardless of which decisions will be made$\}$? – John L. May 31 '19 at 17:27
• Is "a halt state" defined by the empty stack or accepting states? – John L. May 31 '19 at 17:31
• @Apass.Jack I've been going with Sipser, but it shouldn't matter. The two mental models I've encountered for nondeterminism are either as massive parallelism, or as extremely lucky computation. Your two statements seem meaningfully equivalent to me. I'd go further and assert that if your definitions aren't equivalent, then NFSMs, NPDAs, and turing machines are ill-defined. (There should be no model under which they would turn out differently.) As for your second question, I've never heard of a PDA that requires an empty stack. – Ben I. May 31 '19 at 17:35
• @Apass.Jack Upon a second reading, I think I came off as combative. This was unintentional! Please excuse me on this count; the tone in my head was far nicer as I was composing the comment. – Ben I. May 31 '19 at 18:08
• $A$ and $B$ are different. (Assume a halt state means an accepting state.) $A$ is decidable since $\langle N, w\rangle\in A$ is the same as $w\in L(N)$, which is decidable. I believe $B$ is decidable, too. – John L. Jun 1 '19 at 14:08

There is no "minimal normal form" or the like for PDAs. If there was, a first step would be to minimize the PDA. This minimal type of machine would certainly not allow pathological examples like the one in your other post. We can, however, do something similar.

You can convert any NPDA to an equivalent context-free grammar. For these there are ways to remove useless rules and simplify them, and there are normal forms (Greibach and Chomsky). Definitely GNF allows answering the "halting problem", because a word of length n is generated in n steps. Going from GNF back to a PDA you get one with a similar property.

Maybe this method is not satisfactory for you, because you would like a more direct analysis of the given NPDA. But as you have observed, this can be very hard, because of possible very complex epsilon-loops.

To summarize: it is decidable whether for a given NPDA, there exists an equivalent one that always halts. But probably this is always true, because there is (e.g. Greibach NF for all context-free languages).

But you ask about a given PDA, not about whether a halting one exists for the same language. Thus for an answer to your question, one might have to analyze which kind of thing the mentioned grammar transformations eliminate and what that means in terms of PDAs.

Therefore, there is strong evidence that the question is decidable, but I have no definite method. In the transformations, one does not detect whether "useless" loops in the PDA/grammar would halt or not - they are simply eliminated, all of them.

• In other words, it is definitely solvable, but has possibly not been directly solved? – Ben I. May 31 '19 at 2:00
• Sorry, re-reading everything I find that my answer is not completely answering your question. I say that it is decidable whether for a given NPDA there exists an equivalent one that always halts. But probably this is always true, because there is e,g. Greibach NF for all context-free languages. But you ask about a given PDA, not about whether a halting one exists for the same language. Thus for an answer to your question, one might have to analyze which kind of thing the mentioned grammar transformations eliminate and what that means in terms of PDAs. – Peter Leupold May 31 '19 at 5:12
• Summarizing: I think I provide strong evidence that the question is decidable, but I do not provide a definite method. In the transformations, one does not detect whether "useless" loops in the PDA/grammar would halt or not - they are simply eliminated, all of them. – Peter Leupold May 31 '19 at 5:18