This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

\newtheoremrep

mytheoremTheorem[section] \newtheoremrepmyproposition[mytheorem]Proposition \newtheoremrepmylemma[mytheorem]Lemma \newtheoremrepmycorollary[mytheorem]Corollary \newtheoremrepmyexample[mytheorem]Example \newtheoremrepmyremark[mytheorem]Remark \newtheoremrepmydefinition[mytheorem]Definition

Lexicographic Ranking Supermartingales with
Lazy Lower Bounds

Toru Takisaka1    Libo Zhang2    Changjiang Wang1    Jiamou Liu2 1 University of Electronic Science and Technology of China
takisaka@uestc.edu.cn; 202222080938@std.uestc.edu.cn2 The University of Auckland
lzha797@aucklanduni.ac.nz; jiamou.liu@auckland.ac.nz1 University of Electronic Science and Technology of China
takisaka@uestc.edu.cn; 202222080938@std.uestc.edu.cn2 The University of Auckland
lzha797@aucklanduni.ac.nz; jiamou.liu@auckland.ac.nz
Abstract

Lexicographic Ranking SuperMartingale (LexRSM) is a probabilistic extension of Lexicographic Ranking Function (LexRF), which is a widely accepted technique for verifying program termination. In this paper, we are the first to propose sound probabilistic extensions of LexRF with a weaker non-negativity condition, called single-component (SC) non-negativity. It is known that such an extension, if it exists, will be nontrivial due to the intricacies of the probabilistic circumstances.

Toward the goal, we first devise the notion of fixability, which offers a systematic approach for analyzing the soundness of possibly negative LexRSM. This notion yields a desired extension of LexRF that is sound for general stochastic processes. We next propose another extension, called Lazy LexRSM, toward the application to automated verification; it is sound over probabilistic programs with linear arithmetics, while its subclass is amenable to automated synthesis via linear programming. We finally propose a LexRSM synthesis algorithm for this subclass, and perform experiments.

1 Introduction

Background 1: Lexicographic RFs with different non-negativity conditions. Ranking function (RF) is one of the most well-studied tools for verifying program termination. An RF is typically a real-valued function over program states that satisfies: (a) the ranking condition, which requires an RF to decrease its value by a constant through each transition; and (b) the non-negativity condition, which imposes a lower bound on the value of the RF so that its infinite descent through transitions is prohibited. The existence of such a function implies termination of the underlying program, and therefore, one can automate verification of program termination by RF synthesis algorithms.

Improving the applicability of RF synthesis algorithms, i.e., making them able to prove termination of a wider variety of programs, is one of the core interests in the study of RF. A lexicographic extension of RF (LexRF) [BradleyMS05, Ben-AmramG15] is known as a simple but effective approach to the problem. Here, a LexRF is a function to real-valued vectors instead of the reals, and its ranking condition is imposed with respect to the lexicographic order. For example, the value of a LexRF may change from (1,1,1)(1,1,1) to (1,0,2)(1,0,2) through a state transition; here, the value “lexicographically decreases by 1” through the transition, that is, it decreases by 1 in some dimension while it is non-increasing on the left to that dimension. LexRF is particularly good at handling nested structures of programs, as vectors can measure the progress of different “phases” of programs separately. LexRF is also used in top-performing termination provers (e.g., [ultimateAutomizer]).

There are several known ways to impose non-negativity on LexRFs (see also Fig. 1): (a) Strong non-negativity, which requires non-negativity in every dimension of the LexRF; (b) leftward non-negativity, which requires non-negativity on the left of the ranking dimension of each transition, i.e., the dimension where the value of the LexRF should strictly decrease through the transition; and (c) single-component non-negativity, which requires non-negativity only in the ranking dimensions. It is known that any of these non-negativity conditions makes the resulting LexRF sound [BradleyMS05, Ben-AmramG15], i.e., a program indeed terminates whenever it admits a LexRF with either of these non-negativity conditions. For better applicability, single-component non-negativity is the most preferred, as it is the weakest constraint among the three.

1:\ell_{1}: 2:\ell_{2}:     skip; x:=1x:=1;     //𝜼=(a1,b1¯,c1)\boldsymbol{\eta}=(a_{1},\underline{b_{1}},c_{1}) //𝜼=(a2¯,b2,c2)\boldsymbol{\eta}=(\underline{a_{2}},b_{2},c_{2})    

Non-negativity condition 𝜼\boldsymbol{\eta} should be non-neg. at
Strong (ST) non-neg. a1,b1,c1,a2,b2,c2a_{1},b_{1},c_{1},a_{2},b_{2},c_{2}
Leftward (LW) non-neg. a1,b1,a2a_{1},b_{1},a_{2}
Single-component (SC) non-neg. b1,a2b_{1},a_{2}
Figure 1: A demo of different non-negativity conditions for LexRFs. There, the ranking dimensions of the LexRF 𝜼\boldsymbol{\eta} are indicated by underlines, and the last column of the table shows where each condition requires 𝜼\boldsymbol{\eta} to be non-negative.

Background 2: Probabilistic programs and lexicographic RSMs. One can naturally think of a probabilistic counterpart of the above argument. One can consider probabilistic programs that admit randomization in conditional branching and variable updates. The notion of RF is then generalized to Ranking SuperMartingale (RSM), a function similar to RFs except that the ranking condition requires an RSM to decrease its value in expectation. The existence of an RSM typically implies almost-sure termination of the underlying program, i.e., termination of the program with probability 1.

Such a probabilistic extension has been actively studied, in fact: probabilistic programs are used in e.g., stochastic network protocols [parker2013verification], randomized algorithms [dubhashi2009concentration, karp1991introduction], security [barthe2016proving, lobo2021programming, barthe2016programming], and planning [canal2019probabilistic]; and there is a rich body of studies in RSM as a tool for automated verification of probabilistic programs (see §8). Similar to the RF case, a lexicographic extension of RSM (LexRSM[AgrawalCP18, ChatterjeeGNZZ21]) is an effective approach to improve its applicability. In addition to its advantages over nested structures, LexRSM can also witness almost-sure termination of certain probabilistic programs with infinite expected runtime [AgrawalCP18, Fig. 2]; certifying such programs is known as a major challenge for RSMs.

Problem: Sound probabilistic extension of LexRF with weaker non-negativity. strongly non-negative LexRF soundly extends to LexRSM in a canonical way [AgrawalCP18], i.e., basically by changing the clause “decrease by a constant” in the ranking condition of LexRF to “decrease by a constant in expectation”. In contrast, the similar extension of leftward or single-component non-negative LexRF yields an unsound LexRSM notion [ferrer2015probabilistic, ChatterjeeGNZZ21]. To date, a sound LexRSM with the weakest non-negativity in the literature is Generalized LexRSM (GLexRSM) [ChatterjeeGNZZ21], which demands leftward non-negativity and an additional one, so-called expected leftward non-negativity. Roughly speaking, the latter requires LexRSMs to be non-negative in each dimension (in expectation) upon “exiting” the left of the ranking dimension. For example, in Fig. 1, it requires b2b_{2} to be non-negative, as the second dimension of 𝜼\boldsymbol{\eta} “exits” the left of the ranking dimension upon the transition 12\ell_{1}\rightarrow\ell_{2}. GLexRSM does not generalize either leftward or single-component non-negative LexRF, in the sense that the former is strictly more restrictive than the latter two when it is considered over non-probabilistic programs.

These results do not mean that leftward or single-component non-negative LexRF can never be extended to LexRSM, however. More concretely, the following problem is valid (see the last paragraph of §\S3 for a formal argument):

KEY PROBLEM: Find a sound LexRSM notion that instantiates111 We use the term “instantiate” to emphasize that we compare LexRSM and LexRF. single-component non-negative LexRF, i.e., a LexRSM notion whose condition is no stronger than that of single-component non-negative LexRF in non-probabilistic settings.

We are motivated to study this problem for a couple of reasons. First, it is a paraphrase of the following fundamental question: when do negative values of (Lex)RSM cause trouble, say, to its soundness? This question is a typical example in the study of RSM where the question becomes challenging due to its probabilistic nature. The question also appears in other topics in RSM; for example, it is known that the classical variant rule of Floyd-Hoare logic does not extend to almost-sure termination of probabilistic programs in a canonical way [Huang0CG19], due to the complicated treatment of negativity in RSMs. To our knowledge, this question has only been considered in an ad-hoc manner through counterexamples (e.g., [ferrer2015probabilistic, Huang0CG19, ChatterjeeGNZZ21]), and we do not yet have a systematic approach to answering it.

1:\ell_{1}: 2:\ell_{2}: 3:\ell_{3}: 4:\ell_{4}: 5:\ell_{5}: x:=0x:=0; while x<5x<5 do if y<10y<10 then y:=y+𝑈𝑛𝑖𝑓[1,2]y:=y+\mathit{Unif}[1,2] else x:=x+𝑈𝑛𝑖𝑓[1,2]x:=x+\mathit{Unif}[1,2] fi od            𝜼=(152x,12y,1)\boldsymbol{\eta}=(15-2x,12-y,1) 𝜼=(152x,12y,0)\boldsymbol{\eta}=(15-2x,12-y,0) 𝜼=(152x,11y,2)\boldsymbol{\eta}=(15-2x,11-y,2) 𝜼=(142x,         0,1)\boldsymbol{\eta}=(14-2x,\;\;\;\,\;\;\,\;\;0,1) 𝜼=(          0,         0,0)\boldsymbol{\eta}=(\;\;\;\;\;\;\;\;\;\;0,\;\;\,\;\;\,\;\;\;0,0)        [x<7][x<7] [x<5][x<5] [y<10,x<5][y<10,x<5] [y10,x<5][y\geq 10,x<5] [x5][x\geq 5]

Figure 2: A probabilistic modification of speedDis1 [alias2010multi], where 𝑈𝑛𝑖𝑓[a,b]\mathit{Unif}[a,b] is a uniform sampling from the (continuous) interval [a,b][a,b]. Inequalities on the right represent invariants. While 𝜼\boldsymbol{\eta} is not a GLexRSM, it is an LLexRSM we propose; thus it witnesses almost-sure termination of the program.

Second, relaxing the non-negativity condition of LexRSM is highly desirable if we wish to fully unlock the benefit of the lexicographic extension in automated verification. A motivating example is given in Fig. 2. The probabilistic program in Fig. 2 terminates almost-surely, but it does not admit any linear GLexRSM (and hence, the GLexRSM synthesis algorithms in [ChatterjeeGNZZ21] cannot witness its almost-sure termination); for example, the function 𝜼\boldsymbol{\eta} ranks every transition of the program, but violates both leftward and expected leftward non-negativity at the transition 12\ell_{1}\rightarrow\ell_{2} (note 𝜼\boldsymbol{\eta} ranks this transition in the third dimension; to check the violation of expected leftward non-negativity, also note 𝜼\boldsymbol{\eta} ranks 24\ell_{2}\rightarrow\ell_{4} in the first dimension). Here, the source of the problem is that the program has two variables whose progress must be measured (i.e., increment yy to 10 in 3\ell_{3}; and increment xx to 5 in 4\ell_{4}), but one of their progress measures can be arbitrarily small during the program execution (yy can be initialized with any value). Not only that this structure is rather fundamental, it is also expected that our desired LexRSM could handle it, if it exists. Indeed, modify the probabilistic program in Fig. 2 into a non-probabilistic one by changing “𝑈𝑛𝑖𝑓[1,2]\mathit{Unif}[1,2]” to “11”; then the program admits 𝜼\boldsymbol{\eta} as a single-component non-negative LexRF.

Contributions. In this paper, we are the first to introduce sound LexRSM notions that instantiate single-component non-negative LexRF. Our contributions are threefold, as we state below.

  • First, in response to the first motivation we stated above, we devise a novel notion of fixability as a theoretical tool to analyze if negative values of a LexRSM “cause trouble”. Roughly speaking, we identify the source of the trouble as “ill” exploitation of unbounded negativity of LexRSM; our ε\varepsilon-fixing operation prohibits such exploitation by basically setting all the negative values of a LexRSM into the same negative value ε-\varepsilon, and we say a LexRSM is ε\varepsilon-fixable if it retains the ranking condition through such a transformation. We give more details about its concept and key ideas in §2.

    The soundness of ε\varepsilon-fixable LexRSM immediately follows from that of strongly non-negative one [AgrawalCP18] because any LexRSM becomes strongly non-negative through the ε\varepsilon-fixing operation (after globally adding ε\varepsilon). Fixable LexRSM instantiates single-component non-negative LexRF for general stochastic processes (Thm. 4), while also serving as a technical basis for proving the soundness of other LexRSMs. Meanwhile, fixable LexRSM cannot be directly applied to automated verification algorithms due to the inherent non-linearity of ε\varepsilon-fixing; this observation leads us to our second contribution.

  • Second, in response to the second motivation we stated above, we introduce Lazy LexRSM (LLexRSM) as another LexRSM notion that instantiates single-component non-negative LexRF. LLexRSM does not involve the ε\varepsilon-fixing operation in its definition; thanks to this property, we have a subclass of LLexRSM that is amenable to automated synthesis via linear programming (see §6). The LLexRSM condition consists of the single-component non-negative LexRSM condition and stability at negativity we propose (Def. 5), which roughly requires the following: Once the value of a LexRSM gets negative in some dimension, it must stay negative until that dimension exits the left of the ranking one. For example, 𝜼\boldsymbol{\eta} in Fig. 2 is an LLexRSM; indeed, 24\ell_{2}\rightarrow\ell_{4} and 15\ell_{1}\rightarrow\ell_{5} are the only transitions where 𝜼\boldsymbol{\eta} possibly changes its value from negative to non-negative in some dimension (namely, the second one), which is although the right to the ranking dimension (the first one).

    We prove linear LLexRSM is sound for probabilistic programs over linear arithmetics (see Thm. 5 for the exact assumption). The proof is highly nontrivial, which is realized by subtle use of a refined variant of fixability; we explain its core idea in §2. Furthermore, Thm. 5 shows that expected leftward non-negativity in GLexRSM [ChatterjeeGNZZ21] is actually redundant under the assumption in Thm. 5. This is surprising, as expected leftward non-negativity has been invented to restore the soundness of leftward non-negative LexRSM, which is generally unsound.

  • Third, we present a synthesis algorithm for the subclass of LLexRSM we mentioned above, and do experiments; there, our algorithms verified almost-sure termination of various programs that could not be handled by (a better proxy of) the GLexRSM-based one. The details can be found in §7.

2 Key Observations with Examples

Here we demonstrate by examples how intricate the treatment of negative values of LexRSM is, and how we handle it by our proposed notion of fixability.

Blocking “ill” exploitation of unbounded negativity. Fig. 3 is a counterexample that shows leftward non-negative LexRSM is generally unsound (conceptually the same as [ChatterjeeGNZZ21, Ex. 1]). The probabilistic program in Fig. 3 does not terminate almost-surely because the chance of entering 4\ell_{4} from 3\ell_{3} quickly decreases as tt increases. Meanwhile, 𝜼=(η1,η2,η3)\boldsymbol{\eta}=(\eta_{1},\eta_{2},\eta_{3}) in Fig. 3 is a leftward non-negative LexRSM over a global invariant [0x1][0\leq x\leq 1]; in particular, observe η2\eta_{2} decreases by 11 in expectation from 3\ell_{3}, whose successor location is either 4\ell_{4} or 1\ell_{1}.

1:\ell_{1}: 2:\ell_{2}: 3:\ell_{3}: 4:\ell_{4}: 5:\ell_{5}: x:=0x:=0;t:=1t:=1; while x=0x=0 do t:=t+1t:=t+1; if 𝐩𝐫𝐨𝐛(2t)\mathbf{prob}(2^{-t}) then x:=1x:=1 fi od     𝜼=(2x,    0,2)\boldsymbol{\eta}=(2-x,\;\;\;\;0,2) 𝜼=(       2,    0,1)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,\;\;\;\;0,1) 𝜼=(       2,    0,0)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,\;\;\;\;0,0) 𝜼=(       2,2t,0)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,-2^{t},0) 𝜼=(       0,    0,0)\boldsymbol{\eta}=(\;\;\;\;\;\;\,0,\;\;\;\;0,0)

Figure 3: An example of “ill” exploitation.

This example reveals an inconsistency between the ways how the single-component non-negativity and ranking condition evaluate the value of a LexRSM, say 𝜼=(η1,,ηn)\boldsymbol{\eta}=(\eta_{1},\ldots,\eta_{n}). The single-component non-negativity claims 𝜼\boldsymbol{\eta} cannot rank a transition in a given dimension kk whenever ηk\eta_{k} is negative; intuitively, this means that any negative value in the ranking domain \mathbb{R} should be understood as the same state, namely the “bottom” of the domain. Meanwhile, the ranking condition evaluates different negative values differently; a smaller negative value of ηk\eta_{k} can contribute more to satisfy the ranking condition, as one can see from the behavior of η2\eta_{2} in Fig. 3 at 3\ell_{3}. The function 𝜼\boldsymbol{\eta} in Fig. 3 satisfies the ranking condition over a possibly non-terminating program through “ill” exploitation of this inconsistency; as tt becomes larger, the value of η2\eta_{2} potentially drops more significantly through the transition from 3\ell_{3}, but with a smaller probability.

The first variant of our fixability notion, called ε\varepsilon-fixability, enables us to ensure that such exploitation is not happening. We simply set every negative value in a LexRSM 𝜼\boldsymbol{\eta} to a negative constant ε-\varepsilon, and say 𝜼\boldsymbol{\eta} is ε\varepsilon-fixable if it retains the ranking condition through the modification222 To give the key ideas in a simpler way, the description here slightly differs from the actual definition in §4; referred results in §2 are derived from the latter. See Rem. 4. . For example, the ε\varepsilon-fixing operation changes the value of η2\eta_{2} in Fig. 3 at 4\ell_{4} from 2t-2^{t} to ε-\varepsilon, and 𝜼\boldsymbol{\eta} does not satisfy the ranking condition after that. Therefore, 𝜼\boldsymbol{\eta} in Fig. 3 is not ε\varepsilon-fixable for any ε>0\varepsilon>0 (i.e., we successfully reject this 𝜼\boldsymbol{\eta} through the fixability check). Meanwhile, an ε\varepsilon-fixable LexRSM witnesses almost-sure termination of the underlying program; indeed, the fixed LexRSM is a strongly non-negative LexRSM (by globally adding ε\varepsilon to the fixed 𝜼\boldsymbol{\eta}), which is known to be sound [AgrawalCP18].

The notion of ε\varepsilon-fixability is operationally so simple that one might even feel it is a boring idea; nevertheless, its contribution to revealing the nature of possibly negative LexRSM is already significant in our paper. Indeed, (a) ε\varepsilon-fixable LexRSM instantiates single-component non-negative LexRF with an appropriate ε\varepsilon (Thm. 4); (b) ε\varepsilon-fixable LexRSM generalizes GLexRSM [ChatterjeeGNZZ21], and the proof offers an alternative proof of soundness of GLexRSM that is significantly simpler than the original one (Thm. 4); and (c) its refined variant takes the crucial role in proving soundness of our second LexRSM variant, lazy LexRSM.

Allowing “harmless” unbounded negativity. While ε\varepsilon-fixable LexRSM already instantiates single-component non-negative LexRF, we go one step further to obtain a LexRSM notion that is amenable to automated synthesis, in particular via Linear Programming (LP). The major obstacle to this end is the case distinction introduced by ε\varepsilon-fixability, which makes the fixed LexRSM nonlinear. Lazy LexRSM (LLexRSM), our second proposed LexRSM, resolves this problem while it also instantiates single-component non-negative LexRF.

Linear LLexRSM is sound over probabilistic programs with linear arithmetics (Thm. 5). The key to the proof is, informally, the following observation: Restrict our attention to probabilistic programs and functions 𝛈\boldsymbol{\eta} that are allowed in the LP-based synthesis. Then “ill” exploitation in Fig. 3 never occurs, and therefore, a weaker condition than ε\varepsilon-fixability (namely, the LLexRSM one) suffices for witnessing program termination. In fact, Fig. 3 involves (a) non-linear arithmetics in the program, (b) parametrized if-branch in the program (i.e., the grammar “ if prob(p)(p) then PP else QQ fi ” with pp being a variable), and (c) non-linearity of 𝜼\boldsymbol{\eta}. None of them are allowed in the LP-based synthesis (at least, in the standard LP-based synthesis via Farkas’ Lemma [chakarov2013probabilistic, AgrawalCP18, ChatterjeeGNZZ21]). Our informal statement above is formalized as Thm. 5, which roughly says: Under such a restriction to probabilistic programs and 𝜼\boldsymbol{\eta}, any LLexRSM is (ε,γ)(\varepsilon,\gamma)-fixable. Here, (ε,γ)(\varepsilon,\gamma)-fixability is a refined version of ε\varepsilon-fixability; while it also ensures that “ill” exploitation is not happening in 𝜼\boldsymbol{\eta}, it is less restrictive than ε\varepsilon-fixability by allowing “harmless” unbounded negative values of 𝜼\boldsymbol{\eta}.

1:\ell_{1}: 2:\ell_{2}: 3:\ell_{3}: 4:\ell_{4}: 5:\ell_{5}: x:=0x:=0;t:=1t:=1; while x=0x=0 do if 𝐩𝐫𝐨𝐛(0.5)\mathbf{prob}(0.5) then t:=4tt:=4t else x:=1x:=1 fi od     𝜼=(2x,t+1)\boldsymbol{\eta}=(2-x,\;\;\;\;\;t+1) 𝜼=(       2,t)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,\;\;\;\;\;\;\;\;\;\;\;t) 𝜼=(       2,   4t+2)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,\;\;\;4t+2) 𝜼=(       2,2t4)\boldsymbol{\eta}=(\;\;\;\;\;\;\,2,-2t-4) 𝜼=(       0,           0)\boldsymbol{\eta}=(\;\;\;\;\;\;\,0,\;\;\;\;\;\;\;\;\;\;\;0)

Figure 4: An example of “harmless” unbounded negativity.

Fig. 4 gives an example of such a harmless behavior of 𝜼\boldsymbol{\eta} rejected by ε\varepsilon-fixability. It also shows why we cannot simply use ε\varepsilon-fixability to check an LLexRSM does not do “ill” exploitation. The function 𝜼=(η1,η2)\boldsymbol{\eta}=(\eta_{1},\eta_{2}) in Fig. 4 is leftward non-negative over the global invariant [0x1t1][0\leq x\leq 1\land t\geq 1], so it is an LLexRSM for the probabilistic program there; the program and 𝜼\boldsymbol{\eta} are also in the scope of LP-based synthesis; but 𝜼\boldsymbol{\eta} is not ε\varepsilon-fixable for any ε>0\varepsilon>0. Indeed, the ε\varepsilon-fixing operation changes the value of η2\eta_{2} at 4\ell_{4} from 2t4-2t-4 to ε-\varepsilon, and 𝜼\boldsymbol{\eta} does not satisfy the ranking condition at 2\ell_{2} after the change. Here we notice that, however, the unbounded negative values of η2\eta_{2} are “harmless”; that is, the “ill-gotten gains” by the unbounded negative values of η2\eta_{2} at 4\ell_{4} are only “wasted” to unnecessarily increase η2\eta_{2} at 3\ell_{3}. In fact, 𝜼\boldsymbol{\eta} still satisfies the ranking condition if we change the value of η2\eta_{2} at 1,2,3\ell_{1},\ell_{2},\ell_{3} to 2,12,1, and 0, respectively.

We resolve this issue by partially waiving the ranking condition of 𝜼\boldsymbol{\eta} after the ε\varepsilon-fixing operation. It is intuitively clear that the program in Fig. 4 almost-surely terminates, and the intuition here is that the program essentially repeats an unbiased coin tossing until the tail is observed (here, “observe the tail” corresponds to “observe prob(0.5)=true\mbox{\bf prob}(0.5)=\mbox{\bf true} at 2\ell_{2}”). This example tells us that, to witness the almost-sure termination of this program, we only need to guarantee the program (almost-surely) visits either the terminal location 5\ell_{5} or the “coin-tossing location” 2\ell_{2} from anywhere else. The ε\varepsilon-fixed 𝜼\boldsymbol{\eta} in Fig. 4 does witness such a property of the program, as it ranks every transition except those that are from a coin-tossing location, namely 2\ell_{2}.

We generalize this idea as follows: Fix γ(0,1)\gamma\in(0,1), and say a program state is a “coin-tossing state” for 𝜼=(η1,,ηn)\boldsymbol{\eta}=(\eta_{1},\ldots,\eta_{n}) in the kk-th dimension if ηk\eta_{k} drops from non-negative to negative (i.e., the ranking is “done” in the kk-th dimension) with the probability γ\gamma or higher. Then we say 𝜼\boldsymbol{\eta} is (ε,γ)(\varepsilon,\gamma)-fixable (Def. 4) if the ε\varepsilon-fixed 𝜼\boldsymbol{\eta} is a strongly non-negative LexRSM (after adding ε\varepsilon) except that, at each coin-tossing state, we waive the ranking condition of 𝜼\boldsymbol{\eta} in the corresponding dimension. For example, 𝜼\boldsymbol{\eta} in Fig. 4 is (ε,γ)(\varepsilon,\gamma)-fixable for any γ(0,0.5]\gamma\in(0,0.5]. As expected, (ε,γ)(\varepsilon,\gamma)-fixable LexRSM is sound for any ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1) (Cor. 4).

3 Preliminaries

We recall the technical preliminaries. Omitted details are in Appendix A.

Notations. We assume the readers are familiar with the basic notions of measure theory, see e.g. [Ash:book, BertsekasS07]. The sets of non-negative integers and reals are denoted by \mathbb{N} and \mathbb{R}, respectively. The collection of all Borel sets of a topological space 𝒳\mathcal{X} is denoted by (𝒳)\mathcal{B}(\mathcal{X}). The set of all probability distributions over the measurable space (Ω,(Ω))(\Omega,\mathcal{B}(\Omega)) is denoted by 𝒟(Ω)\mathcal{D}(\Omega). The value of a vector 𝒙\boldsymbol{x} at the ii-th index is denoted by 𝒙[i]\boldsymbol{x}[i] or xix_{i}. A subset DD\subseteq\mathbb{R} of the reals is bounded if D[x,x]D\subseteq[-x,x] for some x>0x>0.

For a finite variable set VV and the set valVval^{V} of its valuations, we form predicates as first-order formulas with atomic predicates of the form fgf\leq g, where f,g:valVRf,g\colon val^{V}\to R and RR is linearly ordered. Often, we are only interested in the value of a predicate φ\varphi over a certain subset 𝒳valV\mathcal{X}\subseteq val^{V}, in which case, we call φ\varphi a predicate over 𝒳\mathcal{X}. We identify a predicate φ\varphi over 𝒳\mathcal{X} with a function φ~:𝒳{0,1}\tilde{\varphi}\colon\mathcal{X}\to\{0,1\} such that φ~(x)=1\tilde{\varphi}(x)=1 if and only if φ(x)\varphi(x) is true. The semantics of φ\varphi, i.e., the set {x𝒳φ(x) is true}\{x\in\mathcal{X}\mid\varphi(x)\mbox{ is true}\}, is denoted by φ\llbracket\varphi\rrbracket. The characteristic function 𝟏A:𝒳{0,1}{\bf 1}_{A}:\mathcal{X}\to\{0,1\} of a subset AA of 𝒳\mathcal{X} is a function such that 𝟏A=1=A\llbracket{\bf 1}_{A}=1\rrbracket=A. For a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}), we say φ\varphi over Ω\Omega is (\mathcal{F}-)measurable when φ\llbracket\varphi\rrbracket\in\mathcal{F}. For such a φ\varphi, the satisfaction probability of φ\varphi w.r.t. \mathbb{P}, i.e., the value (φ)\mathbb{P}(\llbracket\varphi\rrbracket), is also denoted by (φ)\mathbb{P}(\varphi); we say φ\varphi holds \mathbb{P}-almost surely (\mathbb{P}-a.s.) if (φ)=1\mathbb{P}(\varphi)=1.

3.1 Syntax and Semantics of Probabilistic Programs

Syntax. We define the syntax of Probabilistic Programs (PPs) similarly to e.g., [AgrawalCP18, TakisakaOUH21]. More concretely, PPs have the standard control structure in imperative languages such as if-branches and while-loops, while the if-branching and variable assignments can also be done in either nondeterministic or probabilistic ways. Namely, if\star describes a nondeterministic branching; ndet(D)(D) describes a nondeterministic assignment chosen from a bounded333 This is also assumed in [ChatterjeeGNZZ21] to avoid a complication in possibly negative LexRSMs. domain D()D\subseteq\mathcal{B}(\mathbb{R}); ifprob(p)(p) with a constant p[0,1]p\in[0,1] describes a probabilistic branching that executes the then branch with probability pp, or the else branch with probability 1p1-p; and sample(d)(d) describes a probabilistic assignment sampled from a distribution d𝒟()d\in\mathcal{D}(\mathbb{R}). We consider PPs without conditioning, which are also called randomized programs [TakisakaOUH21]; PPs with conditioning are considered in e.g. [OlmedoGJKKM18]. The exact grammar is given in Appendix A.

In this paper, we focus our attention on PPs with linear arithmetics; we say a PP is linear if each arithmetic expression in it is linear, i.e., of the form b+i=1naivib+\sum_{i=1}^{n}a_{i}\cdot v_{i} for constants a1,,an,ba_{1},\ldots,a_{n},b and program variables v1,,vnv_{1},\ldots,v_{n}.

Semantics. We adopt probabilistic control flow graph (pCFG) as the semantics of PPs, which is standard in existing RSM works (e.g., [chakarov2013probabilistic, TakisakaOUH21, ChatterjeeGNZZ21]). Informally, it is a labeled directed graph whose vertices are program locations, and whose edges represent possible one-step executions in the program. Edges are labeled with the necessary information so that one can reconstruct the PP represented by the pCFG; for example, an edge ee can be labeled with the assignment commands executed through ee (e.g., ‘x:=x+1x:=x+1’), the probability p[0,1]p\in[0,1] that ee will be chosen (through ifprob(p)(p)), the guard condition, and so on. Below we give its formal definition for completeness; see Appendix A for how to translate PPs into pCFGs.

{mydefinition}

[pCFG] A pCFG is a tuple (L,V,Δ,𝑈𝑝,G)(L,V,\Delta,\mathit{Up},G), where

  1. 1.

    LL is a finite set of locations.

  2. 2.

    V={x1,,x|V|}V=\{x_{1},\ldots,x_{|V|}\} is a finite set of program variables.

  3. 3.

    Δ\Delta is a finite set of (generalized) transitions444Defining these as edges might be more typical, as in our informal explanation. We adopt the style of [AgrawalCP18, ChatterjeeGNZZ21] for convenience; it can handle ifprob(p)(p) by a single τ\tau. , i.e., tuples τ=(,δ)\tau=(\ell,\delta) of a location L\ell\in L and a distribution δ𝒟(L)\delta\in\mathcal{D}(L) over successor locations.

  4. 4.

    𝑈𝑝\mathit{Up} is a function that receives a transition τΔ\tau\in\Delta and returns a tuple (i,u)(i,u) of a target variable index i{1,,|V|}i\in\{1,\ldots,|V|\} and an update element uu. Here, uu is either (a) a Borel measurable function u:|V|u:\mathbb{R}^{|V|}\to\mathbb{R}, (b) a distribution d𝒟()d\in\mathcal{D}(\mathbb{R}), or (c) a bounded measurable set R()R\in\mathcal{B}(\mathbb{R}). In each case, we say τ\tau is deterministic, probabilistic, and non-deterministic, respectively; the collections of these transitions are denoted by Δd\Delta_{d}, Δp\Delta_{p}, and Δn\Delta_{n}, respectively.

  5. 5.

    GG is a guard function that assigns a G(τ):|V|{0,1}G(\tau):\mathbb{R}^{|V|}\to\{0,1\} to each τΔ\tau\in\Delta.

Below we fix a pCFG 𝒞=(L,V,Δ,𝑈𝑝,G)\mathcal{C}=(L,V,\Delta,\mathit{Up},G). A state of 𝒞\mathcal{C} is a tuple s=(,𝒙)s=(\ell,\boldsymbol{x}) of location L\ell\in L and variable assignment vector 𝒙|V|\boldsymbol{x}\in\mathbb{R}^{|V|}. We write 𝒮\mathcal{S} to denote the state set L×|V|L\times\mathbb{R}^{|V|}. Slightly abusing the notation, for τ=(,δ)\tau=(\ell,\delta), we identify the set G(τ)|V|\llbracket G(\tau)\rrbracket\subseteq\mathbb{R}^{|V|} and the set {}×G(τ)𝒮\{\ell\}\times\llbracket G(\tau)\rrbracket\subseteq\mathcal{S}; in particular, we write sG(τ)s\in\llbracket G(\tau)\rrbracket when τ\tau is enabled at ss, i.e., s=(,𝒙)s=(\ell,\boldsymbol{x}), τ=(,δ)\tau=(\ell,\delta) and 𝒙G(τ)\boldsymbol{x}\in\llbracket G(\tau)\rrbracket.

A pCFG 𝒞\mathcal{C} with its state set 𝒮\mathcal{S} can be understood as a transition system over 𝒮\mathcal{S} with probabilistic transitions and nondeterminism (or, more specifically, a Markov decision process with its states 𝒮\mathcal{S}). Standard notions such as successors of a state s𝒮s\in\mathcal{S}, finite paths, and (infinite) runs of 𝒞\mathcal{C} are defined as the ones over such a transition system. The set of all successors of sG(τ)s\in\llbracket G(\tau)\rrbracket via τ\tau is denoted by succτ(s)\mathrm{succ}_{\tau}(s). The set of runs of 𝒞\mathcal{C} is denoted by Π𝒞\Pi_{\mathcal{C}}.

Schedulers resolve nondeterminism in pCFGs. Observe there are two types of nondeterminism: (a) nondeterministic choice of τΔ\tau\in\Delta at a given state (corresponds to if\star), and (b) nondeterministic variable update in a nondeterministic transition τΔn\tau\in\Delta_{n} (corresponds to xi:=x_{i}:=ndet(D)(D)). We say a scheduler is Δ\Delta-deterministic if its choice is non-probabilistic in Case (a).

We assume pCFGs are deadlock-free; we also assume that there are designated locations in\ell_{\mathrm{in}} and out\ell_{\mathrm{out}} that represent program initiation and termination, respectively. An initial state is a state of the form (in,𝒙)(\ell_{\mathrm{in}},\boldsymbol{x}). We assume a transition from out\ell_{\mathrm{out}} is unique, denoted by τout\tau_{\mathrm{out}}; this transition does not update anything.

By fixing a scheduler σ\sigma and an initial state sIs_{I}, the infinite-horizon behavior of 𝒞\mathcal{C} is determined as a distribution sIσ\mathbb{P}_{s_{I}}^{\sigma} over Π𝒞\Pi_{\mathcal{C}}; that is, for a measurable AΠ𝒞A\subseteq\Pi_{\mathcal{C}}, the value sIσ(A)\mathbb{P}_{s_{I}}^{\sigma}(A) is the probability that a run of 𝒞\mathcal{C} from sIs_{I} is in AA under σ\sigma. We call the probability space (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}) the dynamics of 𝒞\mathcal{C} under σ\sigma and sIs_{I}. See [BertsekasS07] for the formal construction; a brief explanation is in Appendix A.

We define the termination time of a pCFG 𝒞\mathcal{C} as the function Tterm𝒞:Π𝒞{+}T_{\mathrm{term}}^{\mathcal{C}}:\Pi_{\mathcal{C}}\to\mathbb{N}\cup\{+\infty\} such that Tterm𝒞(s0s1)=inf{t𝒙.st=(out,𝒙)}T_{\mathrm{term}}^{\mathcal{C}}(s_{0}s_{1}\ldots)=\inf\{t\in\mathbb{N}\mid\exists\boldsymbol{x}.s_{t}=(\ell_{\mathrm{out}},\boldsymbol{x})\}. Now we formalize our objective, i.e., almost-sure termination of pCFG, as follows.

{mydefinition}

[AST of pCFG] A run ωΠ𝒞\omega\in\Pi_{\mathcal{C}} terminates if Tterm𝒞(ω)<T_{\mathrm{term}}^{\mathcal{C}}(\omega)<\infty. A pCFG 𝒞\mathcal{C} is a.s. terminating (AST) under a scheduler σ\sigma and an initial state sIs_{I} if a run of 𝒞\mathcal{C} terminates sIσ\mathbb{P}_{s_{I}}^{\sigma}-a.s. We say 𝒞\mathcal{C} is AST if it is AST for any σ\sigma and sIs_{I}.

3.2 Lexicographic Ranking Supermartingales

Here we recall mathematical preliminaries of the LexRSM theory. A (Lex)RSM typically comes in two different forms: one is a vector-valued function 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n} over states 𝒮\mathcal{S} of a pCFG 𝒞\mathcal{C}, and another is a stochastic process over the runs Π𝒞\Pi_{\mathcal{C}} of 𝒞\mathcal{C}. We recall relevant notions in these formulations, which are frequently used in existing RSM works [chakarov2013probabilistic, ChatterjeeGNZZ21]. We also recall the formal definition of LexRSMs with three different non-negativity conditions in Fig. 1.

LexRSM as a quantitative predicate. Fix a pCFG 𝒞\mathcal{C}. An (nn-dimensional) measurable map (MM) is a Borel measurable function 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n}. For a given 1-dimensional MM η\eta and a transition τ\tau, The (maximal) pre-expectation of η\eta under τ\tau is a function that formalizes “the value of η\eta after the transition τ\tau”. More concretely, it is a function 𝕏¯τη:G(τ)\overline{\mathbb{X}}_{\tau}\eta:\llbracket G(\tau)\rrbracket\to\mathbb{R} that returns, for a given state ss, the maximal expected value of η\eta at the successor state of ss via τ\tau. Here, the maximality refers to the set of all possible nondeterministic choices at ss.

A level map 𝖫𝗏:Δ{0,,n}\mathsf{Lv}:\Delta\to\{0,\ldots,n\} designates the ranking dimension of the associated LexRSM 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n}. We require 𝖫𝗏(τ)=0\mathsf{Lv}(\tau)=0 if and only if τ=τout\tau=\tau_{\mathrm{out}}. We say an MM 𝜼\boldsymbol{\eta} ranks a transition τ\tau in the dimension kk (under 𝖫𝗏\mathsf{Lv}) when k=𝖫𝗏(τ)k=\mathsf{Lv}(\tau). An invariant is a measurable predicate I:𝒮{0,1}I:\mathcal{S}\to\{0,1\} such that I\llbracket I\rrbracket is closed under transitions and in×|V|I\ell_{\mathrm{in}}\times\mathbb{R}^{|V|}\subseteq\llbracket I\rrbracket. The set I\llbracket I\rrbracket over-approximates the reachable states in 𝒞\mathcal{C}.

Suppose an nn-dimensional MM 𝜼\boldsymbol{\eta} and an associated level map 𝖫𝗏\mathsf{Lv} are given. We say 𝜼\boldsymbol{\eta} satisfies the ranking condition (under 𝖫𝗏\mathsf{Lv} and II) if the following holds for each ττout\tau\neq\tau_{\mathrm{out}}, sIG(τ)s\in\llbracket I\land G(\tau)\rrbracket, and k{1,,𝖫𝗏(τ)}k\in\{1,\ldots,\mathsf{Lv}(\tau)\}:

𝕏¯τ𝜼[k](s){𝜼[k](s)if k<𝖫𝗏(τ),𝜼[k](s)1if k=𝖫𝗏(τ).\displaystyle\overline{\mathbb{X}}_{\tau}\boldsymbol{\eta}[k](s)\leq\begin{cases}\boldsymbol{\eta}[k](s)&\text{if }k<\mathsf{Lv}(\tau),\\ \boldsymbol{\eta}[k](s)-1&\text{if }k=\mathsf{Lv}(\tau).\end{cases}

We also define the three different non-negativity conditions in Fig. 1, i.e., STrong (ST), LeftWard (LW), and Single-Component (SC) non-negativity, as follows:

(ST non-neg.) sI.k{1,,n}.\displaystyle\forall s\in\llbracket I\rrbracket.\forall k\in\{1,\ldots,n\}. 𝜼[k](s)0,\displaystyle\boldsymbol{\eta}[k](s)\geq 0,
(LW non-neg.) ττout.sIG(τ).k{1,,𝖫𝗏(τ)}.\displaystyle\forall\tau\neq\tau_{\mathrm{out}}.\forall s\in\llbracket I\land G(\tau)\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}(\tau)\}. 𝜼[k](s)0,\displaystyle\boldsymbol{\eta}[k](s)\geq 0,
(SC non-neg.) ττout.sIG(τ).\displaystyle\forall\tau\neq\tau_{\mathrm{out}}.\forall s\in\llbracket I\land G(\tau)\rrbracket. 𝜼[𝖫𝗏(τ)](s)0.\displaystyle\boldsymbol{\eta}[\mathsf{Lv}(\tau)](s)\geq 0.

All the materials above are wrapped up in the following definition.

{mydefinition}

[(ST/LW/SC)-LexRSM map] Fix a pCFG 𝒞\mathcal{C} with an invariant II. Let 𝜼\boldsymbol{\eta} be an MM associated with a level map 𝖫𝗏\mathsf{Lv}. The MM 𝜼\boldsymbol{\eta} is called a STrongly non-negative LexRSM map (ST-LexRSM map) over 𝒞\mathcal{C} supported by II if it satisfies the ranking condition and the strong non-negativity under 𝖫𝗏\mathsf{Lv} and II. If it satisfies the leftward or single-component non-negativity instead of the strong one, then we call it LW-LexRSM map or SC-LexRSM map, respectively. LexRSM as a stochastic process. When it comes to automated synthesis, a (Lex)RSM is usually a function 𝜼\boldsymbol{\eta} over program states, as defined in Def. 3.2. Meanwhile, when we prove the properties of (Lex)RSMs themselves (e.g., soundness), it is often necessary to inspect the behavior of 𝜼\boldsymbol{\eta} upon the program execution under given scheduler σ\sigma and initial state sIs_{I}. Such a behavior of 𝜼\boldsymbol{\eta} is formalized as a sequence (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} of random variables over the dynamics of the underlying pCFG, which forms a stochastic process.

A (discrete-time) stochastic process in a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) is a sequence (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} of \mathcal{F}-measurable random variables 𝐗t:Ωn\mathbf{X}_{t}:\Omega\to\mathbb{R}^{n} for tt\in\mathbb{N}. In our context, it is typically associated with another random variable T:Ω{+}T:\Omega\to\mathbb{N}\cup\{+\infty\} that describes the termination time of ωΩ\omega\in\Omega. We say TT is AST (w.r.t. \mathbb{P}) if (T<)=1\mathbb{P}(T<\infty)=1; observe that, if (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) is the dynamics of a pCFG 𝒞\mathcal{C} under σ\sigma and sIs_{I}, then 𝒞\mathcal{C} is AST under σ\sigma and sIs_{I} if and only if Tterm𝒞T_{\mathrm{term}}^{\mathcal{C}} is AST w.r.t. \mathbb{P}. As standard technical requirements, we assume there is a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} in (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) such that (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is adapted to (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}, TT is a stopping time w.r.t. (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}, and (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is stopped at TT; see Appendix A for their definitions.

For a stopping time TT w.r.t. (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}, we define a level map (𝖫𝗏t)t=0(\mathsf{Lv}_{t})_{t=0}^{\infty} as a sequence of t\mathcal{F}_{t}-measurable functions 𝖫𝗏t:Ω{0,n}\mathsf{Lv}_{t}:\Omega\to\{0,\ldots n\} such that 𝖫𝗏t=0=Tt\llbracket\mathsf{Lv}_{t}=0\rrbracket=\llbracket T\leq t\rrbracket for each tt. We call a pair of a stochastic process and a level map an instance for TT; just like we construct an MM 𝜼\boldsymbol{\eta} and a level map 𝖫𝗏\mathsf{Lv} as an AST certificate of a pCFG 𝒞\mathcal{C}, we construct an instance for a stopping time TT as its AST certificate. We say an instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) for TT ranks ωΩ\omega\in\Omega in the dimension kk at time tt when T(ω)>tT(\omega)>t and k=𝖫𝗏t(ω)k=\mathsf{Lv}_{t}(\omega).

For c>0c>0, we say an instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) satisfies the cc-ranking condition if, for each tt\in\mathbb{N}, ω𝖫𝗏t0\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket, and k{1,,𝖫𝗏t(ω)}k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\}, we have:

𝔼[𝐗t+1[k]t](ω)𝐗t[k](ω)c𝟏k=𝖫𝗏t(ω)(-a.s.)\displaystyle\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\mathbf{X}_{t}[k](\omega)-c\cdot{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega)\quad(\mathbb{P}\mbox{-a.s.}) (1)

Here, the function 𝔼[𝐗t+1[k]t]\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}] denotes the conditional expectation of 𝐗t+1[k]\mathbf{X}_{t+1}[k] given t\mathcal{F}_{t}, which takes the role of pre-expectation. We mostly let c=1c=1 and simply call it the ranking condition; the only result sensitive to cc is Thm. 4.

We also define the three different non-negativity conditions for an instance as follows. Here we adopt a slightly general (but essentially the same) variant of strong non-negativity instead, calling it uniform well-foundedness; we simply allow the uniform lower bound to be any constant \bot\in\mathbb{R} instead of fixing it to be zero. This makes the later argument simpler.

(UN well-fnd.) .t.ωΩ.k{1,,n}.\displaystyle\exists\bot\in\mathbb{R}.\forall t\in\mathbb{N}.\forall\omega\in\Omega.\forall k\in\{1,\ldots,n\}. 𝐗t[k](ω),\displaystyle\mathbf{X}_{t}[k](\omega)\geq\bot,
(LW non-neg.) t.ω𝖫𝗏t0.k{1,,𝖫𝗏t(ω)}.\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\}. 𝐗t[k](ω)0,\displaystyle\mathbf{X}_{t}[k](\omega)\geq 0,
(SC non-neg.) t.ω𝖫𝗏t0.\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket. 𝐗t[𝖫𝗏t(ω)](ω)0.\displaystyle\mathbf{X}_{t}[\mathsf{Lv}_{t}(\omega)](\omega)\geq 0.
{mydefinition}

[(UN/LW/SC)-LexRSM] Suppose the following are given: a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}); a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} on \mathcal{F}; and a stopping time TT w.r.t. (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}. An instance =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is called a UNiformly well-founded LexRSM (UN-LexRSM) for TT with the bottom \bot\in\mathbb{R} and a constant cc\in\mathbb{R} if (a) (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty}is adapted to (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}; (b) for each tt\in\mathbb{N} and 1kn1\leq k\leq n, the expectation of 𝐗t[k]\mathbf{X}_{t}[k] exists; (c) \mathcal{I}satisfies the cc-ranking condition; and (d) \mathcal{I}is uniformly well-founded with the bottom \bot. We define LW-LexRSM and SC-LexRSM by changing (d) with LW and SC non-negativity, respectively.

We mostly assume c=1c=1 and omit to mention the constant. UN-LexRSM is known to be sound [AgrawalCP18]; meanwhile, LW and SC-LexRSM are generally unsound [ChatterjeeGNZZ21, ferrer2015probabilistic]. We still mention the latter two as parts of sound LexRSMs.

From RSM maps to RSMs. Let 𝜼\boldsymbol{\eta} be an MM over a pCFG 𝒞\mathcal{C} with a level map 𝖫𝗏\mathsf{Lv}. Together with a Δ\Delta-deterministic scheduler σ\sigma and initial state sIs_{I}, it induces an instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) over the dynamics of 𝒞\mathcal{C}, by letting 𝐗t(s0s1)=𝜼(st)\mathbf{X}_{t}(s_{0}s_{1}\ldots)=\boldsymbol{\eta}(s_{t}); it describes the behavior of 𝜼\boldsymbol{\eta} and 𝖫𝗏\mathsf{Lv} through executing 𝒞\mathcal{C} from sIs_{I} under σ\sigma. Properties of 𝜼\boldsymbol{\eta} such as ranking condition or non-negativity are inherited to the induced instance (if the expectation of 𝐗t[k]\mathbf{X}_{t}[k] exists for each tt, kk). For example, an instance induced by an ST-LexRSM map is an UN-LexRSM with =0\bot=0.

Non-probabilistic settings, and instantiation of SC-LexRF. The key question in this paper is to find a LexRSM notion that instantiates SC non-negative LexRF (or SC-LexRF for short); that is, we would like to find a LexRSM notion whose conditions are satisfied by SC-LexRSM555 One would perhaps expect to see “SC-LexRF” here; such a change does not make a difference under a canonical definition of SC-LexRF, so we define the notion of instantiation in this way to save space. See also Appendix A. in the non-probabilistic setting, which we formalize as follows. We say a pCFG is a (non-probabilistic) CFG if (a) δ\deltais Dirac for each (,δ)Δ(\ell,\delta)\in\Delta, and (b) Δp=\Delta_{p}=\emptyset; this roughly means that a CFG is a model of a PP without ifprob(p)(p) and sample(d)(d). We say a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) is trivial if Ω\Omega is a singleton, say {ω}\{\omega\}.

4 Fixable LexRSMs

In §4-6 we give our novel technical notions and results. In this section, we will introduce the notion of fixability and related results. Here we focus on technical rigorousness and conciseness, see §2 for the underlying intuition. Proofs are given in appendices. We begin with the formal definition of ε\varepsilon-fixability.

{myremark}

As in Footnote 2, our formal definitions of fixability in this section slightly differ from an informal explanation in §2. One difference is that the ε\varepsilon-fixing in Def. 4 changes the value of a LexRSM at dimension kk whenever it is negative or kk is strictly on the right to the ranking dimension. This modification is necessary to prove Thm. 4. Another is that we define fixability as the notion for an instance \mathcal{I}, rather than for an MM 𝜼\boldsymbol{\eta}. While the latter can be also done in an obvious way (as informally done in §2), we do not formally do that because it is not necessary for our technical development. One can “fix” the argument in §2 into the one over instances by translating “fixability of 𝜼\boldsymbol{\eta}” to “fixability of an instance induced by 𝜼\boldsymbol{\eta}”.

{mydefinition}

[ε\varepsilon-fixing of an instance] Let =((𝐗t)t=0),(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty}),(\mathsf{Lv}_{t})_{t=0}^{\infty}) be an instance for a stopping time TT, and let ε>0\varepsilon>0. The ε\varepsilon-fixing of \mathcal{I} is another instance ~=((𝐗~t)t=0,(𝖫𝗏t)t=0)\tilde{\mathcal{I}}=((\tilde{\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) for TT, where

𝐗~t[k](ω)={εif 𝐗t[k](ω)<0 or k>𝖫𝗏t(ω),𝐗t[k](ω)otherwise.\displaystyle\tilde{\mathbf{X}}_{t}[k](\omega)=\begin{cases}-\varepsilon&\text{if }\mathbf{X}_{t}[k](\omega)<0\text{ or }k>\mathsf{Lv}_{t}(\omega),\\ \mathbf{X}_{t}[k](\omega)&\text{otherwise}.\end{cases}

We say an SC-LexRSM \mathcal{I} is ε\varepsilon-fixable, or call it an ε\varepsilon-fixable LexRSM, if its ε\varepsilon-fixing ~\tilde{\mathcal{I}} is an UN-LexRSM with the bottom =ε\bot=-\varepsilon.

Observe that the ε\varepsilon-fixing of any instance is uniformly well-founded with the bottom =ε\bot=-\varepsilon, so the ε\varepsilon-fixability only asks if the ranking condition is preserved through ε\varepsilon-fixing. Also, observe that the soundness of ε\varepsilon-fixable LexRSM immediately follows from that of UN-LexRSM [AgrawalCP18].

While we do not directly use ε\varepsilon-fixability as a technical tool, the two theorems below show its conceptual value. The first one answers our key problem: ε\varepsilon-fixable LexRSM instantiates SC-LexRF with sufficiently large ε\varepsilon.

{mytheorem}

[fixable LexRSM instantiates SC-LexRF] Suppose =((𝒙t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\boldsymbol{x}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is an SC-LexRSM for a stopping time TT over the trivial probability space with a constant cc, and let εc\varepsilon\geq c. Then \mathcal{I} is ε\varepsilon-fixable. ∎

The second theorem offers a formal comparison between ε\varepsilon-fixable LexRSM and the state-of-the-art LexRSM variant in the literature, namely GLexRSM [ChatterjeeGNZZ21]. We show the former subsumes the latter. In our terminology, GLexRSM is LW-LexRSM that also satisfies the following expected leftward non-negativity:

t.ω𝖫𝗏t0.k{1,,𝖫𝗏t(ω)}.𝔼[𝟏k>𝖫𝗏t+1𝐗t+1[k]t](ω)0.\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\}.\ \mathbb{E}[{\bf 1}_{\llbracket k>\mathsf{Lv}_{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\geq 0.

We note that our result can be also seen as an alternative proof of the soundness of GLexRSM [ChatterjeeGNZZ21, Thm. 1]. Our proof is also significantly simpler than the original one, as the former utilizes the soundness of UN-LexRSM as a lemma, while the latter does the proof “from scratch”.

{mytheorem}

[fixable LexRSM generalizes GLexRSM] Suppose \mathcal{I} is a GLexRSM for a stopping time TT. Then \mathcal{I} is ε\varepsilon-fixable for any ε>0\varepsilon>0. ∎

Now we move on to a refined variant, (ε,γ)(\varepsilon,\gamma)-fixability. Before its formal definition, we give a theorem that justifies the partial waiving of the ranking condition described in §2. Below, t.φt\overset{\infty}{\exists}t.\varphi_{t} stands for k.t.[t>kφt]\forall k\in\mathbb{N}.\exists t\in\mathbb{N}.[t>k\land\varphi_{t}].

{mytheorem}

[relaxation of the UN-LexRSM condition] Suppose the following are given: a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}); a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} on \mathcal{F}; and a stopping time TT w.r.t. (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}. Let =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) be an instance for TT, and let \bot\in\mathbb{R}. For each k{1,,n}k\in\{1,\ldots,n\}, let (φt,k)t=0(\varphi_{t,k})_{t=0}^{\infty} be a sequence of predicates over Ω\Omega such that

t.φt,k(ω)t.[𝐗t[k](ω)=k>𝖫𝗏t(ω)](-a.s.)\displaystyle\overset{\infty}{\exists}t.\varphi_{t,k}(\omega)\Rightarrow\overset{\infty}{\exists}t.[\mathbf{X}_{t}[k](\omega)=\bot\lor k>\mathsf{Lv}_{t}(\omega)]\quad\mbox{($\mathbb{P}$-a.s.)} (2)

Suppose \mathcal{I} is an UN-LexRSM with the bottom \bot except that, instead of the ranking condition, \mathcal{I} satisfies the inequality (1) only for tt\in\mathbb{N}, k{1,,n}k\in\{1,\ldots,n\}, and ωk𝖫𝗏t¬(𝐗t[k]>φt,k)\omega\in\llbracket k\leq\mathsf{Lv}_{t}\land\lnot(\mathbf{X}_{t}[k]>\bot\land\varphi_{t,k})\rrbracket (with c=1c=1). Then TT is AST w.r.t. \mathbb{P}. ∎ The correspondence between the argument in §2 and Thm. 4 is as follows. The predicate φt,k\varphi_{t,k} is an abstraction of the situation “we are at a coin-tossing state at time tt in the kk-th dimension”; and the condition (2) corresponds to the infinite coin-tossing argument (for a given kk, if φt,k\varphi_{t,k} is satisfied at infinitely many tt, then the ranking in the kk-th dimension is “done” infinitely often, with probability 1). Given these, Thm. 4 says that the ranking condition of UN-LexRSM can be waived over 𝐗t[k]>φt,k\llbracket\mathbf{X}_{t}[k]>\bot\land\varphi_{t,k}\rrbracket. In particular, the theorem amounts to the soundness of UN-LexRSM when φt,k𝑓𝑎𝑙𝑠𝑒\varphi_{t,k}\equiv\mathit{false} for each tt and kk.

Based on Theorem 4, we introduce (ε,γ)(\varepsilon,\gamma)-fixability as follows. There, [φ]:=𝔼[𝟏φ]\mathbb{P}[\varphi\mid\mathcal{F}^{\prime}]:=\mathbb{E}[{\bf 1}_{\llbracket\varphi\rrbracket}\mid\mathcal{F}^{\prime}] is the conditional probability of satisfying φ\varphi given \mathcal{F}^{\prime}.

{mydefinition}

[(ε,γ)(\varepsilon,\gamma)-fixability] Let =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) be an instance for TT, and let γ(0,1)\gamma\in(0,1). We call \mathcal{I} a γ\gamma-relaxed UN-LexRSM for TT if \mathcal{I} satisfies the properties in Thm. 4, where φt,k\varphi_{t,k} is as follows:

φt,k(ω)[𝐗t+1[k]=t](ω)γ.\displaystyle\varphi_{t,k}(\omega)\equiv\mathbb{P}[\mathbf{X}_{t+1}[k]=\bot\mid\mathcal{F}_{t}](\omega)\geq\gamma. (3)

We say \mathcal{I} is (ε,γ)(\varepsilon,\gamma)-fixable if its ε\varepsilon-fixing ~\tilde{\mathcal{I}} is a γ\gamma-relaxed UN-LexRSM. The predicate φt,k(ω)\varphi_{t,k}(\omega) in (3) is roughly read “the ranking by (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is done at time t+1t+1 in dimension kk with probability γ\gamma or higher, given the information about ω\omega at tt”. This predicate satisfies Condition (2); hence we have the following corollary, which is the key to the soundness of lazy LexRSM in §5. {mycorollary}[soundness of (ε,γ)(\varepsilon,\gamma)-fixable instances] Suppose there exists an instance \mathcal{I} over (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) for a stopping time TT that is (ε,γ)(\varepsilon,\gamma)-fixable for any ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1). Then TT is AST w.r.t. \mathbb{P}. ∎

5 Lazy LexRSM and Its Soundness

Here we introduce another LexRSM variant, Lazy LexRSM (LLexRSM). We need this variant for our LexRSM synthesis algorithm; while ε\varepsilon-fixable LexRSM theoretically answers our key question, it is not amenable to LP-based synthesis algorithms because its case distinction makes the resulting constraint nonlinear.

We define LLexRSM map as follows; see Contributions in §1 for its intuitive meaning with an example. The definition for an instance is in Appendix C.

{mydefinition}

[LLexRSM map] Fix a pCFG 𝒞\mathcal{C} with an invariant II. Let 𝜼\boldsymbol{\eta} be an MM associated with a level map 𝖫𝗏\mathsf{Lv}. The MM 𝜼\boldsymbol{\eta} is called a Lazy LexRSM map (LLexRSM map) over 𝒞\mathcal{C} supported by II if it is an SC-LexRSM map over 𝒞\mathcal{C} supported by II, and satisfies stability at negativity defined as follows:

ττout.sIG(τ).k{1,,𝖫𝗏(τ)1}.\displaystyle\forall\tau\neq\tau_{\mathrm{out}}.\forall s\in\llbracket I\land G(\tau)\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}(\tau)-1\}.
𝜼[k](s)<0ssuccτ(s).[𝜼[k](s)<0k>maxτ:sG(τ)𝖫𝗏(τ)].\displaystyle\quad\quad\quad\quad\boldsymbol{\eta}[k](s)<0\Rightarrow\forall s^{\prime}\in\mathrm{succ}_{\tau}(s).\biggl{[}\boldsymbol{\eta}[k](s^{\prime})<0\lor k>\max_{\tau^{\prime}:s^{\prime}\in\llbracket G(\tau^{\prime})\rrbracket}\mathsf{Lv}(\tau^{\prime})\biggr{]}.

We first observe LLexRSM also answers our key question.

{mytheorem}

[LLexRSM instantiates SC-LexRF] Suppose 𝜼\boldsymbol{\eta} is an SC-LexRSM over a non-probabilistic CFG 𝒞\mathcal{C} supported by an invariant II, with a level map 𝖫𝗏\mathsf{Lv}. Then 𝜼\boldsymbol{\eta} is stable at negativity under II and 𝖫𝗏\mathsf{Lv}, and hence, 𝜼\boldsymbol{\eta} is an LLexRSM map over 𝒞\mathcal{C} supported by II, with 𝖫𝗏\mathsf{Lv}. ∎

Below we give the soundness result of LLexRSM map. We first give the necessary assumptions on pCFGs and MMs, namely linearity and well-behavedness. we say a pCFG is linear if the update element of each τΔd\tau\in\Delta_{d} is a linear function (this corresponds to the restriction on PPs to the linear ones); and an MM 𝜼\boldsymbol{\eta} is linear if λ𝒙.𝜼(,𝒙)\lambda\boldsymbol{x}.\boldsymbol{\eta}(\ell,\boldsymbol{x}) is linear for each L\ell\in L. We say a pCFG is well-behaved if its variable samplings are done via well-behaved distributions, which roughly means that their tail probabilities vanish to zero toward infinity quickly enough. We give its formal definition in the appendix (Def. C.1.2), which is somewhat complex; an important fact from the application perspective is that the class of such distributions covers all distributions with bounded supports and some distributions with unbounded supports such as the normal distributions (Prop. C.1.2). Possibly negative (Lex)RSM typically requires some restriction on variable samplings of pCFG (e.g., the integrability in [ChatterjeeGNZZ21]) so that the pre-expectation is well-defined.

The crucial part of the soundness proof is the following theorem, where (ε,γ)(\varepsilon,\gamma)-fixability takes the key role. Its full proof is given in Appendix C.

{mytheorem}

Let 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n} be a linear LLexRSM map for a linear, well-behaved pCFG 𝒞\mathcal{C}. Then for any Δ\Delta-deterministic scheduler σ\sigma and initial state sIs_{I} of 𝒞\mathcal{C}, the induced instance is (ε,γ)(\varepsilon,\gamma)-fixable for some ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1).

Proof (sketch). We can show that the ε\varepsilon-fixing ~=((𝐗~t)t=0,(𝖫𝗏t)t=0)\tilde{\mathcal{I}}=((\tilde{\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) of an induced instance =((𝐗t)t=0,(𝖫𝗏t)t=0){\mathcal{I}}=(({\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) almost-surely satisfies the inequality (1) of the ranking condition for each tt, ω\omega, and kk such that 𝐗~t[k](ω)=ε\tilde{\mathbf{X}}_{t}[k](\omega)=-\varepsilon and 1k𝖫𝗏t(ω)1\leq k\leq\mathsf{Lv}_{t}(\omega) [TakisakaZWL24arXiv, Prop. C.2]. Thus it suffices to show, for each ω\omega, kk, and tt such that 𝐗~t[k](ω)0\tilde{\mathbf{X}}_{t}[k](\omega)\geq 0 and 1k𝖫𝗏t(ω)1\leq k\leq\mathsf{Lv}_{t}(\omega), either ~\tilde{\mathcal{I}} satisfies the inequality (1) or (1) as a requirement on ~\tilde{\mathcal{I}} is waived due to the γ\gamma-relaxation.

Now take any such t,ωt,\omega, and kk, and suppose the run ω\omega reads the program line prog at time tt. Then we can show the desired property by a case distinction over prog as follows. Here, recall ω\omega is a sequence s0s1stst+1s_{0}s_{1}\ldots s_{t}s_{t+1}\ldots of program states; we defined 𝐗t{\mathbf{X}}_{t} by 𝐗t[k](ω)=𝜼[k](st){\mathbf{X}}_{t}[k](\omega)=\boldsymbol{\eta}[k](s_{t}); and 𝔼[𝐗t+1[k]t](ω)\mathbb{E}[{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega) is the expectation of 𝜼[k](s)\boldsymbol{\eta}[k](s^{\prime}), where ss^{\prime} is the successor state of s0sts_{0}\ldots s_{t} under σ\sigma (which is not necessarily st+1s_{t+1}). Also observe the requirement (1) on ~\tilde{\mathcal{I}} is waived for given t,ωt,\omega, and kk when the value of 𝜼[k](s)\boldsymbol{\eta}[k](s^{\prime}) is negative with the probability γ\gamma or higher.

  1. 1.

    Suppose prog is a non-probabilistic program line, e.g., ‘xi:=f(𝒙)x_{i}:=f(\boldsymbol{x})’ or while φ\varphi do. Then the successor state ss^{\prime} of sts_{t} is unique. If 𝜼[k](s)\boldsymbol{\eta}[k](s^{\prime}) is non-negative, then we have 𝔼[𝐗~t+1[k]t](ω)=𝔼[𝐗t+1[k]t](ω)\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)=\mathbb{E}[{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega), so the inequality (1) is inherited from \mathcal{I} to ~\tilde{\mathcal{I}}; if negative, then the requirement (1) on ~\tilde{\mathcal{I}} is waived. The same argument applies to if \star then (recall {\mathcal{I}} is induced from a Δ\Delta-deterministic scheduler).

  2. 2.

    Suppose progif prob(p) then\mbox{\it prog}\equiv\mbox{`{if} {prob$(p)$} {then}'}. By letting γ\gamma strictly smaller than pp, we see either 𝜼[k](s)\boldsymbol{\eta}[k](s^{\prime}) is never negative, or it is negative with a probability more than γ\gamma. Thus we have the desired property for a similar reason to Case 1 (we note this argument requires pp to be a constant).

  3. 3.

    Suppose prog`xi:=sample(d)\mbox{\it prog}\equiv`x_{i}:=\mbox{\bf sample}(d)’. We can show the desired property by taking a sufficiently small γ\gamma; roughly speaking, the requirement (1) on ~\tilde{\mathcal{I}} is waived unless the chance of 𝜼[k](s)\boldsymbol{\eta}[k](s^{\prime}) being negative is very small, in which case the room for “ill” exploitation is so small that the inequality (1) is inherited from \mathcal{I} to ~\tilde{\mathcal{I}}. Almost the same argument applies to ‘xi:=ndet(D)x_{i}:=\mbox{\bf ndet}(D)’.

We note, by the finiteness of program locations LL and transitions Δ\Delta, we can take γ(0,1)\gamma\in(0,1) that satisfies all requirements above simultaneously. ∎


Now we have soundness of LLexRSM as the following theorem, which is almost an immediate consequence of Thm. 5 and Cor. 4.

{mytheorem}

[soundness of linear LLexRSM map over linear, well-behaved pCFG] Let 𝒞\mathcal{C} be a linear, well-behaved pCFG, and suppose there is a linear LLexRSM map over 𝒞\mathcal{C} (supported by any invariant). Then 𝒞\mathcal{C} is AST. ∎

6 Automated Synthesis Algorithm of LexRSM

In this section, we introduce a synthesis algorithm of LLexRSM for automated AST verification of linear PPs. It synthesizes a linear MM in a certain subclass of LLexRSMs. We first define the subclass, and then introduce our algorithm.

Our algorithm is a variant of linear template-based synthesis. There, we fix a linear MM 𝜼\boldsymbol{\eta} with unknown coefficients (i.e., the linear template), and consider an assertion “𝜼\boldsymbol{\eta} is a certificate of AST”; for example, in the standard 1-dimensional RSM synthesis, the assertion is “η\eta is an RSM map”. We then reduce this assertion into a set of linear constraints via Farkas’ Lemma [schrijver1998theory]. These constraints constitute an LP problem with an appropriate objective function. A certificate is synthesized, if feasible, by solving this LP problem. The reduction is standard, so we omit the details; see e.g. [TakisakaOUH21].

Subclass of LLexRSM for automated synthesis. While LLexRSM resolves the major issue that fixable LexRSM confronts toward its automated synthesis, we still need to tweak the notion a bit more, as the stability at negativity condition involves the value of an MM 𝜼\boldsymbol{\eta} in its antecedent part (i.e., it says “whenever 𝜼[k]\boldsymbol{\eta}[k] is negative for some kk…”); this makes the reduced constraints via Farkas’ Lemma nonlinear. Therefore, we augment the condition as follows.

{mydefinition}

[MCLC] Let 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n} be an MM supported by an invariant II, with a level map 𝖫𝗏\mathsf{Lv}. We say 𝜼\boldsymbol{\eta} satisfies the multiple-choice leftward condition (MCLC) if, for each k{1,,n}k\in\{1,\ldots,n\}, it satisfies either (4) or (5) below:

τk<𝖫𝗏.sIG(τ).\displaystyle\forall\tau\in\llbracket k<\mathsf{Lv}\rrbracket.\forall s\in\llbracket I\land G(\tau)\rrbracket. 𝜼[k](s)0,\displaystyle\quad\boldsymbol{\eta}[k](s)\geq 0, (4)
τk<𝖫𝗏.sIG(τ).ssuccτ(s).\displaystyle\forall\tau\in\llbracket k<\mathsf{Lv}\rrbracket.\forall s\in\llbracket I\land G(\tau)\rrbracket.\forall s^{\prime}\in\mathrm{succ}_{\tau}(s). 𝜼[k](s)𝜼[k](s).\displaystyle\quad\boldsymbol{\eta}[k](s^{\prime})\leq\boldsymbol{\eta}[k](s). (5)

Condition (4) is nothing but the non-negativity condition in dimension kk. Condition (5) augments the ranking condition in the strict leftward of the ranking dimension (a.k.a. the unaffecting condition) so that the value of 𝜼[k]\boldsymbol{\eta}[k] is non-increasing in the worst-case. MCLC implies stability at negativity; hence, by Thm. 5, linear SC-LexRSM maps with MCLC certify AST of linear, well-behaved pCFGs. They also instantiate SC-LexRFs as follows. {mytheorem}[SC-LexRSM maps with MCLC instantiate SC-LexRFs] Suppose 𝜼\boldsymbol{\eta} is an SC-LexRSM map over a non-probabilistic CFG 𝒞\mathcal{C} supported by II, with 𝖫𝗏\mathsf{Lv}. Then 𝜼\boldsymbol{\eta} satisfies MCLC under II and 𝖫𝗏\mathsf{Lv}. ∎

The algorithm. Our LexRSM synthesis algorithm mostly resembles the existing ones [ChatterjeeGNZZ21, AgrawalCP18], so we are brief here; a line-to-line explanation with a pseudocode is in Appendix D. The algorithm receives a pCFG 𝒞\mathcal{C} and an invariant II, and attempts to construct a SC-LexRSM with MCLC over 𝒞\mathcal{C} supported by II. The construction is iterative; at the kk-th iteration, the algorithm attempts to construct a one-dimensional MM ηk\eta_{k} that ranks transitions of 𝒞\mathcal{C} that are not ranked by the current construction 𝜼=(η1,,ηk1)\boldsymbol{\eta}=(\eta_{1},\ldots,\eta_{k-1}), while respecting MCLC. If the algorithm finds ηk\eta_{k} that ranks at least one new transition, then it appends ηk\eta_{k} to 𝜼\boldsymbol{\eta} and goes to the next iteration; otherwise, it reports a failure. Once 𝜼\boldsymbol{\eta} ranks all transitions, the algorithm reports a success, returning 𝜼\boldsymbol{\eta} as an AST certificate of 𝒞\mathcal{C}.

Our algorithm attempts to construct ηk\eta_{k} in two ways, by adopting either (4) or (5) as the leftward condition at the dimension kk. The attempt with the condition (4) is done in the same manner as existing algorithms [ChatterjeeGNZZ21, AgrawalCP18]; we require ηk\eta_{k} to rank the unranked transitions as many as possible. The attempt with the condition (5) is slightly nontrivial; the algorithm demands a user-defined parameter Class(U)2U\mbox{Class}(U)\subseteq 2^{U} for each UΔ{τout}U\subseteq\Delta\setminus\{\tau_{\mathrm{out}}\}. The parameter Class(U)\mbox{Class}(U) specifies which set of transitions the algorithm should try to rank, given the set of current unranked transitions UU; that is, for each 𝒯Class(U)\mathcal{T}\in\mbox{Class}(U), the algorithm attempts to find ηk\eta_{k} that exactly ranks transitions in 𝒯\mathcal{T}.

There are two canonical choices of Class(U)\mbox{Class}(U). One is 2U{}2^{U}\setminus\{\emptyset\}, the brute-force trial; the resulting algorithm does not terminate in polynomial time, but ranks the maximal number of transitions (by trying each 𝒯\mathcal{T} in the descending order w.r.t. |𝒯||\mathcal{T}|). This property makes the algorithm complete. Another choice is the singletons of UU, i.e., {{τ}τU}\{\{\tau\}\mid\tau\in U\}; while the resulting algorithm terminates in polynomial time, it lacks the maximality property. It is our future work to verify if there is a polynomial complete instance of our proposed algorithm. Still, any instance of it is complete over yet another class of LLexRSMs, namely linear LW-LexRSMs. The formal statement (Thm. D) with proof is in Appendix D.

7 Experiments

We performed experiments to evaluate the performance of our proposed algorithm. The implementation is publicly available666https://doi.org/10.5281/zenodo.10937558.

Our evaluation criteria are twofold: one is how the relaxed non-negativity condition of our LexRSM—SC non-negativity and MCLC—improves the applicability of the algorithm, compared to other existing non-negativity conditions. To this end, we consider two baseline algorithms.

  1. (a)

    The algorithm STR: This is the one proposed in [AgrawalCP18], which synthesizes an ST-LexRSM. We use the implementation provided by the authors [artifactgit].

  2. (b)

    The algorithm LWN: This synthesizes an LW-LexRSM. LWN is realized as an instance of our algorithm with Class(U)=\mbox{\rm Class}(U)=\emptyset. We use LWN as a proxy of the synthesis algorithm of GLexRSM [ChatterjeeGNZZ21arxiv, Alg. 2], whose implementation does not seem to exist. We note [ChatterjeeGNZZ21arxiv, Alg. 2] synthesizes an LW-LexRSM with some additional conditions; therefore, it is no less restrictive than LWN.

Another criterion is how the choice of Class(U)\mbox{\rm Class}(U) affects the performance of our algorithm. To this end, we consider two instances of it: (a) Singleton Multiple Choice(SMC), given by Class(U)={{τ}τU}\mbox{\rm Class}(U)=\{\{\tau\}\mid\tau\in U\}; and (b) Exhaustive Multiple Choice(EMC), given by Class(U)=2U\mbox{\rm Class}(U)=2^{U}\setminus\emptyset. SMC runs in PTIME, but we do not know if it is complete; EMC does not run in PTIME, but is complete.

We use benchmarks from [AgrawalCP18], which consist of non-probabilistic programs collected in [alias2010multi] and their probabilistic modifications. The modification is done in two different ways: (a) while loops “while φ do P od\textbf{while }\varphi\textbf{ do }P\textbf{ od}” are replaced with probabilistic ones “while φ\varphi do (if prob(0.5)(0.5) then PP else skip fi) od”; (b) in addition to (a), variable assignments “x:=f(𝒙)+ax:=f(\boldsymbol{x})+a” are replaced with “x:=f(𝒙)+𝑈𝑛𝑖𝑓[a1,a+1]x:=f(\boldsymbol{x})+\mathit{Unif}[a-1,a+1]”. We include non-probabilistic programs in our benchmark set because the “problematic program structure” that hinders automated LexRSM synthesis already exists in non-probabilistic programs (cf. our explanation to Fig. 2). We also tried two PPs from [ChatterjeeGNZZ21, Fig. 1], which we call counterexStr1 and counterexStr2.

We implemented our algorithm upon [AgrawalCP18], which is available at [artifactgit]. Similar to [AgrawalCP18], our implementation works as follows: (1) it receives a linear PP as an input, and translates it into a pCFG 𝒞\mathcal{C}; (2) it generates an invariant for 𝒞\mathcal{C}; (3) via our algorithm, it synthesizes an SC-LexRSM map with MCLC. Invariants are generated by ASPIC [feautrier2010accelerated], and all LP problems are solved by CPLEX [CPLEX].

Benchmark spec. Synthesis result Benchmark spec. Synthesis result
Baselines Our algs. Baselines Our algs.
Model p.l. p.a. STR LWN SMC EMC Model p.l. p.a. STR LWN SMC EMC
complex - - ×\times ×\times 7 5 serpent - - ×\times ×\times 3 3
complex \surd - ×\times ×\times 7 5 speedDis1 - - ×\times ×\times 4 4
complex \surd \surd ×\times ×\times 3 3 speedDis2 - - ×\times ×\times 4 4
cousot9 - - ×\times 3 3 3 spdSimMul - - ×\times ×\times 4 4
cousot9 \surd - ×\times ×\times 4 4 spdSimMulDep - - ×\times ×\times 4 4
loops - - ×\times ×\times 4 3 spdSglSgl2 \surd \surd ×\times ×\times 5 5
nestedLoop \surd \surd ×\times ×\times 4 3 speedpldi3 - - ×\times 3 3 3
realheapsort - - ×\times 3 3 3 speedpldi3 \surd - ×\times ×\times 4 4
RHS_step1 - - ×\times 3 3 3 counterexStr1 - \surd N/A 3 3 3
RHS_step1 \surd \surd ×\times 3 3 3 counterexStr2 - \surd ×\times ×\times 4 4
realshellsort \surd \surd ×\times 2 2 2
Table 1: The list of benchmarks in which a feasibility difference is observed between baselines and proposed algorithms. Ticks in “p.l.” and “p.a.” indicate the benchmark has a probabilistic loop and assignment, respectively. Numbers in the result indicate that the algorithm found a LexRSM with that dimension; the crosses indicate failures; “N/A” means we did not run the experiment.

Results. In 135 benchmarks from 55 models, STR succeeds in 98 cases, LWN succeeds in 105 cases while SMC and EMC succeed in 119 cases (we did not run STR for counterexStr1 because it involves a sampling from an unbounded support distribution, which is not supported by STR). Table 1 summarizes the cases where we observe differences in the feasibility of algorithms. As theoretically anticipated, LWN always succeeds in finding a LexRSM whenever STR does; the same relation is observed between SMC vs. LWN and EMC vs. SMC. In most cases, STR, LWN, and SMC return an output within a second777 There was a single example for which more time was spent, due to a larger size. , while EMC suffers from an exponential blowup when it attempts to rank transitions with Condition (5) in Def. 6. The full results are in Appendix E.

On the first evaluation criterion, the advantage of the relaxed non-negativity is evident: SMC/EMC have unique successes vs. STR on 21 programs (21/135 = 15.6% higher success rate) from 16 different models; SMC/EMC also have unique successes vs. LWN in 14 programs (14/135 = 10.4% higher success rate) from 12 models. This result shows that the program structure we observed in Fig. 2 appears in various programs in the real world.

On the second criterion, EMC does not have any unique success compared to SMC. This result suggests that SMC can be the first choice as a concrete instance of our proposed algorithm. Indeed, we suspect that SMC is actually complete—verifying its (in)completeness is a future work. For some programs, EMC found a LexRSM with a smaller dimension than SMC.

Interestingly, LWN fails to find a LexRSM for counterexStr2, despite it being given in [ChatterjeeGNZZ21] as a PP for which a GLexRSM (and hence, an LW non-negative LexRSM) exists. This happens because the implementation in [artifactgit] translates the PP into a pCFG with a different shape than the one in [ChatterjeeGNZZ21] (for the latter, a GLexRSM indeed exists); the former possesses a similar structure as in Fig. 2 because different locations are assigned for the while loop and if branch. This demonstrates the advantage of our algorithm from another point of view, i.e., robustness against different translations of PPs.

8 Related Work

There is a rich body of studies in 1-dimensional RSM [chakarov2013probabilistic, chatterjee2016termination, chatterjee2016algorithmic, chatterjee2017stochastic, ferrer2015probabilistic, mciver2016new, mciver2017new, huang2018new, fu2019termination, moosbrugger2021automated, giesl2019computing], while lexicographic RSM is relatively new [AgrawalCP18, ChatterjeeGNZZ21]. Our paper generalizes the latest work [ChatterjeeGNZZ21] on LexRSM as follows: (a) Soundness of LexRSM as a stochastic process:soundness of ε\varepsilon-fixable LexRSMs (Def. 4) generalizes [ChatterjeeGNZZ21, Thm. 1] in the sense that every GLexRSM is ε\varepsilon-fixable for any ε>0\varepsilon>0 (Thm. 4); (b) Soundness of LexRSM as a function on program states:our result (Thm. 5) generalizes [ChatterjeeGNZZ21, Thm. 2] under the linearity and well-behavedness assumptions; (c) Soundness and completeness of LexRSM synthesis algorithms:our result generalizes the results for one of two algorithms in [ChatterjeeGNZZ21] that assumes boundedness assumption on assignment distribution [ChatterjeeGNZZ21, Thm. 3].

The work [Huang0CG19] also considers a relaxed non-negativity of RSMs. Their descent supermartingale, which acts on while loops, requires well-foundedness only at every entry into the loop body. A major difference from our LexRSM is that they only consider 1-dimensional RSMs; therefore, the problem of relaxing the LW non-negativity does not appear in their setting. Compared with their RSM, our LexRSM has an advantage in verifying PPs with a structure shown in Fig. 2, where the value of our LexRSM can be arbitrarily small upon the loop entrance (at some dimension; see η2\eta_{2} at 1\ell_{1} in Fig. 2).

The work [mciver2017new] extends the applicability of standard RSM on a different aspect from LexRSM. The main feature of their RSM is that it can verify AST of the symmetric random walk. While our LexRSM cannot verify AST of this process, the RSM by [mciver2017new] is a 1-dimensional one, which typically struggles on PPs with nested structures. Such a difference can be observed from the experiment result in [MoosbruggerBKK21] (compare [MoosbruggerBKK21, Table 2] and nested_loops, sequential_loops in [MoosbruggerBKK21, Table 1]).

9 Conclusion

We proposed the first variants of LexRSM that instantiate SC-LexRF. An algorithm was proposed to synthesize such a LexRSM, and experiments have shown that the relaxation of non-negativity contributes applicability of the resulting LexRSM. We have two open problems: one is if the class of well-behaved distributions matches with the one of integrable ones; and another is if the SMC variant of our algorithm (see §7) is complete.

Acknowledgment

We thank anonymous reviewers for their constructive comments on the previous versions of the paper. The term “ill exploitation” is taken from one of the reviews that we found very helpful. We also thank Shin-ya Katsumata, Takeshi Tsukada, and Hiroshi Unno for their comments on the paper.

This work is partially supported by National Natural Science Foundation of China No. 62172077 and 62350710215.

References

  • [1] Ultimate automizer, https://www.ultimate-pa.org/?ui=tool&tool=automizer
  • [2] Abramowitz, M., Stegun., I.A.: Handbook of Mathematical Functions: with Formulas, Graphs, and Mathematical Tables. Dover Publications (2012)
  • [3] Agrawal, S., Chatterjee, K., Novotný, P.: Lexicographic ranking supermartingales: an efficient approach to termination of probabilistic programs. Proc. ACM Program. Lang. 2(POPL), 34:1–34:32 (2018), https://doi.org/10.1145/3158122
  • [4] Agrawal, S., Chatterjee, K., Novotný, P.: Lexicographic ranking supermartingales: an efficient approach to termination of probabilistic programs: Implementation (2018), https://github.com/Sheshansh/prob_termination
  • [5] Alias, C., Darte, A., Feautrier, P., Gonnord, L.: Multi-dimensional rankings, program termination, and complexity bounds of flowchart programs. In: Static Analysis: 17th International Symposium, SAS 2010, Perpignan, France, September 14-16, 2010. Proceedings 17. pp. 117–133. Springer (2010)
  • [6] Ash, R., Doléans-Dade, C.: Probability and Measure Theory. Harcourt/Academic Press (2000)
  • [7] Barthe, G., Gaboardi, M., Grégoire, B., Hsu, J., Strub, P.Y.: Proving differential privacy via probabilistic couplings. In: Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science. pp. 749–758 (2016)
  • [8] Barthe, G., Gaboardi, M., Hsu, J., Pierce, B.: Programming language techniques for differential privacy. ACM SIGLOG News 3(1), 34–53 (2016)
  • [9] Ben-Amram, A.M., Genaim, S.: Complexity of bradley-manna-sipma lexicographic ranking functions. In: Kroening, D., Pasareanu, C.S. (eds.) Computer Aided Verification - 27th International Conference, CAV 2015, San Francisco, CA, USA, July 18-24, 2015, Proceedings, Part II. Lecture Notes in Computer Science, vol. 9207, pp. 304–321. Springer (2015), https://doi.org/10.1007/978-3-319-21668-3_18
  • [10] Bertsekas, D.P., Shreve, S.E.: Stochastic Optimal Control: The Discrete-Time Case. Athena Scientific (2007)
  • [11] Bradley, A.R., Manna, Z., Sipma, H.B.: Linear ranking with reachability. In: Etessami, K., Rajamani, S.K. (eds.) Computer Aided Verification, 17th International Conference, CAV 2005, Edinburgh, Scotland, UK, July 6-10, 2005, Proceedings. Lecture Notes in Computer Science, vol. 3576, pp. 491–504. Springer (2005), https://doi.org/10.1007/11513988_48
  • [12] Canal, G., Cashmore, M., Krivić, S., Alenyà, G., Magazzeni, D., Torras, C.: Probabilistic planning for robotics with rosplan. In: Towards Autonomous Robotic Systems: 20th Annual Conference, TAROS 2019, London, UK, July 3–5, 2019, Proceedings, Part I 20. pp. 236–250. Springer (2019)
  • [13] Chakarov, A., Sankaranarayanan, S.: Probabilistic program analysis with martingales. In: Computer Aided Verification: 25th International Conference, CAV 2013, Saint Petersburg, Russia, July 13-19, 2013. Proceedings 25. pp. 511–526. Springer (2013)
  • [14] Chatterjee, K., Fu, H., Goharshady, A.K.: Termination analysis of probabilistic programs through positivstellensatz’s. In: Computer Aided Verification: 28th International Conference, CAV 2016, Toronto, ON, Canada, July 17-23, 2016, Proceedings, Part I 28. pp. 3–22. Springer (2016)
  • [15] Chatterjee, K., Fu, H., Novotnỳ, P., Hasheminezhad, R.: Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs. In: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 327–342 (2016)
  • [16] Chatterjee, K., Goharshady, E.K., Novotný, P., Zárevúcky, J., Zikelic, D.: On lexicographic proof rules for probabilistic termination. In: Huisman, M., Pasareanu, C.S., Zhan, N. (eds.) Formal Methods - 24th International Symposium, FM 2021, Virtual Event, November 20-26, 2021, Proceedings. Lecture Notes in Computer Science, vol. 13047, pp. 619–639. Springer (2021), https://doi.org/10.1007/978-3-030-90870-6_33
  • [17] Chatterjee, K., Goharshady, E.K., Novotný, P., Zárevúcky, J., Zikelic, D.: On lexicographic proof rules for probabilistic termination. CoRR abs/2108.02188 (2021), https://arxiv.org/abs/2108.02188
  • [18] Chatterjee, K., Novotnỳ, P., Zikelic, D.: Stochastic invariants for probabilistic termination. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. pp. 145–160 (2017)
  • [19] Dubhashi, D.P., Panconesi, A.: Concentration of measure for the analysis of randomized algorithms. Cambridge University Press (2009)
  • [20] Feautrier, P., Gonnord, L.: Accelerated invariant generation for c programs with aspic and c2fsm. Electronic Notes in Theoretical Computer Science 267(2), 3–13 (2010)
  • [21] Ferrer Fioriti, L.M., Hermanns, H.: Probabilistic termination: Soundness, completeness, and compositionality. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 489–501 (2015)
  • [22] Fu, H., Chatterjee, K.: Termination of nondeterministic probabilistic programs. In: Verification, Model Checking, and Abstract Interpretation: 20th International Conference, VMCAI 2019, Cascais, Portugal, January 13–15, 2019, Proceedings 20. pp. 468–490. Springer (2019)
  • [23] Giesl, J., Giesl, P., Hark, M.: Computing expected runtimes for constant probability programs. In: Automated Deduction–CADE 27: 27th International Conference on Automated Deduction, Natal, Brazil, August 27–30, 2019, Proceedings 27. pp. 269–286. Springer (2019)
  • [24] Huang, M., Fu, H., Chatterjee, K.: New approaches for almost-sure termination of probabilistic programs. In: Programming Languages and Systems: 16th Asian Symposium, APLAS 2018, Wellington, New Zealand, December 2–6, 2018, Proceedings 16. pp. 181–201. Springer (2018)
  • [25] Huang, M., Fu, H., Chatterjee, K., Goharshady, A.K.: Modular verification for almost-sure termination of probabilistic programs. Proc. ACM Program. Lang. 3(OOPSLA), 129:1–129:29 (2019), https://doi.org/10.1145/3360555
  • [26] IBM: Ibm ilog cplex 12.7 user’s manual (ibm ilog cplex division, incline village, nv) (2017)
  • [27] Karp, R.M.: An introduction to randomized algorithms. Discrete Applied Mathematics 34(1-3), 165–201 (1991)
  • [28] Lobo-Vesga, E., Russo, A., Gaboardi, M.: A programming language for data privacy with accuracy estimations. ACM Transactions on Programming Languages and Systems (TOPLAS) 43(2), 1–42 (2021)
  • [29] McIver, A., Morgan, C.: A new rule for almost-certain termination of probabilistic-and demonic programs. arXiv preprint arXiv:1612.01091 (2016)
  • [30] McIver, A., Morgan, C., Kaminski, B.L., Katoen, J.P.: A new proof rule for almost-sure termination. Proceedings of the ACM on Programming Languages 2(POPL), 1–28 (2017)
  • [31] Moosbrugger, M., Bartocci, E., Katoen, J.P., Kovács, L.: Automated termination analysis of polynomial probabilistic programs. In: Programming Languages and Systems: 30th European Symposium on Programming, ESOP 2021, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2021, Luxembourg City, Luxembourg, March 27–April 1, 2021, Proceedings 30. pp. 491–518. Springer International Publishing (2021)
  • [32] Moosbrugger, M., Bartocci, E., Katoen, J., Kovács, L.: The probabilistic termination tool amber. In: Huisman, M., Pasareanu, C.S., Zhan, N. (eds.) Formal Methods - 24th International Symposium, FM 2021, Virtual Event, November 20-26, 2021, Proceedings. Lecture Notes in Computer Science, vol. 13047, pp. 667–675. Springer (2021), https://doi.org/10.1007/978-3-030-90870-6_36
  • [33] Olmedo, F., Gretz, F., Jansen, N., Kaminski, B.L., Katoen, J., McIver, A.: Conditioning in probabilistic programming. ACM Trans. Program. Lang. Syst. 40(1), 4:1–4:50 (2018), https://doi.org/10.1145/3156018
  • [34] Parker, D.: Verification of probabilistic real-time systems. Proc. 2013 Real-time Systems Summer School (ETR’13) (2013)
  • [35] Schrijver, A.: Theory of linear and integer programming. John Wiley & Sons (1998)
  • [36] Takisaka, T., Oyabu, Y., Urabe, N., Hasuo, I.: Ranking and repulsing supermartingales for reachability in randomized programs. ACM Trans. Program. Lang. Syst. 43(2), 5:1–5:46 (2021), https://doi.org/10.1145/3450967
  • [37] Takisaka, T., Zhang, L., Wang, C., Liu, J.: Lexicographic ranking supermartingales with lazy lower bounds. CoRR abs/2304.11363 (2024), https://doi.org/10.48550/arXiv.2304.11363

Appendix

𝑝𝑟𝑜𝑔::=skip𝑝𝑣𝑎𝑟:=𝑎𝑠𝑠𝑔𝑛𝑝𝑟𝑜𝑔‘;’𝑝𝑟𝑜𝑔if𝑏𝑒𝑥𝑝𝑟then𝑝𝑟𝑜𝑔else𝑝𝑟𝑜𝑔fiifthen𝑝𝑟𝑜𝑔else𝑝𝑟𝑜𝑔fiifprob(p)then𝑝𝑟𝑜𝑔else𝑝𝑟𝑜𝑔fiwhile𝑏𝑒𝑥𝑝𝑟do𝑝𝑟𝑜𝑔od𝑎𝑠𝑠𝑔𝑛::=𝑒𝑥𝑝𝑟sample(d)ndet(D)𝑙𝑖𝑡𝑒𝑟𝑎𝑙::=𝑒𝑥𝑝𝑟𝑒𝑥𝑝𝑟𝑒𝑥𝑝𝑟𝑒𝑥𝑝𝑟𝑏𝑒𝑥𝑝𝑟::=𝑙𝑖𝑡𝑒𝑟𝑎𝑙¬𝑏𝑒𝑥𝑝𝑟𝑏𝑒𝑥𝑝𝑟or𝑏𝑒𝑥𝑝𝑟𝑏𝑒𝑥𝑝𝑟and𝑏𝑒𝑥𝑝𝑟\begin{array}[]{rrl}\langle\mathit{prog}\rangle&::=&\mbox{`{skip}'}\mid\langle\mathit{pvar}\rangle\,\mbox{`$:=$'}\,\langle\mathit{assgn}\rangle\mid\langle\mathit{prog}\rangle\,\text{`;'}\langle\mathit{prog}\rangle\\ &&\mid\mbox{`{if}'}\,\langle\mathit{bexpr}\rangle\,\mbox{`{then}'}\,\langle\mathit{prog}\rangle\,\mbox{`{else}'}\,\langle\mathit{prog}\rangle\,\mbox{`{fi}'}\\ &&\mid\mbox{`{if}'}\,\mbox{`$\star$'}\,\mbox{`{then}'}\,\langle\mathit{prog}\rangle\,\mbox{`{else}'}\,\langle\mathit{prog}\rangle\,\mbox{`{fi}'}\\ &&\mid\mbox{`{if}'}\,\mbox{`{prob$(p)$}'}\,\mbox{`{then}'}\,\langle\mathit{prog}\rangle\,\mbox{`{else}'}\,\langle\mathit{prog}\rangle\,\mbox{`{fi}'}\\ &&\mid\mbox{`{while}'}\,\langle\mathit{bexpr}\rangle\,\text{`{do}'}\,\langle\mathit{prog}\rangle\,\text{`{od}'}\\ \vspace{\baselineskip}\hfil\\ \langle\mathit{assgn}\rangle&::=&\langle\mathit{expr}\rangle\mid\mbox{`{sample$(d)$}'}\mid\mbox{`{ndet$(D)$}'}\\ \langle\mathit{literal}\rangle&::=&\langle\mathit{expr}\rangle\,\mbox{`$\leq$'}\,\langle\mathit{expr}\rangle\mid\langle\mathit{expr}\rangle\,\mbox{`$\geq$'}\,\langle\mathit{expr}\rangle\\ \langle\mathit{bexpr}\rangle&::=&\langle\mathit{literal}\rangle\mid\neg\langle\mathit{bexpr}\rangle\mid\langle\mathit{bexpr}\rangle\,\mbox{`{or}'}\,\langle\mathit{bexpr}\rangle\\ &&\mid\langle\mathit{bexpr}\rangle\,\mbox{`{and}'}\,\langle\mathit{bexpr}\rangle\end{array}
Figure 5: The syntax of probabilistic programs

Appendix A Omitted Details of Section 3

Notations. The set of finite, nonempty finite, and infinite sequences of elements in a set 𝒳\mathcal{X} are denoted by 𝒳\mathcal{X}^{*}, 𝒳+\mathcal{X}^{+}, and 𝒳\mathcal{X}^{\mathbb{N}}, respectively. For a measurable space (Ω,)(\Omega,\mathcal{F}), the Dirac measure δω\delta_{\omega} at ωΩ\omega\in\Omega is the distribution over (Ω,)(\Omega,\mathcal{F}) such that δω(A)=1\delta_{\omega}(A)=1 if ωA\omega\in A, and δω(A)=0\delta_{\omega}(A)=0 otherwise, for each AA\in\mathcal{F}. The support supp(μ)\mathrm{supp}(\mu) of μ𝒟(Ω)\mu\in\mathcal{D}(\Omega) is the set of samples ωΩ\omega\in\Omega such that μ(A)>0\mu(A)>0 for each open set AA that contains ω\omega. For a random variable XX over a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}), the expectation 𝔼[X]\mathbb{E}_{\mathbb{P}}[X] of XX is the value ΩX𝑑\int_{\Omega}Xd\mathbb{P}, provided it exists (which is possibly infinite). We write (xi,𝒙i)(x_{i},\boldsymbol{x}_{-i}) to denote 𝒙=(x1,,xn)\boldsymbol{x}=(x_{1},\ldots,x_{n}) with an emphasis on a particular variable xix_{i}.

For a set 𝒳\mathcal{X}, a function p:𝒳𝒟(Ω)p\colon\mathcal{X}\to\mathcal{D}(\Omega) is called a stochastic kernel on Ω\Omega given 𝒳\mathcal{X}; it is used to describe the local random behavior of transition systems (e.g. p(x)p(x) may represent the successor distribution given the transition history x𝒳x\in\mathcal{X}). We write p(Ax)p(A\mid x) to denote the value p(x)(A)p(x)(A). We say pp is deterministic if p(x)p(x) is Dirac for x𝒳x\in\mathcal{X}. In this case, we canonically identify the range of pp with Ω\Omega.

For given probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}), random variable X:ΩX:\Omega\to\mathbb{R} and sub-σ\sigma-algebra \mathcal{F}^{\prime}\subseteq\mathcal{F}, the conditional expectation of XX given \mathcal{F}^{\prime} is an \mathcal{F}^{\prime}-measurable function 𝔼[X]:Ω{+,}\mathbb{E}[X\mid\mathcal{F}^{\prime}]:\Omega\to\mathbb{R}\cup\{+\infty,-\infty\} such that A𝔼[X]𝑑=AX𝑑\int_{A}\mathbb{E}[X\mid\mathcal{F}^{\prime}]d\mathbb{P}=\int_{A}Xd\mathbb{P} for each AA\in\mathcal{F}^{\prime}. The conditional probability [φ]\mathbb{P}[\varphi\mid\mathcal{F}^{\prime}] of a predicate φ\varphi is defined as [φ]=𝔼[𝟏φ]\mathbb{P}[\varphi\mid\mathcal{F}^{\prime}]=\mathbb{E}[{\bf 1}_{\llbracket\varphi\rrbracket}\mid\mathcal{F}^{\prime}]. It is known that 𝔼[X]\mathbb{E}[X\mid\mathcal{F}^{\prime}] exists whenever 𝔼[X]\mathbb{E}_{\mathbb{P}}[X] does, and is \mathbb{P}-a.s. unique [Ash:book]888 In the book, XX is either non-negative or integrable; the fact extends to the general case by evaluating the positive and negative parts of XX. Also, if 𝔼[X]\mathbb{E}[X\mid\mathcal{F}^{\prime}] exists, then 𝔼[𝟏AX]\mathbb{E}[{\bf 1}_{A}\cdot X\mid\mathcal{F}^{\prime}] also exists for any AA\in\mathcal{F}. .

The formula t.φt\overset{\infty}{\forall}t.\varphi_{t} stands for k.t.tkφt\exists k.\forall t.t\geq k\Rightarrow\varphi_{t}; the one t.φt\overset{\infty}{\exists}t.\varphi_{t} is defined as the dual.

The syntax of probabilistic programs. See Fig. 5999 In our syntax, the command “x:=x+𝑈𝑛𝑖𝑓[1,2]x:=x+\mathit{Unif}[1,2]” in Fig. 2 is understood as a syntax sugar for “z:=sample(𝑈𝑛𝑖𝑓[1,2]);x:=x+zz:=\textbf{sample$(\mathit{Unif}[1,2])$};x:=x+z”, where zz is an auxiliary variable that stores the sampling result. . There, 𝑝𝑣𝑎𝑟\langle\mathit{pvar}\rangle ranges over program variables 𝒱\mathcal{V}, a fixed countable set; and 𝑒𝑥𝑝𝑟\langle\mathit{expr}\rangle ranges over arithmetic expressions over 𝒱\mathcal{V}, constructed from program variables, real-valued constants and arithmetic operations such as addition and multiplication.

A translation from PPs to pCFGs. See Fig. 6.

i\ell_{i}o\ell_{o}τ:true,1,id~{}\tau:true,1,id~{}
(a) skip
i\ell_{i}o\ell_{o}τ:true,1,(i,u)~{}\tau:true,1,(i,u)
(b) xi:=𝑎𝑠𝑠𝑔𝑛x_{i}:=\langle\mathit{assgn}\rangle
i=\ell_{i}=iA\ell^{A}_{i}oA=\ell^{A}_{o}=iB\ell^{B}_{i}o=\ell_{o}=oB\ell^{B}_{o}
(c) A;B
i\ell_{i}iA\ell^{A}_{i}iB\ell^{B}_{i}o=\ell_{o}=oA=\ell^{A}_{o}=oB\ell^{B}_{o}τ2:¬φ,1,id\tau_{2}:\neg\varphi,1,idτ1:φ,1,id\tau_{1}:\varphi,1,id
(d) if φ\varphi then A else B
i\ell_{i}iA\ell^{A}_{i}iB\ell^{B}_{i}o=\ell_{o}=oA=\ell^{A}_{o}=oB\ell^{B}_{o}τ:true,1p,id\tau:true,1-p,idτ:true,p,id\tau:true,p,id
(e) if prob(p)prob(p) then A else B
i\ell_{i}iA\ell^{A}_{i}iB\ell^{B}_{i}o=\ell_{o}=oA=\ell^{A}_{o}=oB\ell^{B}_{o}τ2:true,1,id\tau_{2}:true,1,idτ1:true,1,id\tau_{1}:true,1,id
(f) if * then A else B
i=\ell_{i}=oA\ell^{A}_{o}iA\ell^{A}_{i}o\ell_{o}τ1:φ,1,id\tau_{1}:\varphi,1,idτ2:¬φ,1,id\tau_{2}:\neg\varphi,1,id
(g) while φ\varphi do A od
Figure 6: A translation of PPs into pCFGs. Circles i\ell_{i} and o\ell_{o} represent the initial and final locations of the translated pCFG, respectively. The description “τ:φ,p,(i,u)\tau:\varphi,p,(i,u)” on an arrow from \ell to \ell^{\prime} shows that the pCFG has a transition τ=(,δ)\tau=(\ell,\delta) such that G(τ)φG(\tau)\equiv\varphi, δ()=p\delta(\ell^{\prime})=p and 𝑈𝑝(τ)=(i,u)\mathit{Up}(\tau)=(i,u), where uu corresponds to the content of 𝑎𝑠𝑠𝑔𝑛\langle\mathit{assgn}\rangle in the case (b); and 𝑖𝑑(1,λ𝒙.x1)\mathit{id}\equiv(1,\lambda\boldsymbol{x}.x_{1}) represents “no update”. Circles iA\ell_{i}^{A} and oA\ell_{o}^{A} represent the initial and final locations of the pCFG for program fragment AA, whose transitions are abstractly shown by a dotted arrow. the pCFG for BB is described similarly.

Deadlock-freeness. We assume pCFGs are deadlock-free, i.e., for any state s𝒮s\in\mathcal{S} there exists τΔ\tau\in\Delta enabled at ss.

Successors. A state (,𝒚)(\ell^{\prime},\boldsymbol{y}) is a successor of (,𝒙)(\ell,\boldsymbol{x}) via τΔ\tau\in\Delta if and only if τ=(,δ)\tau=(\ell,\delta) satisfies 𝒙G(τ)\boldsymbol{x}\in\llbracket G(\tau)\rrbracket, δ()>0\delta(\ell^{\prime})>0, 𝑈𝑝(τ)=(i,u)\mathit{Up}(\tau)=(i,u), and 𝒚[i]\boldsymbol{y}[i] is: (a) equal to u(𝒙)u(\boldsymbol{x}) if τΔd\tau\in\Delta_{d}; (b) in supp(u)\mathrm{supp}(u) if τΔp\tau\in\Delta_{p}; and (c) in uu if τΔn\tau\in\Delta_{n}.

Finite paths and runs. A finite path of 𝒞\mathcal{C} is a nonempty finite sequence s0s1st𝒮+s_{0}s_{1}\ldots s_{t}\in\mathcal{S}^{+} of states such that s0=(in,𝒙)s_{0}=(\ell_{\mathrm{in}},\boldsymbol{x}) for some 𝒙|V|\boldsymbol{x}\in\mathbb{R}^{|V|} and st+1succτ(st)s_{t^{\prime}+1}\in\mathrm{succ}_{\tau}(s_{t^{\prime}}) with τ\tau enabled at sts_{t^{\prime}}, for each t{0,,t1}t^{\prime}\in\{0,\ldots,t-1\}. A run of 𝒞\mathcal{C} is an infinite sequence ω𝒮\omega\in\mathcal{S}^{\mathbb{N}} of states any of whose prefix is a finite path. The set of all finite paths, finite paths with length tt, and runs of 𝒞\mathcal{C} are denoted by Π𝒞f\Pi_{\mathcal{C}}^{f}, Π𝒞t\Pi_{\mathcal{C}}^{t}, and Π𝒞\Pi_{\mathcal{C}}, respectively.

Schedulers. Schedulers resolve nondeterminism. Recall there are two types of nondeterminism in pCFGs: (a) nondeterministic choice of τΔ\tau\in\Delta at a given state (corresponds to if\star), and (b) nondeterministic variable update in a nondeterministic transition τΔn\tau\in\Delta_{n} (corresponds to xi:=x_{i}:=ndet(D)(D)). Therefore, we define a scheduler as a pair of functions σ=(σΔ,σV)\sigma=(\sigma_{\Delta},\sigma_{V}), where σΔ\sigma_{\Delta} and σV\sigma_{V} handle the cases (a) and (b), respectively. Schedulers can make a choice in a probabilistic way, and can be history dependent; that is, σΔ\sigma_{\Delta} and σV\sigma_{V} are (partial) stochastic kernels of the form σΔ:Π𝒞f𝒟(Δ)\sigma_{\Delta}:\Pi_{\mathcal{C}}^{f}\to\mathcal{D}(\Delta) and σV:Π𝒞f×Δn×L𝒟()\sigma_{V}:\Pi_{\mathcal{C}}^{f}\times\Delta_{n}\times L\to\mathcal{D}(\mathbb{R}), respectively.

Formally, a scheduler is a pair of functions σ=(σΔ,σV)\sigma=(\sigma_{\Delta},\sigma_{V}), where, for each s𝒮s\in\mathcal{S} and w𝒮w\in\mathcal{S}^{*} such that wsΠ𝒞fws\in\Pi_{\mathcal{C}}^{f},

  • σΔ:Π𝒞f𝒟(Δ)\sigma_{\Delta}:\Pi_{\mathcal{C}}^{f}\to\mathcal{D}(\Delta) satisfies σΔ(τws)>0\sigma_{\Delta}(\tau\mid ws)>0 only if τ\tau is enabled at ss; and

  • σV:Π𝒞f×Δn×L𝒟()\sigma_{V}:\Pi_{\mathcal{C}}^{f}\times\Delta_{n}\times L\to\mathcal{D}(\mathbb{R}) is a partial function defined on {(ws,τ,)sG(τ),τ=(,δ),δ()>0}\{(ws,\tau,\ell^{\prime})\mid s\in\llbracket G(\tau)\rrbracket,\tau=(\ell,\delta),\delta(\ell^{\prime})>0\} such that supp(σV(ws,τ,))u\mathrm{supp}(\sigma_{V}(ws,\tau,\ell^{\prime}))\subseteq u, where 𝑈𝑝(τ)=(i,u)\mathit{Up}(\tau)=(i,u).

We say σ=(σΔ,σV)\sigma=(\sigma_{\Delta},\sigma_{V}) is Δ\Delta-deterministic if σΔ\sigma_{\Delta} is deterministic, i.e., σΔ(w)\sigma_{\Delta}(w) is Dirac for any wΠ𝒞fw\in\Pi_{\mathcal{C}}^{f}.

The dynamics of 𝒞\mathcal{C}. By fixing a scheduler σ\sigma, the local behavior of a pCFG 𝒞\mathcal{C} (“what will be the next state given the current transition history?”) is determined as a function pσ:Π𝒞f𝒟(𝒮)p^{\sigma}:\Pi_{\mathcal{C}}^{f}\to\mathcal{D}(\mathcal{S}), where pσ(s0st)𝒟(𝒮)p^{\sigma}(s_{0}\ldots s_{t})\in\mathcal{D}(\mathcal{S}) represents the distribution of the successor of sts_{t} under σ\sigma given the transition history s0stΠ𝒞fs_{0}\ldots s_{t}\in\Pi_{\mathcal{C}}^{f}. By additionally fixing an initial state sIs_{I}, the infinite-horizon behavior of 𝒞\mathcal{C} is also determined as a distribution sIσ𝒟(Π𝒞)\mathbb{P}_{s_{I}}^{\sigma}\in\mathcal{D}(\Pi_{\mathcal{C}}), where sIσ\mathbb{P}_{s_{I}}^{\sigma} represents the distribution of runs generated by 𝒞\mathcal{C} under σ\sigma, starting from sIs_{I}. We call the probability space (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}) the dynamics of 𝒞\mathcal{C} under σ\sigma and sIs_{I}. The distribution sIσ\mathbb{P}_{s_{I}}^{\sigma} is realized as the “limit” of the distribution t\mathbb{P}_{t} of the tt-length finite path under σ\sigma and sIs_{I}, which is inductively constructed by pσp^{\sigma} (see e.g. [BertsekasS07, Prop. 7.28] for the precise argument):

1=δsI,t+1(A×B)=wApσ(Bw)dt(AΠ𝒞t,B(𝒮)).\displaystyle\mathbb{P}_{1}=\delta_{s_{I}}\quad,\quad\mathbb{P}_{t+1}(A\times B)=\int_{w\in A}p^{\sigma}(B\mid w)d\mathbb{P}_{t}\quad(A\in\Pi_{\mathcal{C}}^{t},B\in\mathcal{B}(\mathcal{S})).

Cylinder sets. A cylinder set of Ω=Π𝒞\Omega=\Pi_{\mathcal{C}} is a subset of Ω\Omega of the following form for some tt\in\mathbb{N}:

[A0A1At]={s0s1Ωt{0,,t}.stAt},[A_{0}A_{1}\ldots A_{t}]=\{s_{0}s_{1}\ldots\in\Omega\mid\forall t^{\prime}\in\{0,\ldots,t\}.s_{t^{\prime}}\in A_{t^{\prime}}\},

where At𝒮A_{t^{\prime}}\subseteq\mathcal{S} is Borel measurable.

Pre-expectation. The pre-expectation of a (1-dimensional) MM η\eta formalizes the notion of “the value of η\eta after a transition”, which comes in two different forms. One is the pre-expectation under a scheduler σ\sigma, which is defined as the expected value of η\eta at the successor state under σ\sigma, given a transition history. This is formalized as a function 𝕏ση:Π𝒞f\mathbb{X}_{\sigma}\eta:\Pi_{\mathcal{C}}^{f}\to\mathbb{R} such that 𝕏ση(w)=𝔼pσ(w)[η]\mathbb{X}_{\sigma}\eta(w)=\mathbb{E}_{p^{\sigma}(w)}[\eta]; recall pσ(w)𝒟(𝒮)p^{\sigma}(w)\in\mathcal{D}(\mathcal{S}) is the successor distribution under σ\sigma given the transition history ww. Another variant is the maximal pre-expectation under a transition τ\tau, which is defined as the maximal expected value of η\eta at the successor state via τ\tau from a given state (not a history, as such a maximal value is history independent). This is formalized as a function 𝕏¯τη:G(τ)\overline{\mathbb{X}}_{\tau}\eta:\llbracket G(\tau)\rrbracket\to\mathbb{R} such that 𝕏¯τη(s)=sup{𝕏ση(s)σΔ(s)=τ}\overline{\mathbb{X}}_{\tau}\eta(s)=\sup\{\mathbb{X}_{\sigma}\eta(s)\mid\sigma_{\Delta}(s)=\tau\}. Equivalently, we can define the value of 𝕏¯τη(s)\overline{\mathbb{X}}_{\tau}\eta(s) as follows, by explicitly writing 𝕏ση\mathbb{X}_{\sigma}\eta down; for τ=(,δ)\tau=(\ell,\delta) with 𝑈𝑝(τ)=(i,u)\mathit{Up}(\tau)=(i,u) and sG(τ)s\in\llbracket G(\tau)\rrbracket, we let 𝕏¯τη(s)=Lδ()𝕏¯τ,η(s)\overline{\mathbb{X}}_{\tau}\eta(s)=\sum_{\ell^{\prime}\in L}\delta(\ell^{\prime})\cdot\overline{\mathbb{X}}_{\tau,\ell^{\prime}}\eta(s), where

𝕏¯τ,η(,𝒙)={η(,u(𝒙),𝒙i)if τΔd,𝔼u[λxi.η(,xi,𝒙i)]if τΔp,supxiuη(,xi,𝒙i)if τΔn.\displaystyle\overline{\mathbb{X}}_{\tau,\ell^{\prime}}\eta(\ell,\boldsymbol{x})=\begin{cases}\eta(\ell^{\prime},u(\boldsymbol{x}),\boldsymbol{x}_{-i})&\text{if }\tau\in\Delta_{d},\\ \mathbb{E}_{u}[\lambda x_{i}^{\prime}.\eta(\ell^{\prime},x_{i}^{\prime},\boldsymbol{x}_{-i})]&\text{if }\tau\in\Delta_{p},\\ \sup_{x_{i}^{\prime}\in u}\eta(\ell^{\prime},x_{i}^{\prime},\boldsymbol{x}_{-i})&\text{if }\tau\in\Delta_{n}.\end{cases} (6)

Basic notions about stochastic process. A (discrete-time) stochastic process in a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) is a sequence (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} of nn-dimensional, \mathcal{F}-measurable random variables 𝐗t:Ωn\mathbf{X}_{t}:\Omega\to\mathbb{R}^{n} for tt\in\mathbb{N}. In our context, one can suppose the probability space is the dynamics (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}) of a pCFG 𝒞\mathcal{C} under some σ\sigma and sIs_{I}; there, a typical example of a stochastic process is the value of an MM 𝜼\boldsymbol{\eta} over 𝒞\mathcal{C} at time tt:

𝐗t(s0s1)=𝜼(st).\displaystyle\mathbf{X}_{t}(s_{0}s_{1}\ldots)=\boldsymbol{\eta}(s_{t}). (7)

In this case, the process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} represents the behavior of 𝜼\boldsymbol{\eta} along the run of 𝒞\mathcal{C} under σ\sigma and sIs_{I}.

At time tt\in\mathbb{N}, we usually only have a limited knowledge about a sample ωΩ\omega\in\Omega of the probability space; for example, when we observe the behavior of a pCFG 𝒞\mathcal{C}, we only know the finite history s0sts_{0}\ldots s_{t} of a run s0s1Π𝒞s_{0}s_{1}\ldots\in\Pi_{\mathcal{C}} at a given time tt. Such a limitation of knowledge is formalized as a filtration in (Ω,,)(\Omega,\mathcal{F},\mathbb{P}), which is a sequence (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} of sub-σ\sigma-algebras of \mathcal{F} such that tt+1\mathcal{F}_{t}\subseteq\mathcal{F}_{t+1}\subseteq\mathcal{F} for each tt\in\mathbb{N}. Intuitively, two elements ω,ωΩ\omega,\omega^{\prime}\in\Omega can be distinguished according to t\mathcal{F}_{t} if and only if there exists AtA\in\mathcal{F}_{t} such that ωA\omega\in A and ωA\omega^{\prime}\not\in A. In our context, t\mathcal{F}_{t} is typically the σ\sigma-algebra generated by cylinder sets of length t+1t+1, which can distinguish two runs if and only if they branch off by time tt; we call such a filtration the canonical filtration in the dynamics of pCFG.

Given a stochastic process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} and a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} in (Ω,,)(\Omega,\mathcal{F},\mathbb{P}), it is natural to require that the value of 𝐗t\mathbf{X}_{t} should be determined by the knowledge t\mathcal{F}_{t}, i.e., 𝐗t\mathbf{X}_{t} is t\mathcal{F}_{t}-measurable. In such a case, (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is said to be adapted to (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}. The stochastic process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} defined by Eq. (7) is adapted to the canonical filtration; indeed, the value of 𝐗t\mathbf{X}_{t} only depends on the tt-th state sts_{t} of the run, which we know according to the tt-th element of the canonical filtration.

The termination of the process is formalized by a stopping time with respect to a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}, which is a random variable T:Ω{+}T:\Omega\to\mathbb{N}\cup\{+\infty\} such that the set TtΩ\llbracket T\leq t\rrbracket\subseteq\Omega is t\mathcal{F}_{t}-measurable for each tt\in\mathbb{N}. For such a TT, we naturally expect the value of a stochastic process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} does not change after TT, i.e., 𝐗t(ω)=𝐗t+1(ω)\mathbf{X}_{t}(\omega)=\mathbf{X}_{t+1}(\omega) holds for each ωΩ\omega\in\Omega and tt\in\mathbb{N} such that tT(ω)t\geq T(\omega). In such a case, (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is said to be stopped at TT. In our context, a typical instance of stopping time is the termination time Tterm𝒞T_{\mathrm{term}}^{\mathcal{C}} of 𝒞\mathcal{C}; by the absorbing assumption of 𝒞\mathcal{C} at (out,𝒙)(\ell_{\mathrm{out}},\boldsymbol{x}), the stochastic process (7) is stopped at the termination time.

Let 𝜼:Sn\boldsymbol{\eta}:S\to\mathbb{R}^{n} be an MM with 𝖫𝗏:Δ{0,,n}\mathsf{Lv}:\Delta\to\{0,\ldots,n\}. For Δ\Delta-deterministic101010 This is relevant for defining 𝖫𝗏t\mathsf{Lv}_{t}. Similar RSM construction for general σ\sigma is also possible by defining runs of pCFGs as alternating sequences of states and transitions. scheduler σ\sigma and initial state sIs_{I}, one can construct (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty}, (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} and TT as above, and also the level map (𝖫𝗏t)t=0(\mathsf{Lv}_{t})_{t=0}^{\infty} by 𝖫𝗏t(c0c1)=𝖫𝗏(σΔ(c0ct))\mathsf{Lv}_{t}(c_{0}c_{1}\ldots)=\mathsf{Lv}(\sigma_{\Delta}(c_{0}\ldots c_{t})). We say the resulting instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is induced by 𝜼\boldsymbol{\eta} and 𝖫𝗏\mathsf{Lv} under σ\sigma and sIs_{I}.

Conditional expectation takes the role of pre-expectation in stochastic processes. Informally speaking, the random variable 𝔼[𝐗t+1t]\mathbb{E}[\mathbf{X}_{t+1}\mid\mathcal{F}_{t}] represents the “pre-expectation of 𝐗t\mathbf{X}_{t}”, i.e., 𝔼[𝐗t+1t](ω)\mathbb{E}[\mathbf{X}_{t+1}\mid\mathcal{F}_{t}](\omega) is the expected value of 𝐗t+1\mathbf{X}_{t+1} given the knowledge about ω\omega available from t\mathcal{F}_{t}; for a stochastic process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} induced by an MM as Eq. (7), this informal explanation is justified by the following proposition.

{myproposition}

Fix a pCFG 𝒞\mathcal{C}, its strategy σ\sigma and initial state sIs_{I}; let (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}) be the dynamics of 𝒞\mathcal{C} under σ\sigma and sIs_{I}; and let an MM 𝜼\boldsymbol{\eta} over 𝒞\mathcal{C} be given. Define a stochastic process (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} in (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}) by Eq. (7), and let (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} be the canonical filtration in (Π𝒞,(Π𝒞),sIσ)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}_{s_{I}}^{\sigma}). For each tt\in\mathbb{N} and k{1,,n}k\in\{1,\ldots,n\} for which 𝔼[𝐗t[k]]\mathbb{E}_{\mathbb{P}}[\mathbf{X}_{t}[k]] exists, the conditional expectation 𝔼[𝐗t+1[k]t]\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}] is realized by a function f:Π𝒞f:\Pi_{\mathcal{C}}\to\mathbb{R} such that f(s0s1)=𝕏σ𝜼[k](s0st)f(s_{0}s_{1}\ldots)=\mathbb{X}_{\sigma}\boldsymbol{\eta}[k](s_{0}\ldots s_{t}). ∎

Proof.

For simplicity, WLOG assume 𝜼=η\boldsymbol{\eta}=\eta is 1-dimensional. For each tt\in\mathbb{N}, let t\mathbb{P}_{t} be the marginal of \mathbb{P} over Π𝒞t+1\Pi_{\mathcal{C}}^{t+1}. and let g:𝒮g:\mathcal{S}\to\mathbb{R} be such that wsΠ𝒞t+2g(s)𝑑t+1\int_{ws\in\Pi_{\mathcal{C}}^{t+2}}g(s)d\mathbb{P}_{t+1} exists. Then the following equation is known to hold [BertsekasS07, Proposition 7.28]: for each A(Π𝒞t+1)A\in\mathcal{B}(\Pi_{\mathcal{C}}^{t+1}),

wA(s𝒮g(s)𝑑pσ(w))𝑑t=wsA×𝒮g(s)𝑑t+1.\displaystyle\int_{w\in A}\biggl{(}\int_{s\in\mathcal{S}}g(s)dp^{\sigma}(w)\biggr{)}d\mathbb{P}_{t}=\int_{ws\in A\times\mathcal{S}}g(s)d\mathbb{P}_{t+1}. (8)

Recall that t\mathbb{P}_{t} is the marginal of \mathbb{P} over Π𝒞t+1\Pi_{\mathcal{C}}^{t+1}; therefore 𝔼[X]=Xt+1𝑑=wsΠ𝒞t+2η(s)𝑑t+1\mathbb{E}_{\mathbb{P}}[X]=\int X_{t+1}d\mathbb{P}=\int_{ws\in\Pi_{\mathcal{C}}^{t+2}}\eta(s)d\mathbb{P}_{t+1} exists, and hence gg in (8) can be instantiated by η\eta. Recall 𝕏ση\mathbb{X}_{\sigma}\eta is defined by 𝕏ση(w)=η(s)𝑑pσ(w)\mathbb{X}_{\sigma}\eta(w)=\int\eta(s)dp^{\sigma}(w); we also have [A×𝒮]=[A][A\times\mathcal{S}]=[A]; and recall again the relationship between \mathbb{P} and t\mathbb{P}_{t}. With all of these in mind, (8) implies

[A]f𝑑=[A]X𝑑,\int_{[A]}fd\mathbb{P}=\int_{[A]}Xd\mathbb{P},

which proves the claim—recall \mathcal{F}^{\prime} was given as ={[A]A(Π𝒞t+1)}\mathcal{F}^{\prime}=\{[A]\mid A\in\mathcal{B}(\Pi_{\mathcal{C}}^{t+1})\}. ∎

{myremark}

A similar fact as Prop. A is claimed in [ChatterjeeGNZZ21arxiv], as a part of soundness proof of their proposed LexRSM [ChatterjeeGNZZ21arxiv, Thm. 2]. However, there is a certain ambiguity in their proof, and therefore, we prove Prop. A independently.

More concretely, in their definition of generalized LexRSM (GLexRSM) [ChatterjeeGNZZ21arxiv, Thm. 2], they require a GLexRSM (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} that the conditional expectation 𝔼[𝐗t+1𝟏At]\mathbb{E}[\mathbf{X}_{t+1}\cdot{\bf 1}_{A}\mid\mathcal{F}_{t}] exists for each AtA\in\mathcal{F}_{t}. Then in the proof of [ChatterjeeGNZZ21arxiv, Thm. 2], they claim that this conditional expectation exists whenever (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} is induced from an MM 𝜼\boldsymbol{\eta} under a scheduler σ\sigma and an initial state sIs_{I}. They claim it by saying that a similar function as ff in Prop. A satisfies the axiom of conditional expectation [ChatterjeeGNZZ21arxiv, p. 26]; however, our claim in Prop. A is that this holds only when the expectation of 𝐗t[k]\mathbf{X}_{t}[k] exists for each kk, and this existence is not explicitly discussed in their proof. In this paper, we show the existence of 𝐗t[k]\mathbf{X}_{t}[k] under the linearity assumption on MMs and pCFGs (Prop. C.1.3).

On Footnote 5. In this paper, we did not formally define the notion of Lexicographic Ranking Function (LexRF) for non-probabilistic program. If we define it as an MM over non-probabilistic CFG (cf. Non-probabilistic settings, and instantiation of SC-LexRF in §3), then what we need to change in the definition of LexRSM map is the meaning of the next-time operator 𝕏¯\overline{\mathbb{X}}. More concretely, we would be defining the ranking condition by the following non-probabilistic maximal pre-expectation 𝕐¯τη\overline{\mathbb{Y}}_{\tau}\eta that would be defined as

𝕐¯τη(,𝒙)={η(,u(𝒙),𝒙i)if τΔd,supxiuη(,xi,𝒙i)if τΔn,\displaystyle\overline{\mathbb{Y}}_{\tau}\eta(\ell,\boldsymbol{x})=\begin{cases}\eta(\ell^{\prime},u(\boldsymbol{x}),\boldsymbol{x}_{-i})&\text{if }\tau\in\Delta_{d},\\ \sup_{x_{i}^{\prime}\in u}\eta(\ell^{\prime},x_{i}^{\prime},\boldsymbol{x}_{-i})&\text{if }\tau\in\Delta_{n},\end{cases}

where \ell^{\prime} is the successor location of \ell via τ\tau. But this is exactly the same as 𝕏¯τη\overline{\mathbb{X}}_{\tau}\eta when considered over non-probabilistic CFG; therefore, LexRFs can be naturally understood as LexRSMs over non-probabilistic CFG.

Similarly, if we define a LexRF as a stochastic process over the trivial probability space, then we would be changing the inequality (1) in the ranking condition to the following:

𝐗t+1[k](ω)𝐗t[k](ω)c𝟏k=𝖫𝗏t(ω).\displaystyle\mathbf{X}_{t+1}[k](\omega)\leq\mathbf{X}_{t}[k](\omega)-c\cdot{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega).

But this is exactly what (1) means over the trivial probability space, whose Ω\Omega is a singleton. Therefore, when we say a LexRF in this paper, we understand it as a LexRSM (map) over a CFG or the trivial probability space.

Appendix B Omitted details of Section 4

Proof of Thm. 4. Any instance over the trivial probability space satisfies the conditions (a) and (b) of SC-LexRSM (Def. 3.2), hence so does the ε\varepsilon-fixing ((𝒙~t)t=0,(𝖫𝗏t)t=0)((\tilde{\boldsymbol{x}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}). On the ranking condition, take any tt\in\mathbb{N} and k{1,,𝖫𝗏t}k\in\{1,\ldots,\mathsf{Lv}_{t}\}. Notice that, if k=𝖫𝗏tk=\mathsf{Lv}_{t}, then 𝒙~t[k]=𝒙t[k]0\tilde{\boldsymbol{x}}_{t}[k]=\boldsymbol{x}_{t}[k]\geq 0 holds by the non-negativity condition of SC-LexRSM; with this in mind, the inequality 𝒙~t+1[k]𝒙~t[k]c𝟏𝖫𝗏t=k\tilde{\boldsymbol{x}}_{t+1}[k]\leq\tilde{\boldsymbol{x}}_{t}[k]-c\cdot{\bf 1}_{\llbracket\mathsf{Lv}_{t}=k\rrbracket} is easily derived from the ranking condition of SC-LexRSM (with some case distinctions). ∎

Proof of Thm. 4. We write 𝖣𝖮𝖭𝖤kt𝐗t[k]<0k>𝖫𝗏t\mathsf{DONE}_{k}^{t}\equiv\mathbf{X}_{t}[k]<0\lor k>\mathsf{Lv}_{t} to denote the fixing condition (recall Def. 4). Our goal is to show the following, where ~=((𝐗~t)t=0,(𝖫𝗏t)t=0)\tilde{\mathcal{I}}=((\tilde{\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is the ε\varepsilon-fixing of \mathcal{I}:

t.ωΩ.k{1,,𝖫𝗏t(ω)}.𝔼[𝐗~t+1[k]t](ω)𝐗~t[k](ω)𝟏k=𝖫𝗏t(ω)(-a.s.).\forall t\in\mathbb{N}.\forall\omega\in\Omega.\forall k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\}.\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\tilde{\mathbf{X}}_{t}[k](\omega)-{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega)\quad(\mathbb{P}\mbox{-a.s.}).

To this end, we first observe the LHS of the inequality is transformed as follows:

𝔼[𝐗~t+1[k]t](ω)=𝔼[𝟏¬𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)ε(𝖣𝖮𝖭𝖤kt+1).\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)=\mathbb{E}[{\bf 1}_{\llbracket\lnot\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)-\varepsilon\cdot\mathbb{P}(\mathsf{DONE}_{k}^{t+1}).

By LW and SC non-negaitvity, we have 𝖣𝖮𝖭𝖤ktk>𝖫𝗏t\mathsf{DONE}_{k}^{t}\Leftrightarrow k>\mathsf{Lv}_{t} for each tt and kk; hence we have, for t,ω𝖫𝗏t0t\in\mathbb{N},\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket, and k{1,,𝖫𝗏t(ω)}k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\},

𝔼[𝟏¬𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)\displaystyle\mathbb{E}[{\bf 1}_{\llbracket{\lnot\mathsf{DONE}_{k}^{t+1}}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega) =𝔼[𝐗t+1[k]t](ω)𝔼[𝟏𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)\displaystyle=\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)-\mathbb{E}[{\bf 1}_{\llbracket\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)
=𝔼[𝐗t+1[k]t](ω)𝔼[𝟏k>𝖫𝗏t+1𝐗t+1[k]t](ω)\displaystyle=\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)-\mathbb{E}[{\bf 1}_{\llbracket k>\mathsf{Lv}_{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)
𝔼[𝐗t+1[k]t](ω),\displaystyle\leq\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega),

where the last inequality is due to the expected leftward non-negativity. Hence we have the following \mathbb{P}-a.s., for t,ω𝖫𝗏t0t\in\mathbb{N},\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket, and k{1,,𝖫𝗏t(ω)}k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)\}:

𝔼[𝐗~t+1[k]t](ω)\displaystyle\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega) 𝔼[𝐗t+1[k]t](ω)\displaystyle\leq\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)
𝐗t[k](ω)𝟏k=𝖫𝗏t(ω)\displaystyle\leq\mathbf{X}_{t}[k](\omega)-{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega) (ranking condition)
=𝐗~t[k](ω)𝟏k=𝖫𝗏t(ω).\displaystyle=\tilde{\mathbf{X}}_{t}[k](\omega)-{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega). (ωk𝖫𝗏t=¬𝖣𝖮𝖭𝖤kt\omega\in\llbracket k\leq\mathsf{Lv}_{t}\rrbracket=\llbracket\lnot\mathsf{DONE}_{k}^{t}\rrbracket)

Proof of Thm. 4. We use the proof structure in [ChatterjeeGNZZ21] that utilizes Borel-Cantelli Lemma. The main nontrivial part in our setting is how to properly design the non measure-zero set to derive a contradiction (i.e. eq. (9)), which involves an additional complication due to φt,k\varphi_{t,k}.

{mylemma}

[Borel-Cantelli lemma] Let (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) be a probability space, and let (φt)t=0(\varphi_{t})_{t=0}^{\infty} be a sequence of \mathcal{F}-measurable predicates such that t(φt)<\sum_{t}\mathbb{P}(\varphi_{t})<\infty. Then (t.φt)=0\mathbb{P}(\overset{\infty}{\exists}t.\varphi_{t})=0. ∎

Proof.

Assume the contrary, i.e., (T=)>0\mathbb{P}(T=\infty)>0. Under the assumption, it can be shown that there exist t0t_{0}\in\mathbb{N}, k0{1,,n}k_{0}\in\{1,\ldots,n\} and MM\in\mathbb{R} such that

(tt0.[𝐗t[k0]>k0𝖫𝗏t¬φt,k]t.k0=𝖫𝗏t𝐗t0[k0]M)>0.\displaystyle\mathbb{P}(\forall t\geq t_{0}.[\mathbf{X}_{t}[k_{0}]>\bot\land k_{0}\leq\mathsf{Lv}_{t}\land\lnot\varphi_{t,k}]\land\overset{\infty}{\exists}t.k_{0}=\mathsf{Lv}_{t}\land\mathbf{X}_{t_{0}}[k_{0}]\leq M)>0. (9)

Here, predicate in the LHS of (9) is the conjunction of three predicates. Roughly speaking, the first says “after the time t0t_{0}, the ranking condition is always imposed in the dimension k0k_{0}”; the second says “the value of 𝐗t[k0]\mathbf{X}_{t}[k_{0}] decreases by 1 in expectation infinitely often”; the third is a technical one that takes care of the case where 𝔼[𝐗0[k0]]=+\mathbb{E}[\mathbf{X}_{0}[k_{0}]]=+\infty.

As a technical setup, we observe the “weak ranking condition” of \mathcal{I} implies the following (cf. the proof of Prop. C.1.1):

t.ω𝖫𝗏t0.𝐗t[𝖫𝗏t(ω)](ω)>(-a.s.),\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket.\mathbf{X}_{t}[\mathsf{Lv}_{t}(\omega)](\omega)>\bot\quad(\mathbb{P}\mbox{-a.s.}), (10)
t.ω𝖫𝗏t0.k{1,,𝖫𝗏t(ω)1}.𝐗t[k](ω)=𝐗t+1[k](ω)=(-a.s.).\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)-1\}.\mathbf{X}_{t}[k](\omega)=\bot\Rightarrow\mathbf{X}_{t+1}[k](\omega)=\bot\quad(\mathbb{P}\mbox{-a.s.}). (11)

The proof of the statement is as follows; below, we omit the valuation element ωΩ\omega\in\Omega of predicates for brevity, i.e., we write e.g., φ\varphi instead of φ(ω)\varphi(\omega). First, let ψkt.k𝖫𝗏tt.k=𝖫𝗏t\psi_{k}\equiv\overset{\infty}{\forall}t.k\leq\mathsf{Lv}_{t}\land\overset{\infty}{\exists}t.k=\mathsf{Lv}_{t}; then by a standard measure-theoretic argument, there exists k0{1,,n}k_{0}\in\{1,\ldots,n\} such that (ψk0)>0\mathbb{P}(\psi_{k_{0}})>0 holds. Meanwhile, for each k{1,,n}\leq k\in\{1,\ldots,n\}, we have the following \mathbb{P}-a.s.:

ψk\displaystyle\psi_{k} t.[[𝐗t[k]=𝐗t+1[k]=]k𝖫𝗏t]t.k=𝖫𝗏t\displaystyle\implies\overset{\infty}{\forall}t.\bigl{[}[\mathbf{X}_{t}[k]=\bot\Rightarrow\mathbf{X}_{t+1}[k]=\bot]\land k\leq\mathsf{Lv}_{t}\bigr{]}\land\overset{\infty}{\exists}t.k=\mathsf{Lv}_{t} (condition (10) and (11))
t.[𝐗t[k]>k𝖫𝗏t]t.𝖫𝗏t=k\displaystyle\implies\overset{\infty}{\forall}t.[\mathbf{X}_{t}[k]>\bot\land k\leq\mathsf{Lv}_{t}]\land\overset{\infty}{\exists}t.\mathsf{Lv}_{t}=k (see below)
t.[𝐗t[k]>k𝖫𝗏t¬φt,k]t.𝖫𝗏t=k.\displaystyle\implies\overset{\infty}{\forall}t.[\mathbf{X}_{t}[k]>\bot\land k\leq\mathsf{Lv}_{t}\land\lnot\varphi_{t,k}]\land\overset{\infty}{\exists}t.\mathsf{Lv}_{t}=k. (contraposition of (2))

Here, the second implication holds because [t.[𝐗t[k]=𝐗t+1[k]=]t.k=𝖫𝗏t]t.𝐗t[k]>\bigl{[}\overset{\infty}{\forall}t.[\mathbf{X}_{t}[k]=\bot\Rightarrow\mathbf{X}_{t+1}[k]=\bot]\land\overset{\infty}{\exists}t.k=\mathsf{Lv}_{t}\bigr{]}\Rightarrow\overset{\infty}{\forall}t.\mathbf{X}_{t}[k]>\bot is always true. Indeed, the LHS implies t.[𝐗t[k]=𝐗t+1[k]=]t.𝐗t[k]>\overset{\infty}{\forall}t.[\mathbf{X}_{t}[k]=\bot\Rightarrow\mathbf{X}_{t+1}[k]=\bot]\land\overset{\infty}{\exists}t.\mathbf{X}_{t}[k]>\bot by condition (10), from which the RHS easily follows. Hence (ψk0)>0\mathbb{P}(\psi_{k_{0}})>0 implies

α=(t.[𝐗t[k0]>k0𝖫𝗏t¬φt,k0]t.k0=𝖫𝗏t)>0.\alpha=\mathbb{P}(\overset{\infty}{\forall}t.[\mathbf{X}_{t}[k_{0}]>\bot\land k_{0}\leq\mathsf{Lv}_{t}\land\lnot\varphi_{t,k_{0}}]\land\overset{\infty}{\exists}t.k_{0}=\mathsf{Lv}_{t})>0.

Let αt=(tt.[𝐗t[k0]>k0𝖫𝗏t¬φt,k0]t.k0=𝖫𝗏t)\alpha_{t^{\prime}}=\mathbb{P}(\forall t\geq t^{\prime}.[\mathbf{X}_{t}[k_{0}]>\bot\land k_{0}\leq\mathsf{Lv}_{t}\land\lnot\varphi_{t,k_{0}}]\land\overset{\infty}{\exists}t.k_{0}=\mathsf{Lv}_{t}); by Monotone Convergence Theorem we have α=limtαt\alpha=\lim_{t^{\prime}\to\infty}\alpha_{t^{\prime}}, and hence there exists t0t_{0} such that αt0>0\alpha_{t_{0}}>0. Via a similar argument, we can show the existence of MM\in\mathbb{R} for which the inequality (9) holds.

Now let Φtt{0,,t}.[𝐗t+t0[k0]>k0𝖫𝗏t+t0¬φt+t0,k0].\Phi_{t}\equiv\forall t^{\prime}\in\{0,\ldots,t\}.\bigl{[}\mathbf{X}_{t^{\prime}+t_{0}}[k_{0}]>\bot\land k_{0}\leq\mathsf{Lv}_{t^{\prime}+t_{0}}\land\lnot\varphi_{t^{\prime}+t_{0},k_{0}}\bigr{]}. Also let T(ω)=min{t¬Φt(ω)}𝟏𝐗t0[k0]M(ω)T^{\prime}(\omega)=\min\{t\mid\lnot\Phi_{t}(\omega)\}\cdot{\bf 1}_{\llbracket\mathbf{X}_{t_{0}}[k_{0}]\leq M\rrbracket}(\omega). Then the inequality (9) is rewritten as (T=t.k0=𝖫𝗏t)>0.\mathbb{P}(T^{\prime}=\infty\land\overset{\infty}{\exists}t.k_{0}=\mathsf{Lv}_{t})>0. Define a stochastic process (Yt)t=0(Y_{t})_{t=0}^{\infty} stopped at TT^{\prime} by Y0(ω)=Y_{0}(\omega)=\bot for ωT=0\omega\in\llbracket T^{\prime}=0\rrbracket; and Yt(ω)=𝐗t+t0[k0](ω)Y_{t}(\omega)=\mathbf{X}_{t+t_{0}}[k_{0}](\omega) for each tt\in\mathbb{N} and ωTtT0\omega\in\llbracket T^{\prime}\geq t\land T^{\prime}\neq 0\rrbracket; and Yt(ω)=YT(ω)(ω)Y_{t}(\omega)=Y_{T^{\prime}(\omega)}(\omega) otherwise. Then we have 𝔼[Yt]\mathbb{E}[Y_{t}]\geq\bot for each tt by construction. Also notice that 𝔼[Y0]M\mathbb{E}[Y_{0}]\leq M holds. Now, for each tt\in\mathbb{N}, observe the following holds:

T>t\displaystyle T^{\prime}>t 𝐗t+t0[k0]>k0𝖫𝗏t+t0¬φt+t0,k0\displaystyle\implies\mathbf{X}_{t+t_{0}}[k_{0}]>\bot\land k_{0}\leq\mathsf{Lv}_{t+t_{0}}\land\lnot\varphi_{t+t_{0},k_{0}}
k0𝖫𝗏t+t0¬(𝐗t+t0[k0]>φt+t0,k0).\displaystyle\implies k_{0}\leq\mathsf{Lv}_{t+t_{0}}\land\lnot(\mathbf{X}_{t+t_{0}}[k_{0}]>\bot\land\varphi_{t+t_{0},k_{0}}).

Therefore, by the “weak ranking condition” of \mathcal{I}, we have

T>t𝔼[𝐗t+t0+1[k0]t+t0]𝑑T>t𝐗t+t0[k0]𝟏k0=𝖫𝗏t+t0d.\displaystyle\int_{\llbracket T^{\prime}>t\rrbracket}\mathbb{E}[\mathbf{X}_{t+t_{0}+1}[k_{0}]\mid\mathcal{F}_{t+t_{0}}]d\mathbb{P}\leq\int_{\llbracket T^{\prime}>t\rrbracket}\mathbf{X}_{t+t_{0}}[k_{0}]-{\bf 1}_{\llbracket k_{0}=\mathsf{Lv}_{t+t_{0}}\rrbracket}d\mathbb{P}.

Also observe Yt(ω)=𝐗t+t0[k0](ω)Y_{t^{\prime}}(\omega)=\mathbf{X}_{t^{\prime}+t_{0}}[k_{0}](\omega) holds for each t{0,,t+1}t^{\prime}\in\{0,\ldots,t+1\} for ωT>t\omega\in\llbracket T^{\prime}>t\rrbracket. Hence we have T>tYt+1𝑑=T>t𝔼[Yt+1t+t0]𝑑T>tYt𝟏k0=𝖫𝗏t+t0d\int_{\llbracket T^{\prime}>t\rrbracket}Y_{t+1}d\mathbb{P}=\int_{\llbracket T^{\prime}>t\rrbracket}\mathbb{E}[Y_{t+1}\mid\mathcal{F}_{t+t_{0}}]d\mathbb{P}\leq\int_{\llbracket T^{\prime}>t\rrbracket}Y_{t}-{\bf 1}_{\llbracket k_{0}=\mathsf{Lv}_{t+t_{0}}\rrbracket}d\mathbb{P} for each tt\in\mathbb{N}, where the first equality is by definition of the conditional expectation. As we have Yt+1(ω)=Yt(ω)Y_{t+1}(\omega)=Y_{t}(\omega) for ωTt\omega\in\llbracket T^{\prime}\leq t\rrbracket (recall (Yt)t=0(Y_{t})_{t=0}^{\infty} is stopped at TT^{\prime}), we have

𝔼[Yt+1]𝔼[Yt](T>tk0=𝖫𝗏t+t0).\bot\leq\mathbb{E}[Y_{t+1}]\leq\mathbb{E}[Y_{t}]-\mathbb{P}(T^{\prime}>t\land k_{0}=\mathsf{Lv}_{t+t_{0}}).

Hence we have t(T>tk0=𝖫𝗏t+t0)𝔼[Y0]<.\sum_{t\in\mathbb{N}}\mathbb{P}(T^{\prime}>t\land k_{0}=\mathsf{Lv}_{t+t_{0}})\leq\mathbb{E}[Y_{0}]<\infty. By Borel-Cantelli lemma (Lem. B), we have (t.(T>tk0=𝖫𝗏t+t0))=(T=t.k0=𝖫𝗏t)=0\mathbb{P}(\overset{\infty}{\exists}t.(T^{\prime}>t\land k_{0}=\mathsf{Lv}_{t+t_{0}}))=\mathbb{P}(T^{\prime}=\infty\land\overset{\infty}{\exists}t.k_{0}=\mathsf{Lv}_{t})=0, which is a contradiction. ∎

Appendix C Omitted details of Section 5

Proof of Thm. 5. Over a non-probabilistic CFG, the ranking condition of 𝜼\boldsymbol{\eta} implies

ττout.sIG(τ).k{1,,𝖫𝗏(τ)}.ssuccτ(s).[𝜼[k](s)𝜼[k](s)𝟏k=𝖫𝗏(τ)].\forall\tau\neq\tau_{\mathrm{out}}.\forall s\in\llbracket I\land G(\tau)\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}(\tau)\}.\forall s^{\prime}\in\mathrm{succ}_{\tau}(s).\bigl{[}\boldsymbol{\eta}[k](s^{\prime})\leq\boldsymbol{\eta}[k](s)-\mathbf{1}_{k=\mathsf{Lv}(\tau)}\bigr{]}.

From this condition, stability at negativity of 𝜼\boldsymbol{\eta} clearly follows. ∎

C.1 Proof of Thm. 5

The proof of Thm. 5 is quite involved, so we make a devoted subsection for it. We first define the notion of LLexRSM as an instance; we do this only in appendices as it is basically an intermediate notion to connect the LLexRSM condition of an MM 𝜼\boldsymbol{\eta} and (ε,γ)(\varepsilon,\gamma)-fixability of its induced instance.

{mydefinition}

[LLexRSM] Suppose the following are given: a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}); a filtration (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty} on \mathcal{F}; and a stopping time TT w.r.t. (t)t=0(\mathcal{F}_{t})_{t=0}^{\infty}. An instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is called a Lazy Lexicographic Ranking SuperMartingale (LLexRSM) for TT if it is an SC-LexRSM for TT, and additionally satisfies the following:

(stability at negativity) t.ωΩ.k{1,,𝖫𝗏t(ω)1}.\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\Omega.\forall k\in\{1,\ldots,\mathsf{Lv}_{t}(\omega)-1\}.
𝐗t[k](ω)<0𝐗t+1[k](ω)<0k>𝖫𝗏t+1(ω).\displaystyle\qquad\qquad\qquad\qquad\quad\mathbf{X}_{t}[k](\omega)<0\Rightarrow\mathbf{X}_{t+1}[k](\omega)<0\lor k>\mathsf{Lv}_{t+1}(\omega).

C.1.1 Preparation 1: carving out the LLexRSM conditions from fixability

Our plan of soundness proof is the following: if an instance =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is induced by an LLexRSM map under linearity and well-behavedness assumptions (in which case \mathcal{I} is an LLexRSM, as we show in Prop. C.1.3), then \mathcal{I} is (ε,γ)(\varepsilon,\gamma)-fixable, and hence the underlying stopping time is AST. It turns out that each of the LLexRSM conditions of \mathcal{I}—ranking condition, SC non-negativity and stability at negativity—contributes to its fixability in a rather independent way. More concretely, for given tt\in\mathbb{N} and k{1,,n}k\in\{1,\ldots,n\}, split the set k𝖫𝗏tΩ\llbracket k\leq\mathsf{Lv}_{t}\rrbracket\subseteq\Omega (i.e., the set of samples ωΩ\omega\in\Omega on which the ranking condition is imposed in dimension kk at time tt) into the following three:

Ω~1t,k=𝐗~t[k]=εk=𝖫𝗏t,Ω~2t,k=𝐗~t[k]=εk<𝖫𝗏t,Ω~3t,k=𝐗~t[k]0k𝖫𝗏t.\displaystyle\tilde{\Omega}_{1}^{t,k}=\llbracket\tilde{\mathbf{X}}_{t}[k]=-\varepsilon\land k=\mathsf{Lv}_{t}\rrbracket,\quad\tilde{\Omega}_{2}^{t,k}=\llbracket\tilde{\mathbf{X}}_{t}[k]=-\varepsilon\land k<\mathsf{Lv}_{t}\rrbracket,\quad\tilde{\Omega}_{3}^{t,k}=\llbracket\tilde{\mathbf{X}}_{t}[k]\geq 0\land k\leq\mathsf{Lv}_{t}\rrbracket.

Here, ~=((𝐗~t)t=0,(𝖫𝗏t)t=0)\tilde{\mathcal{I}}=((\tilde{\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) is the ε\varepsilon-fixing of \mathcal{I} for a fixed ε>0\varepsilon>0. Then the (ε,γ)(\varepsilon,\gamma)-fixability of \mathcal{I} over Ω~1t,k\tilde{\Omega}_{1}^{t,k}, Ω~2t,k\tilde{\Omega}_{2}^{t,k} and Ω~3t,k\tilde{\Omega}_{3}^{t,k} are derived from its SC non-negativity, stability at negativity and ranking condition, respectively. In this section, we show that the conditions are \mathbb{P}-a.s. equivalent in the first two cases (Prop. C.1.1); We handle the third case later, which is much more nontrivial.

Let Ωt,kΩ\Omega^{t,k}\subseteq\Omega be given for each tt\in\mathbb{N} and k{1,n}k\in\{1,\ldots n\}. We say an instance ((𝐗t)t=0,(𝖫𝗏t)t=0)((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) satisfies the ranking condition over Ωt,k\Omega^{t,k} when it satisfies the following:

t.k{1,,n}.ωT>tΩt,k.𝔼[𝐗t+1[k]t](ω)𝐗t[k](ω)𝟏𝖫𝗏t=k(ω)(-a.s.)\forall t\in\mathbb{N}.\forall k\in\{1,\ldots,n\}.\forall\omega\in\llbracket T>t\rrbracket\cap\Omega^{t,k}.\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\mathbf{X}_{t}[k](\omega)-{\bf 1}_{\llbracket\mathsf{Lv}_{t}=k\rrbracket}(\omega)\ (\mathbb{P}\mbox{-a.s.})

Observe it is the usual ranking condition (Def. 3.2) when Ωt,k=k𝖫𝗏t\Omega^{t,k}=\llbracket k\leq\mathsf{Lv}_{t}\rrbracket. Now the following holds.

{myproposition}

[LLexRSM conditions as partial fixability] Let an instance =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) in a probability space (Ω,,)(\Omega,\mathcal{F},\mathbb{P}) be given, and let ~=((𝐗~t)t=0,(𝖫𝗏t)t=0)\tilde{\mathcal{I}}=((\tilde{\mathbf{X}}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) be its ε\varepsilon-fixing for some ε>0\varepsilon>0. Then the following hold.

  1. (a)

    \mathcal{I} is SC non-negative \mathbb{P}-a.s. iff ~\tilde{\mathcal{I}} satisfies the ranking condition over 𝐗~t[k]=εk=𝖫𝗏t\llbracket\tilde{\mathbf{X}}_{t}[k]=-\varepsilon\land k=\mathsf{Lv}_{t}\rrbracket.

  2. (b)

    \mathcal{I} is stable at negativity \mathbb{P}-a.s. iff ~\tilde{\mathcal{I}} satisfies the ranking condition over 𝐗~t[k]=εk<𝖫𝗏t\llbracket\tilde{\mathbf{X}}_{t}[k]=-\varepsilon\land k<\mathsf{Lv}_{t}\rrbracket. ∎

Proof.

Let 𝒥=((𝐘t)t=0,(𝖫𝗏t)t=0)\mathcal{J}=((\mathbf{Y}_{t})_{t=0}^{\infty},(\mathsf{Lv}^{\prime}_{t})_{t=0}^{\infty}) be a uniformly well-founded instance with a bottom \bot. For given tt\in\mathbb{N} and k{1,,n}k\in\{1,\ldots,n\}, split the set k𝖫𝗏t\llbracket k\leq\mathsf{Lv}^{\prime}_{t}\rrbracket into the following:

Ω1t,k=𝐘t[k]=k=𝖫𝗏t,Ω2t,k=𝐘t[k]=k<𝖫𝗏t,Ω3t,k=𝐘t[k]>k𝖫𝗏t.\displaystyle\Omega_{1}^{t,k}=\llbracket\mathbf{Y}_{t}[k]=\bot\land k=\mathsf{Lv}^{\prime}_{t}\rrbracket,\Omega_{2}^{t,k}=\llbracket\mathbf{Y}_{t}[k]=\bot\land k<\mathsf{Lv}^{\prime}_{t}\rrbracket,\Omega_{3}^{t,k}=\llbracket\mathbf{Y}_{t}[k]>\bot\land k\leq\mathsf{Lv}^{\prime}_{t}\rrbracket. (12)

Then it can be shown that the ranking condition for 𝒥\mathcal{J} over Ω1t,k\Omega_{1}^{t,k} and Ω2t,k\Omega_{2}^{t,k} are equivalent to (13) and (14) below, respectively:

t.ω𝖫𝗏t0.𝐘t[𝖫𝗏t(ω)](ω)>(-a.s.),\displaystyle\forall t\in\mathbb{N}.\forall\omega\in\llbracket\mathsf{Lv}_{t}\neq 0\rrbracket.\mathbf{Y}_{t}[\mathsf{Lv}^{\prime}_{t}(\omega)](\omega)>\bot\quad(\mathbb{P}\mbox{-a.s.}), (13)
t.k{1,,n}.ω𝐘t[k]=k<𝖫𝗏t.𝐘t+1[k](ω)=(-a.s.).\displaystyle\forall t\in\mathbb{N}.\forall k\in\{1,\ldots,n\}.\forall\omega\in\llbracket\mathbf{Y}_{t}[k]=\bot\land k<\mathsf{Lv}^{\prime}_{t}\rrbracket.\mathbf{Y}_{t+1}[k](\omega)=\bot\quad(\mathbb{P}\mbox{-a.s.}). (14)

Indeed, we note that the inequality of the ranking condition is never satisfied over Ω1t,k\Omega_{1}^{t,k}; therefore, 𝒥\mathcal{J} satisfies the ranking condition over Ω1t,k\Omega_{1}^{t,k} iff (Ω1t,k)=0\mathbb{P}(\Omega_{1}^{t,k})=0 for each tt and kk, which is equivalent to (13). The equivalence with (14) is shown from the fact that the following holds \mathbb{P}-a.s. over Ω2t,k\Omega_{2}^{t,k}:

𝔼[𝐘t+1[k]t](ω)𝐘t[k](ω)𝟏𝖫𝗏t=k(ω)𝔼[𝐘t+1[k]t](ω)=𝐘t+1[k](ω)=.\mathbb{E}[\mathbf{Y}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\mathbf{Y}_{t}[k](\omega)-{\bf 1}_{\llbracket\mathsf{Lv}^{\prime}_{t}=k\rrbracket}(\omega)\Leftrightarrow\mathbb{E}[\mathbf{Y}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)=\bot\Leftrightarrow\mathbf{Y}_{t+1}[k](\omega)=\bot.

Now, if 𝒥\mathcal{J} is the ε\varepsilon-fixing ~\tilde{\mathcal{I}} of some \mathcal{I} (whose bottom is ε-\varepsilon), then it is easy to check ~\tilde{\mathcal{I}} satisfies (13) iff \mathcal{I} is SC non-negative \mathbb{P}-a.s.; similarly, ~\tilde{\mathcal{I}} satisfies (14) iff \mathcal{I} is stable at negativity \mathbb{P}-a.s. ∎

{myremark}

We note Prop. C.1.1 implies that LLexRSM generalizes ε\varepsilon-fixable LexRSM modulo \mathbb{P}-a.s., i.e. any ε\varepsilon-fixable LexRSM with ε>0\varepsilon>0 satisfies the ranking conition, SC non-negativity and stability at negativity \mathbb{P}-a.s. This generalization is also strict, in the sense that there is an LLexRSM that is not ε\varepsilon-fixable for any ε>0\varepsilon>0 (Fig. 3 constitutes such a one).

C.1.2 Preparation 2: Well-behaved distributions and its properties

Below we give the formal definition of well-behaved distributions. {mydefinition}[well-behaved distributions] We say a distribution p𝒟()p\in\mathcal{D}(\mathbb{R}) is well-behaved if the following holds: for any a{0}a\in\mathbb{R}\setminus\{0\}, there exist constants C1(0,1)C_{1}\in(0,1) and C2>0C_{2}>0 such that

b.[p(ax+b<0)C1ax+bdpmax{0,ax+b}𝑑pC2p(ax+b<0)].\displaystyle\forall b\in\mathbb{R}.\biggl{[}p(ax+b<0)\leq C_{1}\Rightarrow\int ax+bdp\geq\int\max\{0,ax+b\}dp-C_{2}\cdot p(ax+b<0)\biggr{]}. (15)

Condition (15) is a canonical realization of what we need for the soundness proof. Recall our goal is to show that, if a linear MM 𝜼\boldsymbol{\eta} satisfies the ranking condition, then any of its induced instance \mathcal{I} is (ε,γ)(\varepsilon,\gamma)-fixable over Ω~3t,k=𝐗~t[k]0k𝖫𝗏t\tilde{\Omega}_{3}^{t,k}=\llbracket\tilde{\mathbf{X}}_{t}[k]\geq 0\land k\leq\mathsf{Lv}_{t}\rrbracket. Condition (15) is designed so that this property holds whenever the underlying pCFG updates variables according to well-behaved distributions: roughly speaking, the antecedent part of (15) reads “φt,k(ω)\varphi_{t,k}(\omega) in (3) is false”; and the consequent part of (15) reads “at ω\omega, the ranking condition for \mathcal{I} in the dimension kk at time tt implies the ranking condition for its ε\varepsilon-fixing ~\tilde{\mathcal{I}} for the same kk and tt”.

We formally define our well-behavedness condition of pCFGs below, together with linearity. {mydefinition} For τΔ\tau\in\Delta, let uτu_{\tau} be the second component of 𝑈𝑝(τ)\mathit{Up}(\tau). We say a pCFG 𝒞\mathcal{C} is linear if, for each τΔd\tau\in\Delta_{d}, the function uτ:|V|u_{\tau}:\mathbb{R}^{|V|}\to\mathbb{R} is linear; we say 𝒞\mathcal{C} is well-behaved if, for each τΔp\tau\in\Delta_{p}, the distribution uτu_{\tau} is well-behaved. An MM 𝜼\boldsymbol{\eta} is linear if λ𝒙.𝜼(,𝒙)\lambda\boldsymbol{x}.\boldsymbol{\eta}(\ell,\boldsymbol{x}) is linear for each L\ell\in L.

Below we prove two important classes of distributions are well-behaved. We do not use it in the proof of Thm. 5; we prove it to demonstrate the applicability of LLexRSM.

{myproposition}

The following hold.

  1. (a)

    Any p𝒟()p\in\mathcal{D}(\mathbb{R}) with a bounded support is well-behaved. Moreover, for c>0c>0, let P={p𝒟()supp(p)[c,c]}P=\{p\in\mathcal{D}(\mathbb{R})\mid\mathrm{supp}(p)\subseteq[-c,c]\}; then for a{0}a\in\mathbb{R}\setminus\{0\}, there exist C1C_{1} and C2C_{2} such that (15) holds for any pPp\in P.

  2. (b)

    For any μ\mu\in\mathbb{R} and σ2>0\sigma^{2}>0, the normal distribution Norm(μ,σ2)\mbox{Norm}(\mu,\sigma^{2}) with the mean μ\mu and the standard deviation σ2\sigma^{2} is well-behaved111111 We use μ\mu and σ2\sigma^{2} to represent the mean and standard deviation, following the standard of statistics; there is no relevance to measures and schedulers. . ∎

Proof of Prop. C.1.2. We prove for the case a<0a<0 only; the proof is similar for the case a>0a>0. A proof of (a) is as follows. Fix y0y_{0}\in\mathbb{R} and y1>0y_{1}>0, and take any p𝒟()p\in\mathcal{D}(\mathbb{R}) such that supp(p)[y0,y0+y1]\mathrm{supp}(p)\subseteq[y_{0},y_{0}+y_{1}]. Then for a given bb\in\mathbb{R}, p(ax+b<0)<1p(ax+b<0)<1 implies ay0+b0ay_{0}+b\geq 0, and hence inf{ax+bxsupp(p)}a(y0+y1)+bay1\inf\{ax+b\mid x\in\mathrm{supp}(p)\}\geq a(y_{0}+y_{1})+b\geq ay_{1}. Then we have min{0,ax+b}𝑑p=ax+b<0ax+bdpay1p(ax+b<0).\int_{\mathbb{R}}\min\{0,ax+b\}dp=\int_{\llbracket ax+b<0\rrbracket}ax+bdp\geq ay_{1}\cdot p(ax+b<0). Therefore, we let C1C_{1} be any value in (0,1)(0,1) and C2=ay1C_{2}=-ay_{1} and the proof is done.

A proof of (11) is as follows. We only prove the case where μ=0\mu=0 and σ2=1\sigma^{2}=1; the proof is similar for the general case. Let p=Norm(0,1)p=\mbox{Norm}(0,1). First observe, for yy\in\mathbb{R},

2πyx𝑑p=yxex22𝑑x=[ex22]y=ey22.\sqrt{2\pi}\int_{y}^{\infty}xdp=\int_{y}^{\infty}xe^{-\frac{x^{2}}{2}}dx=\biggl{[}-e^{-\frac{x^{2}}{2}}\biggr{]}_{y}^{\infty}=e^{-\frac{y^{2}}{2}}.

Also there is a known bound yex22𝑑x>yy2+1ey22\int_{y}^{\infty}e^{-\frac{x^{2}}{2}}dx>\frac{y}{y^{2}+1}e^{-\frac{y^{2}}{2}}, see [AbramowitzS:book]. By these, for b<0b<0 we have

baaxbdpba𝑑p=b+abaxex22𝑑xbaex22𝑑x>b+a(b/a)2+1(b/a)=a2b.\frac{\int_{\frac{b}{a}}^{\infty}ax-bdp}{\int_{\frac{b}{a}}^{\infty}dp}=-b+a\cdot\frac{\int_{\frac{b}{a}}^{\infty}xe^{-\frac{x^{2}}{2}}dx}{\int_{\frac{b}{a}}^{\infty}e^{-\frac{x^{2}}{2}}dx}>-b+a\cdot\frac{(b/a)^{2}+1}{(b/a)}=\frac{a^{2}}{b}.

Thus in particular, for b1b\leq-1, we have (LHS)>a2\mbox{(LHS)}>-a^{2}. Now, for a given a{0}a\in\mathbb{R}\setminus\{0\}, let C1=p(ax+1<0)C_{1}=p(ax+1<0). Then we have p(ax+b<0)C1ax+b<0ax+bdpa2p(ax+b<0)p(ax+b<0)\leq C_{1}\Rightarrow\int_{\llbracket ax+b<0\rrbracket}ax+bdp\geq-a^{2}\cdot p(ax+b<0), and hence, we let C2=a2C_{2}=a^{2} and we are done. ∎

C.1.3 Preparation 3: LLexRSM map induces LLexRSM

As written in From RSM maps to RSMs of §3.2, properties of 𝜼\boldsymbol{\eta} such as ranking condition and non-negativity are inherited to its induced instance if the expectation of 𝐗t[k]\mathbf{X}_{t}[k] exists for each tt, kk. This existence is actually not so trivial when 𝜼\boldsymbol{\eta} is unbounded from below. Here we ensure LLexRSM map induces LLexRSM in our setting (Prop. C.1.3).

We say a distribution d𝒟()d\in\mathcal{D}(\mathbb{R}) is integrable (for linear functions) if it satisfies 𝔼d[λx.|x|]<\mathbb{E}_{d}[\lambda x.|x|]<\infty. We note this property of dd implies 𝔼d[|η|]<\mathbb{E}_{d}[|\eta|]<\infty for any linear function η:\eta:\mathbb{R}\to\mathbb{R}; if dd is not integrable, then 𝔼d[|η|]=\mathbb{E}_{d}[|\eta|]=\infty holds for any η\eta that is a non-constant linear function. In [ChatterjeeGNZZ21arxiv], each variable sampling distribution of a pCFG is assumed to be integrable; below we prove that stochastic processes induced by an MM 𝜼\boldsymbol{\eta} has a finite expectation at each tt under this assumption, plus the linearity assumption on MMs and pCFGs.

{myproposition}

Let 𝒞\mathcal{C} be a linear pCFG with its state set 𝒮\mathcal{S}, and let 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n} be a linear MM. Let (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} be induced by 𝜼\boldsymbol{\eta} under a Δ\Delta-deterministic scheduler σ\sigma and an initial state s0s_{0}, and let (Π𝒞,(Π𝒞),)(\Pi_{\mathcal{C}},\mathcal{B}(\Pi_{\mathcal{C}}),\mathbb{P}) be the dynamics of 𝒞\mathcal{C} under σ\sigma and s0s_{0}. Suppose, for each transition τΔp\tau\in\Delta_{p} such that 𝑈𝑝(τ)=(i,u)\mathit{Up}(\tau)=(i,u), the distribution uu is integrable. Then we have 𝔼[|𝐗t[k]|]<\mathbb{E}_{\mathbb{P}}[|\mathbf{X}_{t}[k]|]<\infty for each k{1,,n}k\in\{1,\ldots,n\} and tt\in\mathbb{N}.

Proof.

Without loss of generality we assume 𝜼\boldsymbol{\eta} is 1-dimensional, and denote it by η0\eta_{0}. Let t\mathbb{P}_{t} be the marginal of \mathbb{P} over Π𝒞t+1\Pi_{\mathcal{C}}^{t+1} (the set of finite paths with lengths t+1t+1). We recall 𝔼[|Xt|]=s0stΠ𝒞t+1|η0(st)|𝑑t\mathbb{E}_{\mathbb{P}}[|X_{t}|]=\int_{s_{0}\ldots s_{t}\in\Pi_{\mathcal{C}}^{t+1}}|\eta_{0}(s_{t})|d\mathbb{P}_{t} holds by definition of XtX_{t}. Hence, it suffices to show the following: for each tt\in\mathbb{N} and any 1-dimensional linear MM η\eta, the integral s0stΠ𝒞t+1η(st)𝑑t\int_{s_{0}\ldots s_{t}\in\Pi_{\mathcal{C}}^{t+1}}\eta(s_{t})d\mathbb{P}_{t} is finite.

This is shown by induction on tt. The base case is true as 0=δs0\mathbb{P}_{0}=\delta_{s_{0}} is Dirac. For the step case, for each τΔ\tau\in\Delta and stG(τ)s_{t}\in\llbracket G(\tau)\rrbracket we have 𝕏¯τη(st)𝕏ση(s0st)𝕏¯τη(st)\underline{\mathbb{X}}_{\tau}\eta(s_{t})\leq\mathbb{X}_{\sigma}\eta(s_{0}\ldots s_{t})\leq\overline{\mathbb{X}}_{\tau}\eta(s_{t}); here, the function 𝕏¯τη\underline{\mathbb{X}}_{\tau}\eta is so-called minimal pre-expectation [TakisakaOUH21, ChatterjeeGNZZ21arxiv], which is identical to 𝕏¯τη\overline{\mathbb{X}}_{\tau}\eta except that the supremum is substituted with the infimum. The functions 𝕏¯τη\underline{\mathbb{X}}_{\tau}\eta and 𝕏¯τη\overline{\mathbb{X}}_{\tau}\eta are linear over G(τ)\llbracket G(\tau)\rrbracket whenever η\eta and 𝒞\mathcal{C} are linear, and 𝒞\mathcal{C} satisfies the integrability assumption. Hence wΠ𝒞t+1𝕏ση(w)𝑑t\int_{w\in\Pi_{\mathcal{C}}^{t+1}}\mathbb{X}_{\sigma}\eta(w)d\mathbb{P}_{t} is finite by induction hypothesis, and this value is equal to s0st+1Π𝒞t+2η(st+1)𝑑t+1\int_{s_{0}\ldots s_{t+1}\in\Pi_{\mathcal{C}}^{t+2}}\eta(s_{t+1})d\mathbb{P}_{t+1}, hence finiteness of the latter is proved. ∎

Now we have the desired proposition as follows. {myproposition} Let 𝒞\mathcal{C} be a linear, well-behaved pCFG, and let 𝜼\boldsymbol{\eta} be a linear LLexRSM map over 𝒞\mathcal{C} with a level map 𝖫𝗏\mathsf{Lv} supported by an invariant II. Then for any Δ\Delta-deterministic strategy σ\sigma and an initial state sIs_{I} of 𝒞\mathcal{C}, the instance =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) induced by 𝜼\boldsymbol{\eta} and 𝖫𝗏\mathsf{Lv} under σ\sigma and sIs_{I} is an LLexRSM for the termination time Tterm𝒞T_{\mathrm{term}}^{\mathcal{C}}.

Proof.

The proof of adaptedness of (𝐗t)t=0(\mathbf{X}_{t})_{t=0}^{\infty} and heredity of ranking and SC non-negativity conditions from LexRSM map to LexRSM is identical to the one in existing works [AgrawalCP18, ChatterjeeGNZZ21], so we omit it.

Existence of 𝔼[𝐗t[k]]\mathbb{E}_{\mathbb{P}}[\mathbf{X}_{t}[k]] is shown by Prop. C.1.3. Indeed, any well-behaved distribution is integrable, as we show below. If p𝒟()p\in\mathcal{D}(\mathbb{R}) is well-behaved, then take C1C_{1} in Eq. (15) for a=1a=1, and take sufficiently large bb\in\mathbb{R} so that p(x+b)C1p(x+b)\leq C_{1}. Then we have

x+b<0x+bdp=x<bx𝑑p+bp(x+b<0)C2p(x+b<0),\int_{\llbracket x+b<0\rrbracket}x+bdp=\int_{\llbracket x<-b\rrbracket}xdp+b\cdot p(x+b<0)\geq-C_{2}\cdot p(x+b<0),

which proves x<bx𝑑p>\int_{\llbracket x<-b\rrbracket}xdp>-\infty. Similarly, by letting a=1a=-1 in Eq. (15), we can derive an inequality x>bx𝑑p<\int_{\llbracket x>b^{\prime}\rrbracket}xdp<\infty for some bb^{\prime}\in\mathbb{R}. As we have bxb|x|𝑑p<\int_{\llbracket-b\leq x\leq b^{\prime}\rrbracket}|x|dp^{\prime}<\infty for any p𝒟()p^{\prime}\in\mathcal{D}(\mathbb{R}), the claim holds.

Stability at negativity of the induced instance \mathcal{I} is proved as follows. For ω=s0s1Π𝒞\omega=s_{0}s_{1}\ldots\in\Pi_{\mathcal{C}}, let τt(ω)=σΔ(s0st)\tau_{t}(\omega)=\sigma_{\Delta}(s_{0}\ldots s_{t}). Then the stability at negativity of \mathcal{I} is described as follows: For a given tt\in\mathbb{N}, ω=s0s1Π𝒞\omega=s_{0}s_{1}\ldots\in\Pi_{\mathcal{C}}, and k{1,,𝖫𝗏(τt(ω))1}k\in\{1,\ldots,\mathsf{Lv}(\tau_{t}(\omega))-1\}, it holds that

𝜼[k](st)<0𝜼[k](st+1)<0k>𝖫𝗏(τt+1(ω)).\displaystyle\boldsymbol{\eta}[k](s_{t})<0\Rightarrow\boldsymbol{\eta}[k](s_{t+1})<0\lor k>\mathsf{Lv}(\tau_{t+1}(\omega)). (16)

This is derived from the stability at negativity of 𝜼\boldsymbol{\eta}; indeed, if sts_{t} is a terminal state, then 𝖫𝗏t(ω)=0\mathsf{Lv}_{t}(\omega)=0 and there is nothing to be checked. Otherwise, we have stIs_{t}\in\llbracket I\rrbracket as s0s1Π𝒞s_{0}s_{1}\ldots\in\Pi_{\mathcal{C}} means sts_{t} is reachable from an initial state s0s_{0}; we also have stG(τt(ω))s_{t}\in\llbracket G(\tau_{t}(\omega))\rrbracket because τt(ω)\tau_{t}(\omega) is chosen by σ\sigma at sts_{t}; and hence, Eq. (16) follows from the stability at negativity of 𝜼\boldsymbol{\eta}. ∎

C.1.4 The main proof

Now we wrap up everything into the proof of the main theorem. The hardest part is the proof of Thm. 5, which we give below.

Proof of Thm. 5. Let =((𝐗t)t=0,(𝖫𝗏t)t=0)\mathcal{I}=((\mathbf{X}_{t})_{t=0}^{\infty},(\mathsf{Lv}_{t})_{t=0}^{\infty}) be the induced instance. Then by Prop. C.1.3 \mathcal{I} is an LLexRSM for the termination time Tterm𝒞T_{\mathrm{term}}^{\mathcal{C}}. Therefore, by Prop. C.1.1, for any ε>0\varepsilon>0, the ε\varepsilon-fixing ~\tilde{\mathcal{I}} of \mathcal{I} satisfies the ranking condition over 𝐗~t[k]=εk𝖫𝗏t\llbracket\tilde{\mathbf{X}}_{t}[k]=-\varepsilon\land k\leq\mathsf{Lv}_{t}\rrbracket. Hence, the proof is done if we find ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1) under which ~\tilde{\mathcal{I}} satisfies the ranking condition over 𝐗~t[k]0k𝖫𝗏t¬φt,k\llbracket\tilde{\mathbf{X}}_{t}[k]\geq 0\land k\leq\mathsf{Lv}_{t}\land\lnot\varphi_{t,k}\rrbracket, where φt,k(ω)[𝐗~t+1[k]=εt](ω)γ,\varphi_{t,k}(\omega)\equiv\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon\mid\mathcal{F}_{t}](\omega)\geq\gamma, as in Eq. (3). More explicitly, our goal is to find ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1) under which the following holds \mathbb{P}-a.s. for each tt\in\mathbb{N} and k{1,,n}k\in\{1,\ldots,n\}:

𝐗~t[k](ω)0k𝖫𝗏t(ω)¬φt,k(ω)𝔼[𝐗~t+1[k]t](ω)𝐗~t[k](ω)𝟏𝖫𝗏t=k(ω).\displaystyle\tilde{\mathbf{X}}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega)\land\lnot\varphi_{t,k}(\omega)\Rightarrow\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\tilde{\mathbf{X}}_{t}[k](\omega)-{\bf 1}_{\llbracket\mathsf{Lv}_{t}=k\rrbracket}(\omega). (17)

Observe that the following are equivalent: (a) 𝐗~t[k](ω)0\tilde{\mathbf{X}}_{t}[k](\omega)\geq 0, (b) 𝐗t[k](ω)0k𝖫𝗏t(ω)\mathbf{X}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega), and (c) 𝐗~t[k](ω)=𝐗t[k](ω)0k𝖫𝗏t(ω)\tilde{\mathbf{X}}_{t}[k](\omega)=\mathbf{X}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega). Hence, (17) is equivalent to

𝐗t[k](ω)0k𝖫𝗏t(ω)¬φt,k(ω)𝔼[𝐗~t+1[k]t](ω)𝐗t[k](ω)𝟏𝖫𝗏t=k(ω).\displaystyle\mathbf{X}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega)\land\lnot\varphi_{t,k}(\omega)\Rightarrow\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\mathbf{X}_{t}[k](\omega)-{\bf 1}_{\llbracket\mathsf{Lv}_{t}=k\rrbracket}(\omega). (18)

We prove (18) via two case distinctions. If ω\omega satisfies [𝐗~t+1[k]=εt](ω)=0\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon\mid\mathcal{F}_{t}](\omega)=0, then we have 𝐗~t+1[k](ω)0\tilde{\mathbf{X}}_{t+1}[k](\omega)\geq 0 \mathbb{P}-a.s., and hence 𝔼[𝐗~t+1[k]t](ω)=𝔼[𝐗t+1[k]t](ω)\mathbb{E}[\tilde{\mathbf{X}}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)=\mathbb{E}[\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega) \mathbb{P}-a.s. Therefore, in this case, (18) is proved by the ranking condition for \mathcal{I}.

The rest of the proof is devoted to the case where [𝐗~t+1[k]=εt](ω)>0\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon\mid\mathcal{F}_{t}](\omega)>0 holds (thus it is always assumed below). For ω=s0s1Ω\omega=s_{0}s_{1}\ldots\in\Omega, let τt(ω)=σΔ(s0st)\tau_{t}(\omega)=\sigma_{\Delta}(s_{0}\ldots s_{t}) (i.e., the transition chosen by σ\sigma given the history s0sts_{0}\ldots s_{t}; recall σ\sigma is Δ\Delta-deterministic). We first show that τt(ω)Δd\tau_{t}(\omega)\not\in\Delta_{d} holds when γ\gamma is sufficiently small. Observe that, by Prop. A, the value [𝐗~t+1[k=εt](ω)=[𝐗t+1[k]<0k>𝖫𝗏t+1t](ω)\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k=-\varepsilon\mid\mathcal{F}_{t}](\omega)=\mathbb{P}[\mathbf{X}_{t+1}[k]<0\lor k>\mathsf{Lv}_{t+1}\mid\mathcal{F}_{t}](\omega) \mathbb{P}-a.s. represents the probability that either 𝜼[k](s)<0\boldsymbol{\eta}[k](s^{\prime})<0 or k>𝖫𝗏(σΔ(s0sts))k>\mathsf{Lv}(\sigma_{\Delta}(s_{0}\ldots s_{t}s^{\prime})) holds, where ss^{\prime} is the successor of sts_{t} under τt(ω)\tau_{t}(\omega). Also observe that, through a deterministic transition τ=(δ,u)Δd\tau=(\delta,u)\in\Delta_{d}, the successor state (,𝒙)(\ell^{\prime},\boldsymbol{x}^{\prime}) is determined once the successor location \ell^{\prime} is sampled from the distribution δ\delta. Hence, if τt(ω)=(,δ)Δd\tau_{t}(\omega)=(\ell,\delta)\in\Delta_{d}, then it should hold \mathbb{P}-a.s. that [𝐗~t+1[k]=εt](ω)=sSδ(s)\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon\mid\mathcal{F}_{t}](\omega)=\sum_{s^{\prime}\in S^{\prime}}\delta(s^{\prime}) for some Ssupp(δ)S^{\prime}\subseteq\mathrm{supp}(\delta). Therefore, if γ<δ()\gamma<\delta(\ell^{\prime}) holds for every (,δ)Δ(\ell,\delta)\in\Delta and supp(δ)\ell^{\prime}\in\mathrm{supp}(\delta), then it is \mathbb{P}-a.s. true that [𝐗~t+1[k]=εt](ω)(0,γ)\mathbb{P}[\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon\mid\mathcal{F}_{t}](\omega)\in(0,\gamma) implies τt(ω)Δd\tau_{t}(\omega)\not\in\Delta_{d}.

Now observe that the consequent part of (18) can be rewritten as follows, by explicitly writing 𝐗~t\tilde{\mathbf{X}}_{t} down: here we use the notation 𝖣𝖮𝖭𝖤kt𝐗t[k]<0k>𝖫𝗏t\mathsf{DONE}_{k}^{t}\equiv\mathbf{X}_{t}[k]<0\lor k>\mathsf{Lv}_{t} to describe the fixing condition (recall Def. 4).

𝔼[𝟏¬𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)ε[𝖣𝖮𝖭𝖤kt+1t](ω)𝐗t[k](ω)𝟏k=𝖫𝗏t(ω).\mathbb{E}[{\bf 1}_{\llbracket\lnot\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)-\varepsilon\cdot\mathbb{P}[\mathsf{DONE}_{k}^{t+1}\mid\mathcal{F}_{t}](\omega)\leq\mathbf{X}_{t}[k](\omega)-{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega).

Meanwhile, the antecedent part of (18) implies the following, due to the ranking condition of \mathcal{I}:

𝔼[𝟏¬𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)+𝔼[𝟏𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)𝐗t[k](ω)𝟏k=𝖫𝗏t(ω).\mathbb{E}[{\bf 1}_{\llbracket\lnot\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)+\mathbb{E}[{\bf 1}_{\llbracket\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\mathbf{X}_{t}[k](\omega)-{\bf 1}_{\llbracket k=\mathsf{Lv}_{t}\rrbracket}(\omega).

Hence, to prove (18), it suffices to show 𝔼[𝟏𝖣𝖮𝖭𝖤kt+1𝐗t+1[k]t](ω)ε[𝖣𝖮𝖭𝖤kt+1t](ω)-\mathbb{E}[{\bf 1}_{\llbracket\mathsf{DONE}_{k}^{t+1}\rrbracket}\cdot\mathbf{X}_{t+1}[k]\mid\mathcal{F}_{t}](\omega)\leq\varepsilon\cdot\mathbb{P}[\mathsf{DONE}_{k}^{t+1}\mid\mathcal{F}_{t}](\omega) whenever the antecedent of (18) and τt(ω)Δd\tau_{t}(\omega)\not\in\Delta_{d} holds. In particular, it suffices to show

𝐗t[k](ω)0k𝖫𝗏t(ω)φt,k(ω)τt(ω)Δd𝔼[min{0,𝐗t+1[k]}t](ω)ε[𝐗t+1[k]<0t](ω).\displaystyle\begin{split}\mathbf{X}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega)&\land\varphi_{t,k}(\omega)\land\tau_{t}(\omega)\not\in\Delta_{d}\\ &\Rightarrow-\mathbb{E}[\min\{0,\mathbf{X}_{t+1}[k]\}\mid\mathcal{F}_{t}](\omega)\leq\varepsilon\cdot\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega).\end{split} (19)

Let P𝒟()P\subseteq\mathcal{D}(\mathbb{R}) be the set of all distributions over \mathbb{R} that can be used for variable updates in the pCFG 𝒞\mathcal{C}; more precisely, let P={uττΔp}τΔn{usupp(u)uτ}P=\{u_{\tau}\mid\tau\in\Delta_{p}\}\cup\bigcup_{\tau\in\Delta_{n}}\{u^{\prime}\mid\mathrm{supp}(u^{\prime})\subseteq u_{\tau}\}. For a given a{0}a\in\mathbb{R}\setminus\{0\}, there are numbers C1(a)(0,1)C_{1}(a)\in(0,1) and C2(a)>0C_{2}(a)>0 such that (15) holds under C1=C1(a)C_{1}=C_{1}(a) and C2=C2(a)C_{2}=C_{2}(a) for any pPp\in P; this is derived from Prop. C.1.2.(a). In what follows, we fix such C1(a)C_{1}(a) and C2(a)C_{2}(a) for each a{0}a\in\mathbb{R}\setminus\{0\}. Also, for L\ell^{\prime}\in L and 𝒙i|V|1\boldsymbol{x}_{-i}\in\mathbb{R}^{|V|-1}, define 𝜼,𝒙i:n\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}:\mathbb{R}\to\mathbb{R}^{n} by 𝜼,𝒙i(xi)=𝜼(,xi,𝒙i)\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}(x_{i})=\boldsymbol{\eta}(\ell^{\prime},x_{i},\boldsymbol{x}_{-i}). Notice that 𝜼,𝒙i[k]\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k] is a 1-dimensional linear function of the form 𝜼,𝒙i[k](xi)=a,kxi+b\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k](x_{i})=a_{\ell^{\prime},k}x_{i}+b, where the coefficient a,ka_{\ell^{\prime},k} only depends on \ell^{\prime} and kk, and is independent of 𝒙i\boldsymbol{x}_{-i}. Let C1=min,kC1(a,k)C_{1}=\min_{\ell^{\prime},k}C_{1}(a_{\ell^{\prime},k}) and C2=max,kC2(a,k)C_{2}=\max_{\ell^{\prime},k}C_{2}(a_{\ell^{\prime},k}); as LL is finite, C1(0,1)C_{1}\in(0,1) and 0<C2<0<C_{2}<\infty.

Now fix τ=(,δ)Δp\tau=(\ell,\delta)\in\Delta_{p} and u=uτu=u_{\tau}. By the well-behavedness of the pCFG 𝒞\mathcal{C}, we have the following for each k{1,,n}k\in\{1,\ldots,n\}:

.𝒙i.[u(𝜼,𝒙i[k]<0)C1min{0,𝜼,𝒙i[k]}𝑑uC2u(𝜼,𝒙i[k]<0)].\displaystyle\forall\ell^{\prime}.\forall\boldsymbol{x}_{-i}.\ \biggl{[}u(\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]<0)\leq C_{1}\Rightarrow\int_{\mathbb{R}}\min\{0,\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]\}du\geq-C_{2}\cdot u(\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]<0)\biggr{]}. (20)

Also, by Prop. A we have the following \mathbb{P}-a.s. for any tt\in\mathbb{N} and k{1,,n}k\in\{1,\ldots,n\}; if τt(ω)=τ\tau_{t}(\omega)=\tau, then

[𝐗t+1[k]<0t](ω)=Lδ()u(𝜼,𝒙i[k]<0),\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega)=\sum_{\ell^{\prime}\in L}\delta(\ell^{\prime})\cdot u(\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]<0),

where ω=s0s1\omega=s_{0}s_{1}\ldots and st=(,xi,𝒙i)s_{t}=(\ell,x_{i},\boldsymbol{x}_{-i}). Hence, for γ(0,1)\gamma\in(0,1) that satisfies γ<δ()C1\gamma<\delta(\ell^{\prime})\cdot C_{1} for each supp(δ)\ell^{\prime}\in\mathrm{supp}(\delta), we have the following \mathbb{P}-a.s. for any tt\in\mathbb{N}: if τt(ω)=τ\tau_{t}(\omega)=\tau, then

[𝐗t+1[k]<0t](ω)<γsupp(δ).u(𝜼,𝒙i[k]<0)C1.\displaystyle\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega)<\gamma\Rightarrow\forall\ell^{\prime}\in\mathrm{supp}(\delta).u(\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]<0)\leq C_{1}. (21)

Now, for any tt\in\mathbb{N}, let ω=s0s1\omega=s_{0}s_{1}\ldots be given, let st=(,xi,𝒙i)s_{t}=(\ell,x_{i},\boldsymbol{x}_{-i}), and suppose τt(ω)=τ\tau_{t}(\omega)=\tau and ¬φt,k(ω)\lnot\varphi_{t,k}(\omega) holds (observe 𝐗t+1[k]<0𝐗~t+1[k]=ε\mathbf{X}_{t+1}[k]<0\Rightarrow\tilde{\mathbf{X}}_{t+1}[k]=-\varepsilon always holds, and thus ¬φt,k(ω)\lnot\varphi_{t,k}(\omega) implies [𝐗t+1[k]<0t](ω)<γ\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega)<\gamma). Then we have

𝔼[min{0,𝐗t+1[k]}t](ω)\displaystyle\mathbb{E}[\min\{0,\mathbf{X}_{t+1}[k]\}\mid\mathcal{F}_{t}](\omega) =Lδ()min{0,𝜼,𝒙i[k]}𝑑u\displaystyle=\sum_{\ell^{\prime}\in L}\delta(\ell^{\prime})\cdot\int_{\mathbb{R}}\min\{0,\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]\}du (Prop. A)
Lδ()C2u(𝜼,𝒙i[k]<0)\displaystyle\geq\sum_{\ell^{\prime}\in L}\delta(\ell^{\prime})\cdot-C_{2}\cdot u(\boldsymbol{\eta}_{\ell^{\prime},\boldsymbol{x}_{-i}}[k]<0) (conditions (20) and (21))
=C2[𝐗t+1[k]<0t](ω).(-a.s.)\displaystyle=-C_{2}\cdot\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega).\quad\mbox{($\mathbb{P}$-a.s.)} (Prop. A)

Now we let ε=C2\varepsilon=C_{2} and γ(0,1)\gamma\in(0,1) be a number that satisfies γ<δ()C1\gamma<\delta(\ell^{\prime})\cdot C_{1} for each (,δ)Δ(\ell,\delta)\in\Delta and supp(δ)\ell^{\prime}\in\mathrm{supp}(\delta) (such a γ\gamma can be taken from (0,1)(0,1) as Δ\Delta and LL are finite). The argument above shows that the following holds \mathbb{P}-a.s.;

𝐗t[k](ω)0k𝖫𝗏t(ω)\displaystyle\mathbf{X}_{t}[k](\omega)\geq 0\land k\leq\mathsf{Lv}_{t}(\omega) φt,k(ω)τt(ω)Δd\displaystyle\land\varphi_{t,k}(\omega)\land\tau_{t}(\omega)\not\in\Delta_{d}
𝔼[min{0,𝐗t+1[k]}t](ω)ε[𝐗t+1[k]<0t](ω).\displaystyle\Rightarrow-\mathbb{E}[\min\{0,\mathbf{X}_{t+1}[k]\}\mid\mathcal{F}_{t}](\omega)\leq\varepsilon\cdot\mathbb{P}[\mathbf{X}_{t+1}[k]<0\mid\mathcal{F}_{t}](\omega).

This holds \mathbb{P}-a.s. for any τΔp\tau\in\Delta_{p}; it can be shown via the similar argument that this also holds \mathbb{P}-a.s. for each τΔn\tau\in\Delta_{n}. Hence (19) holds \mathbb{P}-a.s. ∎

Having Thm. 5 proved, soundness of LLexRSM maps now easily follows.

Proof of Thm. 5. By Thm. 5, for any Δ\Delta-deterministic scheduler σ\sigma and an initial state sIs_{I}, the instance \mathcal{I} induced by 𝜼\boldsymbol{\eta} and 𝖫𝗏\mathsf{Lv} under σ\sigma and sIs_{I} is (ε,γ)(\varepsilon,\gamma)-fixable for some ε>0\varepsilon>0 and γ(0,1)\gamma\in(0,1). By Cor. 4, this proves that 𝒞\mathcal{C} is AST under σ\sigma and sIs_{I}. As 𝒞\mathcal{C} is AST whenever it is AST for each Δ\Delta-deterministic σ\sigma and an initial state sIs_{I} [ChatterjeeGNZZ21arxiv, Prop. 1], the claim follows. ∎

Appendix D Omitted details of Section 6

Proof of Thm. 6. Over a non-probabilistic CFG, the ranking condition of 𝜼:𝒮n\boldsymbol{\eta}:\mathcal{S}\to\mathbb{R}^{n} implies

ττout.sIG(τ).k{1,,𝖫𝗏(τ)}.ssuccτ(s).[𝜼[k](s)𝜼[k](s)𝟏k=𝖫𝗏(τ)].\forall\tau\neq\tau_{\mathrm{out}}.\forall s\in\llbracket I\land G(\tau)\rrbracket.\forall k\in\{1,\ldots,\mathsf{Lv}(\tau)\}.\forall s^{\prime}\in\mathrm{succ}_{\tau}(s).\bigl{[}\boldsymbol{\eta}[k](s^{\prime})\leq\boldsymbol{\eta}[k](s)-\mathbf{1}_{k=\mathsf{Lv}(\tau)}\bigr{]}.

This condition clearly implies the pointwise unafecting condition (5) at every k{1,,n}k\in\{1,\ldots,n\}, and hence, 𝜼\boldsymbol{\eta} satisfies MCLC. ∎

Line-by-line explanation of the synthesis algorithm. The pseudocode of our algorithm is given in Alg. 1. whose summary is as follows. Similar to existing LexRSM synthesis algorithms [ChatterjeeGNZZ21, AgrawalCP18], it constructs a LexRSM (η1,,ηd)(\eta_{1},\cdots,\eta_{d}) in an iterative way. At the kk-th iteration, the algorithm attempts to construct ηk\eta_{k} that ranks transitions in UΔU\subseteq\Delta, i.e, those which are not ranked by η1,,ηk1\eta_{1},\ldots,\eta_{k-1} (Line 1-1). It first tries to construct such ηk\eta_{k} under the non-negativity condition (4). This is done by solving the LP problem 𝒫U1\mathcal{L}\mathcal{P}_{U}^{1} (Line 1), which looks for a 1-dimensional MM η\eta such that

  1. (a)

    for every τU\tau\in U and sIG(τ)s\in\llbracket I\land G(\tau)\rrbracket, we have 𝕏¯τη(s)η(s)\overline{\mathbb{X}}_{\tau}\eta(s)\leq\eta(s) and η(s)0\eta(s)\geq 0; and

  2. (b)

    for as many τU\tau\in U as possible, we have sIG(τ)𝕏¯τη(s)η(s)1s\in\llbracket I\land G(\tau)\rrbracket\Rightarrow\overline{\mathbb{X}}_{\tau}\eta(s)\leq\eta(s)-1 (i.e., η\eta ranks τ\tau).

The LP problem 𝒫U1\mathcal{L}\mathcal{P}_{U}^{1} is obtained by the reduction of conditions (a-b) via Farkas’ lemma. If the solution η\eta of 𝒫U1\mathcal{L}\mathcal{P}_{U}^{1} ranks at least one transition in UU, then the algorithm lets ηk=η\eta_{k}=\eta, adds it to the output, and eliminates ranked transitions from UU (line 1-1); otherwise, it tries to construct ηk\eta_{k} under the pointwise unaffecting condition (5). This is done by solving 𝒫U,𝒯2\mathcal{L}\mathcal{P}_{U,\mathcal{T}}^{2} for each 𝒯Class(U)\mathcal{T}\in\mbox{Class}(U) (line 1), where Class(U)2U{}\mbox{Class}(U)\subseteq 2^{U}\setminus\{\emptyset\} is a user-defined parameter; there, the LP problem 𝒫U,𝒯2\mathcal{L}\mathcal{P}_{U,\mathcal{T}}^{2} looks for η\eta that exactly ranks transitions in 𝒯\mathcal{T}, that is,

  1. (a’)

    for every τ𝒯\tau\in\mathcal{T} and sIG(τ)s\in\llbracket I\land G(\tau)\rrbracket, we have 𝕏¯τη(s)η(s)1\overline{\mathbb{X}}_{\tau}\eta(s)\leq\eta(s)-1 and η(s)0\eta(s)\geq 0; and

  2. (b’)

    for every τΔ𝒯\tau\in\Delta\setminus\mathcal{T}, sIG(τ)s\in\llbracket I\land G(\tau)\rrbracket and ssuccτ(s)s^{\prime}\in\mathrm{succ}_{\tau}(s), we have η(s)η(s)\eta(s^{\prime})\leq\eta(s).

Once 𝒫U,𝒯2\mathcal{L}\mathcal{P}_{U,\mathcal{T}}^{2} is solved for any 𝒯Class(U)\mathcal{T}\in\mbox{Class}(U), the algorithm does a similar update as line 1-1 and breaks (line 1-1); if it fails to solve 𝒫U,𝒯2\mathcal{L}\mathcal{P}_{U,\mathcal{T}}^{2} for every 𝒯\mathcal{T}, then it concludes a failure and terminates (line 1-1). If ηk\eta_{k} is computed (line 1 or 1), the algorithm goes to the next iteration after updating UU; the iteration continues until UU is empty.

1 Input: A pCFG 𝒞\mathcal{C} with an invariant II;
2 Initialize UU\leftarrow all generalized transitions of pCFG 𝒞\mathcal{C} ; d0d\leftarrow 0;
3 while UU is not empty do
4       dd+1d\leftarrow d+1;rankedFalseranked\leftarrow False;
5       Construct and solve 𝒫U1\mathcal{LP}^{1}_{U};
6       if No solution to 𝒫U1\mathcal{LP}^{1}_{U} then
7             for each 𝒯Class(U)\mathcal{T}\in\mbox{Class}(U) do
8                   Construct and solve 𝒫U,𝒯2\mathcal{LP}^{2}_{U,\mathcal{T}};
9                   if Exist solution to 𝒫U,𝒯2\mathcal{LP}^{2}_{U,\mathcal{T}} then
10                         ηd\eta_{d}\leftarrow RF from Solution of 𝒫U,𝒯2\mathcal{LP}^{2}_{U,\mathcal{T}};rankedTrueranked\leftarrow True;
11                         UU\𝒯U\leftarrow U\backslash\mathcal{T};
12                         break;
13                        
14            if not rankedranked then
15                   Return FALSE;
16                  
17      else
18             ηd\eta_{d}\leftarrow ranking function from Solution of 𝒫U1\mathcal{LP}^{1}_{U};
19             UU\{τηd ranks τ}U\leftarrow U\backslash\{\tau\mid\eta_{d}\mbox{ ranks $\tau$}\};
20            
Return (η1,η2,,ηd)(\eta_{1},\eta_{2},\cdots,\eta_{d})
Algorithm 1 synthesis algorithm of linear SC-LexRSM map with MCLC.
{mytheorem}

For any Class(U)\mbox{\rm Class}(U), the algorithm returns a linear SC-LexRSM map with MCLC for a linear, well-behaved pCFG 𝒞\mathcal{C} whenever it reports a success; it also decides if 𝒞\mathcal{C} admits a linear LW-LexRSM map, and whenever 𝒞\mathcal{C} does, the output 𝜼\boldsymbol{\eta} has the minimal dimension among those. When Class(U)=2U{}\mbox{\rm Class}(U)=2^{U}\setminus\{\emptyset\}, the algorithm decides in NP if 𝒞\mathcal{C} admits a linear SC-LexRSM with MCLC. ∎

Proof.

Fix a linear, well-behaved pCFG 𝒞\mathcal{C}. Suppose 𝒞\mathcal{C} admits a linear SC-LexRSM 𝜼=(η1,,ηn)\boldsymbol{\eta}=(\eta_{1},\ldots,\eta_{n}) with MCLC, and Alg. 1 has generated (η^1,,η^m)(\hat{\eta}_{1},\ldots,\hat{\eta}_{m}) (which possibly does not rank all transitions) and terminated. Let UkΔU_{k}\subseteq\Delta and U^kΔ\hat{U}_{k}\subseteq\Delta be the set of transitions unranked by (η1,,ηk)(\eta_{1},\ldots,\eta_{k}) and (η^1,,η^k)(\hat{\eta}_{1},\ldots,\hat{\eta}_{k}), respectively. We prove that, for each k{0,,n}k\in\{0,\ldots,n\}, there exists k^{0,,m}\hat{k}\in\{0,\ldots,m\} such that U^k^Uk\hat{U}_{\hat{k}}\subseteq U_{k} if either of the following holds;

  1. 1.

    The LexRSM 𝜼\boldsymbol{\eta} satisfies leftward non-negativity, or

  2. 2.

    2U{}2^{U}\setminus\{\emptyset\}.

We also show that kk^k\leq\hat{k} additionally holds for each kk in Case 1. The base case is true because U0=U^0U_{0}=\hat{U}_{0}. For the step case, if we have U^k^Uk+1\hat{U}_{\hat{k}}\subseteq U_{k+1} then we are done. If not,

  • in Case 1, it must be the case that U^k^+1\hat{U}_{\hat{k}+1} exists and U^k^+1Uk+1\hat{U}_{\hat{k}+1}\subseteq U_{k+1}; indeed, 𝒫Uk1\mathcal{LP}^{1}_{U_{k}} is no easier than 𝒫U^k^1\mathcal{LP}^{1}_{\hat{U}_{\hat{k}}}, so Alg. 1 should find a solution of 𝒫U^k^1\mathcal{LP}^{1}_{\hat{U}_{\hat{k}}} whenever Uk+1U_{k+1} exists. Then by a similar analysis as [ChatterjeeGNZZ21arxiv], η^k^+1+ηk+1\hat{\eta}_{\hat{k}+1}+\eta_{k+1} must be also in the solution space of 𝒫U^k^1\mathcal{LP}^{1}_{\hat{U}_{\hat{k}}}, and this would rank strictly more transitions than η^k^+1\hat{\eta}_{\hat{k}+1} if U^k^+1Uk+1\hat{U}_{\hat{k}+1}\subseteq U_{k+1} does not hold. This contradicts the maximality property of 𝒫U1\mathcal{LP}^{1}_{U}. Hence the claim follows.

  • in Case 2, if ηk+1\eta_{k+1} satisfies the condition by Definition 6.(4), then we have the same argument as Case 1. Suppose ηk+1\eta_{k+1} satisfies the condition by Definition 6.(5), and let 𝒯\mathcal{T} be the set of transitions ranked by ηk+1\eta_{k+1}. Then for any UUkU\subseteq U_{k}, the function ηk+1\eta_{k+1} must be in the solution space of 𝒫U,U𝒯2\mathcal{LP}^{2}_{U,U\cap\mathcal{T}}. Because Alg. 1 does the brute-force search, this means that Alg. 1 never returns FALSE before ranking every transition in 𝒯\mathcal{T}. As Δ\Delta is finite, we eventually observe U^lUk+1\hat{U}_{l}\subseteq U_{k+1} for some ll.

Because 𝜼\boldsymbol{\eta} is an SC-LexRSM, We have Un=U_{n}=\emptyset; and we proved there is an ll such that U^lUn\hat{U}_{l}\subseteq U_{n} when either Case 1 or Case 2 is true, and we also have lnl\leq n in Case 1. Hence the theorem is proved. ∎

Appendix E Full Experiment Result

Full experiment result. Experiments are performed on Ryzen7 6800H, 16GB RAM machine, WSL-Ubuntu 20.04 platform.

Table 2: Full Experiment Result. Ticks in “p.l.” and “p.a.” indicate the benchmark has a probabilistic loop and assignment, respectively. In the “dim.” column, a number indicates that the algorithm found a LexRSM with that dimension; a cross indicates a failure; ×\times* means the computation is aborted by our experiment platform due to out of memory; “N/A” means we did not run the experiment. The “time” column shows the computation time in seconds.
Benchmark Spec. Synthesis result
Baselines Our Algs
STR LWN SMC EMC
Model p.l. p.a. dim. time dim. time dim. time dim. time
aaron2 ×\times ×\times 2 0.12 2 0.06 2 0.05 2 0.06
aaron2 \surd ×\times 2 0.05 2 0.06 2 0.06 2 0.06
aaron2 \surd \surd 2 0.05 2 0.05 2 0.06 2 0.06
alain ×\times ×\times 2 0.08 2 0.07 2 0.07 2 0.07
alain \surd ×\times 2 0.09 2 0.11 2 0.10 2 0.10
alain \surd \surd 3 0.16 3 0.15 3 0.17 3 0.17
ax ×\times ×\times 3 0.08 3 0.07 3 0.07 3 0.08
ax \surd ×\times 3 0.07 3 0.08 3 0.07 3 0.08
ax \surd \surd 3 0.08 3 0.08 3 0.08 3 0.09
catmouse ×\times ×\times 2 0.06 2 0.06 2 0.05 2 0.05
catmouse \surd ×\times 2 0.05 2 0.06 2 0.05 2 0.06
catmouse \surd \surd 2 0.05 2 0.05 2 0.05 2 0.06
complex ×\times ×\times ×\times 0.08 ×\times 0.06 7 0.16 5 254.03
complex \surd ×\times ×\times 0.06 ×\times 0.07 7 0.20 5 4300.40
complex \surd \surd ×\times 0.07 ×\times 0.07 3 0.09 3 281.59
counterex1a ×\times ×\times ×\times 0.07 ×\times 0.06 ×\times 0.20 ×\times 18.38
counterex1b ×\times ×\times 3 0.07 3 0.06 3 0.07 3 0.07
counterex1b \surd ×\times 3 0.07 3 0.07 3 0.07 3 0.08
counterex1b \surd \surd 3 0.08 3 0.07 3 0.08 3 0.08
counterex1c ×\times ×\times ×\times 0.08 ×\times 0.07 ×\times 0.14 ×\times 3.96
counterex1c \surd ×\times ×\times 0.07 ×\times 0.08 ×\times 0.17 ×\times 17.07
counterex1c \surd \surd ×\times 0.08 ×\times 0.08 ×\times 0.17 ×\times 17.43
cousot9 ×\times ×\times ×\times 0.06 3 0.06 3 0.07 3 0.07
cousot9 \surd ×\times ×\times 0.06 ×\times 0.07 4 0.10 4 0.17
easy1 ×\times ×\times 1 0.05 1 0.04 1 0.05 1 0.04
easy1 \surd ×\times 1 0.04 1 0.05 1 0.04 1 0.05
easy1 \surd \surd 1 0.05 1 0.05 1 0.05 1 0.05
easy2 ×\times ×\times 2 0.05 2 0.05 2 0.05 2 0.05
easy2 \surd ×\times 2 0.06 2 0.05 2 0.06 2 0.06
easy2 \surd \surd 2 0.06 2 0.06 2 0.06 2 0.06
exmini ×\times ×\times 2 0.05 2 0.05 2 0.05 2 0.06
exmini \surd ×\times 2 0.06 2 0.05 2 0.06 2 0.06
exmini \surd \surd 2 0.06 2 0.06 2 0.06 2 0.06
insertsort ×\times ×\times 3 0.06 3 0.07 3 0.07 3 0.07
insertsort \surd ×\times 3 0.07 3 0.07 3 0.07 3 0.08
insertsort \surd \surd 3 0.07 3 0.07 3 0.07 3 0.07
loops ×\times ×\times ×\times 0.06 ×\times 0.05 4 0.09 3 3.99
ndecr ×\times ×\times 2 0.05 2 0.05 2 0.05 2 0.05
ndecr \surd ×\times 2 0.05 2 0.05 2 0.05 2 0.06
ndecr \surd \surd 2 0.05 2 0.05 2 0.05 2 0.06
nestedLoop ×\times ×\times ×\times 0.07 ×\times 0.07 ×\times 0.11 ×\times 263.17
nestedLoop \surd ×\times 3 0.08 3 0.09 3 0.09 3 0.09
nestedLoop \surd \surd ×\times 0.15 ×\times 0.15 4 0.18 3 535.30
perfect ×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.08
perfect \surd ×\times 3 0.07 3 0.07 3 0.07 3 0.08
perfect \surd \surd 3 0.08 3 0.08 3 0.08 3 0.08
perfect1 ×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.07
perfect1 \surd ×\times 3 0.07 3 0.07 3 0.07 3 0.08
perfect1 \surd \surd 3 0.08 3 0.08 3 0.08 3 0.08
perfect2 ×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.07
perfect2 \surd ×\times 3 0.07 3 0.07 3 0.07 3 0.08
perfect2 \surd \surd ×\times 0.08 ×\times 0.07 ×\times 0.11 ×\times 0.20
random1d ×\times ×\times 2 0.06 2 0.05 2 0.05 2 0.06
random1d \surd ×\times 2 0.05 2 0.05 2 0.06 2 0.06
random1d \surd \surd 2 0.06 2 0.05 2 0.06 2 0.07
real2 ×\times ×\times ×\times 0.06 ×\times 0.05 ×\times 0.15 ×\times 66.48
realbubble ×\times ×\times 3 0.08 3 0.07 3 0.07 3 0.11
realbubble \surd ×\times 3 0.07 3 0.07 3 0.08 3 0.08
realbubble \surd \surd 3 0.09 3 0.08 3 0.09 3 0.09
realheapsort ×\times ×\times ×\times 0.09 3 0.08 3 0.09 3 0.10
realheapsort
_step1
×\times ×\times ×\times 0.07 3 0.07 3 0.07 3 0.08
realheapsort
_step1
\surd \surd ×\times 0.07 3 0.07 3 0.07 3 0.08
realheapsort
_step2
×\times ×\times 1 0.06 1 0.06 1 0.05 1 0.06
realselect ×\times ×\times 3 0.07 3 0.07 3 0.07 3 0.08
realselect \surd ×\times 3 0.07 3 0.07 3 0.08 3 0.08
realselect \surd \surd 3 0.09 3 0.08 3 0.09 3 0.10
realshellsort ×\times ×\times 1 0.05 1 0.04 1 0.05 1 0.05
realshellsort \surd ×\times 1 0.05 1 0.04 1 0.05 1 0.05
realshellsort \surd \surd ×\times 0.06 2 0.06 2 0.07 2 0.07
rsd ×\times ×\times ×\times 0.06 ×\times 0.05 ×\times 0.14 ×\times 2.66
rsd \surd ×\times ×\times 0.06 ×\times 0.06 ×\times 0.16 ×\times 10.57
rsd \surd \surd 1 0.07 1 0.07 1 0.07 1 0.07
serpent ×\times ×\times ×\times 0.06 ×\times 0.06 3 0.08 3 30.59
serpent \surd ×\times 2 0.06 2 0.06 2 0.07 2 0.07
serpent \surd \surd 3 0.08 3 0.08 3 0.09 3 0.09
sipma91 ×\times ×\times 2 0.07 2 0.07 2 0.07 2 0.08
sipma91 \surd ×\times 1 0.06 1 0.06 1 0.06 1 0.06
sipma91 \surd \surd 2 0.08 2 0.08 2 0.09 2 0.08
sipmabubble ×\times ×\times 3 0.07 3 0.07 3 0.07 3 0.08
sipmabubble \surd ×\times 3 0.08 3 0.07 3 0.08 3 0.08
sipmabubble \surd \surd 3 0.08 3 0.07 3 0.08 3 0.08
sipma
mergesort
×\times ×\times ×\times 213.99 ×\times 185.24 ×\times 183.39 ×\times* ×\times*
speedDis1 ×\times ×\times ×\times 0.06 ×\times 0.06 4 0.09 4 0.19
speedDis2 ×\times ×\times ×\times 0.06 ×\times 0.06 4 0.09 4 0.10
speedFails1 ×\times ×\times 2 0.05 2 0.05 2 0.05 2 0.06
speedFails1 \surd ×\times 2 0.06 2 0.05 2 0.06 2 0.06
speedFails1 \surd \surd 2 0.05 2 0.05 2 0.05 2 0.06
speedFails2 ×\times ×\times ×\times 0.05 ×\times 0.05 ×\times 0.07 ×\times 0.07
speedFails2 \surd ×\times ×\times 0.06 ×\times 0.05 ×\times 0.08 ×\times 0.17
speedFails2 \surd \surd ×\times 0.05 ×\times 0.05 ×\times 0.08 ×\times 0.18
speedFails4 ×\times ×\times ×\times 0.05 ×\times 0.05 ×\times 0.09 ×\times 0.30
speedNested
Multiple
×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.07
speedNested
Multiple
\surd ×\times 3 0.08 3 0.06 3 0.07 3 0.07
speedNested
Multiple
\surd \surd 3 0.07 3 0.06 3 0.07 3 0.07
speedNested
MultipleDep
×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.07
speedNested
MultipleDep
\surd ×\times 3 0.09 3 0.06 3 0.07 3 0.07
speedNested
MultipleDep
\surd \surd 3 0.08 3 0.08 3 0.08 3 0.08
speedSimple
Multiple
×\times ×\times ×\times 0.06 ×\times 0.06 4 0.08 4 0.10
speedSimple
MultipleDep
×\times ×\times ×\times 0.06 ×\times 0.06 4 0.09 4 0.10
speedSingle
Single
×\times ×\times 2 0.05 2 0.05 2 0.06 2 0.06
speedSingle
Single
\surd ×\times 2 0.10 2 0.06 2 0.05 2 0.06
speedSingle
Single
\surd \surd 2 0.06 2 0.06 2 0.06 2 0.06
speedSingle
Single2
×\times ×\times 2 0.06 2 0.06 2 0.06 2 0.06
speedSingle
Single2
\surd ×\times 2 0.08 2 0.06 2 0.06 2 0.07
speedSingle
Single2
\surd \surd ×\times 0.08 ×\times 0.08 5 0.17 5 1.79
speedpldi2 ×\times ×\times 2 0.06 2 0.05 2 0.06 2 0.06
speedpldi2 \surd ×\times 2 0.08 2 0.05 2 0.06 2 0.06
speedpldi2 \surd \surd 2 0.07 2 0.07 2 0.06 2 0.07
speedpldi3 ×\times ×\times ×\times 0.07 3 0.06 3 0.07 3 0.07
speedpldi3 \surd ×\times ×\times 0.08 ×\times 0.06 4 0.10 4 0.18
speedpldi3 \surd \surd 3 0.08 3 0.08 3 0.08 3 0.09
speedpldi4 ×\times ×\times 2 0.06 2 0.05 2 0.06 2 0.06
speedpldi4 \surd ×\times 2 0.09 2 0.05 2 0.06 2 0.06
speedpldi4 \surd \surd 2 0.06 2 0.07 2 0.06 2 0.06
terminate ×\times ×\times 2 0.05 2 0.05 2 0.06 2 0.06
terminate \surd ×\times 2 0.08 2 0.05 2 0.06 2 0.06
terminate \surd \surd 2 0.06 2 0.06 2 0.06 2 0.06
unperfect ×\times ×\times 3 0.07 3 0.07 3 0.08 3 0.07
unperfect \surd ×\times 3 0.10 3 0.08 3 0.08 3 0.08
unperfect \surd \surd ×\times 0.09 ×\times 0.10 ×\times 0.34 ×\times 473.42
wcet0 ×\times ×\times 2 0.06 2 0.06 2 0.08 2 0.06
wcet0 \surd ×\times 2 0.09 2 0.07 2 0.06 2 0.07
wcet0 \surd \surd 2 0.08 2 0.08 2 0.08 2 0.10
wcet1 ×\times ×\times 2 0.06 2 0.06 2 0.07 2 0.06
wcet1 \surd ×\times 2 0.11 2 0.07 2 0.06 2 0.07
wcet1 \surd \surd 2 0.08 2 0.09 2 0.07 2 0.08
wcet2 ×\times ×\times 2 0.05 2 0.05 2 0.06 2 0.06
wcet2 \surd ×\times 2 0.09 2 0.06 2 0.06 2 0.06
wcet2 \surd \surd 2 0.06 2 0.06 2 0.07 2 0.06
while2 ×\times ×\times 3 0.06 3 0.06 3 0.07 3 0.07
while2 \surd ×\times 3 0.11 3 0.06 3 0.07 3 0.07
while2 \surd \surd 3 0.07 3 0.08 3 0.08 3 0.08
wise ×\times ×\times ×\times 0.05 ×\times 0.05 ×\times 0.09 ×\times 0.29
counterexStr1 ×\times \surd N/A N/A 3 0.08 3 0.06 3 0.18
counterexStr2 ×\times \surd ×\times 0.06 ×\times 0.10 4 0.13 4 0.36