[Math] NFA of $k$ states recognizing all words of length $\le k$

automata

Let $N$ be an NFA with $k$ states that recognizes some language $A$.

a. Show that if $A$ is nonempty, $A$ contains some string of length at most $k$.

b. Show, by giving an example, that part (a) is not necessarily true if you replace both $A$’s by $\overline{A}$.

c. Show that if $\overline{A}$ is nonempty, $\overline{A}$ contains some string of length at most $2^k$.

d. Show that the bound given in part (c) is nearly tight; that is, for each $k$, demonstrate an NFA recognizing a language $A_k$ where $\overline{A_k}$ is nonempty and where $\overline{A_k}$’s shortest member strings are of length exponential in $k$. Come as close to the bound in (c) as you can.

This is problem 1.64 from Introduction to the Theory of Computation, 3rd Edition by Michael Sipser.

Parts (a) and (c) are easy. I'm struggling with part (b). There are a couple of things about such an NFA that must be true: it has more than one state and it has at least one cycle. I've been trying to construct an automation for $\Sigma = \{0\}$ but with no success. Every time I create a cycle either $\bar A$ becomes empty or there are "holes" in that cycle (non-accept states) which require another cycle and when I construct that the situation recurses. Extending $\Sigma$ seems only to complicate the problem. I suspect solving part (b) would give a hint for part (d) but I can crack neither.

Best Answer

a. If $A$ is nonempty, there is a path through $N$ from a start state to an accepting state. By removing cycles, we may suppose the path has length at most $k$. The word along the edges of this path is a word of length $\le k$ accepted by $N$.

b. See d. below

c. Use the subset construction to find a DFA $D$ accepting $A$. $D$ has less or equal to $2^k$ vertices by construction. Let $D'$ be the DFA obtained from $D$ by reversing the accepting states (a nonaccepting state is now accepting and vice versa). Then $D'$ accepts $\overline A$. Apply the argument from the first part to find a word of length $\le 2^k$ which $D'$ accepts, or equivalently lies in $\overline A$

d. Let the alphabet consist of one letter '1', and consider words as their corresponding natural numbers in unary. Fix a set of natural numbers $X$. For each $n\in X$, there is an NFA $N_n$ of $n$ states which accepts all numbers which are not divisible by $n$ (its just a cycle with one nonaccepting state same as the start state). Let a new NFA $N$ be the union of the $N_n$ for $n\in X$ with an additional start state (which is accepting), which has a single $\epsilon$ edge to each of the start states of the $N_n$. The natural numbers not accepted by $N$ are precisely the nonzero multiples of $\text{lcm}(X)$, and $N$ has $1 + \sum_{n\in X} n$ states.

We can for instance take $X$ to be the primes less than $p$ for some $p$ to obtain one parameterized sequence of NFA's $N_p$ with the required property. Indeed, arguing very coarsely, $N_p$ has at most $p^2$ states but the first number not accepted is at least $2^{\pi(p)} \ge 2^{p / \log p -1}$ for sufficiently large $p$. Unfortunately this is only super polynomial in the number of states, and not quite exponential. I'm not sure if the idea can be improved to be properly exponential.

Related Question