Given an automata [DFA $A=(Q,Σ,δ,q_0,F)$], is there a way to determine whether it accepts an infinite or finite language?
5 Answers
This is well enough known that you should be able to find it in most intro theory texts:
Theorem. The language accepted by a DFA $M$ with $n$ states is infinite if and only if $M$ accepts a string of length $k$, where $n\le k < 2n$.
This makes the decision problem simple: just try all strings of length at least $n$ and less than $2n$ and answer "yes" if $M$ accepts one of them and "no" if there's no string in that range that's accepted.
- 15,016
- 5
- 43
- 54
On Drawing a DFA , if there are loops in states then there is a possiblity that automata accepts infinite language .
Whereas if there are no loops in a DFA , then it certainly accepts finite language .
- 69
- 3
You can easily calculate for each state the set of states that can be reached from that state.
The CFA accepts an infinite number of inputs if there is a state X with the properties: X can be reached from the initial state, X can be reached from X, and some terminating state can be reached from X.
- 82,470
- 26
- 145
- 239
- 32,238
- 36
- 56
A DFA accepts infinitely many strings iff there exists a loop in the path from initial state to final state.
- 7,298
- 2
- 29
- 50
- 135
- 6
To prove why we only need to check strings of length within $[n,2n)$. It is sufficient to prove the following statement. If a DFA $D$ with $n$ states accepts infinite many strings, then $D$ accepts some string $s$ whose length falls in $[n,2n)$.
Suppose it is not the case, then $\forall u\in L(D)$, length of $u$, denoted as $\text{len}(u)$ must either has $\text{len}(u)<n$ or $\text{len}(u)\geq 2n$.
As $D$ accepts infinite many strings and the set $\{u\in L(D)~|~\text{len}(u)<n \}$ is finite, $S=\{u\in L(D)~|~\text{len}(u)\geq n\}\neq \emptyset$. Choose a $z\in S$, where such $\forall u\in S $ we have $ \text{len}(z)\leq \text{len}(u)$. As $\text{len}(z)\geq n$ (hence $\text{len}(z)$ $\geq 2n$), it must contain a loop. Aka, it admits a decomposition $$z=ab^mc.$$ Where $n\geq \text{len}(b)\geq1$. This further imposes $$z'=ab^{m-1}c \in L(D).$$ Note that $\text{len}(z')=\text{len}(z)-\text{len}(b) \geq 2n-n=n.$ This imposes $z' \in S.$ However, $\text{len}(z')<\text{len}(z)$ contradicts with the minimality of length of $z$. A contradiction arises and the statement at top holds at the first place.
- 101
- 2