Quantitative Analysis of Assertion Violations inProbabilistic Programsโ
Jinyi Wangโ
Shanghai Jiao Tong University
Yican Sunโ
Peking University
Hongfei Fuโก
Shanghai Jiao Tong University
Krishnendu Chatterjee
IST Austria
Amir Kafshdar Goharshady
IST Austria
AbstractWe consider the fundamental problem of deriving quanti-
tative bounds on the probability that a given assertion is
violated in a probabilistic program. We provide automated
algorithms that obtain both lower and upper bounds on
the assertion violation probability. The main novelty of our
approach is that we prove new and dedicated fixed-point the-
orems which serve as the theoretical basis of our algorithms
and enable us to reason about assertion violation bounds in
terms of pre and post fixed-point functions. To synthesize
such fixed-points, we devise algorithms that utilize a wide
range of mathematical tools, including repulsing ranking
supermartingales, Hoeffdingโs lemma, Minkowski decompo-
sitions, Jensenโs inequality, and convex optimization.
On the theoretical side, we provide (i) the first automated
algorithm for lower-bounds on assertion violation proba-
bilities, (ii) the first complete algorithm for upper-bounds
of exponential form in affine programs, and (iii) provably
and significantly tighter upper-bounds than the previous ap-
proaches. On the practical side, we show our algorithms can
handle a wide variety of programs from the literature and
synthesize bounds that are remarkably tighter than previous
results, in some cases by thousands of orders of magnitude.
1 IntroductionProbabilistic Programs. Extending classical imperative pro-
grams with the ability of sampling random values from pre-
determined probability distributions leads to probabilistic
programs [20]. Probabilistic programs are ubiquitous in vir-
tually all parts of computer science, including machine learn-
ing [13, 36, 40], robotics [46], and network analysis [18, 27,
42]. As a result, there are many probabilistic programming
โChinese authors are ordered by contribution, while Austrian authors
are ordered alphabetically.
โ Equal contribution
โกCorresponding author
Conferenceโ17, July 2017, Washington, DC, USA
2020. ACM ISBN 978-x-xxxx-xxxx-x/YY/MM. . . $15.00
https://doi.org/10.1145/nnnnnnn.nnnnnnn
languages and their formal analysis is a central topic in pro-
gramming languages and verification [1, 6, 14, 23, 28, 34, 35].
QualitativeAnalysis of Probabilistic Programs.Themost
well-studied problem in the qualitative analysis of prob-
abilistic programs is that of termination. Various notions
of termination, such as finite-time termination [3, 11, 17]
and probability-1 (almost-sure) termination [6, 28], have
been considered, and a wealth of methods have been pro-
posed, e.g. patterns [14], abstraction [32], martingale-based
[6, 8, 11, 24], proof rules [29, 33, 35], and compositional [25].
Quantitative Analysis of Probabilistic Programs.Gener-
ally speaking, quantitative analyses of probabilistic programs
are subtler and more complex than qualitative ones. Funda-
mental problems in this category include expected runtime
analysis [4, 19, 29], cost and resource analysis [10, 34, 48],
concentration bounds on the runtime [11, 30, 47], and the
focus of this work, namely assertion violation bounds.
Assertion Violation Bounds. Consider a probabilistic pro-
gram, together with one or more assertions at some points of
the program. We are interested in the probability that an as-
sertion is violated when assuming a given initial state for the
program. Specifically, we focus on finding upper and lower
bounds for the assertion violation probability. This problem
was first considered in [6] and has since become one of the
most fundamental quantitative analyses in probabilistic pro-
gramming. Previous methods include concentration inequal-
ities [6, 8, 11, 12, 47] and automata-based approaches [41].
See Section 8 for a detailed comparison with previous works.
Our Contributions. Our first theoretical contribution is
that we provide novel fixed-point theorems which charac-
terize assertion violation bounds in terms of pre and post
fixed-point functions (Section 4). We then focus on exponen-
tial bounds and use this characterization to obtain synthesis
algorithms for both upper and lower bounds. The reason
why we choose exponential bounds is that they best suit the
common situation where the assertion violation probability
decreases drastically wrt a combination of program variables.
Our algorithmic contributions are as follows:
arX
iv:2
011.
1461
7v2
[cs
.PL
] 1
Dec
202
0
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
โข In Section 5.1, we provide a sound polynomial-time
algorithm for upper-bound synthesis via repulsing su-
permartingales and Hoeffdingโs lemma. Our algorithm
is guaranteed to obtain a significantly tighter bound
than [12].
โข In Section 5.2, we provide a sound and complete syn-
thesis algorithm for exponential upper-bounds (with
linear combinations of program variables as the expo-
nent) for affine programs. This is achieved byMinkowski
decomposition and a dedicated quantifier elimination
procedure.
โข In Section 6, we turn our focus to exponential lower-
bounds and, through Jensenโs inequality, obtain a sound
polynomial-time algorithm for the synthesis of such
bounds in almost-surely terminating affine programs.
On the practical side, we provide extensive experimental
results (Section 7), showing that, over several classical pro-
grams, our bounds are significantly tighter than previous
approaches, in some cases by thousands of orders of magni-
tude.
Novelty. This work is novel in a number of directions: (a) we
provide dedicated fixed-point theorems for assertion viola-
tion analysis and use them as the theoretical basis of our
algorithms, whereas previous methods relied on either con-
centration bounds or automata-based approaches; (b) we
provide automated algorithms for inferring both upper and
lower bounds, whereas previous methods could only han-
dle upper-bounds; (c) each of our algorithms has non-trivial
novel components such as our dedicated and efficient quan-
tifier elimination method, or the application of Hoeffdingโs
lemma and Jensenโs inequality in the context of assertion
violation analysis; (d) our algorithm in Section 5.2 is com-
plete in the sense of finding a near-optimal template given
any error bound, while staying practical. This is the first
such completeness result in assertion violation analysis of
probabilistic programs.
Limitations. Given that the problem we are attempting is
undecidable in its most general case, our algorithms have
the following limitations: (a) they only focus on deriving ex-
ponential bounds over affine/polynomial programs; (b) our
lower-bound results assume almost-sure termination, i.e. they
assume that the probabilistic program under analysis termi-
nates with probability 1.While this is a routine assumption,
our results depend on it; (c) there is currently a trade-off be-
tween completeness and polynomial runtime. Our algorithm
in Section 5.2 provides completeness but is not guaranteed
to run in polynomial time. Conversely, our algorithms in
Sections 5.1 and 6 are polynomial-time but not necessarily
complete. Nevertheless, they provide tighter bounds than
previous methods (Remark 2). Moreover, the trade-off is in
theory, only. Our experimental results (Section 7) show that
our complete algorithm is extremely efficient in practice.
2 PreliminariesThroughout this work, we use a Probabilistic Transition
System (PTS) [6] to model and analyze each of our programs.
A PTS is conceptually similar to a probabilistic control flow
graph [8, 11]. Hence, translating an imperative probabilistic
program into an equivalent PTS is a straightforward process.
Valuations. Let ๐ be a finite set of variables. A valuation
over ๐ is a function v : ๐ โ R. We denote the set of all
valuations over ๐ by R๐ .Moreover, we write v(๐ฅ) to denotethe value assigned by v to ๐ฅ โ ๐ .
Program and Sampling Variables. In the sequel, we con-
sider two disjoint sets of variables: (i) the set ๐ of program
variables whose values are determined by assignment state-
ments in the program, and (ii) the set ๐ of sampling variables
whose values are independently sampled from a predefined
probability distribution each time they are accessed. For a
sampling variable ๐, we denote its distribution by D(๐ ) andits support, i.e. the set of all values that can be assigned to ๐ ,
by U(๐ ).We also define U =โ
๐ โ๐ U(๐ ).
Update Functions. An update function upd is a function
upd : R๐ รR๐ โ R๐ that assigns a new valuation to program
variables based on the current values of both program and
sampling variables. Informally, we use update functions to
model the effect of running a basic block of code.
We are now ready to define the notion of a PTS. We extend
the definition in [6] with assertion violations.
Probabilistic Transition Systems. A Probabilistic Transi-
tion System is a tupleฮ = (๐ , ๐ ,D, L,๐, โinit, vinit, โt, โf ),where:
โข ๐ is a finite set of program variables.
โข ๐ is a finite set of sampling variables and ๐ โฉ๐ = โ .โข D is a function that assigns a probability distribution
D(๐ ) to each sampling variable ๐ โ ๐ .โข L is a finite set of locations or program counters.
โข โinit โ L is the initial location and vinit โ R๐ is the
initial valuation for program variables.
โข โf , โt โ L. Intuitively, โt represents program termination
and โf corresponds to assertion violation.
โข ๐ is a finite set of transitions. Each transition ๐ โ ๐ is
a tuple ๐ = โจโsrc, ๐, ๐น1, ๐น2, ยท ยท ยท , ๐น๐โฉ such that
โ โsrc โ L \ {โt, โf } is the source location;โ ๐ is a logical formula over valuations on ๐ which
serves as the transitionโs guard or condition;
โ Each ๐น ๐ is called a fork and is of the form ๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉin which โdst๐ โ L is the destination location, ๐ ๐ โ(0, 1] is the probability assigned to this fork, and upd๐is an update function. It is guaranteed that
โ๐๐=1 ๐ ๐ =
1.
A state of ฮ is a pair ๐ = (โ, v) โ L ร R๐ that consists of a
location and a valuation. In the sequel, we assume that we
have fixed a PTS ฮ = (๐ , ๐ ,D, L,๐, โinit, vinit, โt, โf ).
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
Intuitive Description. The program starts at (โinit, vinit).A transition โจโsrc, ๐, ๐น1, ๐น2, ยท ยท ยท , ๐น๐โฉ with ๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉstates that if the current location is โsrc and the current valu-
ation v of program variables satisfies the condition ๐ , then
each fork ๐น ๐ is chosen and applied with probability ๐ ๐ .When
we apply ๐น ๐ , the next location is โdst๐ and the next valuation
is upd๐ (v, r), in which r โ R๐ is obtained by independently
sampling a value for each ๐ โ ๐ according to D(๐ ).
Example 1. Figure 1 shows a PTS representation of a program.
Oval nodes represent locations and square nodes model the
forking behavior of transitions. An edge entering a square node
is labeled with the condition of its respective transition. The
numbers in green denote the probability of each fork, while
blue expressions show the update functions.
Additional Assumption.To disallow non-determinism and
undefined behavior, we require that: (i) any two transitions
๐ โ ๐ โฒ with the same source location be mutually exclusive,
i.e. if their guards are ๐ and ๐ โฒ, then ๐ โง ๐ โฒ is unsatisfiable;(ii) the set of transitions be complete, i.e. for every location โ
other than โt, โf and every valuation v โ R๐ , there must exist
a transition out of โ whose guard condition is satisfied by v.
Semantics. The semantics of ฮ is formalized by its corre-
sponding PTS process ฮ. ฮ is a stochastic process {๏ฟฝ๏ฟฝ๐}๐โฅ0 onstates. Given the current state ๏ฟฝ๏ฟฝ๐ = (โ๐, v๐), if โ๐ โ {โf , โt},the transition is specified as follows: (1) Take the unique
transition โจโ๐, ๐, ๐น1, . . . , ๐น๐โฉ with v๐ |= ๐ . (2) Choose the fork๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉ with probability ๐ ๐ . (3) Obtain a valua-
tion r over our sampling variables ๐ by sampling each ๐ โ ๐ independently according toD(๐ ). (4) Apply the chosen fork:
(โ๐+1, v๐+1) = (โdst๐ , upd๐ (v๐, r)). If either โt or โf is reached,(โ๐+1, v๐+1) = (โ๐, v๐). See Appendix A for details.
๐ฅ : =40 ; ๐ฆ : = 0 ;
while (๐ฅ โค 99 โง ๐ฆ โค 99 ) :
i f prob ( 0.5 ) :
โจ๐ฅ,๐ฆโฉ := โจ๐ฅ + 1, ๐ฆ + 2โฉe l se :
โจ๐ฅ,๐ฆโฉ := โจ๐ฅ + 1, ๐ฆโฉas se r t (๐ฅ โฅ 100 )
Figure 1. A Probabilistic Program (top) and its PTS (bottom)
Paths and Reachability. Let ฮ be a PTS. A path in ฮ is an
infinite sequence of states ๐0, ๐1, . . . such that:
โข ๐0 = (โinit, vinit), andโข for each ๐ โฅ 0, the states ๐๐ = (โ๐, v๐) and ๐๐+1 =
(โ๐+1, v๐+1) satisfy one of the following cases:
โ โ๐ โ {โt, โf } and there is a transition โจโ๐, ๐, ๐น1,. . . , ๐น๐โฉwith a fork ๐น ๐ such that v |= ๐ , ๐น ๐ = โจโ๐+1, ๐ ๐ , upd๐ โฉ,and v๐+1 = upd๐ (v๐, r) for some r โ U;
โ โ๐ โ {โt, โf } and (โ๐+1, v๐+1) = (โ๐, v๐).A state ๐ is reachable if there is a path ๐0, ๐1, . . . such that
๐๐ = ๐ for some ๐ โฅ 0. S denotes the set of reachable states.
Invariants. For a PTS ฮ , an invariant is a function ๐ผ : Lโ2R๐
that assigns to each location โ โ L, a subset ๐ผ (โ) ofvaluations over program variables such that S โ {(โ, v) |v โ ๐ผ (โ)}. An invariant over-approximates reachable states.
Example 2. In Figure 1, every location has an associated
formula in red, representing an invariant at that location.
We now formalize the central problem studied in this
work:
Quantitative Assertion Violation Analysis. Given a PTS
ฮ and an invariant ๐ผ , the Quantitative Assertion Violation
Analysis (QAVA) problem is to infer upper and lower bounds
for the probability that the PTS process ฮ, starting at initialstate (โinit, vinit), ends with assertion violation. Formally, the
goal is to synthesize upper and lower bounds for
Pr[โ๐. โ๐ = โf | ๏ฟฝ๏ฟฝ0 = (โinit, vinit)] .We abbreviate the upper-bound analysis problem as UQAVA,
and its lower-bound counterpart as LQAVA.
3 Illustration and Motivating ExamplesIn this section, we illustrate our approach over three exam-
ples from different application domains. We will provide a
more formal treatment in Section 4.
โข In Section 3.1, we show the basic ideas using an exam-
ple program, taken from the literature on stochastic
invariants, that models a tortoise-hare race.
โข In Section 3.2, we show how our approach can be used
to solve one of the most classical problems in prob-
abilistic termination analysis, namely concentration
bounds.
โข While the two examples above rely on upper-bounds,
in Section 3.3, we illustrate our approach for lower-
bounds and apply it to quantify the probability of error
in computations performed on unreliable hardware.
3.1 Tortoise-Hare RaceConsider the program of Figure 1, which is often encountered
in works on stochastic invariants (e.g. [12]). This program
models a classical tortoise-hare race. The variable ๐ฅ repre-
sents our tortoiseโs position, while ๐ฆ is the position of the
hare. Initially, the tortoise is given a 40-unit edge. In each
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
iteration, the tortoise moves one step forward, and the hare
either takes a two-unit jump or rests. The finish line is at posi-
tion 100. So, the assert corresponds to a win for the tortoise.
We aim to obtain an upper-bound for the hareโs winning
probability, i.e. the probability of assertion violation.
We establish such an upper-bound by relying on fixed-
point theorems. The fundamental idea is to synthesize a
function ๐ (๐ฅโ, ๐ฆโ) that serves as an overapproximation of the
probability that the assertion is eventually violated, assuming
that we start running the program from the entry point of
our while loop with variable valuations ๐ฅ = ๐ฅโ and ๐ฆ = ๐ฆโ .We can set up the following constraints over ๐ (๐ฅโ, ๐ฆโ):
(I) โ๐ฅโ, ๐ฆโ . ๐ (๐ฅโ, ๐ฆโ) โฅ 0;
(II) โ๐ฅโ, ๐ฆโ . ๐ฅโ โค 99 โง ๐ฆโ โฅ 100โ ๐ (๐ฅโ, ๐ฆโ) โฅ 1;
(III) โ๐ฅโ, ๐ฆโ . ๐ฅโ โค 99 โง ๐ฆโ โค 99 โ ๐ (๐ฅโ, ๐ฆโ) โฅ 0.5 ยท๐ (๐ฅโ + 1, ๐ฆโ + 2) + 0.5 ยท ๐ (๐ฅโ + 1, ๐ฆโ).
Informally, constraint (I) is natural since probability values
are always non-negative. Constraint (II) requires that when
the program terminates with an assertion violation, the value
of ๐ is at least 1. Finally, constraint (III) is applied when
another iteration of the loop is about to run and enforces
that our approximation of the probability of violating the
assertion at this point is no less than its expectation after
the execution of one iteration. More formally, this condi-
tion is derived from the fixed-point theorem and states that
๐ (๐ฅโ, ๐ฆโ) is a prefixed-point (See Theorem 4.3).
By Tarskiโs fixed-point theorem (Theorem 4.1), any func-
tion ๐ (๐ฅโ, ๐ฆโ) that satisfies the constraints (I)โ(III) serves asan upper-bound for the assertion violation probability given
any initial valuation ๐ฅโ, ๐ฆโ. Specifically, we focus on synthe-
sizing such a function ๐ so that we can use ๐ (40, 0) as ourupper-bound on the probability of assertion violation.
In this work, we focus on assertions whose probability
of violation decreases exponentially with respect to a com-
bination of program variables. We follow a template-based
method (see e.g. [6, 8, 11]) and set up an exponential tem-
plate ๐ (๐ฅโ, ๐ฆโ) := exp(๐ ยท ๐ฅโ + ๐ ยท ๐ฆโ + ๐). Our goal is tosynthesize values for the variables ๐, ๐, ๐ such that ๐ satisfies
constraints (I)โ(III) above, while simultaneously minimizing
๐ (40, 0). This template specifies that the assertion violation
probability decreases exponentially with respect to the lin-
ear expression ๐ ยท ๐ฅโ + ๐ ยท ๐ฆโ + ๐ . Thus, it suffices to solve
the following optimization problem with unknown variables
๐, ๐, ๐:
Minimize exp(40 ยท ๐ + 0 ยท ๐ + ๐)Subject to constraints (I)โ(III)
In general, solving such optimization problems is hard,
since the constraints are universally quantified and involve
exponential terms. Surprisingly, in Section 5.2, we show that
a large class of optimization problems of this kind, including
the problem above, can be exactly solved through convex
programming. By solving this optimization problem, we de-
rive ๐ โ โ1.19, ๐ โ 4.26, ๐ โ 31.79, and the optimal value is
๐ฅ : =0 ; ๐ก : =0 ;
while (๐ฅ โค 99 ) :
switch :
prob ( 0.75 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ + 1, ๐ก + 1โฉprob ( 0.25 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ โ 1, ๐ก + 1โฉ
as se r t ( ๐ก โค 500 )
Figure 2. An Asymmetric Random Walk
โ exp(โ15.697) โ 1.524 ยท 10โ7. Hence, the probability that
the assertion is violated is at most 1.524 ยท 10โ7 .
3.2 Concentration BoundsConcentration analysis of termination time is a fundamental
problem in probabilistic programming [11] whose goal is to
derive rapidly-decreasing upper-bounds in terms of ๐ for the
probability that a probabilistic program does not terminate
(continues running) after ๐ steps. To model this problem in
our framework, we introduce a new program variable ๐ก that
keeps track of the running time and is incremented in every
iteration/step of the program. We also add the assertion
assert(๐ก < ๐) at the endpoint of the program. Here, ๐ is
either a user-specified natural number or a fresh variable.
As an example, consider the program in Figure 2 which
models an asymmetric random walk. In this program, the
variable ๐ฅ represents our current position in the random
walk. The switch statement within the loop body specifies
that at each step, we move forwards with probability3
4and
backwards with probability1
4. The variable ๐ก records the
number of loop iterations. At the end of the loop body, the
assert statement checks whether the program has run for at
most 500 iterations. Our goal is to find an upper-bound for
the probability of violation of this assertion, i.e. the proba-
bility that our asymmetric random walk does not terminate
(does not reach ๐ฅ > 99) within 500 steps.
Again, we synthesize a function ๐ (๐ฅโ, ๐กโ) that over-estimates
the assertion-violation probability assuming the program is
started at the while loop with valuation ๐ฅ = ๐ฅโ, ๐ก = ๐กโ. Sucha function should satisfy the following constraints:
(I) โ๐ฅโ, ๐กโ . ๐ (๐ฅโ, ๐กโ) โฅ 0;
(II) โ๐ฅโ, ๐กโ . ๐ฅโ โค 100 โง ๐กโ โฅ 501โ ๐ (๐ฅโ, ๐กโ) โฅ 1;
(III) โ๐ฅโ, ๐กโ . ๐ฅโ โค 99 โง ๐กโ โค 500 โ 0.25 ยท ๐ (๐ฅโ โ 1, ๐กโ +1) + 0.75 ยท ๐ (๐ฅโ + 1, ๐กโ + 1) โค ๐ (๐ฅโ, ๐กโ).
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
The intuition behind these constraints is similar to the pre-
vious section. By Tarskiโs fixed-point theorem (Theorem 4.1),
any function ๐ satisfying these constraints is an upper-bound
on the assertion-violation probability. Given the initial val-
ues ๐ฅ = ๐ก = 0, by letting ๐ (๐ฅโ, ๐กโ) := exp(๐ ยท ๐ฅโ + ๐ ยท ๐กโ + ๐)and solving for ๐, ๐, ๐ (See Section 5.2 for details), we obtain
๐ โ โ0.351, ๐ โ 0.124, ๐ โ โ27.181. The assertion violation
probability is at most ๐ (0, 0) โ exp(โ27.181) โ 1.569 ยท 10โ12.
3.3 Computing on Unreliable HardwareConsider an unreliable hardware that might malfunction
with a tiny probability at each execution step and cause
the program to collapse or compute erroneously. Reliability
analysis of programs run over unreliable hardware is an
active area of research (see e.g. [5, 41]). We now show how
the reliability analysis can be reduced to the derivation of
lower-bounds for the probability of assertion violation, and
provide an outline of our approach for deriving such lower-
bounds.
Take the random walk example from the previous section,
but assume that it is run on an unreliable hardware and any
iteration may fail with probability ๐ = 10โ7. Our goal is to
derive a lower-bound for the probability that the random
walk executes correctly until termination. By incorporating
hardware failure into the random walk, we get the program
in Figure 3. The only difference with the original random
walk is that in each loop iteration, the hardware fails with
probability ๐. This is modeled by the exit statement. We deli-
brately have the assertion false at the end of the program so
that the assertion fails iff there is no hardware failure during
the whole execution. Thus, we are aiming to synthesize a
lower-bound for the probability of assertion violation.
Since we need to infer a lower-bound instead of an upper-
bound, we will synthesize a function ๐ (๐ฅโ) at the entry pointof the loop that always under-estimates the probability of
assertion violation. We establish a new fixed point theorem
(Theorem 4.4) by which the function ๐ should satisfy:
(I) โ๐ฅโ . ๐ฅโ โค 100โ 0 โค ๐ (๐ฅโ) โค 1;
(II) โ๐ฅโ . ๐ฅโ โค 99โ ๐ (๐ฅโ) โค 0.75 ยท (1 โ ๐) ยท ๐ (๐ฅโ + 1) +0.25 ยท (1 โ ๐) ยท ๐ (๐ฅโ โ 1) + ๐ ยท 0
These constraints are, in a sense, duals of the constraints
used for upper-bounds. The differences are that, in constraint
(I), we restrict the value to be at most 1 and that, in constraint
(II), we have a post fixed-point rather than a pre fixed-point,
i.e. ๐ (๐ฅโ) is less than or equal to its expectation after the
execution of one iteration.
As in the previous cases, we set up an exponential template
๐ (๐ฅโ) := exp(๐ ยท ๐ฅโ + ๐). Note that the initial value of ๐ฅ is
1. Therefore, in order to obtain as tight a lower-bound as
possible, we need to maximize ๐ (1). So, we have to solve
the following optimization problem with unknown variables
๐, ๐:
Maximize exp(๐ + ๐)
๐ฅ : =1 ;
while (๐ฅ โค 99 ) :
switch :
prob (๐ ) : ex i tprob ( 0.75 ยท (1 โ ๐) ) : ๐ฅ : =๐ฅ + 1prob ( 0.25 ยท (1 โ ๐) ) : ๐ฅ : =๐ฅ โ 1
as se r t ( false )
Figure 3. Random Walk Run with Unreliable Hardware
Subject to constraints (I)โ(II)
As we will see in Section 6, (I) can be transformed into an
equivalent collection of linear constraints over ๐, ๐ using
Farkasโ Lemma. In (II), we divide both sides by exp(๐ ยท๐ฅโ+๐):
0.75 ยท (1 โ ๐) ยท exp(๐) + 0.25 ยท (1 โ ๐) ยท exp(โ๐) โฅ 1.
This is not a convex inequality. Hence, we cannot apply
convex programming to solve this optimization problem.
Instead, we use Jensenโs inequality (Theorem 6.1) to relax
these exponential constraints to linear ones. Concretely, (II)
is satisfied if: 0.75 ยท ๐ + 0.25 ยท (โ๐) โฅ โ ln (1 โ ๐). After thesetransformations, since maximizing exp(๐ + ๐) is equivalentto maximizing ๐ +๐, the problem is relaxed and reduced to a
linear programming instance, which can be solved efficiently.
In this case, we obtain ๐ โ 2 ยท 10โ7, ๐ โ โ2 ยท 10โ5. So, ourlower-bound is โ exp(โ1.98 ยท 10โ5) โ 0.99998.
4 A Fixed-Point Approach to QAVAIn this section, we show how fixed-point theorems can be
applied to the QAVA problem. Our results provide a theo-
retical basis for obtaining upper and lower bounds on the
assertion violation probability.
4.1 Lattices and Fixed-point Theorems
Suprema and Infima. Given a partial order โ over a set ๐พ,
and a subset ๐พ โฒ โ ๐พ, an upper-bound of ๐พ โฒ is an element
๐ข โ ๐พ that is larger than every element of ๐พ โฒ, i.e. โ๐ โฒ โ๐พ โฒ. ๐ โฒ โ ๐ข. Similarly, a lower-bound for ๐พ โฒ is an element ๐
that is smaller than every element of ๐พ โฒ, i.e. โ๐ โฒ โ ๐พ โฒ. ๐ โ ๐ โฒ.The suprema of ๐พ โฒ, denoted by
โ๐พ โฒ, is an element ๐ขโ โ ๐พ
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
such that ๐ขโ is an upper-bound of ๐พ โฒ and for every upper-
bound ๐ข of ๐พ โฒ, we have ๐ขโ โ ๐ข. Similarly, the infima
.๐พ โฒ is
a lower-bound ๐โ of ๐พ โฒ such that for every lower-bound ๐ of
๐พ โฒ, we have ๐ โ ๐โ .We also define โฅ :=.๐พ and โค :=โ๐พ. In
general, suprema and infima may not exist.
Complete Lattice. A partial order (๐พ, โ) is called a complete
lattice if every subset ๐พ โฒ โ ๐พ has an suprema and a infima.
Monotone Functions. Given a partial order (๐พ, โ), a func-tion ๐ : ๐พ โ ๐พ is called monotone if for every ๐1 โ ๐2 in ๐พ ,we have ๐ (๐1) โ ๐ (๐2).Continuity. Given a complete lattice (๐พ, โ), a function ๐ :
๐พ โ ๐พ is called continuous if for every increasing chain
๐0 โ ๐1 โ . . . in ๐พ, we have ๐ (โ{๐๐}โ๐=0) = โ{๐ (๐๐)}โ๐=0,
and cocontinuous if for every decreasing chain ๐0 โ ๐1 โ . . .of elements of ๐พ, we have ๐ (.{๐๐}โ๐=0) = .{๐ (๐๐)}โ๐=0.Fixed-Points.Given a complete lattice (๐พ, โ) and a function๐ : ๐พ โ ๐พ, an element ๐ฅ โ ๐พ is called a fixed-point if
๐ (๐ฅ) = ๐ฅ . Moreover, ๐ฅ is a pre fixed-point if ๐ (๐ฅ) โ ๐ฅ and
a post fixed-point if ๐ (๐ฅ) โ ๐ฅ . The least fixed-point of ๐ ,
denoted by lfp๐ , is a fixed-point that is smaller than every
fixed-point under โ . Analogously, the greatest fixed-pointof ๐ , gfp๐ , is a fixed-point that is larger than all fixed-points.
Theorem 4.1 (Knaster-Tarski [45]). Let (๐พ, โ) be a complete
lattice and ๐ : ๐พ โ ๐พ a monotone function. Then, both lfp ๐
and gfp ๐ exist. Moreover, lfp ๐ is the infima of all pre fixed-
points, and gfp ๐ is the suprema of all post fixed-points.
lfp ๐ =. {๐ฅ | ๐ (๐ฅ) โ ๐ฅ} (1)
gfp ๐ =โ {๐ฅ | ๐ฅ โ ๐ (๐ฅ)} (2)
The next theorem provides a construction for the fixed-
points.
Theorem 4.2 ([37]). Let (๐พ, โ) be a complete lattice and
๐ : ๐พ โ ๐พ be an continuous function. Then, we have
lfp ๐ =โ
๐โฅ0{๐ (๐) (โฅ)
}.
Analogously, if ๐ is cocontinuous, we have
gfp ๐ =.
๐โฅ0{๐ (๐) (โค)
}.
4.2 Fixed-point Theorems in QAVA
Violation Probability Function. We start with the viola-
tion probability function vpf . Intuitively, vpf (โ, v) is the prob-ability that the PTS process ฮ starting from the state (โ, v)ends with an assertion violation. Formally,
vpf (โ, v) := Pr
[โ๐. โ๐ = โf | ๏ฟฝ๏ฟฝ0 = (โ, v)
].
Sketch of theMethod.Our goal is to derive upper and lower
bounds on vpf (โinit, vinit). We define a set K๐of state func-
tions equipped with a natural partial order, as well as a prob-
ability transformer function ptf : K๐ โ K๐ .We then apply
Theorem 4.2 to show that vpf is the least fixed-point of ptf .
State Functions. Let ๐ โ [1,โ).We define K๐as the set
of all functions ๐ : Sโ [0, ๐] that map each reachable state
to a real number between 0 and๐ and satisfy the following:
โข โv โ R๐ . ๐ (โt, v) = 0, and
โข โv โ R๐ . ๐ (โf , v) = 1.
The partial order โ on K๐is defined standardly, i.e. for
every ๐ , ๐ โฒ โ K๐, we have ๐ โ ๐ โฒ iff โ๐ โ S. ๐ (๐) โค ๐ โฒ(๐).
It is straightforward to verify that (K๐ , โ) is a complete
lattice. Furthermore, its smallest (resp. greatest) element โฅ๐(resp. โค๐ ) is the function whose value is 0 (resp. ๐) at all
states (โ, v) โ S where โ โ {โt, โf }. We could similarly define
Kโ as the set of all functions ๐ : S โ [0,โ) โช {โ}, andthe complete lattice structure on Kโ. See Appendix B for
details.
Probability Transformer Function. The probability trans-
former function ptf๐ : K๐ โ K๐is a higher-order function
that computes the expected value of a given function after
one step of PTS execution. Formally, it is defined as follows:
โข ptf๐ (๐ ) (โf , v) := 1;
โข ptf๐ (๐ ) (โt, v) := 0;
โข If โ โ {โf , โt}, then for every valuation v โ R๐ , thereexists a unique transition ๐ = (โ, ๐, ๐น1, . . . , ๐น๐ ) withv |= ๐. Let its ๐-th fork be ๐น๐ = (โdst๐ , ๐๐ , upd๐ ). Then,
ptf๐ (๐ ) (โ, v) := โ๐๐=1 ๐๐ ยท E
[๐ (โdst๐ , upd๐ (v, r))
]where r โ R๐ is sampled according to D.
We can now obtain our first fixed-point theorem for QAVA.
Theorem 4.3 (Proof in Appendix B). lfp ptfโ = vpf .
Proof Sketch. We apply Theorem 4.2 by plugging in โฅโ. Theresult follows by expanding the function composition. โก
Upper Bounds on vpf . By combining the theorem above
with Kanster-Tarskiโs fixed-point theorem, we see that to
infer an upper-bound for vpf, it suffices to find a pre fixed-
point \ โ Kโ (as illustrated in Section 3.1).
Lower Bounds on vpf . Theorem 4.1 only provides lower
bounds on the greatest fixed-point, but not the least one.
Nevertheless, we can use these bounds if we can guarantee
the uniqueness of our fixed-point, then every post fixed-
point \ โ K๐ , for some๐ โฅ 1, would be a lower-bound on
vpf .
Almost-sure Termination. To achieve the desired unique-
ness property, we further assume that our PTS terminates
almost-surely (for all ๐ โ S). Formally, Pr[โ๐. โ๐ = โt โจ โ๐ =
โf | (โinit, vinit) = (โ, v)] = 1 for all (โ, v) โ S. We show that
under this assumption, the fixed-point is unique.
Theorem 4.4. Let ฮ be an almost-surely terminating PTS.
Then for every๐ โฅ 1, we have vpf = lfp ptf๐ = gfp ptf๐ .
Proof Sketch. Since๐ is finite, ptf๐ is both continuous and
cocontinuous. By plugging in the concrete form of โฅ๐ and
โค๐ into the formula of Theorem 4.2, and using the definition
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
of almost-sure termination assumption, one can derive the
desired result. See Appendix B for details. โก
Remark 1. Given the almost-sure termination assumption,
one may argue that the lower-bound problem can be trans-
formed into the upper-bound problem by swapping โt and โf , as
a lower bound for assertion violation is an upper bound for no
assertion violation. However, through Theorem 4.4 we reduce
the lower-bound problem to post fixed-point synthesis, which
is key to our algorithmic approach in Section 6.
Based on the discussion above, the problem of inferring
upper (resp. lower) bounds on vpf has now turned into the
synthesis of pre (resp. post) fixed-points in K๐. In the next
sections, we will focus on automated synthesis algorithms.
5 Algorithmic Approaches to UQAVA
In this section, we consider the UQAVA problem and focus
on inferring upper-bounds for the assertion violation prob-
ability. As mentioned in Section 4, every pre fixed-point in
K๐is an upper-bound on vpf . We consider the case where
the PTS ฮ and the invariant ๐ผ are affine.
Affine PTS. A PTS ฮ is affine if (i) every transitionโs guard
condition is a conjunction of affine inequalities over program
variables, i.e. inequalities of the form aT ยท ยฎ๐ โค ๐ where aT is
a constant vector, ยฎ๐ is the vector of program variables, and ๐
is a real number, and (ii) every update function upd is affine,
i.e. upd(v, u) = Q ยท v + R ยท u + e where Q and R are constant
matrices and e is a constant vector.Affine Invariants. An invariant map ๐ผ is affine if for each
โ โ L, ๐ผ (L) is a conjunction of affine inequalities over pro-
gram variables.
We focus on synthesizing exponential upper-bounds (pre
fixed-points). This choice best suits the common cases where
the assertion violation probability decreases exponentially
with respect to a combination of program variables. In gen-
eral, due to transcendentality, exponential functions are
much harder to synthesize than the widely-studied cases
of linear functions [6, 11] or polynomials [8], which are
respectively handled by Farkasโ Lemma [15] and Positivstel-
lensรคtze [38]. We present two algorithmic approaches for
this problem:
โข In Section 5.1, we show that Repulsing Ranking Su-
permartingales (RepRSMs), first defined in [12] in the
context of stochastic invariants, can be exploited to
obtain exponential pre fixed-points. Our approach is
based on Hoeffdingโs lemma and leads to an efficient
sound algorithm that first synthesizes a linear/poly-
nomial RepRSM, and then obtains an exponential pre
fixed-point based on it. Our bounds are significantly
better than the ones obtained in [12] using Azumaโs in-
equality (Remark 2). However, this efficient algorithm
is not complete.
โข In Section 5.2, we provide a sound and complete algo-
rithm for exponential bounds of the form exp(๐ ยทv+๐)for affine PTSs. This algorithm depends on Minkowski
decomposition. Hence, in theory, it is not as efficient as
the one in Section 5.1. However, it provides complete-
ness guarantees and reduces the problem to convex
optimization. In practice, it inherits the efficiency of
convex optimization and easily handles various bench-
marks (Section 7).
5.1 A Sound Polynomial-time AlgorithmTo present our first synthesis algorithm, we define the notion
of RepRSMs. The definition below is taken from [12] and
slightly modified to become applicable to PTSs.
RepRSMs. A (๐ฝ,ฮ, ๐)-Repulsing Ranking Supermartingale is
a Lebesgue-measurable, e.g. linear or polynomial, function
[ : Sโ R satisfying the following conditions:
(C1) [ (โinit, vinit) โค 0;
(C2) โv โ R๐ . v |= ๐ผ (โf ) โ [ (โf , v) โฅ 0;
(C3) For every transition ๐ = (โsrc, ๐, ๐น1, ๐น2, ยท ยท ยท , ๐น๐ ), where๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉ, it holds that:
โv โR๐ .v |= ๐ผ (โsrc) โง ๐ โโ๐
๐=1 ๐ ๐ ยท Er [[ (โdst๐ , upd๐ (v, r))] โค [ (โsrc, v) โ ๐.
(C4) For every ๐ as above and 1 โค ๐ โค ๐ , we have:
โv โ R๐ ,r โ U.v |= ๐ผ (โsrc) โง ๐ โ๐ฝ โค [ (โdst๐ , upd๐ (v, r)) โ [ (โsrc, v) โค ๐ฝ + ฮ.
Informally, (C1) says that the initial value of [ is non-positive,
while (C2) means that when the program terminates with
assertion failure, the value of [ should be non-negative. (C3)
specifies that the expected value of [ decreases by at least
๐ after each transition in the PTS. Finally, (C4) states that
the difference between current and next values of [ always
falls in the interval [๐ฝ, ๐ฝ + ฮ]. In [12], it is shown that a
RepRSM leads to an exponentially-decreasing upper-bound
for assertion violation. We now obtain a much tighter bound.
Lemma 1 (Hoeffdingโs Lemma [31]). For any random vari-
able ๐ such that ๐ โค ๐ โค ๐, and all ๐ก โฅ 0, we have
E[exp(๐ก ยท ๐ )] โค exp
(๐ก ยท E[๐ ] + ๐ก2 ยท (๐โ๐)2
8
).
We now present a theorem that establishes a connection
between RepRSMs and pre fixed-point state functions, and
serves as a basis for our first algorithm:
Theorem 5.1 (Proof in Appendix C). Let [ be a (๐ฝ,ฮ, ๐)-RepRSM, then exp
(8ยท๐ฮ2ยท [
)is a pre fixed-point state function.
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
Proof Sketch. Define \ := exp( 8ยท๐ฮ2ยท [). To prove ptf (\ )
โ \ , we expand the left-hand-side and directly upper-bound
the exponential term using Lemma 1. โก
Combining the theorem abovewith our results in Section 4,
it is straightforward to see that exp( 8ยท๐ฮ2ยท [ (โinit, vinit)) is an
upper-bound on the probability of assertion violation.
Remark 2. Note that [12] also obtains an upper bound on
assertion violation using RepRSMs. However, their method ap-
plies Azumaโs inequality, which corresponds to the special case
of ๐ฝ < 0 โง ฮ = 2 ยท ๐ฝ in our setting. In their case, given a
(โฮ/2,ฮ, ๐)-RepRSM [, the obtained bound is no less than
exp
(4ยท๐ฮ2ยท [
), while our bound is exp( 8ยท๐
ฮ2ยท [). Note that by
condition (C1) in the definition of RepRSMs, [ (โinit, vinit) isnon-positive. Thus, our bound is always substantially tighter.
As shown by Theorem 5.1, it is sufficient to synthesize
a RepRSM in order to obtain an upper-bound for the as-
sertion violation probability. In the rest of this section, we
provide an algorithm that synthesizes linear RepRSMs over
a given affine PTS ฮ with an affine invariant ๐ผ . This algo-
rithm is a standard application of Farkasโ lemma, as in [6, 11].
Hence, we only provide a high-level overview. See [6, 11]
for a more detailed exposition. Finally, it is noteworthy that
the algorithm can also be extended to polynomial RepRSMs
(Remark 3).
The HoeffdingSynthesis Algorithm. Our algorithm de-
rives an exponential upper-bound in four steps:
Step 1 (Setting up templates). The algorithm creates un-
known coefficients ยฎaโ , ๐โ for every location โ โ L. Each ยฎaโ isa row vector of |๐ | unknown coefficients and each ๐โ is an
unknown scalar. Moreover, the algorithm symbolically com-
putes [ (โ, v) := ยฎaโ ยท v + ๐โ for every location โ . The goal is to
find values for the unknown coefficients ยฎaโ , ๐โ , and RepRSM
parameters ๐ฝ,ฮ, ๐ so that [ becomes a RepRSM.
Step 2 (Collecting constraints). The algorithm transforms
(C2)โ(C4) into conjunctions of constraints of the form
โv โ ๐ .(cT ยท v โค ๐
),
where ๐ is a constant polyhedron and c, ๐ are, respectively,
a vector and a scalar, with each of their component being an
affine combination of the unknown coefficients created in
the previous step. This step can be accomplished since both
the ฮ and the invariant are affine.
Step 3 (Applying Farkasโ Lemma). Using Farkasโ lemma,
the algorithm transforms the constraints into an equiva-
lent conjunctive collection of linear constraints over the
unknowns.
Lemma 2 (Farkasโ Lemma [15]). Let A โ R๐ร๐ , b โ R๐ ,๐ โ R๐ and ๐ โ R. Assume that ๐ := {x โ R๐ | A ยทx โค b} โ โ .Then ๐ โ {x โ R๐ | cT ยท v โค ๐} iff there exists y โฅ 0 such
that yT ยท A = cT and yT ยท b โค ๐ .
Every constraint of the previous step is of the form โv โ๐
(cT ยท v โค ๐
), which fits perfectly into the Farkasโ Lemma.
Thus, by applying Farkasโ Lemma, the algorithm obtains a
linear programming instance over the unknown variables.
Notably, no program variable appears in this linear program.
Step 4 (Solving the unknown coefficients). Our algorithm
finds values for the unknown coefficients by solving the
linear programming instance generated in the previous step
together with the linear constraint from (C1). Additionally, if
the goal is to obtain the tightest possible upper-bound, rather
than just any upper-bound, the algorithm instead solves
the optimization problem with the objective of minimizing
8ยท๐ฮ2ยท [ (โinit, vinit). Finally, it obtains a RepRSM by plugging
the obtained solution back into the template of Step 1, and
an upper-bound on the assertion violation probability by
simply computing8ยท๐ฮ2ยท [ (โinit, vinit).
Theorem 5.2 (Soundness). If HoeffdingSynthesis success-fully synthesizes [ (โ, v), then the output exp( 8ยท๐
ฮ2ยท[ (โinit, vinit))
is an upper-bound on the probability of assertion violation in
ฮ , given the initial state (โinit, vinit).
Proof. It is easy to verify, by definition chasing, that our al-
gorithm is sound and complete for obtaining affine RepRSMs
[12] , since all steps reduce the problem to a new equivalent
format. The desired result is obtained by combining Theorem
5.1 and the proof in Section 4 that every pre fixed-point is
an upper-bound on vpf . โก
Remark 3 (Extension to Polynomial Exponents). The algo-rithm above handles the case where the exponent in our upper-
bound is an affine combination of program variables. However,
it can be straightforwardly extended to polynomial exponents
through Positivstellesรคtze [38] and semidefinite programming.
We obtain an exponential template with an affine exponent
by directly synthesizing its affine exponent. This technique is
also applicable to exponential templates with polynomial expo-
nents, which are in turn obtained from polynomial RepRSMs.
We refer to [8] for algorithmic details such as the use of Pos-
itivstellesรคtze and semi-definite programming to synthesize
polynomial (Rep)RSMs.
Time Complexity. The linear RepRSM synthesis takes poly-
nomial time (via linear programming). The same applies to
polynomial RepRSMs [8]. See Appendix C.2 for more details.
5.2 A Sound and Complete Algorithm forExponential Bounds with Affine Exponents
We provide a sound and complete algorithm for the synthesis
of upper-bounds which are of the form exp( ยฎ๐ ยท v+๐). Our al-gorithm is based on Minkowski decomposition of polyhedra
and a dedicated quantifier elimination method.
Polyhedra. A subset ๐ โ R๐ is a polyhedron if ๐ = {x โR๐ | Ax โค b} for some matrix A โ R๐ร๐ and vector
b โ R๐ . A polytope is a bounded polyhedron. A cone is
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
a polyhedron ๐ such that ๐ = {x โ R๐ | Ax โค 0} forsome matrix A โ R๐ร๐ . A generator set for a polytope
๐ is a set of vectors {v1, v2, ยท ยท ยท , v๐ }, such that every ele-
ment v โ ๐ is representable as a convex combination of this
set, i.e. v =โ๐
๐=1 _๐ ยท v๐ , for some coefficients _๐ โฅ 0 withโ๐๐=1 _๐ = 1.
Minkowski sum. Given two sets ๐ด and ๐ต of vectors, their
Minkowski sum is defined as ๐ด + ๐ต := {๐ฅ +๐ฆ | ๐ฅ โ ๐ด,๐ฆ โ ๐ต}.
Theorem5.3 (Decomposition Theorem [39]). For every poly-
hedron ๐, there exists a polytope ๐ and a polyhedral cone ๐ถ,
such that ๐ = ๐ +๐ถ.
The ExpLinSyn Algorithm. Our algorithm takes as input
an affine PTS ฮ and an affine invariant ๐ผ for ฮ . If there existsan exponential pre fixed-point whose exponent is an affine
expression over program variables, then it outputs such a
function for ฮ . Otherwise, the algorithm asserts that there
is no such state function. It consists of five steps:
Step 1 (Setting up templates). The algorithm sets up a tem-
plate \ as follows: For each โ โ {โt, โf }, it symbolically com-
putes \ (โ, v) := exp([ (โ, v)) in which [ (โ, v) is an affine
function over program variables with unknown coefficients,
i.e. [ (โ, v) := ยฎaโ ยท v + ๐โ where ยฎaโ is a vector of unknown
coefficients and ๐โ is an unknown scalar. Moreover, it sets
\ (โt, v) โก 0 and \ (โf , v) โก 1. As in the previous section, our
goal is to synthesize values for the unknown variables so
that \ becomes a pre fixed-point (an upper-bound).
Example 3. Consider the tortoise-hare example in Section
3.1, whose PTS is shown in Figure 1. For every location, we
set up a vector of unknowns: ยฎaโinit , ยฎaโswitch , ยฎaโassert . We also set up
unknown scalars ๐โinit , ๐โassert , ๐โswitch . We also compute \ and [
symbolically, e.g.
[ (โswitch, v) = ๐โswitch,1 ยท v[๐ฅ] + ๐โswitch,2 ยท v[๐ฆ] + ๐โswitch ,
\ (โswitch, v) = exp(๐โswitch
,1 ยท v[๐ฅ] + ๐โswitch
,2 ยท v[๐ฆ] + ๐โswitch).
Step 2 (Collecting constraints). The algorithm imposes
pre fixed-point constraints to \ . Following the definition
of ptf, for each transition ๐ = (โsrc, ๐, ๐น1, ๐น2, . . . , ๐น๐ ), where๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉ, the algorithm symbolically computes
the following universally-quantified constraint and calls it
ฮ๐:
โv โ R๐ . v |= ๐ผ (โsrc) โง ๐ โ (3)
\ (โsrc, v) โฅ โ๐๐=1 ๐ ๐ ยท Er [\ (โdst๐ , upd๐ (v, r))] .
Intuitively, ฮ๐requires that for every valuation v that sat-
isfies the invariant and the guard of transition ๐, the pre
fixed-point condition must be satisfied after going along ๐ .
Example 4. Continuing with the previous example, consider
the transition ๐ from โswitch. The invariant for โswitch is (๐ฅ โค99 โง ๐ฆ โค 99) and the transition guard is ๐ = true. Thus,
every state (โswitch, v) that takes this transition must satisfy
(๐ฅ โค 99โง๐ฆ โค 99). The algorithm computes the pre fixed-point
constraint ฮ๐as follows:
โ๐ฅ,๐ฆ โ R. (๐ฅ โค 99 โง ๐ฆ โค 99) โ\ (โ
switch, ๐ฅ,๐ฆ) โฅ 0.5 ยท \ (โinit, ๐ฅ + 1, ๐ฆ + 2) + 0.5 ยท \ (โinit, ๐ฅ + 1, ๐ฆ) .
Step 3 (Canonicalization). The algorithm transforms every
constraint of Step 2 into the following canonical form:
โv โ R๐ . (v โ ฮจ) โ ฮ๐,๐ผ,๐ฝ,๐พโณ (v),
where ฮจ is a polyhedron in R๐ and ฮ๐,๐ผ,๐ฝ,๐พโณ (v) involves ex-
ponential terms on unknown coefficients and program vari-
ables, and is defined as:
ฮ๐,๐ผ,๐ฝ,๐พโณ (v) :=(
๐โ๐=1
๐ ๐ ยท exp(๐ผ ๐ ยท v + ๐ฝ ๐
)ยท Er
[exp
(๐พ ๐ ยท r
) ]โค 1
).
Here, ๐ผ ๐ , ๐ฝ ๐ , ๐พ ๐ are affine expressions over unknown coeffi-
cients, and ๐ ๐ โ [0, +โ). We denote such a canonical con-
straint as๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโณ ). We now show how the algorithm
canonicalizes every constraint of Step 2. Consider the for-
mula in (3). The algorithm expands it based on the template:
exp([ (โsrc, v)) โฅ โ๐๐=1 ๐ ๐ ยท Er
[exp
([ (โdst๐ , upd๐ (v, r))
)]Now suppose that upd๐ (v, r) := Q๐v+R๐ r+e๐ . By further ex-panding both sides based on the template for [ and dividing
them by the left-hand-side, the algorithm obtains:โ๐๐=1 ๐ ๐ ยท exp
(๐ผ ๐ ยท v + ๐ฝ ๐
)ยท Er
[exp
(๐พ ๐ ยท r
) ]โค 1
where ๐ผ ๐ := aโdst๐Q๐ โ aโsrc , ๐ฝ ๐ := ๐โdst
๐โ aโdst
๐ยท e๐ โ ๐โsrc ,
and ๐พ ๐ := aโdst๐R๐ are affine expressions over the unknown
coefficients.
Example 5. Continuing with the previous example, by plug-
ging in the template, the algorithm obtains:
exp(๐โswitchยท v + ๐โ
switch) โฅ
0.5 ยท exp(๐โinit ยท (v + [1 2]๐ ) + ๐โinit )+
0.5 ยท exp(๐โinit ยท (v + [1 0]๐ ) + ๐โinit )which it then rewrites equivalently as:
0.5 ยท exp(๐ผ ยท v + ๐ฝ1) + exp(๐ผ ยท v + ๐ฝ2) โค 1
where ๐ผ = aโinit โ aโswitch
, ๐ฝ1 = aโinit ยท [1 2]๐ + ๐โinit , ๐ฝ2 = aโinit ยท[1 0]๐ + ๐โinit are affine expressions. Let ฮจ be the polyhedron defined
by inequalities ๐ฅ โค 99โง๐ฆ โค 99. Then, ฮจ forms a canonical constraint
together with the inequality above.
Step 4 (Quantifier Elimination). In this step, the algo-
rithm eliminates the universal quantifier in the canonical
constraints. Our elimination technique relies on the decom-
position theorem (Theorem 5.3) to decompose a polyhedron
and Farkasโ Lemma (Theorem 2) to deal with linear con-
straints.
For each canonical constraint, the algorithmfirst computes
a decomposition of ฮจ as a Minkowski sum of a polytope ๐
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
and a polyhedral cone ๐ถ and then transforms the constraint
using the following proposition:
Proposition 1 (Proof in Appendix C). Given a canonical
constraint๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโณ ), the polyhedron ฮจ = {v | Mv โค d}
can be decomposed as ฮจ = ๐ +๐ถ , where ๐ is a polytope and
๐ถ = {v | Mv โค 0}. Then, ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโณ ) is satisfied iff:
(D1) โ๐, v. Cv โค 0โ ๐ผ ๐ ยท v โค 0, and
(D2) For every generator vโ of ๐ , vโ |= ฮ๐,๐ผ,๐ฝ,๐พโณ (vโ).
Proof Sketch. For the if part, pick any v โ ฮจ, by Theorem 5.3,
v = v1 + v2, where Mv1 โค 0 and v2 โ ๐. By plugging in vwith v1 + v2 into ฮโณ and the convexity of exp(ยท), we provethat ฮ
๐,๐ผ,๐ฝ,๐พโณ (v) holds. For the only if part, if๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พ
โณ )is satisfied, (D2) is true since ๐ โ ฮจ. We prove (D1) by
contradiction. Suppose there exists v โ ๐ถ and ๐ such that
๐ผ ๐ ยท v > 0, choose any v0 โ ๐ and consider ฮ๐,๐ผ,๐ฝ,๐พโณ (๐กv + v0)
for ๐ก โฅ 0. By taking ๐ก โ โ, ฮ๐,๐ผ,๐ฝ,๐พโณ (๐กv + v0) would be
eventually violated, causing a contradiction. โก
The algorithm computes (D1) and (D2). It translates (D1)
to linear constraints using Lemma 2, and utilizes the double
description method [2] to find all generators of ๐ and write
(D2) as a conjunction of finitely many convex inequalities.
Example 6. Again, continuing with the previous example,
the algorithm decomposes ฮจ into {(๐ฅ,๐ฆ) | ๐ฅ โค 0 โง ๐ฆ โค 0}and the polytope generated by a single point {(99, 99)} by the
algorithm in [2]. Then, it decomposes ฮ๐,๐ผ,๐ฝ,๐พโณ into:
โ๐ฅ,๐ฆ โ R. ๐ฅ โค 0 โง ๐ฆ โค 0โ ๐ผ โค 0, and
0.5 ยท(exp(๐ผ ยท [99 99]๐ + ๐ฝ1) + exp(๐ผ ยท [99 99]๐ + ๐ฝ2)
)โค 1
It then reduces the former to a conjunction of linear constraints
on the unknown coefficients by Farkasโ Lemma.
Step 5 (Optimization). After the steps above, all quantified
canonical formulas are now reduced to a set of convex in-
equalities without quantifiers. To infer a tight upper-bound,
our algorithm solves the following optimization problem ฮover the unknown variables defined in Step 1:
Minimize exp(๐โinit ยท vinit + ๐โinit ) (4)
Subject to the constraints obtained in Step 4 above.
It calls an external solver to obtain the optimal solution.
Theorem 5.4 (Proof in Appendix C). ฮ is a convex optimiza-
tion problem.
Proof. Every constraint of Step 4 is either linear or of the
form ๐ฟ โค 1where ๐ฟ is a non-negative combination of convex
functions. This is due to the convexity of exp(ยท). โก
So, we can use convex optimization tools to solve ฮ. It isstraightforward to verify the soundness of ExpLinSyn. Ouralgorithm is also complete, formally:
Theorem 5.5. Given an affine PTS, an affine invariant, and
๐ > 0, ExpLinSyn outputs an ๐-optimal solution for the un-
known coefficients in an exponential template with affine ex-
ponent.
Proof. This follows from Proposition 1 that equivalently
transforms the original synthesis into convex optimization.
โก
Remark 4. The completeness is w.r.t exponential templates
with affine exponent, i.e. ExpLinSyn can derive an approx-
imately optimal template within any additive error bound.
Thus, the completeness is not related to decidability.
Efficiency. Theoretically, the costliest step of our algorithm
is Step 3, because it requires the computation of decom-
positions of the polyhedra, which may cause exponential
blow-up. In practice, the constraint size after decomposition
rarely explodes in real-world instances. So, our algorithm
inherits the well-known efficiency of convex programming.
Generality. Our algorithm is applicable to all cases in which
we can expand Er [exp(๐พ ๐ ยท r)] =โ
๐ โ๐ E๐ [exp(๐พ ๐,๐ ยท ๐ )] intoa simple closed form. Hence, it can handle all discrete distri-
butions andmanywidely-used continuous distributions such
as uniform distribution. For ๐ โผ uniform[๐, ๐], E๐ [exp(๐พ ๐,๐ ยท๐ )] = 1
๐พ ๐,๐ยท (exp(๐ ยท ๐พ ๐,๐ ) โ exp(๐ ยท ๐พ ๐,๐ )) is the closed form.
6 An Algorithmic Approach to LQAVA
In this section, we provide an efficient and automated al-
gorithm for LQAVA over affine PTSs with affine invariants.
Recall that in Section 4, under the assumption of almost-sure
termination, we succeeded in reducing the LQAVA prob-
lem to the synthesis of a post fixed-point (See Theorems 4.1
and 4.4).
Unlike our algorithm for pre fixed-point synthesis (Sec-
tion 5), exponential post fixed-point synthesis can no longer
be transformed into convex optimization. Instead, we pro-
pose a sound but incomplete algorithm that synthesizes expo-
nential post fixed-point functions with linear exponents. Our
algorithm transforms the problem to linear programming by
applying Jensenโs inequality.
Theorem6.1 (Jensenโs inequality [49]). For any convex func-
tion ๐ and random variable ๐ , we have E[๐ (๐ )] โฅ ๐ (E[๐ ]).
The ExpLowSynAlgorithm. Our algorithm synthesizes an
exponential lower-bound for assertion violation in five steps:
Step 1 (Setting up templates). Similar to our previous al-
gorithms in Section 5, the algorithm introduces unknown
coefficients ยฎaโ , ๐โ for every location โ โ L, and symbolically
computes the template \ (โ, v) := exp(aโ ยท v + ๐โ ) for everyโ โ {โf , โt}. As usual, it lets \ (โt, v) โก 0 and \ (โf , v) โก 1.
Example 7. We now illustrate our algorithm on the program
in Figure 3. As in Example 3, the algorithm introduces unknown
coefficients aโinit , aโswitch , aโassert and ๐โinit , ๐โassert , ๐โswitch .
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
Step 2 (Bounding). Note that Theorem 4.4 requires that
\ be bounded. To ensure this, the algorithm introduces a
new unknown coefficient ๐ and generates the following
constraint for every โ โ L:โv โ R๐ . v |= ๐ผ (โ) โ aโ ยท v + ๐โ โค ๐.
Example 8. Continuing from Example 7, the algorithm in-
troduces a new unknown coefficient๐ and sets up a constraint
for every location. For example, for โinit, whose invariant is
(๐ฅ โค 100), it generates the following constraint:โ๐ฅ โ R. ๐ฅ โค 100โ aโinit + ๐โinit ยท ๐ฅ โค ๐.
Step 3 (Collecting constraints and canonicalization). Sim-
ilar to Section 5.2, the algorithm generates constraints that
model the post fixed-point conditions. For every transition,
the constraint is identical with Equation 3, except that โฅis replaced with โค. The algorithm then applies the same
canonicalization as in Step 3 of Section 5.2, i.e. the constraint
is transformed into the canonical form ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโฒ ), in
which ฮ๐,๐ผ,๐ฝ,๐พโฒ is ฮ
๐,๐ผ,๐ฝ,๐พโณ with โค replaced by โฅ.
Example 9. Continuing with Example 8, consider the unique
transition out of โswitch. The algorithm generates
โ๐ฅ โ R. ๐ฅ โค 99โ\ (โswitch, ๐ฅ) โค ๐ ยท \ (โt, ๐ฅ) + 0.75(1 โ ๐) ยท \ (โinit, ๐ฅ + 1)
+ 0.25(1 โ ๐) ยท \ (โinit, ๐ฅ โ 1).
It writes this constraint in canonical form ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโฒ ),
where ฮจ = (๐ฅ โค 99), and ฮ๐,๐ผ,๐ฝ,๐พโฒ is as follows:
0.25 ยท (1 โ ๐) ยท (3 ยท exp(๐ผ ยท ๐ฅ + ๐ฝ1) + exp(๐ผ ยท ๐ฅ + ๐ฝ2)) โฅ 1
in which ๐ผ = aโinitโaโswitch , ๐ฝ1 = aโinit +๐โinit and ๐ฝ2 = ๐โinitโaโinitare affine expressions over unknown coefficients.
Step 4 (Applying Jensenโs inequality). Given a canoni-
cal constraint ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโฒ ), the algorithm strengthens
ฮ๐,๐ผ,๐ฝ,๐พโฒ to a conjunction of linear inequalities. For ฮ
๐,๐ผ,๐ฝ,๐พโฒ as
below:โ๐๐=1 ๐ ๐ ยท exp
(๐ผ ๐ ยท v + ๐ฝ ๐
)ยท Er
[exp
(๐พ ๐ ยท r
) ]โฅ 1
it divides both sides by ๐ :=โ๐
๐=1 ๐ ๐ , and applies Theo-
rem 6.1, deriving the strengthened form ฮ๐,๐ผ,๐ฝ,๐พ
โฒ :
๐โ1 ยทโ๐๐=1 ๐ ๐ ยท
(๐ผ ๐ ยท v + ๐ฝ ๐ + ๐พ ๐ ยท Er [r]
)โฅ โ ln๐
Since ๐ผ ๐ , ๐ฝ ๐ , ๐พ ๐ are affine expressions, ฮ๐,๐ผ,๐ฝ,๐พ
โฒ is a linear in-
equality over our unknown coefficients. Note that this strength-
ening is sound but incomplete, i.e. if ฮ๐,๐ผ,๐ฝ,๐พ
โฒ is satisfied, then
so is ฮ๐,๐ผ,๐ฝ,๐พโฒ , because we can apply Jensenโs inequality with
exponential ๐ . However, the converse may not hold.
Example 10. Continuing with Example 9, as per Jensenโs in-
equality, the algorithm derives the strengthened form ฮ๐,๐ผ,๐ฝ,๐พ
โฒ :
0.75 ยท (๐ผ ยท ๐ฅ + ๐ฝ1) + 0.25 ยท (๐ผ ยท ๐ฅ + ๐ฝ2) โฅ โ ln(1 โ ๐).
Step 5 (Farkasโ Lemma and LP). The algorithm directly
applies Lemma 2 to convert every constraint generated in
Steps 2 and 4 into an equivalent conjunction of linear con-
straints over the unknown coefficients. Finally, it uses linear
programming to solve these linear constraints. In order to
obtain as tight a lower-bound as possible, the LP instance
is solved with the objective of maximizing aโinit ยท vinit + ๐โinit .Finally, the algorithm plugs the LP solutions back into the
template and reports exp(aโinit ยท vinit + ๐โinit ) as the desiredbound.
Theorem 6.2 (Soundness). Given an affine almost-surely
terminating PTS ฮ and an affine invariant ๐ผ , the solution of the
algorithm above is a bounded post fixed-point, and exp(aโinit ยทvinit +๐โinit ) is a lower-bound on assertion violation probability.
Proof Sketch. The constraints in Step 2 ensure the bounded-
ness of \ . By Theorem 6.1, the strengthening in Step 4 is
sound. By (2) in Theorem 4.1, the desired result is obtained.
See Appendix D for details. โก
Complexity. We now analyze the time complexity of Ex-pLowSyn. In Step 5 we apply Farkasโ Lemma, which takes
polynomial time. It is straightforward to verify that the sym-
bolic computations in all other steps take polynomial time,
as well. Finally, since LP can be solved in polynomial time,
we conclude that our algorithm runs in polynomial time with
respect to the size of the input PTS and invariant.
Remark 5 (The Polynomial Case). Similar to Remark 3, Ex-pLowSyn can also be extended to polynomial exponents via
Positivstellensรคtze and semidefinite programming.
7 Experimental ResultsImplementation. We implemented our algorithms in C++
and Matlab, and used PPL 1.2 [2] for Minkowski decompo-
sitions and CVX 2.2 [21, 22] for linear/convex optimization.
All results were obtained on an Intel Core i7-8700K (3.7 GHz)
machine with 32 GB of memory, running MS Windows 10.
Benchmarks. We consider the following benchmarks from
a variety of application domains [5, 6, 10โ12, 34, 41]:
โข Deviation: In these benchmarks, taken from [6], the goal
is to infer upper-bounds on the probability of large devia-
tion of a program variable from its expected value upon
termination. We compare the bounds obtained by our al-
gorithms with those provided by [6].
โข Concentration: In this category, the goal is to derive
upper-bounds on the probability that a probabilistic pro-
gram does not terminate within a given number of steps.
The programs are taken from [11, 34], and we compare
our results with those of [11].
โข StoInv: Stochastic invariants are closely related to and
useful for deriving upper-bounds on the assertion violation
probability. We take three benchmarks, namely 1DWalk,
2DWalk, and 3DWalk, from [12] and also include our
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
motivating example Race of Section 3.1. We compare our
derived upper-bounds with those of [12].
โข Hardware: These benchmarks require lower-bounds on
the probability that a program run on unreliable hardware
terminates successfully, i.e. runs without errors until termi-
nation. The two benchmarks Ref and Newton are taken
from [5, 41], whereasM1Dwalk is our motivating example
in Section 3.3. We made necessary abstractions to make
the program fit into our framework, but we guarentee that
the lower bound for abstracted program is also feasible for
the original. When the data is available, we compare our
derived lower-bounds with those from [5, 41].
See Appendix E for details of benchmarks.
Invariants and Termination. We manually derived affine
invariants for the input PTSs. Alternatively, invariant gen-
eration, which is an orthogonal problem to ours, can be
automated by approaches such as [9, 26, 44, 50]. Similarly,
we proved almost-sure termination by manually construct-
ing ranking supermartingales [6, 11]. Proving almost-sure
termination can also be automated by previous works such
as [6, 8, 11, 24, 33].
Parameters. Each benchmark set has distinct parameters:
For Deviation and Concentration the parameter is the
deviation bound. For StoInv, the parameters are the initial
values of program variables. For Hardware, the parameter
is the probability of failure in each iteration.
Results. Our experimental results are summarized in Ta-
bles 1 and 2. โNo resultโ means there is no previous experi-
mental result reported and no available implementations to
obtain such results. โNot applicableโ means the benchmark
is outside the theoretical framework of the previous work.
Note that in the Hardware examples, the data was only
available for ๐ = 10โ7
in the literature and we could not find
a public implementation of the approach. See Appendix E
for more technical details.
Discussion. The experimental results show that our upper-
bounds significantly beat the previous methods. Our algo-
rithm from Section 5.2, which is complete, consistently and
significantly outperforms previous methods on all the bench-
marks. The ratio of the bounds ranges from 1.07 to 1.3ยท102069,i.e. 2069 orders of magnitude! Moreover, it achieves this in
a maximum runtime of 1.72 seconds, which demonstrates
its efficiency in practice. On the other hand, our other algo-
rithm (Section 5.1), which is provably polynomial-time but
not complete, synthesizes slightly looser bounds than [6] in
a number of cases. We believe this is because [6] is specific
to probabilistic programs with a fixed number of iterations,
while our algorithm is applicable to general probabilistic
programs. In case of lower-bounds, we are providing the
first automated algorithm. As such, there is very little data
available from previous sources (i.e. only for Ref). In this
case, we also beat previous methods by a factor of 3.33.
8 Related Works
Probability Bounds for Assertion Violation. This prob-
lem was first considered in [6], where it was shown that
exponentially-decreasing upper bounds for the probability of
large deviation from expected values can be derived through
concentration inequalities and automatically generated us-
ing supermartingales. Then, [8, 11] introduced a sound ap-
proach for deriving exponentially-decreasing upper bounds
for the concencentration of termination time through con-
centration inequalities, and developed automated algorithms
through linear and polynomial ranking supermartingales.
For probabilistic programs that may not have exponentially
decreasing concentration, sound approaches for deriving
polynomial and square-root reciprocal upper bounds are
introduced in [7, 24, 30, 47]. QAVA was formally proposed
in [12] as stochastic invariants, where concentration inequal-
ities were utilized to derive upper bounds for the probability
of assertion violation and the synthesis of linear repulsive
ranking supermartingales was adopted as the main algo-
rithmic technique. Later, probabilistic assertion violation
analysis was considered as accuracy analysis in [41] and an
automata-based algorithm was proposed for loops with fixed
number of iterations. In our approach, we introduce novel
fixed-point theorems for reasoning about both probability
upper and lower bounds, and then develop new algorithmic
techniques for synthesizing exponential templates that rep-
resent pre and post fixed-points. Hence, compared with the
above previous results, we have the following novelties:
โข our method is based on new insights in fixed-point theory
rather than concentration inequalities or automata theory;
โข our approach derives both upper and lower bounds, while
previous work only derive upper bounds;
โข we consider exponential templates that best match the
situation where assertion violation probability decreases
exponentially w.r.t certain amount.
โข we devise new algorithms for solving the exponential tem-
plates, including an algorithm that provides completeness
in solving the template when the probabilistic program is
affine and the exponent in the template is linear;
โข we prove in theory that the bounds generated by our ap-
proach is surely better than those from [12];
โข the experimental results show that the bounds generated
by our approaches are much better than previous results.
Expectation Bounds. There are also many results on ex-
pectation bounds for probabilistic programs, such as those
based on fixed-point theorems [34, 48], optional stopping
theorems [10, 19, 48] and limit characterization [29, 35]. Al-
though assertion violation probabilities can be treated as
expectation of indicator random variables that represent
reachability to assertion violation, there are fundamental
differences between our approach and these results.
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
Benchmark ParametersAlgorithm of Section 5.1 Algorithm of Section 5.2
Previous Results RatioUpper-bound Time (s) Upper-bound Time (s)
Deviation RdAdder
Pr[๐ โ E[๐ ] โฅ 25] 7.54 ยท 10โ2 57.45 7.43 ยท 10โ2 0.95 8.00 ยท 10โ2 1.07
Pr[๐ โ E[๐ ] โฅ 50] 3.95 ยท 10โ5 58.05 3.54 ยท 10โ5 0.99 4.54 ยท 10โ5 1.28
Pr[๐ โ E[๐ ] โฅ 75] 1.44 ยท 10โ10 57.45 9.17 ยท 10โ11 0.91 1.69 ยท 10โ10 1.84
Robot
Pr[๐ โ E[๐ ] โฅ 1.8] 1.66 ยท 10โ1 127.00 9.64 ยท 10โ6 1.72 2.04 ยท 10โ5 2.11
Pr[๐ โ E[๐ ] โฅ 2.0] 6.81 ยท 10โ3 124.02 4.78 ยท 10โ7 1.27 1.62 ยท 10โ6 3.39
Pr[๐ โ E[๐ ] โฅ 2.2] 5.66 ยท 10โ5 125.72 1.51 ยท 10โ8 1.24 9.85 ยท 10โ8 6.52
Concentration
Coupon
Pr[๐ > 100] 1.02 ยท 10โ1 80.52 7.01 ยท 10โ5 1.24 6.00 ยท 10โ3 85.59
Pr[๐ > 300] 4.02 ยท 10โ5 81.41 7.44 ยท 10โ22 1.41 9.01 ยท 10โ10 1.21 ยท 1012
Pr[๐ > 500] 1.40 ยท 10โ8 80.80 4.01 ยท 10โ40 1.23 1.05 ยท 10โ16 2.61 ยท 1023
Prspeed
Pr[๐ > 150] 5.42 ยท 10โ7 108.66 7.43 ยท 10โ23 1.44 5.00 ยท 10โ3 6.72 ยท 1019
Pr[๐ > 200] 1.89 ยท 10โ10 106.82 8.03 ยท 10โ36 1.19 2.59 ยท 10โ5 3.23 ยท 1030
Pr[๐ > 250] 5.65 ยท 10โ14 108.09 2.71 ยท 10โ49 1.09 9.17 ยท 10โ8 3.38 ยท 1041
Rdwalk
Pr[๐ > 400] 1.85 ยท 10โ3 44.44 2.12 ยท 10โ7 0.55 3.18 ยท 10โ6 17.19
Pr[๐ > 500] 1.43 ยท 10โ5 50.89 1.57 ยท 10โ12 0.58 1.40 ยท 10โ10 89.17
Pr[๐ > 600] 5.47 ยท 10โ8 49.16 4.81 ยท 10โ18 0.66 2.68 ยท 10โ15 557.17
StoInv
1DWalk
๐ฅ = 10 1.73 ยท 10โ64 48.44 7.82 ยท 10โ208 1.19 5.1 ยท 10โ5 6.52 ยท 10202
๐ฅ = 50 6.77 ยท 10โ62 41.86 1.79 ยท 10โ199 1.08 1.0 ยท 10โ4 5.59 ยท 10194
๐ฅ = 100 1.04 ยท 10โ58 41.18 5.03 ยท 10โ189 0.97 2.5 ยท 10โ4 4.97 ยท 10184
2DWalk
(๐ฅ, ๐ฆ) = (1000, 10) 4.14 ยท 10โ73 53.69 1 ยท 10โ655 1.35 2.4 ยท 10โ11 2.4 ยท 10644
(๐ฅ, ๐ฆ) = (500, 40) 6.43 ยท 10โ37 53.00 9.61 ยท 10โ278 1.03 5.5 ยท 10โ4 5.72 ยท 10273
(๐ฅ, ๐ฆ) = (400, 50) 1.11 ยท 10โ29 52.58 1.02 ยท 10โ218 1.37 1.9 ยท 10โ2 1.86 ยท 10216
3DWalk
(๐ฅ,๐ฆ,๐ง) = (100,100,100) 4.83 ยท 10โ281 85.07 1 ยท 10โ3230 1.20 4.4 ยท 10โ17 4.4 ยท 103213
(๐ฅ,๐ฆ,๐ง) = (100,150,200) 6.66 ยท 10โ221 84.86 1 ยท 10โ2538 1.25 2.9 ยท 10โ9 2.9 ยท 102529
(๐ฅ,๐ฆ,๐ง) = (300,100,150) 7.86 ยท 10โ181 83.28 1 ยท 10โ2076 1.37 1.3 ยท 10โ7 1.3 ยท 102069
Race
(๐ฅ, ๐ฆ) = (40, 0) 9.08 ยท 10โ4 55.24 1.52 ยท 10โ7 0.89 No result โ
(๐ฅ, ๐ฆ) = (35, 0) 6.84 ยท 10โ3 54.23 2.16 ยท 10โ5 0.78 No result โ
(๐ฅ, ๐ฆ) = (45, 0) 6.65 ยท 10โ5 56.39 8.65 ยท 10โ11 0.67 No result โ
Table 1. Our Experimental Results for Upper-bound Benchmarks. The last column isprevious bound
our bound.
Benchmark ParametersAlgorithm of Section 6
Previous Results RatioLower-bound Time (s)
Hardware
M1DWalk
๐ = 10โ7
0.999984 0.64 Not applicable โ
๐ = 10โ5
0.998401 0.73 Not applicable โ
๐ = 10โ4
0.984126 0.54 Not applicable โ
Newton
๐ = 5 ยท 10โ4 0.728492 0.72 No result โ
๐ = 10โ3
0.534989 1.20 No result โ
๐ = 1.5 ยท 10โ3 0.392823 0.67 No result โ
Ref
๐ = 10โ7
0.998463 1.03
0.994885 in [5]
0.992832 in [41]
3.33
4.66
๐ = 10โ6
0.984738 1.03 No result โ
๐ = 10โ5
0.857443 1.14 No result โ
Table 2. Our Experimental Results for Lower-bound Benchmarks. The last column is1โprevious bound
1โour bound .
โข Compared with the results using fixed-point theorems (e.g.
[34, 48]), the main strengths of our approach are: (i) we
develop new fixed-point theorems that can derive both
upper and lower bounds, while the classical least-fixed-
point characterization only provides upper bounds; and (ii)
we consider exponential templates and devise algorithmic
approaches that can solve them with completeness, while
previous results only consider polynomial templates.
โข On the other hand, the results using optional stopping the-
orems (e.g. [10, 19, 48]) are difficult to apply to probability
bounds of assertion violation. This is because in optional
stopping theorems, one usually needs to interpret the ran-
dom variable ๐๐ w.r.t a stochastic process ฮ = ๐0, ๐1, . . .
and a stopping time ๐ , but for assertion violation it is dif-
ficult to find a suitable interpretation for ๐๐ where the
stochastic process ฮ is typically defined by a template [
(i.e. ๐๐ := [ (๐ฃ๐) where ๐ฃ๐ is the valuation at ๐-th step).
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
โข Finally, the results using limit characterization [29, 35]
require to build an infinite sequence of expressions that
converges to certain limit. As such, they are difficult to
automate. In contrast, our approach is entirely automated
by constructing templates at each program counter and
reducing the problem to optimization tasks.
Probability Bounds in Hybrid Systems. There are also
several results that consider concentration bounds for hybrid
systems [16, 43]. [43] also considers the synthesis of expo-
nential templates. However, it only considers exponential
templates in a very specific form, i.e the exponent is a positive
semidefinite quadratic polynomial. In contrast, we use Ho-
effdingโs Lemma and Jensenโs inequality to handle exponents
in general form, and a novel convex optimization technique
to completely solve the case that the both exponent and the
underlying probabilistic program are affine. [16] considers
concentration bounds of stochastic differential equations
and reduces the problem to semidefinite programming. Thus
it is completely different from our approach.
9 Conclusion and Future workIn this work, we considered the problem of deriving quanti-
tative bounds for assertion violation probabilities in proba-
bilistic programs. We established novel fixed-point theorems
for upper and lower bounds on the assertion violation prob-
ability and presented three algorithms for deriving bounds
in exponential form, one through RepRSMs and Hoeffdingโs
Lemma, one through convex programming, and one through
Jensenโs inequality. The experimental results show that our
derived upper and lower bounds are much tighter than pre-
vious results. An interesting direction for future work is to
explore other, perhaps more expressive, forms of bounds. An-
other future direction is to study compositional verification
methods for bounding assertion violation probabilities.
References[1] Sheshansh Agrawal, Krishnendu Chatterjee, and Petr Novotnรฝ. 2018.
Lexicographic ranking supermartingales: an efficient approach to ter-
mination of probabilistic programs. PACMPL 2, POPL (2018), 34:1โ
34:32.
[2] Roberto Bagnara, Elisa Ricci, Enea Zaffanella, and Patricia M. Hill.
2002. Possibly Not Closed Convex Polyhedra and the Parma Polyhedra
Library. In SAS (Lecture Notes in Computer Science), Vol. 2477. Springer,
213โ229. https://doi.org/10.1007/3-540-45789-5_17[3] Olivier Bournez and Florent Garnier. 2005. Proving Positive Almost-
Sure Termination. In RTA. 323โ337.
[4] Tomรกs Brรกzdil, Stefan Kiefer, Antonรญn Kucera, and Ivana Hutarovรก
Varekovรก. 2015. Runtime analysis of probabilistic programs with
unbounded recursion. J. Comput. Syst. Sci. 81, 1 (2015), 288โ310.
[5] Michael Carbin, Sasa Misailovic, and Martin C. Rinard. 2013. Verify-
ing quantitative reliability for programs that execute on unreliable
hardware. In OOPSLA. ACM, 33โ52. https://doi.org/10.1145/2509136.2509546
[6] Aleksandar Chakarov and Sriram Sankaranarayanan. 2013. Probabilis-
tic Program Analysis with Martingales. In CAV. 511โ526.
[7] Krishnendu Chatterjee and Hongfei Fu. 2017. Termination of Nonde-
terministic Recursive Probabilistic Programs. CoRR abs/1701.02944
(2017).
[8] Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady.
2016. Termination Analysis of Probabilistic Programs Through Posi-
tivstellensatzโs. In CAV 2016. 3โ22.
[9] Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and
Ehsan Kafshdar Goharshady. 2020. Polynomial invariant generation
for non-deterministic recursive programs. In PLDI. ACM, 672โ687.
https://doi.org/10.1145/3385412.3385969[10] Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and
Nastaran Okati. 2018. Computational Approaches for Stochastic Short-
est Path on Succinct MDPs. In IJCAI 2018. 4700โ4707.
[11] Krishnendu Chatterjee, Hongfei Fu, Petr Novotnรฝ, and Rouzbeh
Hasheminezhad. 2018. Algorithmic Analysis of Qualitative and
Quantitative Termination Problems for Affine Probabilistic Programs.
TOPLAS 40, 2 (2018), 7:1โ7:45.
[12] Krishnendu Chatterjee, Petr Novotnรฝ, and รorฤe ลฝikeliฤ. 2017. Sto-
chastic invariants for probabilistic termination. In POPL 2017. 145โ160.
[13] Guillaume Claret, Sriram K Rajamani, Aditya V Nori, Andrew D Gor-
don, and Johannes Borgstrรถm. 2013. Bayesian inference using data
flow analysis. In Joint Meeting on Foundations of Software Engineering.
ACM, 92โ102.
[14] Javier Esparza, Andreas Gaiser, and Stefan Kiefer. 2012. Proving Ter-
mination of Probabilistic Programs Using Patterns. In CAV. 123โ138.
[15] J. Farkas. 1894. A Fourier-fรฉle mechanikai elv alkalmazรกsai (Hungar-
ian). Mathematikaiรฉs Termรฉszettudomรกnyi รrtesitรถ 12 (1894), 457โ472.
[16] Shenghua Feng, Mingshuai Chen, Bai Xue, Sriram Sankaranarayanan,
and Naijun Zhan. 2020. Unbounded-Time Safety Verification of Sto-
chastic Differential Dynamics. In CAV (Lecture Notes in Computer
Science), Vol. 12225. Springer, 327โ348. https://doi.org/10.1007/978-3-030-53291-8_18
[17] Luis Marรญa Ferrer Fioriti and Holger Hermanns. 2015. Probabilistic Ter-
mination: Soundness, Completeness, and Compositionality. In POPL.
489โ501.
[18] Nate Foster, Dexter Kozen, Konstantinos Mamouras, Mark Reitblatt,
and Alexandra Silva. 2016. Probabilistic NetKAT. In ESOP 2016.
Springer, 282โ309.
[19] Hongfei Fu and Krishnendu Chatterjee. 2019. Termination of Nonde-
terministic Probabilistic Programs. In VMCAI. 468โ490.
[20] Andrew D Gordon, Thomas A Henzinger, Aditya V Nori, and Sriram K
Rajamani. 2014. Probabilistic programming. In Proceedings of the on
Future of Software Engineering. ACM, 167โ181.
[21] Michael Grant and Stephen Boyd. 2008. Graph implementations for
nonsmooth convex programs. In Recent Advances in Learning and
Control, V. Blondel, S. Boyd, and H. Kimura (Eds.). Springer-Verlag
Limited, 95โ110. http://stanford.edu/~boyd/graph_dcp.html.[22] Michael Grant and Stephen Boyd. 2014. CVX: Matlab Software for
Disciplined Convex Programming, version 2.1. http://cvxr.com/cvx.[23] Marcel Hark, Benjamin Lucien Kaminski, Jรผrgen Giesl, and Joost-Pieter
Katoen. 2020. Aiming low is harder: induction for lower bounds in
probabilistic program verification. In POPL. 37:1โ37:28.
[24] Mingzhang Huang, Hongfei Fu, and Krishnendu Chatterjee. 2018. New
Approaches for Almost-Sure Termination of Probabilistic Programs.
In APLAS. 181โ201.
[25] Mingzhang Huang, Hongfei Fu, Krishnendu Chatterjee, and Amir Kaf-
shdar Goharshady. 2019. Modular verification for almost-sure termina-
tion of probabilistic programs. Proc. ACM Program. Lang. 3, OOPSLA
(2019), 129:1โ129:29. https://doi.org/10.1145/3360555[26] Bertrand Jeannet and Antoine Minรฉ. 2009. Apron: A Library of
Numerical Abstract Domains for Static Analysis. In CAV (Lecture
Notes in Computer Science), Vol. 5643. Springer, 661โ667. https://doi.org/10.1007/978-3-642-02658-4_52
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
[27] David M. Kahn. 2017. Undecidable Problems for Probabilistic Network
Programming. In MFCS 2017. 68:1โ68:17.
[28] Benjamin Lucien Kaminski and Joost-Pieter Katoen. 2015. On the
Hardness of Almost-Sure Termination. In MFCS. 307โ318. https://doi.org/10.1007/978-3-662-48057-1_24
[29] Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja,
and Federico Olmedo. 2018. Weakest Precondition Reasoning for
Expected Runtimes of Randomized Algorithms. J. ACM 65, 5 (2018),
30:1โ30:68. https://doi.org/10.1145/3208102[30] Satoshi Kura, Natsuki Urabe, and Ichiro Hasuo. 2019. Tail Probabil-
ities for Randomized Program Runtimes via Martingales for Higher
Moments. In TACAS (Lecture Notes in Computer Science), Vol. 11428.
Springer, 135โ153.
[31] Colin McDiarmid. 1998. Concentration. In Probabilistic Methods for
Algorithmic Discrete Mathematics. 195โ248.
[32] Annabelle McIver and Carroll Morgan. 2005. Abstraction, Refinement
and Proof for Probabilistic Systems. Springer.
[33] Annabelle McIver, Carroll Morgan, Benjamin Lucien Kaminski, and
Joost-Pieter Katoen. 2017. A new proof rule for almost-sure termi-
nation. Proceedings of the ACM on Programming Languages 2, POPL
(2017), 33.
[34] Van Chan Ngo, Quentin Carbonneaux, and Jan Hoffmann. 2018.
Bounded expectations: resource analysis for probabilistic programs.
In PLDI 2018. 496โ512.
[35] Federico Olmedo, Benjamin Lucien Kaminski, Joost-Pieter Katoen, and
Christoph Matheja. 2016. Reasoning about Recursive Probabilistic
Programs. In LICS 2016. 672โ681.
[36] DM Roy, VK Mansinghka, ND Goodman, and JB Tenenbaum. 2008.
A stochastic programming perspective on nonparametric Bayes. In
Nonparametric Bayesian Workshop, Int. Conf. on Machine Learning,
Vol. 22. 26.
[37] Davide Sangiorgi. 2011. Introduction to Bisimulation and Coinduction.
Cambridge University Press.
[38] Claus Scheiderer. 2008. Positivity and Sums of Squares: A Guide to
Recent Results. The IMA Volumes in Mathematics and its Applications
149 (2008), 271โ324.
[39] Alexander Schrijver. 1999. Theory of Linear and Integer Programming.
Wiley.
[40] Adam ลcibior, Zoubin Ghahramani, and Andrew D Gordon. 2015. Prac-
tical probabilistic programming with monads. In ACM SIGPLAN No-
tices, Vol. 50. ACM, 165โ176.
[41] Calvin Smith, Justin Hsu, and Aws Albarghouthi. 2019. Trace abstrac-
tion modulo probability. Proc. ACM Program. Lang. 3, POPL (2019),
39:1โ39:31. https://doi.org/10.1145/3290352[42] Steffen Smolka, Praveen Kumar, Nate Foster, Dexter Kozen, andAlexan-
dra Silva. 2017. Cantor meets Scott: semantic foundations for proba-
bilistic networks. In POPL 2017. 557โ571.
[43] Jacob Steinhardt and Russ Tedrake. 2012. Finite-time regional verifica-
tion of stochastic non-linear systems. Int. J. Robotics Res. 31, 7 (2012),
901โ923. https://doi.org/10.1177/0278364912444146[44] StInG [n.d.]. StInG: Stanford Invariant Generator. http://theory.
stanford.edu/~srirams/Software/sting.html.[45] Alfred Tarski. 1955. A lattice-theoretical fixpoint theorem and its
applications. Pacific J. Math. 5, 2 (1955), 285โ309.
[46] Sebastian Thrun. 2002. Probabilistic robotics. Commun. ACM 45, 3
(2002), 52โ57.
[47] Di Wang, Jan Hoffmann, and Thomas W. Reps. 2020. Tail Bound
Analysis for Probabilistic Programs via Central Moments. CoRR
abs/2001.10150 (2020). https://arxiv.org/abs/2001.10150[48] Peixin Wang, Hongfei Fu, Amir Kafshdar Goharshady, Krishnendu
Chatterjee, Xudong Qin, and Wenjun Shi. 2019. Cost analysis of
nondeterministic probabilistic programs. In PLDI. ACM, 204โ220.
https://doi.org/10.1145/3314221.3314581
[49] David Williams. 1991. Probability with martingales. Cambridge uni-
versity press.
[50] Jianan Yao, Gabriel Ryan, Justin Wong, Suman Jana, and Ronghui Gu.
2020. Learning nonlinear loop invariants with gated continuous logic
networks. In PLDI. ACM, 106โ120. https://doi.org/10.1145/3385412.3385986
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
A Appendix for Section 2A.1 Formal Definition of the PTS processDefinition 1 (PTS Process). Let ฮ be a PTS. Suppose that
{u๐ [๐ ]}๐โฅ0,๐ โ๐ is an independent collection of random vari-
ables such that each u๐ [๐ ] is the random variable that observes
the probability distribution D(๐ ) and represents the sampled
value for the sampling variable ๐ at the ๐th step.
The stochastic process ฮ induced by ฮ is a Markov process.
It is an infinite sequence {๏ฟฝ๏ฟฝ๐}๐โฅ0 of random variables such
that (i) each ๏ฟฝ๏ฟฝ๐ equals (โ๐, v๐) where โ๐ and v๐ are the ran-
dom variables that represent the current location and resp. the
current valuation for program variables at the ๐th step, and
(ii) the random variables ๏ฟฝ๏ฟฝ๐ are inductively defined as follows:
โข Initial Step. ๏ฟฝ๏ฟฝ0 = (โ0, v0) := (โinit, vinit) (i.e. a constantrandom variable).
โข Inductive Step. for each๐ โฅ 0, we have ๏ฟฝ๏ฟฝ๐+1 = (โ๐+1, v๐+1)where (โ๐+1, v๐+1) is defined as follows:โ if โ๐ โ {โt, โf }, then we have exactly one transition
โจโsrc, ๐, ๐น1, . . . , ๐น๐โฉ such that โ๐ = โsrc and v๐ |= ๐ . Inthis case, a fork ๐น ๐ = โจโdst๐ , ๐ ๐ , upd๐ โฉ is chosen with
probability๐ ๐ andwe have (โ๐+1, v๐+1) = (โdst๐ , upd๐ (v๐, u๐));โ if โ๐ โ {โt, โf } then the value of (โ๐+1, v๐+1) is taken tobe the same as that of (โ๐, v๐).
Note that the mutual-exclusiveness and completeness of transi-
tions ensure that the stochastic process {๏ฟฝ๏ฟฝ๐}๐โฅ0 is well-defined.
B Proofs of Section 4We first establish some properties of K๐
.
Proposition 2. For every 1 โค ๐ โค โ, (K๐ , โ) is a complete
lattice. Furthermore, the smallest (resp. greatest) element โฅ๐(resp.โค๐ ) is the function whose value is 0 (resp.๐) at all states
(โ, v) โ S such that โ โ {โt, โf }.
Proof. We show that every subset ^ โ K๐has an infimum
and a supremum, thus (K๐ , โ) is a complete lattice. Fix any
nonempty set ^ โ K๐, define two functions ^sup and ^ inf :
^sup (๐ฅ) := sup {๐ (๐ฅ) | ๐ โ ^}^ inf (๐ฅ) := inf {๐ (๐ฅ) | ๐ โ ^}
We now verify that ^sup and ^ inf are suprema and infima
respectively, which directly follows from the definition of
sup and inf . In detail, by definition of sup, โ๐ โ ^,โ๐ โS, ๐ (๐) โค ^sup (๐), thus ^sup is an upper bound. Moreover,
for any ๐ โ K๐. If ๐ is an upper bound of ๐ , then for โ๐ โ
^,โ๐ โ S, ๐ (๐) โค ๐(๐), then sup{๐ (๐) | ๐ โ ๐} โค ๐(๐), then^sup (๐) โค ๐(๐). Hence ^sup is the supremum. Similar for ^ inf .
Hence (K๐ , โ) is a complete lattice.
By definition, โค๐ โ K๐, and for any function ๐ โ K๐
,
since โ๐ โ S, ๐ (๐) โค ๐ = โค๐ (๐), hence ๐ โค โค๐ . Thus โค๐is the greatest element. A similar argument handles the case
of โฅ๐ . โก
We now prove some propositions on the connection of
ptf and PTS.
Proposition 3. For every 1 โค ๐ โค โ, ptf๐ : K๐ โ K๐is
a well-defined function. Furthermore, it is continuous for any
๐ , and cocontinuous for finite๐ .
Proof. Fix any 1 โค ๐ โค +โ.We first prove that ptf๐ is well-
defined. For every function ๐ โ K๐, we need to prove that
for every (โ, v), ptf๐ (๐ ) (โ, v) โ [0, ๐]. We do case analysis
on (โ, v):โข If โ = โf , then ptf๐ (๐ ) (โ, v) = 1 โ [0, ๐].โข If โ = โt, then ptf๐ (๐ ) (โ, v) = 0 โ [0, ๐].โข Otherwise, there is a unique transition๐ = (โsrc, ๐, ๐น1, ๐น2,ยท ยท ยท , ๐น๐ ) such that โ = โsrc โง v |= ๐ , where the fork ๐น ๐is โจโdst๐ , ๐ ๐ , upd๐ โฉ:
ptf๐ (๐ ) (โ, v) =๐โ๐=1
๐ ๐ ยท Er [๐ (โdst๐ , upd๐ (v, r))]
โค๐โ๐=1
๐ ๐ ยท Er [๐]
=
๐โ๐=1
๐ ๐ ยท๐
= ๐
Similarly, we can prove that ptf๐ (๐ ) (โ, v) โฅ 0. Thus, ptf๐
is well-defined. Now we prove that ptf๐ is monotone. Given
any function ๐ , ๐ such that ๐ โ ๐, by case analysis on (โ, v):โข If โ = โf , then
ptf๐ (๐ ) (โ, v) = 1 = ptf๐ (๐) (โ, v)โข If โ = โt, then
ptf๐ (๐ ) (โ, v) = 0 = ptf๐ (๐) (โ, v)โข Otherwise, there is a unique transition๐ = (โsrc, ๐, ๐น1, ๐น2,ยท ยท ยท , ๐น๐ ) such that โ = โsrc โง v |= ๐ , where the fork ๐น ๐is โจโdst๐ , ๐ ๐ , upd๐ โฉ:
ptf๐ (๐ ) (โ, v)
=
๐โ๐=1
๐ ๐ ยท Er [๐ (โdst๐ , upd๐ (v, r))]
โค๐โ๐=1
๐๐, ๐ ยท Er [๐(โdst๐ , upd๐ (v, r))]
= ptf๐ (๐) (โ, v)
Thus ptf๐ (๐ ) โ ptf๐ (๐), hence it is monotone. Next we
prove upper continuity of ptf๐ . Choose any increasing chain๐0 โ ๐1 โ ๐2 โ ยท ยท ยท and do another case analysis on (โ, v):โข If โ = โf , then
ptf๐ (โ๐โฅ0{๐๐})(โ, v) = 1 =
โ๐โฅ0
{ptf๐ (๐๐)
}(โ, v)
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
โข If โ = โt, then
ptf๐ (โ๐โฅ0{๐๐})(โ, v) = 0 =
โ๐โฅ0
{ptf๐ (๐๐)
}(โ, v)
โข Otherwise, there is a unique transition๐ = (โsrc, ๐, ๐น1, ๐น2,ยท ยท ยท , ๐น๐ ) such that โ = โsrc โง v |= ๐ , where the fork ๐น ๐is โจโdst๐ , ๐ ๐ , upd๐ โฉ:
ptf๐ (โ๐โฅ0{๐๐})(โ, v)
=
๐โ๐=1
๐ ๐ ยท Er
[(โ๐โฅ0{๐๐})(โdst๐ , upd๐ (v, r))
]=
๐โ๐=1
๐ ๐ ยท Er[sup
๐โฅ0
{๐๐ (โdst๐ , upd๐ (v, r))
}]=
๐โ๐=1
๐ ๐ ยท Er[lim
๐โโ
{๐๐ (โdst๐ , upd๐ (v, r))
}]MCT
=
๐โ๐=1
๐ ๐ ยท lim๐โโEr
[๐๐ (โdst๐ , upd๐ (v, r))
]= lim
๐โโ
๐โ๐=1
๐ ๐ ยท Er[๐๐ (โdst๐ , upd๐ (v, r))
]= lim
๐โโptf๐ (๐๐) (โ, v)
= sup
๐โฅ0
{ptf๐ (๐๐) (โ, v)
}=
โ๐โฅ0
{ptf๐ (๐๐)
}(โ, v)
The โMCTโ above denotes the monotone convergence theo-
rem. A similar argument establishes cocontinuity for finite
๐ and decreasing chains. โก
Proposition 4. Consider a PTS process ๏ฟฝ๏ฟฝ0, ๏ฟฝ๏ฟฝ1, ๏ฟฝ๏ฟฝ2, ยท ยท ยท . For ev-ery๐ โฅ 0, 1 โค ๐ โค +โ, and any function ๐ โ K๐
, ptf๐ (๐ ) (๏ฟฝ๏ฟฝ๐) =E[๐ (๏ฟฝ๏ฟฝ๐+1) | ๏ฟฝ๏ฟฝ๐]
Proof. By definition, if โ๐ = โt, then ๐ฟ๐ป๐ = 0, and โ๐+1 = โ๐ =
โt . Hence ๐ (๏ฟฝ๏ฟฝ๐+1) = 0 and ๐ ๐ป๐ = 0 = ๐ฟ๐ป๐ . The case for
โf is similar. Otherwise, suppose at ๐th step, we choose the
transition ๐ = (โsrc, ๐, ๐น1, ๐น2, ยท ยท ยท , ๐น๐ ) such that โ = โsrc โง v |=๐ , where the fork ๐น ๐ is โจโdst๐ , ๐ ๐ , upd๐ โฉ:
๐ ๐ป๐ = E
[๐โ๐=1
๐ ๐ ๐ (โdst๐ , upd๐, ๐ (v๐, r))]
=
๐โ๐=1
๐ ๐Er
[๐ (โdst๐ , upd๐ (v๐, r))
]= ๐ฟ๐ป๐
โก
If we consider iteratively applying ptf for ๐ times we de-
rive the corollary below, which is useful in applying Theorem
4.2:
Corollary B.1. For any integer ๐, and any 1 โค ๐ โค โ,ptf๐,๐ (๐ ) (โ, v) = E [๐ (๏ฟฝ๏ฟฝ๐) | ๏ฟฝ๏ฟฝ0 = (โ, v)]
where ptf๐,๐denotes the application of ptf๐ to ๐ for ๐ times.
For ๐ = 0, we define ptf๐,0 (๐ ) := ๐ .
Proof. We prove by induction.
Base case. For ๐ = 0, the result is obvious.
Induction case. Suppose the lemma holds fo ๐ = ๐0, we
prove that it also holds for ๐ = ๐0 + 1.๐ฟ๐ป๐ = E[ptf๐ (๐ ) (๏ฟฝ๏ฟฝ๐0
) | ๏ฟฝ๏ฟฝ0 = (โ, v)]= E[E[๐ (๏ฟฝ๏ฟฝ๐0+1) | ๏ฟฝ๏ฟฝ๐0
] | ๏ฟฝ๏ฟฝ0 = (โ, v)]= E[๐ (๏ฟฝ๏ฟฝ๐0+1) | ๏ฟฝ๏ฟฝ0 = (โ, v)]
The second equality is by Proposition 4. โก
B.1 Proof of Theorem 4.3Proof. Fix any 1 โค ๐ โค โ. by Proposition 3, ptf is a contin-uous function. Now by Theorem 4.2, we have:
lfp ptf๐ =โ๐โฅ0
{ptf๐,๐ (โฅ๐ )
}.
Thus, for every (โ, v) โ S:lfp ptf๐ (โ, v) = sup
๐โฅ0
{ptf๐,๐ (โฅ๐ ) (โ, v)
}.
We now apply Corollary B.1 to the ๐ ๐ป๐ :
๐ ๐ป๐ = sup
๐โฅ0
{E[โฅ๐ (๏ฟฝ๏ฟฝ๐ ) | ๏ฟฝ๏ฟฝ0 = (โ, v)]
}= sup
๐โฅ0
{Pr[โ๐ = โf | ๏ฟฝ๏ฟฝ0 = (โ, v)]
}= Pr[โ๐ .โ๐ = โf | ๏ฟฝ๏ฟฝ0 = (โ, v)] = vpf (โ, v)
โก
B.2 Proof of Theorem 4.4Proof. Fix any 1 โค ๐ < โ. Since๐ is finite, then by Propo-
sition 3, ptf๐ is both continuous and cocontinuous. So, by
Theorem 4.2,
lfp ptf๐ (โ, v) = sup
๐โฅ0
{ptf๐,๐ (โฅ๐ ) (โ, v)
}gfp ptf๐ (โ, v) = inf
๐โฅ0
{ptf๐,๐ (โค๐ ) (โ, v)
}Now by Proposition 2 and Corollary B.1, we can plug in
the concrete form of โฅ and โค, and expand the right side:
lfp ptf๐ (โ, v) = sup
๐โฅ0{Pr[โ๐ = โf ]}
gfp ptf๐ (โ, v) = inf
๐โฅ0{๐ Pr[โ๐ โ โt โง โ๐ โ โf ] + Pr[โ๐ = โf ]}
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
Thus, for every ๐:
gfp ptf๐ (โ, v) โ lfp ptf๐ (โ, v)โค inf
๐โฅ0{๐ ยท Pr[โ๐ โ โt โง โ๐ โ โf ]}
= 0
Thus, gfp ptf๐ = lfp ptf๐ , combined with Theorem 4.3, we
derive this theorem. โก
C Proofs of Section 5C.1 Proof of Theorem 5.1Define \ (โ, v) := exp( 8๐
ฮ2[ โฒ(โ, v)) and ๐ผ := 8๐
ฮ2. First, we prove
that \ โ K+โ. By construction, for every v, \ (โt, v) = 0 โง\ (โf , v) = 1. Thus, \ โ K+โ. Now, by the definition of pre
fixed-point, we need to prove ptf+โ (\ ) โ \ . We prove this
by case analysis:
For โ = โt, ptf+โ (\ ) (โt, v) = 0 โค \ (โt, v).For โ = โf , ptf+โ (\ ) (โf , v) = 1 โค \ (โf , v).Otherwise, for every state (โ, v) with โ โ {โt, โf }, suppose
it would transit along ๐๐ with ๐ forks:
ptf+โ (\ ) (โ, v)\ (โ, v)
=1
\ (โ, v)
๐โ๐=1
๐๐, ๐ EuโผD
[\ (โdst๐, ๐ , ๐น๐, ๐ (v, u))
]=
๐โ๐=1
๐๐, ๐ EuโผD
[exp
(๐ผ
([ โฒ(โdst๐, ๐ , ๐น๐, ๐ (v, u)) โ [
โฒ(โsrc๐ , v)))]
โค๐โ๐=1
๐๐, ๐ EuโผD
[exp
(๐ผ
([ (โdst๐, ๐ , ๐น๐, ๐ (v, u)) โ [ (โ
src
๐ , v)))]
We further upper bound the expectation by Hoeffdingโs
Lemma:
EuโผD
[exp
(๐ผ
([ (โdst๐, ๐ , ๐น๐, ๐ (v, u)) โ [ (โ
src
๐ , v)))]
โค exp
(E
uโผD
[๐ผ
([ (โdst๐, ๐ , ๐น๐, ๐ (v, u)) โ [ (โ
src
๐ , v))]+ (๐ผ ยท ฮ)
2
8
)โค exp
(๐ผ ยท (โ๐) + (๐ผ ยท ฮ)
2
8
)โค exp
(โ8๐
2
ฮ2+ 8๐2
ฮ2
)= 1
Thus,
ptf+โ (\ ) (โ, v)\ (โ, v) โค
๐โ๐=1
๐๐, ๐ = 1
ptf+โ (\ ) (โ, v) โค \ (โ, v)
So, ptf+โ (\ ) โ \ , and we conclude that \ is a pre fixed-
point.
C.2 Details of Quadratic ProgrammingIn this section, we introduce our algorithm for solving the
quadratic programming problem in Section 5.1.
Before demonstrating our algorithm, we first establish
some properties of this optimization problem. Recall the
original optimization problem:
min
8๐
ฮ2[ (โinit, vinit)
such that (C1)โ(C4) are satisfied. Furthermore, we need to
restrict ๐ โฅ 0,ฮ > 0, [ (โinit, vinit) โค 0.
First, we simplify the problem. Since we can scale [, it
suffices to find a solution with ฮ = 1. Next, we introduce a
fresh unknown coefficient ๐ and add the constraint 0 โฅ ๐ โฅaโinit ยท vinit +๐โinit . Finally, we modify the objective function to
8 ยท ๐ ยท ๐ . Since we need to minimize the objective function,
the original problem is equivalent to the simplified one.
After simplification, this optimization problem is an in-
stance of quadratic programming, since the objective func-
tion is the multiplication of two unknown coefficients and
all constraints are linear. However, it is not an instance of
convex programming because the objective function is not
convex. This being said, we can still prove the uniqueness of
local optimum.
For simplicity, in the rest of this section we use _ to repre-
sent all unknown coefficients other than ๐ and ๐ , including
๐ฝ, ๐ฟ, aโฒ๐ , ๐ โฒ๐ in the original problem.
Proposition 5. If the optimization problem has a solution
with ๐ > 0 and ๐ < 0, then the local optimum is unique.
Proof. Since there is a solution with ๐ < 0 and ๐ > 0, there
is no local optimum with ๐ = 0 or ๐ = 0. After wiping out
the case of ๐ = 0 or ๐ = 0, we prove this proposition by
contradiction. Suppose there are two different local optima
(๐1, ๐1, _1) and (๐2, ๐2, _2), with ๐1, ๐2 > 0 โง ๐1, ๐2 < 0. We
prove ๐1 = ๐2 โง ๐1 = ๐2.
Without loss of generality, we assume ๐1 ยท ๐1 โฅ ๐2 ยท ๐2.
Then there exists 0 โฅ ๐ โฒ โฅ ๐2 such that ๐2 ยท ๐ โฒ = ๐1 ยท ๐1. By
construction (๐2, ๐ โฒ, _2) is still a feasible solution. Since everyconstraint is linear, for all ๐ก โ [0, 1], (๐ก ยท๐1+(1โ๐ก)ยท๐2, ๐ก ยท๐1+(1โ๐ก) ยท๐ โฒ, ๐ก ยท_1+ (1โ๐ก) ยท_2) is a feasible solution, whose objectivevalue is ๐1 ยท๐1+
(2๐ก2 โ 2๐ก
)ยท๐1 ยท๐1+๐ก ยท (1โ๐ก) ยท (๐1 ยท๐ โฒ+๐2 ยท๐1),
which is strictly less than ๐1 ยท ๐1 for all ๐ก โ (0, 1). This isderived by the following calculation:(
2๐ก2 โ 2๐ก)ยท ๐1 ยท ๐1 + ๐ก ยท (1 โ ๐ก) ยท (๐1 ยท ๐ โฒ + ๐2 ยท ๐1)
= (๐ก2 โ ๐ก) ยท (๐1 โ ๐2) ยท (๐1 โ ๐ โฒ) < 0
Hence, (๐1, ๐1, _1) is not a local optimum, causing a contra-
diction. โก
Suppose the unique local optimum is (๐โ, ๐โ, _โ). By unique-ness, it is also a global optimum. Now we can take a different
perspective of this optimization problem.We regard this opti-
mization problem as finding theminimum value of a function
of ๐ . Fix ๐ and define (๐, ๐opt (๐), _opt (๐)) as the choice thatminimizes the objective function under ๐ . If the optimization
problem is infeasible under ๐ , we define ๐opt (๐) := โ. We
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
further define ๐ (๐) := 8 ยท ๐ ยท ๐opt (๐) as the optimal value of
objective function under fixed ๐ .
Since all constraints become stricter as ๐ increases,๐opt (๐)is a monotonically increasing function of ๐.We define ๐max :=
inf{๐ | ๐opt (๐) < โ}. We further show that ๐ (๐) first strictlydecreases and then strictly increases. Formally:
Proposition 6. In [0, ๐โ], ๐ (๐) is a strictly decreasing func-tion, and it is a strictly increasing function in [๐โ, ๐max].
Proof. We only prove the case for ๐ โ [0, ๐โ], the other case issimilar. Arbitrarily pick 0 โค ๐1 < ๐2 โค ๐โ .We need to prove
that ๐ (๐1) > ๐ (๐2). If ๐2 = ๐โ, by uniqueness of optimum,
๐ (๐1) < ๐ (๐โ) = ๐ (๐2). If ๐2 < ๐โ, since ๐ (๐1) < ๐ (๐โ),we can take 0 โฅ ๐ โฒ > ๐โ such that ๐ (๐1) = ๐ โฒ ยท ๐โ, andby construction (๐โ, ๐ โฒ, _โ) is also a feasible solutions. By
linearity of constraints, for all ๐ก โ [0, 1], (๐ก ยท ๐1 + (1 โ ๐ก) ยท๐โ, ๐ก ยท ๐opt (๐1) + (1 โ ๐ก) ยท ๐ โฒ, ๐ก ยท _opt (๐1) + (1 โ ๐ก) ยท _โ) is afeasible solution, whose objective value is ๐ (๐1) +
(2๐ก2 โ 2๐ก
)ยท
๐ (๐1) + ๐ก ยท (1 โ ๐ก) ยท (๐1 ยท ๐ โฒ + ๐โ ยท ๐opt (๐1)), which is strictly
smaller than ๐ (๐1). Plugging in ๐ก0 =๐โโ๐2๐โโ๐1 โ (0, 1), we get
that (๐2, ๐ก0 ยท๐opt๐1 + (1โ ๐ก0) ยท๐ โฒ, ๐ก0 ยท_opt (๐1) + (1โ ๐ก0) ยท_โ) is afeasible solution. Thus, ๐ (๐1) > ๐2 ยท (๐ก0 ยท๐opt๐1+(1โ๐ก0) ยท๐ โฒ) โฅ๐2 ยท ๐opt (๐2) = ๐ (๐2). โก
Now we describe our algorithm Ser. Ser takes an opti-
mization problem in the form of Section 5.1 and outputs a
solution to the optimization problem.
Step 1. Feasibility checking. In this step, we first check
whether ๐max = โ. This can be achieved through linear
programming, where the objective is to maximize ๐ and the
constraints are the same. If ๐max = โ, we can simply output 0
and terminate the algorithm. Then, we check whether there
exists a solution with ๐ > 0 and ๐ < 0, which is equivalent
to ๐max > 0 and ๐opt (0) < 0. This is also achievable by linear
programming. If there is no such solution, we simply output
1 and terminate the algorithm.
Step 2. Search for ๐โ. If the algorithm does not terminate
after Step 1, we know that the global optimum is unique.
Then, we iteratively search ๐โ, the iteration procedure starts
with ๐ = 0, ๐ = ๐max, every time in iteration, our algorithm
calculates๐1 =1
3(2๐ + ๐ ),๐2 =
1
3(๐ + 2๐ ), if ๐ (๐1) < ๐ (๐2),
then it sets ๐ โ ๐2 else it sets ๐ โ ๐1 and then repeats
the iteration again. Note that we can solve ๐ (๐), ๐opt (๐) and_opt (๐) by linear programming, since when ๐ is fixed, both
the objective function and the constraints are linear. The
iteration stops when ๐ โ ๐ < `, where ` is a given error
bound. Finally, the algorithm outputs ๐ , ๐opt (๐) and _opt (๐)as the final solution.
Our algorithm can efficiently approach the global opti-
mum with arbitrarily small error. Formally, we have the
following theorem:
Theorem C.1. Given the optimization problem in the form
of Section 5.1, and any error bound ` > 0, Ser outputs a solu-tion (๐0, ๐0, _0) such that |๐0 โ ๐โ | โค ` in ๐ (log ๐max
`) within
iterations of applying linear programming.
Proof. We first prove that in any iteration, ๐โ โ [๐, ๐ ]. Hence,when the iteration stops, we derive that |๐ โ ๐โ | โค |๐ โ ๐ | โค `.We prove this by induction.
Base case. At the start of iteration, ๐ = 0 โง ๐ = ๐max. It is
obvious that ๐โ โ [๐, ๐ ].Inductive step. In each iteration, suppose ๐โ โ [๐, ๐ ] . If๐ (๐1) < ๐ (๐2), then we claim that ๐โ โ [๐2, ๐ ]. Otherwise๐1 < ๐2 < ๐
โ < ๐ . By Proposition 6, we must have ๐ (๐1) >๐ (๐2), causing a contradiction. Hence, ๐โ โ [๐,๐2] and the
induction succeeds. Similarly, if ๐ (๐1) > ๐ (๐2), we can also
prove that ๐โ โ [๐1, ๐ ].Suppose we iterate ๐ times, then ๐ โ ๐ after ๐ iterations
would be
(2
3
)๐๐max. Since the iteration stops when ๐ โ ๐ < `,
we conclude that ๐ = ๐ (log ๐max
`). Since in each iteration
we solve ๐ (1) linear programming instances, we derive the
theorem. โก
C.3 Proof of Proposition 1Consider the canonical constraint ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พ
โณ ), whereฮจ = (Mv โค d). Then, ฮจ = ๐ +๐ถ , where ๐ is a polytope and
๐ถ = {v | Mv โค 0}. Suppose vโ1, vโ
2ยท ยท ยท , vโ๐ are generators of
๐ .
For the if part, pick any v |= ฮจ. By Theorem 5.3, v = v1+v2,whereMv1 โค 0 and v2 โ ๐ . We plug in v with v1 + v2 intothe ๐ฟ๐ป๐ of ฮ
๐,๐ผ,๐ฝ,๐พโณ (v):
๐ฟ๐ป๐ =
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท (v1 + v2) + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ]โค
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท v2 + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ]The first โค is derived by (D1). Since v2 โ ๐ , v2 can be
represented as a convex combination over generators: v2 =โ1โค๐โค๐ _๐ ยท vโ๐ , where _๐ โฅ 0 and
โ1โค๐โค๐ _๐ = 1. By Jensenโs
inequality (Theorem 6.1), we can further upper bound:
๐ฟ๐ป๐ โค๐โ๐=1
_๐
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท vโ๐ + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ]โค max
1โค๐โค๐
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท vโ๐ + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ] By (D2), ๐ฟ๐ป๐ โค 1, thus ฮ
๐,๐ผ,๐ฝ,๐พโณ (v) is true.
For the only if part, if ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโณ ) is satisfied, (D2) is
true since ๐ โ ฮจ. We prove (D1) by contradiction. Suppose
there exists v โ ๐ถ and ๐โ such that ๐ผ ๐โ ยท v > 0. Choose some
element v0 โ ๐ and consider the ๐ฟ๐ป๐ of ฮ๐,๐ผ,๐ฝ,๐พโณ (๐กv+ v0) for
๐ก โฅ 0 (Note that since v โ ๐ถ and v0 โ ๐ , thus ๐กv โ ๐ถ and
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
๐กv + v0 |= ฮจ):
๐ฟ๐ป๐ =
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท (๐กv + v0) + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ]โฅ exp
(๐ผ ๐โ ยท (๐กv + v0) + ๐ฝ ๐โ
)Eu
[exp
(๐พ ๐โ ยท u
) ]= exp
(๐ผ ๐โ ยท v0 + ๐ก (๐ผ ๐โ ยท v) + ๐ฝ ๐โ
)Eu
[exp
(๐พ ๐โ ยท u
) ]Since ๐ผ ๐โ ยท v > 0, by taking ๐ก โ โ, the exponent would
go to infinity, thus ๐ฟ๐ป๐ โโ, and there exists ๐ก0 such that
๐ฟ๐ป๐ > 1. Therefor, ฮ๐,๐ผ,๐ฝ,๐พโณ (๐กv + v0) is violated, deriving a
contradiction.
C.4 Proof of Theorem 5.4First, the objective function is convex. We consider every
constraint collected after Step 3. It is either: (1) a linear con-
straint, or (2) an instantiation ฮ๐,๐ผ,๐ฝ,๐พโณ (vโ) for some canonical
constraint ๐ถ๐๐(ฮจ,ฮ๐,๐ผ,๐ฝ,๐พโณ ) and some vโ โ ฮจ. For (2), we ex-
pand ฮ๐,๐ผ,๐ฝ,๐พโณ (vโ):๐โ๐=1
๐ ๐ ยท exp(๐ผ ๐ ยท vโ + ๐ฝ ๐
)ยท Er
[exp
(๐พ ๐ ยท r
) ]โค 1
By definition, to prove that ฮ is a convex optimization prob-
lem, it suffices to prove ๐ฟ๐ป๐ is a convex function over un-
known coefficients. First, since ๐ผ ๐ , ๐ฝ ๐ are affine, by convexity
of exp(ยท), exp(๐ผ ๐ ยท vโ + ๐ฝ ๐
)is convex. Then, we prove the
expectation term Er[exp
(๐พ ๐ ยท r
) ]is convex. Since the com-
position of a convex function and a affine function is convex,
and ๐พ ๐ is a affine function over unknown coefficients, it suf-
fices to prove that is Er [exp (๐พ ยท r)] convex over ๐พ . We prove
this by definition. Choose any pair (๐พ,๐พ โฒ), and any 0 โค ๐ โค 1:
Er[exp
((๐ ยท ๐พ + (1 โ ๐) ยท ๐พ โฒ) ยท r
) ]= Er
[exp
(๐ ยท ๐พ ยท r + (1 โ ๐) ยท ๐พ โฒ ยท r
) ]โค Er
[๐ ยท exp (๐พ ยท r) + (1 โ ๐) ยท exp
(๐พ โฒ ยท r
) ]= ๐ ยท Er [exp (๐พ ยท r)] + (1 โ ๐) ยท Er
[exp
(๐พ โฒ ยท r
) ]Since the product of two positive convex function is convex,
exp
(๐ผ ๐ ยท vโ + ๐ฝ ๐
)ยท Er
[exp
(๐พ ๐ ยท r
) ]is a convex function over
unknown coefficients. Finally, since ๐ ๐ โฅ 0, the whole ๐ฟ๐ป๐ is
a non-negative combination of convex functions. Therefore,
the ๐ฟ๐ป๐ is a convex function over unknown coefficients.
Hence, ฮ is a convex optimization problem.
D Proofs of Section 6D.1 Proof of Theorem 6.2We first prove the strengthening in Step 4 is sound.
Lemma 3 (Soundness of Strengthening). If ฮ๐,๐ผ,๐ฝ,๐พ
โฒ is satis-
fied, then so is ฮ๐,๐ผ,๐ฝ,๐พโฒ .
Proof. By Theorem 6.1, set the constant ๐ :=โ๐
๐=1 ๐ ๐ . We
have:
๐โ๐=1
๐ ๐ exp(๐ผ ๐ ยท v + ๐ฝ ๐
)Eu
[exp
(๐พ ๐ ยท u
) ]โฅ
๐โ๐=1
๐ ๐ exp
(๐ผ ๐ ยท v + ๐ฝ ๐ + ๐พ ๐ ยท E
u[u]
)= ๐ ยท๐โ1
๐โ๐=1
๐ ๐ exp
(๐ผ ๐ ยท v + ๐ฝ ๐ + ๐พ ๐ ยท E
u[u]
)โฅ ๐ ยท exp ยฉยญยซ๐โ1
๐โ๐=1
๐ ๐ (๐ผ ๐ ยท v + ๐ฝ ๐ + ๐พ ๐ ยท Eu[u])ยชยฎยฌ
โฅ ๐ ยท exp(โ ln๐) = 1
โก
We are now ready to prove the theorem.
Proof of Theorem 6.2. The constraints in Step 2 ensure bound-
ness of \ . By Lemma 3, we derive that if there exists a solution
under strengthened constraints, then there exists a bounded
post fixed-point \ . The theorem follows. โก
E Evaluatoin DetailsE.1 BenchmarksOur benchmarks are presented below. Please also note that
there are 3 example benchmarks in Section 3.
๐ : =0 ; ๐ฅ : =0 ;
while (๐ฅ โค 99 ) doswitch do
prob ( 0.5 ) : โจ๐, ๐ฅโฉ : = โจ๐ + 1, ๐ฅ + 1โฉprob ( 0.5 ) : โจ๐, ๐ฅโฉ : = โจ๐ + 1, ๐ฅโฉ
od ;
as se r t (๐ฅ โค 200 )
od
Figure 4. RdAdder: Randomized accumulation
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
๐ : =0 ; ๐ฅ : =0 ; ๐๐ฅ : =0 ; ๐๐๐ : =0 ;
while ( ๐ โค 500 ) doswitch do
prob ( 0.1 ) : ๐๐๐ := 1 / / SW
prob ( 0.1 ) : ๐๐๐ := 2 / / SE
prob ( 0.1 ) : ๐๐๐ := 3 / / W
prob ( 0.1 ) : ๐๐๐ := 4 / / E
ยท ยท ยทprob ( 0.2 ) : ๐๐๐ := 9 / / STAY
od ;
i f (๐๐๐ == 1 ) then / / SW Act ion
switch do / / Add no i s e
prob ( 0.5 ) :
๐ := ๐ + 1๐ฅ := ๐ฅ โ 1.414 โ 0.05๐๐ฅ := ๐๐ฅ โ 1.414
prob ( 0.5 ) :
๐ := ๐ + 1๐ฅ := ๐ฅ โ 1.414 + 0.05๐๐ฅ := ๐๐ฅ โ 1.414
ode l seยท ยท ยทi f (๐๐๐ == 9 ) then
ยท ยท ยทf i
odas se r t (๐ฅ โ ๐๐ฅ โฅ โ3 )
Figure 5. Robot: Deadrock robot
๐ฅ : =0 ;
while (๐ฅ โฅ 0 ) doas se r t (๐ฅ โค 1000 )
switch doprob ( 0.5 ) : โจ๐ฅโฉ : = โจ๐ฅ โ 2โฉprob ( 0.5 ) : โจ๐ฅโฉ : = โจ๐ฅ + 1โฉ
od ;
od
Figure 6. 1DWalk: 1D random walk with assertions
๐ฅ : =0 ; ๐ฆ : =0 ;
while (๐ฆ โฅ 1 ) doi f prob ( 0.5 ) then
switch doprob ( 0.75 ) : ๐ฅ : =๐ฅ + 1prob ( 0.25 ) : ๐ฅ : =๐ฅ โ 1
od ;
e l seswitch do
prob ( 0.75 ) : ๐ฆ : =๐ฆ โ 1prob ( 0.25 ) : ๐ฆ : =๐ฆ + 1
od ;
f ia s s e r t (๐ฅ โฅ 1 )
od
Figure 7. 2DWalk: 2D random walk with assertions
๐ฅ : =0 ; ๐ฆ : =0 ;
while (๐ฅ โฅ 0 โง ๐ฆ โฅ 0 โง ๐ง โฅ 0 ) doas se r t (๐ฅ + ๐ฆ + ๐ง โค 1000 )
i f prob ( 0.9 ) thenswitch doprob ( 0.5 ) : โจ๐ฅ,๐ฆโฉ : = โจ๐ฅ โ 1, ๐ฆ โ 1โฉprob ( 0.5 ) : โจ๐งโฉ : = โจ๐ง โ 1โฉ
od ;
e l seswitch do
prob ( 0.5 ) : โจ๐ฅ,๐ฆโฉ : = โจ๐ฅ + 0.1, ๐ฆ + 0.1โฉprob ( 0.5 ) : โจ๐งโฉ : = โจ๐ง + 0.1โฉ
od ;
f iod
Figure 8. 3DWalk: 3D random walk with assertions
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
๐ : =0 ; ๐ก : =0 ;
while ( ๐ โค 5 ) doi f ๐ = 0 then๐ := ๐ + 1๐ก := ๐ก + 1
e l sei f ๐ = 1 then
i f prob ( 0.8 ) then๐ := ๐ + 1๐ก := ๐ก + 1
e l se๐ก := ๐ก + 1
f ie l s eยท ยท ยทi f ๐ = 4 then
i f prob ( 0.2 ) then๐ := ๐ + 1๐ก := ๐ก + 1
e l se๐ก := ๐ก + 1
f if ia s s e r t ( ๐ก โค 100 )
od
Figure 9.Coupon: Concentration of running time of coupon
collector with 5 items
๐ฅ : =0 ; ๐ฆ : =0 ; ๐ก : =0 ;
while (๐ฅ + 3 โค 50 ) doi f (๐ฆ โค 49 ) then
i f prob ( 0 . 5 ) thenโจ๐ฆ, ๐กโฉ : = โจ๐ฆ + 1, ๐ก + 1โฉ
e l seโจ๐ฆ, ๐กโฉ : = โจ๐ฆ, ๐ก + 1โฉ
f ie l s e
switch doprob ( 0.25 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ, ๐ก + 1โฉprob ( 0.25 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ + 1, ๐ก + 1โฉprob ( 0.25 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ + 2, ๐ก + 1โฉprob ( 0.25 ) : โจ๐ฅ, ๐กโฉ : = โจ๐ฅ + 3, ๐ก + 1โฉ
f if ia s s e r t ( ๐ก โค 100 )
od
Figure 10. Prspeed: Concentration of running time of ran-
dom walk with randomized speed
๐ : =0 ; ๐ : =10โ7
while ( ๐ โค 40 ) doi f prob ( (1 โ ๐)5 ) then
skip / / ABSTRACTED
e l seex i t
f ii f prob ( 0.9999 ) then
skip / / ABSTRACTED
e l seex i t
f ii f prob ( 0.9999 ) then
skip / / ABSTRACTED
e l seex i t
f ii f prob ( (1 โ ๐)3 ) then
skip / / ABSTRACTED
e l seex i t
f ii f prob ( (1 โ ๐)6 ) then
skip / / ABSTRACTED
e l seex i t
f i๐ : = ๐ + 1
od
Figure 11. Newton: Executing Newtonโs iteration algo-
rithm on unreliable hardware (Abstracted version)
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
๐ : =0 ; ๐ : =10โ7
while ( ๐ โค 19 ) do๐ : =0
while ( ๐ โค 15 ) do๐ : =0
while (๐ โค 15 ) doi f prob ( (1 โ ๐)3 ) then
skip / / ABSTRACTED
e l seex i t
f i๐ : =๐ + 1
od๐ : = ๐ + 1
odi f prob ( 1 โ ๐ ) then
skip / / ABSTRACTED
e l seex i t
f i๐ : = ๐ + 1
od
Figure 12. Ref: Executing Searchref algorithm on unreliable
hardware (Abstracted version)
E.2 Detailed resultThe detailed result is listed in Table 3 Table 4 Table 5, where
we report the symbolic bound for every benchmark.
Conferenceโ17, July 2017, Washington, DC, USA Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady
Benchmark Parameters Algorithm of Section 5.1
Deviation RdAdder
Pr[๐ โ E[๐ ] โฅ 25] exp(8 ยท 0.05 ยท (โ1.0 ยท ๐ฅ + 0.45 ยท ๐ โ 25.25))Pr[๐ โ E[๐ ] โฅ 50] exp(8 ยท 0.02 ยท (โ1.0 ยท ๐ฅ + 0.47 ยท ๐ โ 12.75))Pr[๐ โ E[๐ ] โฅ 75] exp(8 ยท 0.07 ยท (โ1.0 ยท ๐ฅ + 0.42 ยท ๐ โ 37.75))
Robot
Pr[๐ โ E[๐ ] โฅ 1.8] exp(8 ยท 0.07 ยท (โ0.14 ยท ๐ โ 10 ยท ๐ฅ + 10 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 9))Pr[๐ โ E[๐ ] โฅ 2.0] exp(8 ยท 0.08 ยท (โ0.16 ยท ๐ โ 10 ยท ๐ฅ + 10 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 10))Pr[๐ โ E[๐ ] โฅ 2.2] exp(8 ยท 0.09 ยท (โ0.18 ยท ๐ โ 10 ยท ๐ฅ + 10 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 11))
Concentration
Coupon
Pr[๐ > 100] exp(8 ยท 0.03(โ1 ยท ๐ + 0.12 ยท ๐ก โ 7.60))Pr[๐ > 300] exp(8 ยท 0.04 ยท (โ1 ยท ๐ + 0.10 ยท ๐ก โ 27.60))Pr[๐ > 500] exp(8 ยท 0.04 ยท (โ1 ยท ๐ + 0.10 ยท ๐ก โ 47.57))
Prspeed
Pr[๐ > 150] exp(8 ยท 0.06 ยท (โ0.33 ยท ๐ฅ โ 1 ยท ๐ฆ + 0.29 ยท ๐ก โ 32.75))Pr[๐ > 200] exp(8 ยท 0.07 ยท (โ0.33 ยท ๐ฅ โ 1 ยท ๐ฆ + 0.28 ยท ๐ก โ 45.24))Pr[๐ > 250] exp(8 ยท 0.06 ยท (โ0.33 ยท ๐ฅ โ 1 ยท ๐ฆ + 0.31 ยท ๐ก โ 20.24))
Rdwalk
Pr[๐ > 400] exp(8 ยท 0.03 ยท (โ0.5 ยท ๐ฅ + 0.17 ยท ๐ฆ โ 37.62))Pr[๐ > 500] exp(8 ยท 0.03 ยท (โ0.5 ยท ๐ฅ + 0.18 ยท ๐ฆ โ 25.12))Pr[๐ > 600] exp(8 ยท 0.04 ยท (โ0.5 ยท ๐ฅ + 0.16 ยท ๐ฆ โ 40.12))
StoInv
1DWalk
๐ฅ = 10 exp(8 ยท 0.05 ยท (0.33 ยท ๐ฅ โ 333.55))๐ฅ = 50 exp(8 ยท 0.05 ยท (0.33 ยท ๐ฅ โ 333.55))๐ฅ = 100 exp(8 ยท 0.05 ยท (0.33 ยท ๐ฅ โ 333.55))
2DWalk
(๐ฅ, ๐ฆ) = (1000, 10) exp(8 ยท 0.04 ยท (โ0.5 ยท ๐ฅ + 0 ยท ๐ฆ + 7.99 ยท 10โ8))(๐ฅ, ๐ฆ) = (500, 40) exp(8 ยท 0.04 ยท (โ0.5 ยท ๐ฅ + 0 ยท ๐ฆ + 1.8 ยท 10โ7))(๐ฅ, ๐ฆ) = (400, 50) exp(8 ยท 0.04 ยท (โ0.5 ยท ๐ฅ + 0 ยท ๐ฆ + 1.8 ยท 10โ7))
3DWalk
(๐ฅ,๐ฆ,๐ง) = (100,100,100) exp(8 ยท 0.19 ยท (0.58 ยท ๐ฅ + 0.58 ยท ๐ฆ + 0.58 ยท ๐ง โ 487.80))(๐ฅ,๐ฆ,๐ง) = (100,150,200) exp(8 ยท 0.19 ยท (0.58 ยท ๐ฅ + 0.58 ยท ๐ฆ + 0.58 ยท ๐ง โ 487.90))(๐ฅ,๐ฆ,๐ง) = (300,100,150) exp(8 ยท 0.19 ยท (0.58 ยท ๐ฅ + 0.58 ยท ๐ฆ + 0.58 ยท ๐ง โ 487.80))
Race
(๐ฅ, ๐ฆ) = (40, 0) exp(8 ยท 0.08 ยท (โ0.67 ยท ๐ฅ + 0.5 ยท ๐ฆ + 16.58)(๐ฅ, ๐ฆ) = (35, 0) exp(8 ยท 0.07 ยท (โ0.63 ยท ๐ฅ + 0.5 ยท ๐ฆ + 13.34)(๐ฅ, ๐ฆ) = (45, 0) exp(8 ยท 0.10 ยท (โ0.70 ยท ๐ฅ + 0.5 ยท ๐ฆ + 20.41)
Table 3. Symbolic Results for Upper-bound Benchmarks of Algorithm of Section 5.1 .
Quantitative Analysis of Assertion Violations in Probabilistic Programs Conferenceโ17, July 2017, Washington, DC, USA
Benchmark Parameters Algorithm of Section 5.2
Deviation RdAdder
Pr[๐ โ E[๐ ] โฅ 25] exp(โ0.20 ยท ๐ฅ + 0.09 ยท ๐ โ 2.6)Pr[๐ โ E[๐ ] โฅ 50] exp(โ0.40 ยท ๐ฅ + 0.18 ยท ๐ โ 10.25)Pr[๐ โ E[๐ ] โฅ 75] exp(โ0.62 ยท ๐ฅ + 0.26 ยท ๐ โ 23.11)
Robot
Pr[๐ โ E[๐ ] โฅ 1.8] exp(โ0.22 ยท ๐ โ 13.85 ยท ๐ฅ + 13.85 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 11.55)Pr[๐ โ E[๐ ] โฅ 2.0] exp(โ0.29 ยท ๐ โ 16.09 ยท ๐ฅ + 16.09 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 14.55)Pr[๐ โ E[๐ ] โฅ 2.2] exp(โ0.38 ยท ๐ โ 18.70 ยท ๐ฅ + 18.70 ยท ๐๐ฅ + 0 ยท ๐๐ฅ๐ โ 18.00)
Concentration
Coupon
Pr[๐ > 100] exp(โ1.56 ยท ๐ + 0.17 ยท ๐ก โ 9.56)Pr[๐ > 300] exp(โ2.69 ยท ๐ + 0.20 ยท ๐ก โ 48.65)Pr[๐ > 500] exp(โ3.21 ยท ๐ + 0.21 ยท ๐ก โ 90.71)
Prspeed
Pr[๐ > 150] exp(โ0.51 ยท ๐ฅ โ 2.45 ยท ๐ฆ + 0.61 ยท ๐ก โ 63.39)Pr[๐ > 200] exp(โ0.53 ยท ๐ฅ โ 2.70 ยท ๐ฆ + 0.62 ยท ๐ก โ 92.96)Pr[๐ > 250] exp(โ0.47 ยท ๐ฅ โ 2.12 ยท ๐ฆ + 0.58 ยท ๐ก โ 35.54)
Rdwalk
Pr[๐ > 400] exp(โ0.34 ยท ๐ฅ + 0.12 ยท ๐ฆ โ 27.18)Pr[๐ > 500] exp(โ0.29 ยท ๐ฅ + 0.11 ยท ๐ฆ โ 15.35)Pr[๐ > 600] exp(โ0.38 ยท ๐ฅ + 0.12 ยท ๐ฆ โ 39.87)
StoInv
1DWalk
๐ฅ = 10 exp(0.48 ยท ๐ฅ โ 481.69)๐ฅ = 50 exp(0.48 ยท ๐ฅ โ 481.69)๐ฅ = 100 exp(0.48 ยท โ481.69)
2DWalk
(๐ฅ, ๐ฆ) = (1000, 10) exp(โ1.31 ยท ๐ฅ + 0.54 ยท ๐ฆ โ 3.02 ยท 10โ9)(๐ฅ, ๐ฆ) = (500, 40) exp(โ1.31 ยท ๐ฅ + 0.48 ยท ๐ฆ โ 1.46 ยท 10โ9)(๐ฅ, ๐ฆ) = (400, 50) exp(โ1.31 ยท ๐ฅ + 0.44 ยท ๐ฆ โ 2.44 ยท 10โ9)
3DWalk
(๐ฅ,๐ฆ,๐ง) = (100,100,100) exp(9.22 ยท ๐ฅ + 9.22 ยท ๐ฆ + 9.22 ยท ๐ง โ 9.22 ยท 103)(๐ฅ,๐ฆ,๐ง) = (100,150,200) exp(9.22 ยท ๐ฅ + 9.22 ยท ๐ฆ + 9.22 ยท ๐ง โ 9.22 ยท 103)(๐ฅ,๐ฆ,๐ง) = (300,100,150) exp(9.22 ยท ๐ฅ + 9.22 ยท ๐ฆ + 9.22 ยท ๐ง โ 9.22 ยท 103)
Race
(๐ฅ, ๐ฆ) = (40, 0) exp(โ1.18 ยท ๐ฅ + 0.85 ยท ๐ฆ + 31.79)(๐ฅ, ๐ฆ) = (35, 0) exp(โ0.82 ยท ๐ฅ + 0.63 ยท ๐ฆ + 18.19)(๐ฅ, ๐ฆ) = (45, 0) exp(โ0.82 ยท ๐ฅ + 0.63 ยท ๐ฆ + 18.19)
Table 4. Symbolic Results for Upper-bound Benchmarks of Algorithm of Section 5.2.
Benchmark Parameters Algorithm of Section 6
Hardware
M1DWalk
๐ = 10โ7
exp(2 ยท 10โ7 ยท ๐ฅ โ 2 ยท 10โ4)๐ = 10
โ5exp(2 ยท 10โ4 ยท ๐ฅ โ 0.002)
๐ = 10โ4
exp(2 ยท 10โ4 ยท ๐ฅ โ 0.02)
Newton
๐ = 5 ยท 10โ4 exp(7.7 ยท 10โ3 ยท ๐ โ 0.31)๐ = 10
โ3exp(1.52 ยท 10โ2 ยท ๐ โ 0.62)
๐ = 1.5 ยท 10โ3 exp(2.27 ยท 10โ2 ยท ๐ โ 0.93)
Ref
๐ = 10โ7
exp(7.69 ยท 10โ4 ยท ๐ + 0 ยท ๐ + 0 ยท ๐ โ 0.015)๐ = 10
โ6exp(7.7 ยท 10โ3 ยท ๐ + 0 ยท ๐ + 0 ยท ๐ โ 0.15)
๐ = 10โ5
exp(7.7 ยท 10โ2 ยท ๐ + 0 ยท ๐ + 0 ยท ๐ โ 1.53)Table 5. Symbolic Results for Lower-bound Benchmarks of Algorithm of Section 6.