+ All Categories
Home > Documents > Quantitative Analysis of Assertion Violations in ...

Quantitative Analysis of Assertion Violations in ...

Date post: 13-Nov-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
25
Quantitative Analysis of Assertion Violations in Probabilistic Programs โˆ— Jinyi Wang โ€  Shanghai Jiao Tong University [email protected] Yican Sun โˆ— Peking University [email protected] Hongfei Fu โ€ก Shanghai Jiao Tong University [email protected] Krishnendu Chatterjee IST Austria [email protected] Amir Kafshdar Goharshady IST Austria [email protected] Abstract We 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 ๏ฌxed-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 ๏ฌxed-point functions. To synthesize such ๏ฌxed-points, we devise algorithms that utilize a wide range of mathematical tools, including repulsing ranking supermartingales, Hoe๏ฌ€dingโ€™s lemma, Minkowski decompo- sitions, Jensenโ€™s inequality, and convex optimization. On the theoretical side, we provide (i) the ๏ฌrst automated algorithm for lower-bounds on assertion violation proba- bilities, (ii) the ๏ฌrst complete algorithm for upper-bounds of exponential form in a๏ฌƒne programs, and (iii) provably and signi๏ฌcantly 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 Introduction Probabilistic 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 hps://doi.org/10.1145/nnnnnnn.nnnnnnn languages and their formal analysis is a central topic in pro- gramming languages and veri๏ฌcation [1, 6, 14, 23, 28, 34, 35]. Qualitative Analysis of Probabilistic Programs. The most well-studied problem in the qualitative analysis of prob- abilistic programs is that of termination. Various notions of termination, such as ๏ฌnite-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. Speci๏ฌcally, we focus on ๏ฌnding upper and lower bounds for the assertion violation probability. This problem was ๏ฌrst 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 ๏ฌrst theoretical contribution is that we provide novel ๏ฌxed-point theorems which charac- terize assertion violation bounds in terms of pre and post ๏ฌxed-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: arXiv:2011.14617v2 [cs.PL] 1 Dec 2020
Transcript
Page 1: Quantitative Analysis of Assertion Violations in ...

Quantitative Analysis of Assertion Violations inProbabilistic Programsโˆ—

Jinyi Wangโ€ 

Shanghai Jiao Tong University

[email protected]

Yican Sunโˆ—

Peking University

[email protected]

Hongfei Fuโ€ก

Shanghai Jiao Tong University

[email protected]

Krishnendu Chatterjee

IST Austria

[email protected]

Amir Kafshdar Goharshady

IST Austria

[email protected]

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

Page 2: Quantitative Analysis of Assertion Violations in ...

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 ).

Page 3: Quantitative Analysis of Assertion Violations in ...

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

Page 4: Quantitative Analysis of Assertion Violations in ...

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) โ‰ค ๐‘“ (๐‘ฅโˆ—, ๐‘กโˆ—).

Page 5: Quantitative Analysis of Assertion Violations in ...

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 ๐‘ขโˆ— โˆˆ ๐พ

Page 6: Quantitative Analysis of Assertion Violations in ...

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

Page 7: Quantitative Analysis of Assertion Violations in ...

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.

Page 8: Quantitative Analysis of Assertion Violations in ...

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

Page 9: Quantitative Analysis of Assertion Violations in ...

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 ๐‘„

Page 10: Quantitative Analysis of Assertion Violations in ...

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 .

Page 11: Quantitative Analysis of Assertion Violations in ...

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

Page 12: Quantitative Analysis of Assertion Violations in ...

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.

Page 13: Quantitative Analysis of Assertion Violations in ...

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).

Page 14: Quantitative Analysis of Assertion Violations in ...

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

Page 15: Quantitative Analysis of Assertion Violations in ...

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

Page 16: Quantitative Analysis of Assertion Violations in ...

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)

Page 17: Quantitative Analysis of Assertion Violations in ...

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 ]}

Page 18: Quantitative Analysis of Assertion Violations in ...

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

Page 19: Quantitative Analysis of Assertion Violations in ...

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

Page 20: Quantitative Analysis of Assertion Violations in ...

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

Page 21: Quantitative Analysis of Assertion Violations in ...

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

Page 22: Quantitative Analysis of Assertion Violations in ...

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)

Page 23: Quantitative Analysis of Assertion Violations in ...

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.

Page 24: Quantitative Analysis of Assertion Violations in ...

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 .

Page 25: Quantitative Analysis of Assertion Violations in ...

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.


Recommended