A expected solution to a simple problem
Consider the unary languages of the form , exactly for what is this language regular? Intuitively, by the pumping lemma, you may end up with some where if has the same defined property as . For example, can be pumped, but cannot, because as you pump, you are not guaranteed that the length added will be a square. It would seem that those languages which are pumpable must have this semi-linear like property. After searching a long time for an answer, I found one.
A language is unary and regular if and only if it is the finite union of languages whos elements have lengths which follow an arithmetic progression, and a finite language.
The reverse direction is easier, so lets begin. Suppose we have a union of the form where is finite, and each . Finite languages are regular. Each arithmetic progression language is regular because there exists the regex . Finally, we have a finite union of regular languages, so by closure, our language is regular.
This direction is trickier. Suppose we have a unary regular language. Then there exists a DFA for it. A DFA over a unary alphabet has much more limited structure than a general DFA. Representing the DFA as a directed graph, the unary DFAs are the directed graphs with outgoing degree one, which are strongly connected. They have vertices, and exactly edges. Although it might be hard to prove, intuitively, these graphs can only look like one thing.
You have some tail of length , followed by a loop of length . Consider some computation from the start state. As you go from state to state, you can either go to a new state you have not seen before, or one that you have. If its one you haven’t seen before, great. If its one that you have, then you cannot go anywhere else since the state has outgoing degree one. Every state after must be the ones you have seen.
To get from this shape to our large union depends on the selection of final states. For each final state only on the tail, we add one word of appropriate length to . For each final state on the loop of length , of distances from the start state, we see that words which land on these states have lengths . We associate the words which land on one state as the infinite language . The union of all of these sets is exactly the set of accepted strings, and the result follows.
I gave this problem to my students this semester, and most people seemed to get it, with enough time. Given just the statement, its not hard to figure out the rest, but starting with just trying to characterize the unary regular languages requires some trial and error. Someone mentioned they have found a solution for the forward implication by transforming a regular expression to the desired form of a union of kleene stars. I am not sure if this is possible just within the calculus of a regular expression, but the spirited idea is there. I am also curious if there is a solution to a similar problem in grammars. The first corollary of Parikh’s theorem is that every every unary context-free language is also regular. I wonder if there is a way to prove this without using Parikh’s theorem. Something like transforming a unary CFG to a regular grammar, in such a way which could not work for all CFGs. That might just end up looking like a special case of Parikh’s theorem, kind of like this proof does.