0

Question Statement: Given a NFA $N$, design an algorithm that runs in polynomial time such that it determines if $L(N)$ is infinite. (Note that converting NFA to DFA is exponential time).

For any DFA, By pumping lemma, I am very sure that the following algorithm works:

T = Upon input <M> (a DFA) 
  Accept if any state q in DFA has the property:
    1. There is a path from starting state to some final state through q
    2. There is a (directed) cycle that loops from q back to q.
  (Reject if neither property is satisfied)

I intend to prove that this algorithm can be directly applied to NFA. After all, if there is no loop in this NFA, then every accepted string is bounded by the number of states (by pumping lemma). Therefore to make sure the NFA accepts infinite language, a loop is necessary.

Is the thinking correct? Further, what would be the optimal algorithm to see if an NFA generates infinite language?

D.W.
  • 167,959
  • 22
  • 232
  • 500

1 Answers1

-1

Your algorithm is incorrect. Think about the minimal DFA for $ab^*c$.

Related: Do self-loops in DFA cause infinite languages?, Do all DFA's containing an "accepting path containing a cycle" accept infinite languages?.

D.W.
  • 167,959
  • 22
  • 232
  • 500