Algorithmic Verification of Recursive Probabilistic State Machines
Algorithmic Verification of Recursive Probabilistic State Machines
Algorithmic Verification of Recursive Probabilistic State Machines
1 Introduction
Recursive Markov Chains (RMCs) are a natural abstract model of procedural
probabilistic programs. They succinctly define a natural class of denumerable
Markov chains that generalize multi-type branching (stochastic) processes. In-
formally, an RMC consists of a collection of finite state component Markov
chains (MC) that can call each other in a potentially recursive manner. Each
component MC has a set of nodes (ordinary states), a set of boxes (each mapped
to a component MC), a well-defined interface consisting of a set of entry and
exit nodes (nodes where it may start and terminate), and a set of probabilistic
transitions connecting the nodes and boxes. A transition to a box specifies the
entry node and models the invocation of the component MC associated with the
N. Halbwachs and L. Zuck (Eds.): TACAS 2005, LNCS 3440, pp. 253–270, 2005.
c Springer-Verlag Berlin Heidelberg 2005
254 K. Etessami and M. Yannakakis
box; when (and if) the component MC terminates at an exit, execution of the
calling MC resumes from the corresponding exit of the box.
RMCs are a probabilistic version of Recursive State Machines (RSMs). RSMs
([AEY01, BGR01]) and closely related models like Pushdown Systems (PDSs)
(see, e.g., [EHRS00, BR00]) have been studied extensively in recent research on
model checking and program analysis, because of their applications to verifica-
tion of sequential programs with procedures. Recursive Markov Chains gener-
alize other well-studied models involving probability and recursion: Stochastic
Context-Free Grammars (SCFGs) have been extensively studied, mainly in nat-
ural language processing (NLP) (see [MS99]). Multi-Type Branching Processes
(MT-BPs), are an important family of stochastic processes with many applica-
tions in a variety of areas (see, e.g., [Har63]). Both SCFG’s and MT-BP’s are
essentially equivalent to single-exit RMC’s: the special case of RMC’s in which
all components have one exit. Probabilistic models of programs and systems are
of interest for several reasons. First, a program may use randomization, in which
case the transition probabilities reflect the random choices of the algorithm. Sec-
ond, we may want to model and analyse a program or system under statistical
conditions on its behaviour (e.g., based on profiling statistics or on statistical
assumptions), and to determine the induced probability of properties of interest
We introduced RMCs in [EY05] and developed some of their basic theory,
focusing on algorithmic reachability analysis: what is the probability of reaching
a given state starting from another? In this paper we study the more general
problem of model checking an RMC against an ω-regular specification: given an
RMC A and a Büchi automaton B, what is the probability that an execution of
A is accepted by B? The techniques we develop in this paper for model checking
go far beyond what was developed in [EY05] for reachability analysis.
General RMCs are intimately related to probabilistic Pushdown Systems
(pPDSs), and there are efficient translations between RMCs and pPDSs. There
has been some recent work on model checking of pPDSs ([EKM04, BKS05]). As
we shall describe shortly, our results yield substantial improvements, when trans-
lated to the setting of pPDSs, on the best algorithmic upper and lower bounds
known for ω-regular model checking of pPDSs.
We now outline the main results in this paper. We are given an RMC A
and a property in the form of a (non-deterministic) Büchi automaton (BA)
B, whose alphabet corresponds to (labels on) the vertices of A. Let PA (L(B))
denote the probability that an execution of A is accepted by B (i.e., satisfies the
property). The qualitative model checking problems are: (1) determine whether
almost all executions of A satisfy the property B (i.e. is PA (L(B)) = 1?, this
corresponds to B being a desirable correctness property), and (2) whether almost
no executions of A satisfy B (i.e. is PA (L(B)) = 0?, corresponding to B being an
undesirable error property). In the quantitative model checking problems we wish
to compare PA (L(B)) to a given rational threshold p, i.e., is PA (L(B)) ≥ p?, or
alternatively, we may wish to approximate PA (L(B)) to within a given number
of bits of precision. Note that in general PA (L(B)) may be irrational or may not
even be expressible by radicals [EY05]. Hence it cannot be computed exactly.
Algorithmic Verification of Recursive Probabilistic State Machines 255
Related Work. Model checking of flat Markov chains has received extensive
attention both in theory and practice (e.g. [CY95, Kwi03, PZ93, Var85]). It is
known that model checking of a Markov chain A with respect to a Büchi au-
tomaton B is PSPACE-complete, and furthermore the probability PA (L(B)) can
256 K. Etessami and M. Yannakakis
PrΩ (C(s0 s1 . . . sn )) = pinit (s0 )ps0 ,s1 ps1 ,s2 . . . psn−1 ,sn
See, e.g., [Bil95]. RMCs where every component has at most one exit are called
1-exit RMCs. RMCs where the total number of entries and exits is bounded by
k
a constant c, (i.e., i=1 |Eni | + |Exi | ≤ c) are called Bounded total entry-exit
RMCs (Bd-RMCs, for short).
Note, with a routine for the problem PA (L(B)) ≥ p?, we can approximate
PA (L(B)) to within i bits using binary search with i calls to the routine. Thus,
for quantitative model checking the first problem entails the second. Note that
probabilistic reachability is a special case of model checking: given vertex u of
RMC A and a subset of vertices F , the probability that the RMC starting at u
visits some vertex in F (in some stack context) is equal to PA (L(B)), where we
let the labelling L map vertices in F to 1 and the other vertices to 0, and B is
Algorithmic Verification of Recursive Probabilistic State Machines 259
the 2-state automaton that accepts strings that contain a 1. Similarly, for the
repeated reachability problem, where we are interested whether a trajectory from
u infinitely often visits a vertex of F , we can let B be the (2-state deterministic)
automaton that accepts strings with an infinite number of 1’s.
To simplify the descriptions of our results, we assume henceforth that Σ = Q,
the vertices of A. This is w.l.o.g. since the problem can be reduced to this case
by relabelling the RMC A and modifying the automaton B (see, e.g., [CY95]),
however care is needed when measuring complexity separately in RMC, A, and
BA, B, since typically B and Σ are small in relation to A. Our complexity results
are all with respect to the standard sizes of A and B.
Theorem 1. ([EY05], see also [EKM04]) q∗ ∈ [0, 1]n is the Least Fixed Point
solution, LFP(P ), of x = P (x). Thus, q∗ = P (q∗ ) and q∗ = limk→∞ xk , and
for all k ≥ 0, xk xk+1 q∗ , and for all q ∈ Rn≥0 , if q = P (q ), then q∗ q .
260 K. Etessami and M. Yannakakis
∗
There are already 1-exit RMCs for which the probability q(en,ex) is irrational
and not “solvable by radicals” ([EY05]). Thus, we can’t compute probabilities
exactly. Given a system x = P (x), and a vector q ∈ [0, 1]n , consider the following
sentence in the Existential Theory of Reals (which we denote by ExTh(R)):
m
m
m
ϕ ≡ ∃x1 , . . . , xm Pi (x1 , . . . , xm ) = xi ∧ 0 ≤ xi ∧ xi ≤ qi
i=1 i=1 i=1
3 The Conditioned Summary Chain MA
∗
For an RMC A, suppose we somehow have the probabilities q(u,ex) “in hand”.
Based on these, we construct a conditioned summary chain, MA , a finite Markov
chain that will allow us to answer repeated reachability questions. Extensions
of MA will later be a key to model checking RMCs. Since probabilities q(u,ex) ∗
are potentially irrational, we can not compute MA exactly. However, MA will be
important in our correctness arguments, and we will in fact be able to compute
the “structure” of MA , i.e., what transitions have non-zero probability. The
structure of MA will be sufficient for answering various “qualitative” questions.
We will assume, w.l.o.g., that each RMC has one initial state s0 = , eninit ,
with eninit the only entry of a component that does not contain any exits. Any
RMC can readily be converted to an “equivalent” one in this form.
Before describing MA , let us recall from [AEY01], the construction of a “sum-
mary graph”, HA = (Q, EHA ), which ignores probabilities and is based only on
information about reachability in the underlying RSM of A. Let R be the binary
relation between entries and exits of components such that (en, ex) ∈ R precisely
when there exists a path from , en to , ex , in the underlying graph of MA .
The edge set EHA is defined as follows. For u, v ∈ Q, (u, v) ∈ EHA iff one of the
following holds:
1. u is not a call port, and (u, pu,v , v) ∈ δ, for pu,v > 0.
2. u = (b, en) is a call port, and (en, ex) ∈ R, and v = (b, ex) is a return port.
3. u = (b, en) is a call port, and v = en is the corresponding entry.
For each vertex v ∈ Qi , let us define the probability of never exiting: ne(v) =
∗
1 − ex∈Exi q(v,ex) . Call a vertex v deficient if ne(v) > 0, i.e. there is a nonzero
probability that if the RMC starts at v it will never terminate (reach an exit of
the component).
We define MA = (QMA , δMA ) as follows. The set of states QMA of MA is the
set of deficient vertices: QMA = {v ∈ Q | ne(v) > 0}. For u, v ∈ QMA , there is a
transition (u, pu,v , v) in δMA if and only if one of the following conditions holds:
pu,v ·ne(v)
1. u, v ∈ Qi and (u, pu,v , v) ∈ δi , and pu,v = ne(u) .
∗
∗ q(en,ex) ne(v)
2. u = (b, en) ∈ Callb , v = (b, ex) ∈ Returnb , q(en,ex) > 0, & pu,v = ne(u) .
3. u = (b, en) ∈ Callb and v = en, and pu,v = ne(u)
ne(v)
. We call these transitions,
from a call port to corresponding entry, special red transitions.
Note that in all three cases, pu,v is well-defined (the denominator is nonzero)
and it is positive. Recall that we assumed that the initial vertex eninit is the
entry of a component A0 , and A0 has no exits. Thus for all v ∈ Q0 , ne(u) = 1,
and thus Q0 ⊆ QMA , and if (u, pu,v , v) ∈ δ0 , then (u, pu,v , v) ∈ δMA .
Proposition 1. Probabilities on transitions out of each state in QMA sum to 1.
MA is an ordinary (flat) Markov chain. Let (Ω , F , PrΩ’ ) denote the probability
space on traces of MA . We now define a mapping ρ : Ω → Ω ∪ {
}, that maps
262 K. Etessami and M. Yannakakis
n
n
k
ϕ ≡ ∃x1 , . . . , xn Pi (x1 , . . . , xn ) = xi ∧ 0 ≤ xi ∧ x(u,exj ) < 1
i=1 i=1 j=1
Since q∗ is the LFP solution of x = P (x), ϕ is true in the reals if and only
k ∗
if j=1 q(u,ex j)
< 1. This query can be answered in PSPACE. In the special
∗
case of a 1-exit RMC, we have Exi = {ex1 }, and ne(u) > 0 iff q(u,ex 1)
< 1.
As mentioned in section 2.2, this can be answered in P-time for 1-exit RMCs
([EY05]). Similarly, for Bd-RMCs the question can be answered in P-time by
the techniques developed in [EY05].
Algorithmic Verification of Recursive Probabilistic State Machines 263
Proof. Recall that u ∈ QHA precisely when u ∈ Q and ne(u) > 0. Thus we can
determine the set of nodes with the said complexities, respectively. The tran-
sitions of type 1 and 3 in the definition of MA are immediately determined.
For the type 2 transitions, where u = (b, en) and v = (b, ex), in order to de-
termine whether to include the corresponding summary edge (u, v) we need to
∗
decide whether q(en,ex) > 0. This can be done in polynomial time by invoking
the reachability algorithm for RSM’s [AEY01, BGR01].
– Case 1: v is not a call port. Then for every transition (v, pv,v , v ) ∈ δMA , we
have a corresponding transition ((v, T ), pv,v , (v , R (T, v ))) ∈ δMA,B
.
– Case 2: v is a call port, v = (b, en) where v is vertex in component Ai and box
b is mapped to component Aj . If there is a red transition (v, pv,en , en) ∈ δMA
then there is a red transition ((v, T ), pv,en , (en, R (T, en)) ∈ δMA,B with the
same probability.
– Case 3: If v has a summary transition (v, pv,v , v ) in MA , where v = (b, ex),
then we have summary transitions of the form ((v, T ), p , (v , T )) in MA,B
264 K. Etessami and M. Yannakakis
Lemma 2. Suppose (v, q) is special and that RMC A starts at , v and first
performs the transitions in γ(v, q). Then with probability 1 such a trajectory t
of the RMC is accepted by B with initial state q. Specifically, there is a corre-
sponding accepting run r of B such that ρ(t, r) is a run of MA ⊗ B starting from
(v, q) that infinitely repeats node (v, q) if (v, q) is special of type 1, or repeats an
accepting edge out of (v, q) if (v, q) is special of type 2.
Theorem 6. PA (L(B)) is equal to the probability that a trajectory of MA,B
starting from the initial state (v0 , {q0 }) reaches an accepting bottom SCC.
Thus, PA (L(B)) = 1 iff all bottom SCCs of MA,B reachable from (v0 , {q0 }) are
accepting, and PA (L(B)) = 0 iff no reachable bottom SCC is accepting (i.e., by
Prop. 3, there is no path in MA ⊗ B from (v0 , {q0 }) to a special node (v, q)).
As with MA and HA
, let HA,B denote the underlying directed graph of MA,B
.
For the qualitative problem, we only need (1) to construct HA,B and thus only
need to know which nodes and edges are present, and (2) to determine which
pairs (v, q) are special, and hence which bottom SCCs are accepting. Thus we
first have to identify the vertices u of the RMC A for which ne(u) > 0, which
can be done in PSPACE for general RMCs and P-time for 1-exit RMCs and
for Bd-RMCs. Then, the edges of HA,B can be determined by the standard
reachability algorithm for RSMs ([AEY01]). This works by first constructing the
genuine product of the underlying RSM of A (ignoring probabilities on transi-
tions) together with the Büchi automaton B . This defines a new RSM A ⊗ B
(no probabilities), whose size is polynomial in A and B , and thus is exponen-
tial in the original non-deterministic Büchi automaton B. The time required
for reachability analysis for RSMs is polynomial ([AEY01]). Thus, once we have
identified the deficient vertices of the RMC, the rest of the construction of HA,B
takes time polynomial in A and B .
To determine which pairs (v, q) are special, we construct for each candidate
(v, q) the graph D(v, q). For (v, q) with q ∈ F , this is immediate from HA,B . For
(v, q) with q ∈/ F and v = (b, en) a call port of a box b, we test for each return
port v = (b, ex) of the box and each state q of B whether there should be an
edge vq → (v , {q }); this involves a call to the RSM algorithm of [AEY01] to
determine whether there is a path in the RSM A ⊗ B from (en, q) to (ex, q )
(with empty stack) that goes through a vertex whose second component is an
accepting state of B. Once we determine these edges, we can construct D(v, q).
This takes time polynomial in A and B . Then compute the SCCs of D(v, q),
examine the bottom SCCs and check if one of them contains (v, T ) with q ∈ T .
Finally, once we have identified the special pairs, we examine the reachable
bottom SCCs of HA,B and determine which ones are accepting and which are
rejecting. The dependence of the time complexity on the size of the given RMC A
is polynomial except for the identification of the vertices u for which ne(u) > 0.
The dependence on |B| is exponential because of the subset construction. If B
is deterministic to begin with, we avoid the exponential blow-up and thus have
polynomial complexity in B. Thus we have:
Theorem 7. Given RMC A & Büchi automaton B, we can decide whether
PA (L(B)) = 0, PA (L(B)) = 1, or 0 < PA (L(B)) < 1 in PSPACE in A, and EX-
PTIME in B. For a 1-exit RMC or Bd-RMC, the time complexity is polynomial
in |A|. And, if B is deterministic, the time complexity in |B| is also polynomial.
Theorem 10. Given RMC, A, and BA, B, and a rational value p ∈ [0, 1], we
can decide whether PA (L(B)) ≥ p in PSPACE in |A| and in EXPSPACE in B,
specifically in space O(|A|c1 2c2 |B| ) for some constants c1 , c2 . Furthermore, if B
is deterministic we can decide this in PSPACE in both A and B.
Proof. We make crucial use of Theorem 9, and we combine this with use of
the summary chain MA,B , and queries to ExTh(R). Observe that by Theorem
6, all we need to do is “compute” the probability that a trajectory of MA,B ,
starting from the initial state (v0 , {q0 }) reaches an accepting bottom SCC. We
can not compute MA,B exactly, however, we will be able to identify the transition
probabilities uniquely inside a ExTh(R) query, and will, inside the same query
identify the probability of reaching an accepting bottom SCC.
Let q∗ = LFP(P ) be the solution vector of probabilities for the system x =
P (x) associated with RMC A. Recall that by Proposition 2, we can compute in
PSPACE in |A| the set Q = {u ∈ Q | ne(u) > 0} of deficient vertices. We do
this as a first step. Consider next the following quantifier-free formula, where
c(u) is the index of the component of a vertex u:
ϕ1 (x) ≡ x = P (x) ∧ 0 x ∧ x(u,ex) < 1 ∧ x(u,ex) = 1
u∈Q ex∈Exc(u) u∈Q\Q ex∈Exc(u)
∗
By Theorem 9, the only vector x in Rn for which ϕ1 (x) holds true is q . In ∗other
words, ϕ1 uniquely identifies LFP(P ). Recall that ne(u) = 1− ex∈Exc(u) q(u,ex) .
Now,
vector of variables indexed by vertices of A, and let ϕ2 (x, y) ≡
let y be a
u∈Q yu = 1 − ex∈Exc(u) x(u,ex) . The only vector of reals (x, y) that satisfies
∗
ϕ1 ∧ϕ2 is the one where x(u,ex) = q(u,ex) and yu = ne(u). Recall the construction
of MA,B . The states of MA,B are pairs (v, T ), where v ∈ Q , and T ⊆ S is a set
of states of B. The transitions of MA,B come in three varieties.
268 K. Etessami and M. Yannakakis
Case 1: v is not a call port, and (v, pv,v , v ) ∈ δMA . Then we have a corresponding
transition ((v, T ), pv,v , (v , R (T, v ))) ∈ δMA,B
, where pv,v = pv,v ne(v )/ ne(v),
and thus pv,v ne(v) = pv,v ne(v ). Associate a variable zv,v with each such prob-
ability pv,v , and define the formula: ϕ3 (y, z) ≡ (v,v )∈Case1 zv,v yv = pv,v yv .
Case 3: v is a call port that has a summary transition (v, pv,v , v ) in MA to a ver-
tex v = (b, ex), then we have summary transitions of the form ((v, T ), p , (v , T ))
in MA,B to the following set of states of the form (v , T ): If there exists a
path of MA that starts at the entry en of Aj and ends at the exit ex (with
empty call stack) which, viewed as a string drives B from T to T , then we
include the edge ((v, T ), p(v,T ),(v ,T ) , (v , T )) in δMA,B
, where p(v,T ),(v ,T ) =
∗ ∗
q((en,T ),(ex,T )) · ne(v )/ne(v), and where q((en,T ),(ex,T )) is the probability of
reaching , (ex, T ) from , (en, T ) in the product RMC A ⊗ B . First, com-
pute A ⊗ B and its associated equations w = P ⊗ (w) explicitly. Note that
|A ⊗ B | = O(|A||B |). Let Q⊗ be the set of vertices of A ⊗ B . We can compute
the set Q⊗ of vertices v of A ⊗ B , for which ne(v) > 0 in PSPACE in |A ⊗ B |.
Consider now the quantifier-free formula:
ϕ5 (w) ≡ w = P ⊗ (w) ∧ 0 w ∧ w(u,ex) < 1 ∧ w(u,ex) =1
u∈Q⊗ ex∈Exc(u) u∈Q⊗ \Q⊗ ex∈Exc(u)
we also remove all nodes that can not reach v ∗ , and all transitions into those
nodes. (Technically, some nodes of MA,B may no longer have full probability on
the transitions leaving them, but that is ok for our purposes.)
Now, recall from Markov chain theory (see, e.g., [Bil95]) that for such a
finite (sub-)Markov chain MA,B , there is a linear system of equations t = F (t),
over variables tu,v∗ , where u is any node of MA,B , and where the coefficients in
Algorithmic Verification of Recursive Probabilistic State Machines 269
Theorem 11. For a fixed BA, B, given a Bd-RMC, A, and a rational value
p ∈ [0, 1], we can decide whether PA (L(B)) ≥ p in time polynomial in |A|.
References
[AEY01] R. Alur, K. Etessami, and M. Yannakakis. Analysis of recursive state ma-
chines. In Proc. of 13th Int. Conf. on Computer-Aided Verification, pages
304–313, 2001.
[BGR01] M. Benedikt, P. Godefroid, and T. Reps. Model checking of unrestricted
hierarchical state machines. In Proc. of ICALP’01, volume 2076 of LNCS,
pages 652–666, 2001.
[Bil95] P. Billingsley. Probability and Measure. J. Wiley and Sons, 3rd edition,
1995.
[BKS05] T. Brázdil, A. Kučera, and O. Stražovský. Decidability of temporal prop-
erties of probabilistic pushdown automata. In Proc. of 22nd STACS’05.
Springer, 2005.
[BPR96] S. Basu, R. Pollack, and M. F. Roy. On the combinatorial and algebraic
complexity of quantifier elimination. J. of the ACM, 43(6):1002–1045, 1996.
[BR00] T. Ball and S. Rajamani. Bebop: A symbolic model checker for boolean
programs. In SPIN’2000, volume 1885 of LNCS, pages 113–130, 2000.
[Can88] J. Canny. Some algebraic and geometric computations in PSPACE. In Prof.
of 20th ACM STOC, pages 460–467, 1988.
[CY95] C. Courcoubetis and M. Yannakakis. The complexity of probabilistic veri-
fication. Journal of the ACM, 42(4):857–907, 1995.
[EE04] J. Esparza and K. Etessami. Verifying probabilistic procedural programs.
In Proc. FSTTCS’04, 2004. (Invited survey paper).
[EHRS00] J. Esparza, D. Hansel, P. Rossmanith, and S. Schwoon. Efficient algorithms
for model checking pushdown systems. In 12th CAV, volume 1855, pages
232–247. Springer, 2000.
[EKM04] Javier Esparza, Antonı́n Kučera, and Richard Mayr. Model checking prob-
abilistic pushdown automata. In Proc. of 19th IEEE LICS’04, 2004.
270 K. Etessami and M. Yannakakis