### Model Checking Markov Chains Against Unambiguous Automata: The Quantitative Case

In my first post I promised to give a polynomial-time procedure to compute the probability that an infinite word (chosen uniformly at random) is accepted by a given unambiguous Büchi automaton. For example, let's take this Büchi automaton again:
Let's call the probability $x_1, x_2, x_3$, depending on the start state: $\begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} := \begin{pmatrix} \text{Pr(state 1 accepts a random word)}\\ \text{Pr(state 2 accepts a random word)}\\ \text{Pr(state 3 accepts a random word)} \end{pmatrix}$ I showed in the first post that $x_1, x_2, x_3$ are nonzero in this example. In order to compute the $x_i$ we set up a linear system of equations and solve it. We have $x_1 \ = \ \frac12 \cdot x_{1,a} + \frac12 \cdot x_{1,b}\,,$ where $x_{1,a}$ and $x_{1,b}$ denote the (conditional) probabilities that state $1$ accepts a random word, under the condition that the word starts with $a$ and $b$, respectively.
• $x_{1,b} = 0$ because state $1$ has no $b$-labelled outgoing transitions;
• $x_{1,a} = x_1 + x_3$ because state $1$ has $a$-labelled transitions to states $1$ and $3$. You might be afraid that we are double-counting events here, but we are not: by unambiguousness, it is impossible that the same word, say $w$, is accepted by both states $1$ and $3$, because then state $1$ would accept the word $a w$ along two different paths.
In this way we obtain a linear system of equations for $x_1, x_2, x_3$: $\begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} \ = \ T \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix}\,,$ where $T = \frac12 T(a) + \frac12 T(b)$ is the average of the transition matrices for the letters $a$ and $b$. We have three equations for three unknowns, but unfortunately the equations are dependent and do not have a unique solution. For instance, $x_1 = x_2 = x_3 = 0$ is a trivial solution.

The equation system above says that the probabilities $x_1, x_2, x_3$ are the entries of an eigenvector of $T$, corresponding to eigenvalue $1$. It follows from the Perron-Frobenius theorem for irreducible matrices that all such eigenvectors are scalar multiples of each other. So we just need to add one independent equation to the system in order to make the solution unique. What should that equation be?

I claim that this additional equation can be $x_1 + x_3 = 1$ or $x_2 = 1$ (either works). The relevant feature of $\{1,3\}$ and $\{2\}$ is that they can be reached from start state $1$ but cannot reach the empty set $\emptyset$ in the determinization of our automaton:
Here is why the equalities $x_2 = 1$ and $x_1 + x_3 = 1$ hold:
• Clearly, we have $x_2 \le 1$. We also have $x_1 + x_3 \le 1$ because otherwise some word, say $w$, would be accepted by both states $1$ and $3$, and so state $1$ would accept the word $a w$ along two different paths.
• These inequalities cannot be strict. Let's argue for $x_1 + x_3 \ge 1$. Recall that no word leads from $\{1,3\}$ to the empty set $\emptyset$. So for any finite word $v$, the probability that state $1$ or state $3$ accepts $v w$ (where $w$ is a random infinite word) is at least $\min\{x_1, x_2, x_3\}$, which is bounded away from $0$. Applying a general probability principle (Lévy's zero–one law) we can conclude that the probability that state $1$ or state $3$ accepts a random infinite word is $1$. Hence $x_1 + x_3 \ge 1$.
We conclude $x_1 + x_3 = 1$ and $x_2 = 1$. Combining one of these equations with the previous system we obtain: \begin{aligned} \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} &\ = \ \underbrace{ \begin{pmatrix} \frac12 & 0 & \frac12 \\ \frac12 & \frac12 & \frac12 \\ 0 & \frac12 & 0 \end{pmatrix} }_T \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} \\ x_1 + x_3 &\ = \ 1\,, \end{aligned} which has a unique solution: $\begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} = \begin{pmatrix} 1/2 \\ 1 \\ 1/2 \end{pmatrix}$
In general, assume the states are $1, \ldots, n$. Without much loss of generality we can assume (as before) that every state is accepting and is reachable from every other state. Here is how to compute the probabilities $x_1, \ldots, x_n$:
1. Determine in polynomial time if all $x_i$ are zero, as shown in the first post. If that's not the case, then all $x_i$ are nonzero, as the states can reach each other.
2. Compute the average transition matrix $T$ and set up the linear system $\begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix} \ = \ T \begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix}\,.$
3. Compute a set of states $\alpha \subseteq \{1, \ldots, n\}$ that can be reached from a single state but cannot reach the empty set $\emptyset$ in the determinization. I explained in the previous post how this can be done in polynomial time, without computing the determinization. Add to the linear system the extra equation $x_{i_1} + \cdots + x_{i_k} = 1\,, \quad \text{where }\{i_1, \ldots, i_k\} = \alpha\,.$
4. Solve the linear system.
The whole procedure can be generalized to the case where the random word is produced by a Markov chain:
Given a Markov chain and an unambiguous Büchi automaton, one can compute in polynomial time the probability the automaton accepts a word randomly generated by the Markov chain.
Using an unpublished result (modifying step 3. above), one can sharpen the theorem by replacing "polynomial time" with the complexity class "NC", which captures problems that can be efficiently solved in parallel. This leads to an automata-theoretic PSPACE procedure for model-checking Markov chains against LTL specifications, which is optimal.

The material from this post is from a CAV'16 paper by Christel Baier, Joachim Klein, Sascha Klüppelholz, David Müller, James Worrell, and myself.

### Popular posts from this blog

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 w…

### Equivalence Checking

There is a compact data structure for words: automata. Finite automata can “store” many words, even infinitely many—in the sense that the language of a finite automaton can be infinite. This powerful feature makes automata ubiquitous in computer science. Lecture notes by Javier Esparza emphasize this view of automata as data structures.

The most fundamental algorithmic problems on automata are:
operations, such as computing set union or complement of the languages of automata; tests, such as checking their languages for equality. In this post I focus on the latter: equivalence checking. In general, equivalence checking for automata is PSPACE-complete, which is excusable considering how compact and flexible data structures they are. One can check two deterministic finite automata for equivalence in polynomial time, by searching their product.

Less known is the fact that one can efficiently check much wider classes of automata for equivalence, including unambiguous automata, probab…

### 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$. (…