I'm wondering, what is the time-complexity of determining emptiness for 2-way DFAs? That is, finite automata which can move backwards on their read-only input tape.

According to Wikipedia, they are equivalent to DFAs, though the equivalent DFA might be exponentially larger. I've found state complexity for their complements and intersections, but not for their emptiness-testing.

Does anyone know of a paper where I could find this?

  • 1
    $\begingroup$ I strongly suggest you read one of the two proofs reducing 2DFAs to DFAs. They could give you some insight on the problem. $\endgroup$ Jul 28, 2013 at 14:44

2 Answers 2


Friend Google suggests the following "The PSPACE-completeness of the emptiness problem for two-way deterministic finite-state automata in Exercise 5.5.4 is due to Hunt (1973)." (An Introduction to the Theory of Computation, Eitan Gurari, Computer Science Press, 1989, online)

Hunt, H. (1973). "On the time and tape complexity of languages," Proceedings of the 5th Annual ACM Symposium on Theory of Computing, 10-19.

(I have now looked at the reference) The paper is written in an abstract way as you note. The crucial part for us is the proof of Thm 3.7, where it is suggested that one can construct a 2FSA $\cal A$ that accepts valid computations of a linear bounded automaton $\cal M$ on a fixed(!) string $x$ (which is close to the definition of PSPACE). The 2FSA $\cal A$ is constructable in polynomial time (in the size of $\cal M$ and $x$). A computation of a LBA can be written as $x\$x_1\$\dots\$x_n$ where the $x_i$ are all of the same length as $x$ and are consecutive steps of $\cal M$. How does $\cal A$ check that $x_i$ and $x_{i+1}$ are equal (up to a very local change of a state and a single symbol as the operation of a LBA)? By checking letter by letter, going both ways on the tape. For that we need a counter of size $|x|$ implemented in the finite state control of $\cal A$.

It turns out that the problem is mentioned in the appendix of the classic reference by Garey & Johnson, Computers and Intractability, problem [AL2] "Two-way finite state automaton non-emptiness" with the explicit remark "PSPACE-complete even if $\cal A$ is deterministic". Reference again Hunt, with the clarification "Transformation from Linear Bounded Automaton Acceptance" (Given LBA $\cal A$ and input $x$, does $\cal A$ accept $x$?). The latter problem is [AL3] with reference to the famous Karp (1972) paper "Reducibility Among Combinatorial Problems" (where LBA Acceptance is mentioned as Context-Sensitive Recognition).

  • 1
    $\begingroup$ I checked the reference. I'm pretty sure it follows from Theorem 3.8, though it was a bit complicated. It's phrased more as a Rice's theorem-style result for arbitrary predicates/properties, rather than a simple "emptiness is PSPACE complete". $\endgroup$ Jul 29, 2013 at 16:39

Intersection Non-Emptiness for DFA's is as follows:

Input: A finite list of DFA's $D_1$, $D_2$, ..., $D_k$.

Question: Does there exist a string $w$ such that for every $i \in [k]$, $D_i$ accepts $w$? In other words, is the intersection of their associated regular languages non-empty?

Intersection Non-Emptiness is a classic PSPACE-complete problem (Kozen 1977 - "Lower bounds for natural proof systems")

Relevance: There is a nice and simple parameterized reduction from intersection non-emptiness for one-way DFA's to non-emptiness for two-way DFA's.

Pick the number of DFA's to be the parameter for Intersection Non-Emptiness and the number of turns (switches from moving left to right or right to left) as the parameter for Non-Emptiness for two-way DFA's.

Claim: Intersection Non-Emptiness for $k$ DFA's is reducible to Non-Emptiness for $(2k-2)$-turn two-way DFA's. (I believe that there is a related reduction for the other direction too.)

Given DFA's $D_1$, $D_2$, ..., $D_k$, we can construct a $(2k-2)$-turn two-way DFA that evaluates each of the DFA's on the input string one at a time.

First, it evaluates $D_1$ on the input. Then, it moves the tape head back to the beginning and evaluates $D_2$ on the input. Then, it moves the tape head back to the beginning and evaluates $D_3$ on the input. ... Finally, it moves the tape head back to the beginning and evaluates $D_k$ on the input.

If all of them accept, then it does the evaluation on all of them and then accepts. If one of them rejects, then it stops (doesn't finish evaluating on all of them) and immediately rejects.

Hardness: If you can solve Intersection Non-Emptiness for $k$ DFA's in less than $n^k$ time, then the strong exponential time hypothesis is false.

Related link: https://cstheory.stackexchange.com/questions/29142/deciding-emptiness-of-intersection-of-regular-languages-in-subquadratic-time/29166#29166

Therefore, by the reduction, if you can solve non-emptiness for $(2k-2)$-turn two-way DFA's in less than $n^k$ time, then the strong exponential time hypothesis is false as well.

Conclusion: If you were to find a faster algorithm for non-emptiness for two-way DFA's, then that would lead to a more efficient simulation of non-deterministic machines. Let me know if you have any thoughts to share. Thank you for asking the question! :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.