The question is pretty much in the title. Is there ever a time where some language $L$ can be accepted by a minimal DFA with $n$ states, but $L^R$, the reversal of $L$, can be accepted by a DFA with $m$ states, where $m<n$?
-
3The reverse of a DFA is not even necessarily deterministic. A DFA that accepts the regex AAA+ has a terminal state with two inbound arrows with the same label. – Ian May 08 '14 at 05:47
2 Answers
The minimal DFA accepting the reversal of the language can be smaller. Consider the finite language $$ L = (0+1)^22+(0+2)^21+(1+2)^20. $$ The words $\epsilon,0,1,2,00,01,02,11,12,22,000,001$ are inequivalent, so any DFA for $L$ requires at least 12 states; in fact there is a DFA with exactly 12 states. The reverse language $$ L^R = 2(0+1)^2 + 1(0+2)^2 + 0(1+2)^2 $$ is accepted by a DFA with only 9 states: an initial state, states corresponding to initial $0,1,2$, states corresponding to initial $0(1+2),1(0+2),2(0+1)$, an accepting state and a fail state; this is also the optimal DFA, since $\epsilon,0,1,2,01,12,20,011,000$ are inequivalent.
Summarizing, the minimal DFA for $L$ requires 12 states, while the one for $L^R$ requires only 9 states.
As jmite mentions in their comment, for NFAs with multiple starting states this phenomenon can't happen, since if you flip the direction of all arrows in a NFA for $L$ then you get a valid NFA for $L^R$.

- 276,994
- 27
- 311
- 503
-
Thanks! I somehow got it in my head that you could reverse a DFA and (directly) get a DFA back, I think I got it confused with complement. – Joey Eremondi May 07 '14 at 20:22
-
1@jmite I had the same brain fart, and typed out an elegant proof by contradiction of the wrong answer. :) It's complement that works like I thought, not reversal. Oops. – Patrick87 May 07 '14 at 20:51
The "standard" example that shows that the NFA to DFA construction is exponential in size also works for reversal.
The DFA for $\{0,1\}^*1\{0,1\}^n$, the $n+1$-st symbol from the right is $1$, must have an exponential number of states as it has to recall all positions with $1$, whereas its reversal $\{0,1\}^n 1\{0,1\}^*$ can be accepted with only a linear number of states, just counting to $n$.

- 30,578
- 1
- 51
- 105