3 Answers
3

What you are asking about is known as the universality problem. In the slides by Jeffrey Shallit (http://www.cs.uwaterloo.ca/~shallit/Talks/open10r.pdf, slide 36) it is mentioned that this problem is PSPACE-complete for NFA. So it is highly unlikely that a polynomial algorithm exists for it. Please, let me know if you need an exact reference to the proof of the PSPACE-completeness (see edit2).

edit. I forgot to mention that because the universality problem for DFA is simply solved in polynomial time the existence of a poly(n, d) algorithm in your second question also implies PSPACE=P and is very unlikely.

Grigory, your edit is definitely wrong unless you can guarantee that d is poly(n) -- if d is 2^n, then it takes exponential time to write down the DFA.
–
JBLMay 13 '10 at 0:17

1

Suppose someone has developed a $poly(n,d)$-time algorithm $A(x)$ for the problem and we know this $poly(n,d)$, which is equal to some $p(n,d)$. Because for the minimal DFA that accepts all strings $d=1$, then the running time of the algorithm A is equal to some polynomial $q(n)$ if the given NFA is universal. If the given NFA is not universal than we just let A make $q(n)$ steps and terminate it if it hasn't terminated: either we found the DFA and can check directly or terminated and we know that the resulting DFA cannot be universal.
–
Grigory YaroslavtsevMay 13 '10 at 8:51

Your second question is a little ambiguous, because it admits the following cheating affirmative answer, which is probably not what you intend.

Namely, every NFA with n states is equivalent to a DFA with d states for d sufficiently large. And for large $d$, allowing poly(n,d) steps is plenty of time. The well-known equivalent DFA, such as the one provided in Sipser's book, has $2^n$ states (plus a constant), and this example can be constructed in poly(n,2^n) steps, simply because $d=2^n$ is already so large here. More generally, for even larger $d$, we can simply pad this one with extra irrelevant states, and build it also in poly(n,d) steps.

Perhaps you mean to ask about the optimal $d$? Or do you want to ask for all $d$ for which there is an equivalent DFA with $d$ states? Or do you also want to ask whether the optimal $d$ itself is poly(n)?

To determine if an NFA $M$ accepts all strings you can first construct the machine that accepts the complement language $\overline{M}$ (here is the exponential bottleneck since you must first convert to a DFA). Then you can use Harry Altman's suggestion to check for emptiness.

To convert $M$ with $n$ states which accepts a language $L$ to a DFA $D$ which also accepts $L$ but using $d$ steps in poly$(n,d)$ time on a Turing machine is easy, however $d$ in the worst case is exponential in $n$ (using the naive algorithm undergrads learn).
This problem is very well studied and in practice many programmes use tricks to do this more efficiently. I'm not at all familiar with these though so I cannot say if they use poly$(n)$ space and time average case.

Niall, what do you mean by the complement (sorry to be a pedant, but note the spelling) of an NFA? An NFA that accepts the complementary language?
–
JBLMay 13 '10 at 0:18

1

To compute the complement, don't you first have to build the equivalent DFA? This could take more than poly(n) time.
–
Joel David HamkinsMay 13 '10 at 3:18

Yes sorry I meant the complement (corrected). And yes, you will need exponential sequential time and as Grigory points out, the problem PSPACE complete. So polynomial parallel time if you have an exponential number of processors.
–
Niall MurphyMay 13 '10 at 9:33