Skip to main content

Unambiguous Automata: From PSPACE to P

Computer science is about leveraging mathematical structure, for instance, in order to accelerate algorithms. More often than we'd like we can't accelerate much: For instance, checking two NFAs for language inclusion or equivalence is PSPACE-complete. Even the problem whether an NFA accepts all words is PSPACE-complete. For DFAs, those problems are easy. This means that for NFAs we can't do much better than determinizing (using the subset construction and incurring an exponential blowup) and solving the resulting DFA problem.

In this post I'll discuss an automata problem that seems to call for determinization and is, in fact, PSPACE-complete for NFAs. But there is an efficient algorithm for unambiguous automata.

Here is an example of an unambiguous automaton:
The notion of accepting states is not used in this post. By unambiguousness I just mean that the automaton has no diamonds, that is, for any states $q, r$, any word $w$ labels at most one path from $q$ to $r$. (In other words, all paths from $q$ to $r$ are labelled by different words.) One can check an NFA for unambiguousness in polynomial time, by searching for diamonds in the product of the automaton with itself. We'll assume that every state is reachable from every other state.

By determinization of the automaton I mean the subset construction. In the example we get (from start state $1$):
We call a set $\alpha$ of states a cut if it can be reached from a single state and cannot reach the empty set in the determinization. Formally, $\alpha$ is a cut if there is a state $q$ and a word $w$ such that $\delta(q,w) = \alpha$ and $\delta(q,w x) \ne \emptyset$ holds for all words $x$. In the example, the sets $\{1,2,3\}$ and $\{1,2,4\}$ are cuts, reached from state $1$ via $a a$ and $a a b$.

Checking whether a given NFA has a cut is PSPACE-complete. But an unambiguous automaton has a cut if and only if the spectral radius of the average transition matrix is $1$, which can be checked in polynomial time. Details of that are in the previous post but are not important here. We solve a potentially harder problem:
Given an unambiguous automaton that has a cut.
Compute a cut $\alpha$.
Compute also a state $q$ and a word $w$ with $\delta(q,w) = \alpha$.
It's curious that the spectral-radius algorithm decides the existence of a cut without computing a cut. Neither gives the spectral-radius algorithm an indication whether a shortest word that leads to a cut has polynomial length.

Fix some state $q$. Imagine there is a cut from some other state $q_1$, that is, $\delta(q_1, v_1)$ is a cut for some word $v_1$. Since all states are reachable from each other, there is a word $v_0$ that labels a path from $q$ to $q_1$. Then $\delta(q,v_0 v_1)$ is also a cut. Again since all states are reachable from each other, there is a word $v_2$ that labels a path from a state in $\delta(q, v_0 v_1)$ to $q$, hence $\delta(q, v_0 v_1 v_2) \ni q$. It follows from the definition of a cut that $\delta(q, v_0 v_1 v_2)$ is also a cut ("once a cut, always a cut"). So when we search for cuts, we may as well fix the start state $q$ and focus on cuts that contain $q$. Let's fix $q$ for the rest of the post.

Our approach for computing a cut is to start from the singleton set $\{q\}$ and to gradually increase the set until it is a cut. Here is how we might increase the set:
Let $w$ be a word. Suppose there are a word $v$ and a state $q' \ne q$ with $\delta(q,v) \supseteq \{q, q'\}$ and $\delta(q',w) \ne \emptyset$.
Then $\delta(q,v w) \supsetneq \delta(q,w)$.
Let $r \in \delta(q',w)$. The situation can be visualized as follows:
It can be read off that \[ \delta(q,v w) \ \supseteq \ \delta(q,w) \cup \{r\} \,. \] We also see in the picture that $v w$ labels a path from $q$ to $r$ via $q'$. By unambiguousness it follows that $r \not\in \delta(q,w)$ because otherwise $v w$ would label a second path from $q$ to $r$. So the inclusion $\delta(q, v w) \supseteq \delta(q, w)$ is strict.
Let's call a word $v$ as in the proposition an extender:
Let $w$ be a word. A word $v$ is an extender (for $w$) if there there is a state $q' \ne q$ with $\delta(q,v) \supseteq \{q, q'\}$ and $\delta(q',w) \ne \emptyset$.
Now we can rephrase the proposition:
Let $w$ be a word.
For any extender $v$ we have $\delta(q,v w) \supsetneq \delta(q,w)$.
The proposition allows us to increase the set $\delta(q,w)$ by appending $w$ to an extender. We can find an extender in polynomial time (if it exists): We only have to search the product of the automaton with itself to check if there is a path from $(q,q)$ to $(q,q')$ where $q' \ne q$ is a state with $\delta(q',w) \ne \emptyset$. If such a path exists, it is labelled by an extender. The shortest path yields an extender of length at most $n^2$, where $n$ is the number of states in the automaton.

The proposition above yields a method of increasing a set $\delta(q,w)$. Is it complete? That is, is there an extender as long as we haven't hit a cut yet? The answer is yes:
Let $w$ be a word such that $\delta(q,w)$ is not a cut.
Then there is an extender $v$. Hence, by the proposition above, $\delta(q,v w) \supsetneq \delta(q,w)$.
Let $v$ be word such that $\delta(q,v) \ni q$ is a cut. Then $\delta(q,v w)$ is a cut ("once a cut, always a cut"), and it includes $\delta(q,w)$ because $\delta(q,v)$ contains $q$. So we have \[ \delta(q, v w) \supseteq \delta(q, w)\,, \] and the inclusion is strict because $\delta(q, v w)$ is a cut and $\delta(q,w)$ isn't. This means there is a state $q' \in \delta(q,v) \setminus \{q\}$ with $\delta(q', w) \ne \emptyset$. So $v$ is an extender.
We get the following theorem:
Given an unambiguous automaton that has a cut, and a state $q$, the following algorithm is a polynomial-time algorithm that computes a word $w$ of length at most $n^3$ (where $n$ is the number of states in the automaton) such that $\delta(q,w)$ is a cut.
  1. $w := \varepsilon$ (the empty word)
  2. while there is an extender $v$:
       $w := v w$
  3. return $w$
Let's run the algorithm on the previous example automaton:
  1. $w := \varepsilon$ (the empty word)
  2. the word $a$ is an extender, as $\delta(1,a) = \{1,2\}$ and $\delta(2,\varepsilon) = \{2\}$:
    $w := a w = a$
  3. the word $a$ is an extender, as $\delta(1,a) = \{1,2\}$ and $\delta(2,a) = \{3\}$:
    $w := a w = aa$
  4. return $w = aa$, as there is no extender
Looking again at the determinization, the word $w = aa$ takes state $1$ to the cut $\{1,2,3\}$:
In the previous post I promised to show how to compute the probability that an infinite word (chosen uniformly at random) is accepted by a given unambiguous Büchi automaton. When I make good on that promise in the next post, the key ingredient will be the cut-computation method presented above.

If an unambiguous automaton does not have a cut then one can show that it has a killing word, that is, a word $w$ with $\delta(q,w) = \emptyset$ for all states $q$. Here is an open problem:
If an unambiguous automaton does not have a cut, does it always have a killing word of polynomial length? Can it be computed in polynomial time?

The idea of this post can be found in the following paper:
M.-P. Béal, E. Czeizler, J. Kari, D. Perrin. Unambiguous Automata. In Mathematics in Computer Science, 1(4):625-638, 2008. Springer.
Our CAV'16 paper has it closer to the form presented here.

Update (March 2019): The open problem has been solved.

Comments

Post a Comment

Popular posts from this blog

Tell me the price of memory and I give you €100

Markov Decision Processes (MDPs) are Markov chains plus nondeterminism: some states are random, the others are controlled (nondeterministic). In the pictures, the random states are round, and the controlled states are squares: The random states (except the brown sink state) come with a probability distribution over the successor states. In the controlled states, however, a controller chooses a successor state. What does the controller want to achieve? That depends. In this blog post, the objective is very simple: take a red transition . The only special thing about red transitions is that the controller wants to take them. We consider only MDPs with the following properties: There are finitely many states and transitions. The MDP is acyclic, that is, it has no cycles. There are a unique start state from which any run starts (in the pictures: blue, at the top) and a unique sink state where any run ends (in the pictures: brown, at the bottom). No matter what the controller does,

Calibrating Assessments

Last year I wrote a post on how Oxford selects undergraduate students for computer science. Oxford undergraduate admissions are politically charged: the British public suspects that Oxbridge is biased towards privileged applicants. This post is unpolitical though. I'm advocating a better way of solving a typical problem in academia: you have many candidates (think: papers, grant proposals, or Oxford applicants) and few assessors (think: members of program committees, assessment panels, or admission tutors), and the goal of the assessors is to select the best candidates. Since there are many candidates, each assessor can assess only some candidates. From a candidate's point of view: a paper may get 3 reviews, a grant proposal perhaps 5, and a shortlisted Oxford applicant may get 3 interviews. Each such review comes with a score that reflects the assessor's estimate of the candidate's quality. The problem is that different assessors will score the same candidate differ

Oxford Admissions

An initial draft of this post was about how to make rankings more meaningful, a piece of mathsy computer science, as you expect it from this blog. My motivation is personal: I'm involved in selecting CS undergraduate students. Some people might be curious how Oxford admissions work: it's certainly a favourite subject for UK politicians and news media. Therefore I decided to postpone my original plan and to write this post about Oxford admissions. I hope I'm not playing with too much fire and the blog will not suddenly become famous for the wrong reasons! The tenor in newspapers and political campaigns is that the Oxbridge admissions process is “opaque” and unfair. Here I am going to offer transparency and some comments on fairness. The views expressed here are my own, and may not necessarily coincide with the university's views. Oxford's goal is to admit the strongest applicants. One can disagree with this basic premise, but we try to admit those applicants who