Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

Many classic questions in formal methods can be seen as involving comparisons between different system runs or inputs. Consider the problem of verifying if a system S satisfies a linear-time temporal property P. Traditionally, this problem is phrased language-theoretically: S and P are interpreted as sets of (infinite) words, and S is determined to satisfy P if \(S \subseteq P\). The problem, however, can also be framed in terms of a comparison between words in S and P. Suppose a word w is assigned a weight of 1 if it belongs to the language of the system or property, and 0 otherwise. Then determining if \(S \subseteq P\) amounts to checking whether the weight of every word in S is less than or equal to its weight in P [5].

The need for such a formulation is clearer in quantitative systems, in which every run of a word is associated with a sequence of (rational-valued) weights. The weight of a run is given by aggregate function \(f: \mathbb {Q}^{\omega }\rightarrow \mathbb {R}\), which returns the real-valued aggregate value of the run’s weight sequence. The weight of a word is given by the supremum or infimum of the weight of all its runs. Common examples of aggregate functions include discounted-sum and limit-average.

In a well-studied class of problems involving quantitative systems, the objective is to check if the aggregate value of words of a system exceed a constant threshold value [14,15,16]. This is a natural generalization of emptiness problems in qualitative systems. Known solutions to the problem involve arithmetic reasoning via linear programming and graph algorithms such as negative-weight cycle detection, computation of maximum weight of cycles etc. [4, 18].

A more general notion of comparison relates aggregate values of two weight sequences. Such a notion arises in the quantitative inclusion problem for weighted automata [1], where the goal is to determine whether the weight of words in one weighted automaton is less than that in another. Here it is necessary to compare the aggregate value along runs between the two automata. Approaches based on arithmetic reasoning do not, however, generalize to solving such problems. In fact, the known solution to discounted-sum inclusion with integer discount-factor combines linear programming with a specialized subset-construction-based determinization step, rendering an EXPTIME algorithm [4, 6]. Yet, this approach does not match the PSPACE lower bound for discounted-sum inclusion.

In this paper, we present an automata-theoretic formulation of this form of comparison between weighted sequences. Specifically, we introduce comparator automata (comparators, in short), a class of automata that read pairs of infinite weight sequences synchronously, and compare their aggregate values in an online manner. While comparisons between weight sequences happen implicitly in prior approaches to quantitative systems, comparator automata make these comparisons explicit. We show that this has many benefits, including generic algorithms for a large class of quantitative reasoning problems, as well as a direct solution to the problem of discounted-sum inclusion that also closes its complexity gap.

A comparator for aggregate function f is an automaton that accepts a pair (AB) of sequences of bounded rational numbers iff f(A) R f(B), where R is an inequality relation (>, <, \(\ge \), \(\le \)) or the equality relation. A comparator could be finite-state or (pushdown) infinite-state. This paper studies such comparators.

A comparator is \(\omega \)-regular if it is finite-state and accepts by the Büchi condition. We show that \(\omega \)-regular comparators lead to generic algorithms for a number of well-studied problems including the quantitative inclusion problem, and in showing existence of winning strategies in incomplete-information quantitative games. Our algorithm yields PSPACE-completeness of quantitative inclusion when the \(\omega \)-regular comparator is provided. The same algorithm extends to obtaining finite-state representations of counterexample words in inclusion.

Next, we show that the discounted-sum aggregation function admits an \(\omega \)-regular comparator when the discount-factor \(d>1\) is an integer. Using properties of \(\omega \)-regular comparators, we conclude that the discounted-sum inclusion is PSPACE-complete, hence resolving the complexity gap. Furthermore, we prove that the discounted-sum comparator for \(1<d<2\) cannot be \(\omega \)-regular. We suspect this result extends to non-integer discount-factors as well.

Finally, we investigate the limit-average comparator. Since limit-average is only defined for sequences in which the average of prefixes converge, limit-average comparison is not well-defined. We show that even a Büchi pushdown automaton cannot separate sequences for which limit-average exists from those for which it does not. Hence, we introduce the novel notion of prefix-average comparison as a relaxation of limit-average comparison. We show that the prefix-average comparator admits a comparator that is \(\omega \)-context-free, i.e., given by a Büchi pushdown automaton, and we discuss the utility of this characterization.

This paper is organized as follows: Preliminaries are given in Sect. 2. Comparator automata is formally defined in Sect. 3. Generic algorithms for \(\omega \)-regular comparators are discussed in Sects. 3.1 and 3.2. The construction and properties of discounted-sum comparator, and limit-average and prefix-average comparator are given in Sects. 4 and 5, respectively. We conclude with future directions in Sect. 6.

Related Work. The notion of comparison has been widely studied in quantitative settings. Here we mention only a few of them. Such aggregate-function based notions appear in weighted automata [1, 17], quantitative games including mean-payoff and energy games [16], discounted-payoff games [3, 4], in systems regulating cost, memory consumption, power consumption, verification of quantitative temporal properties [14, 15], and others. Common solution approaches include graph algorithms such as weight of cycles or presence of cycle [18], linear-programming-based approaches, fixed-point-based approaches [8], and the like. The choice of approach for a problem typically depends on the underlying aggregate function. In contrast, in this work we present an automata-theoretic approach that unifies solution approaches to problems on different aggregate functions. We identify a class of aggregate functions, ones that have an \(\omega \)-regular comparator, and present generic algorithms for some of these problems.

While work on finite-representations of counterexamples and witnesses in the qualitative setting is known [5], we are not aware of such work in the quantitative verification domain. This work can be interpreted as automata-theoretic arithmetic, which has been explored in regular real analysis [12].

2 Preliminaries

Definition 1

(Büchi automata [21]). A (finite-state) Büchi automaton is a tuple \(\mathcal {A}= ( S , \varSigma , \delta , { Init }, \mathcal {F})\), where \( S \) is a finite set of states, \( \varSigma \) is a finite input alphabet, \( \delta \subseteq ( S \times \varSigma \times S ) \) is the transition relation, \( { Init }\subseteq S \) is the set of initial states, and \( \mathcal {F}\subseteq S \) is the set of accepting states.

A Büchi automaton is deterministic if for all states s and inputs a, \(|\{s'|(s, a, s') \in \delta \text { for some}\, s' \}| \le 1\) and \(|{ Init }|=1\). Otherwise, it is nondeterministic. For a word \( w = w_0w_1\dots \in \varSigma ^{\omega } \), a run \( \rho \) of w is a sequence of states \(s_0s_1\dots \) s.t. \( s_0 \in { Init }\), and \( \tau _i =(s_i, w_i, s_{i+1}) \in \delta \) for all i. Let \( inf (\rho ) \) denote the set of states that occur infinitely often in run \({\rho }\). A run \(\rho \) is an accepting run if \( inf (\rho )\cap \mathcal {F}\ne \emptyset \). A word w is an accepting word if it has an accepting run. Büchi automata are known to be closed under set-theoretic union, intersection, and complementation [21]. Languages accepted by these automata are called \(\omega \)-regular languages.

Definition 2

(Weighted \(\omega \)-automaton [10, 20]). A weighted \(\omega \)-automaton over infinite words is a tuple \(\mathcal {A}= (\mathcal {M}, \gamma )\), where \(\mathcal {M} = ( S , \varSigma , \delta , { Init }, S ) \) is a Büchi automaton, and \(\gamma : \delta \rightarrow \mathbb {Q}\) is a weight function.

Words and runs in weighted \(\omega \)-automata are defined as they are in Büchi automata. Note that all states are accepting states in this definition. The weight sequence of run \(\rho = s_0 s_1 \dots \) of word \(w = w_0w_1\dots \) is given by \(wt_{\rho } = n_0 n_1 n_2\dots \) where \(n_i = \gamma (s_i, w_i, s_{i+1})\) for all i. The weight of a run \(\rho \) is given by \(f(wt_{\rho })\), where \(f: \mathbb {Q}^{\omega } \rightarrow \mathbb {R}\) is an aggregate function. We use \(f(\rho )\) to denote \(f(wt_{\rho })\).

Here the weight of a word \(w \in \varSigma ^{\omega }\) in weighted \(\omega \)-automata is defined as \(wt_{\mathcal {A}}(w) = sup \{f(\rho ) | \rho \) is a run of w in \(\mathcal {A}\}\). It can also be defined as the infimum of the weight of all its runs. By convention, if word \(w\notin \mathcal {A}\), \(wt_{\mathcal {A}}(w)=0\) [10].

Definition 3

(Quantitative inclusion). Given two weighted \(\omega \)-automata P and Q with aggregate function f, the quantitative-inclusion problem, denoted by \(P \subseteq _f Q\), asks whether for all words \(w \in \varSigma ^{\omega }\), \(wt_{P}(w) \le wt_{Q}(w)\).

Quantitative inclusion is PSPACE-complete for limsup and liminf [10], and undecidable for limit-average [16]. For discounted-sum with integer discount-factor it is in EXPTIME [6, 10], and decidability is unknown for rational discount-factors

Definition 4

(Incomplete-information quantitative games). An incomplete-information quantitative game is a tuple \(\mathcal {G}= (S,s_{\mathcal {I}} , O , \varSigma , \delta , \gamma , f)\), where S, \( O \), \(\varSigma \) are sets of states, observations, and actions, respectively, \(s_{\mathcal {I}} \in S\) is the initial state, \(\delta \subseteq S \times \varSigma \times S\) is the transition relation, \(\gamma : S \rightarrow \mathbb {N}\times \mathbb {N}\) is the weight function, and \(f: \mathbb {N}^{\omega }\rightarrow \mathbb {R} \) is the aggregate function.

The transition relation \(\delta \) is complete, i.e., for all states p and actions a, there exists a state q s.t. \((p, a, q)\in \delta \). A play \(\rho \) is a sequence \(s_0a_0s_1a_1\dots \), where \(\tau _i=(s_i, a_i, s_{i+1}) \in \delta \). The observation of state s is denoted by \( O (s) \in O \). The observed play \(o_{\rho }\) of \(\rho \) is the sequence \(o_0a_0o_1aa_1\dots \), where \(o_i = O (s_i)\). Player \(P_0\) has incomplete information about the game \(\mathcal {G}\); it only perceives the observation play \(o_{\rho }\). Player \(P_1\) receives full information and witnesses play \(\rho \). Plays begin in the initial state \(s_0 = s_\mathcal {I}\). For \(i\ge 0\), Player \(P_0\) selects action \(a_i\). Next, player \(P_1\) selects the state \(s_{i+1}\), such that \((s_i, a_i, s_{i+1}) \in \delta \). The weight of state s is the pair of payoffs \(\gamma (s) = (\gamma (s)_0, \gamma (s)_1)\). The weight sequence \(wt_i\) of player \(P_i\) along \(\rho \) is given by \(\gamma (s_0)_i \gamma (s_1)_i \dots \), and its payoff from \(\rho \) is given by \(f(wt_i)\) for aggregate function f, denoted by \(f(\rho _i)\), for simplicity. A play on which a player receives a greater payoff is said to be a winning play for the player. A strategy for player \(P_0\) is given by a function \(\alpha : O ^* \rightarrow \varSigma \) since it only sees observations. Player \(P_0\) follows strategy \(\alpha \) if for all i, \(a_i = \alpha (o_0\dots o_i)\). A strategy \(\alpha \) is said to be a winning strategy for player \(P_0\) if all plays following \(\alpha \) are winning plays for \(P_0\).

Definition 5

(Büchi pushdown automata [13]). A Büchi pushdown automaton (Büchi PDA) is a tuple \(\mathcal {A}= ( S , \varSigma , \varGamma , \delta , { Init }, Z_0, \mathcal {F})\), where \( S \), \(\varSigma \), \(\varGamma \), and \(\mathcal {F}\) are finite sets of states, input alphabet, pushdown alphabet and accepting states, respectively. \( \delta \subseteq ( S \times \varGamma \times (\varSigma \cup \{\epsilon \}) \times S \times \varGamma ) \) is the transition relation, \( { Init }\subseteq S \) is a set of initial states, \(Z_0 \in \varGamma \) is the start symbol.

A run \(\rho \) on a word \( w = w_0 w_1\dots \in \varSigma ^{\omega } \) of a Büchi PDA \(\mathcal {A}\) is a sequence of configurations \((s_0,\gamma _0),(s_1,\gamma _1)\dots \) satisfying (1) \( s_0 \in { Init }\), \(\gamma _0 = Z_0\), and (2) (\(s_i, \gamma _i, w_i, s_{i+1}, \gamma _{i+1}) \in \delta \) for all i. Büchi PDA consists of a stack, elements of which are the tokens \(\varGamma \), and initial element \(Z_0\). Transitions push or pop token(s) to/from the top of the stack. Let \( inf (\rho ) \) be the set of states that occur infinitely often in state sequence \(s_0s_1\dots \) of run \(\rho \). A run \(\rho \) is an accepting run in Büchi PDA if \( inf (\rho )\cap \mathcal {F}\ne \emptyset \). A word w is an accepting word if it has an accepting run. Languages accepted by Büchi PDA are called \(\omega \)-context-free languages (\(\omega \)-CFL).

We introduce some notation. For an infinite sequence \(A = (a_0, a_1, \dots )\), A[i] denotes its i-th element. Abusing notation, we write \( w \in \mathcal {A}\) and \(\rho \in \mathcal {A}\) if w and \(\rho \) are an accepting word and an accepting run of \(\mathcal {A}\) respectively.

For missing proofs and constructions, refer to the supplementary material.

3 Comparator Automata

Comparator automata (often abbreviated as comparators) are a class of automata that can read pairs of weight sequences synchronously and establish an equality or inequality relationship between these sequences. Formally, we define:

Definition 6

(Comparator automata). Let \(\varSigma \) be a finite set of rational numbers, and \(f:\mathbb {Q}^{\omega }\rightarrow \mathbb {R}\) denote an aggregate function. A comparator automaton for aggregate function f is an automaton over the alphabet \(\varSigma \times \varSigma \) that accepts a pair (AB) of (infinite) weight sequences iff f(A) R f(B), where R is an inequality or the equality relation.

From now on, unless mentioned otherwise, we assume that all weight sequences are bounded, natural number sequences. The boundedness assumption is justified since the set of weights forming the alphabet of a comparator is bounded. For all aggregate functions considered in this paper, the result of comparison of weight sequences is preserved by a uniform linear transformation that converts rational-valued weights into natural numbers; justifying the natural number assumption.

Fig. 1.
figure 1

State \(f_k\) is an accepting state. Automaton \(\mathcal {A}_k\) accepts (AB) iff \(\mathsf {LimSup(A)}=k\), \(\mathsf {LimSup(B)}\le k\). \(*\) denotes \(\{0,1\dots \mu \}\), \(\le m\) denotes \(\{0,1\dots , m\}\)

We explain comparators through an example. The limit supremum (limsup, in short) of a bounded, integer sequence A, denoted by \( \mathsf {LimSup(A)}\), is the largest integer that appears infinitely often in A. The limsup comparator is a Büchi automaton that accepts the pair (AB) of sequences iff \(\mathsf {LimSup(A)}\ge \mathsf {LimSup(B)} \).

The working of the limsup comparator is based on non-deterministically guessing the limsup of sequences A and B, and then verifying that \(\mathsf {LimSup(A)}\ge \mathsf {LimSup(B)}\). Büchi automaton \(\mathcal {A}_k\) (Fig. 1) illustrates the basic building block of the limsup comparator. Automaton \(\mathcal {A}_k\) accepts pair (AB) of number sequences iff \(\mathsf {LimSup(A)} = k\), and \(\mathsf {LimSup(B)}\le k\), for integer k. To see why this is true, first note that all incoming edges to accepting state \(f_k\) occur on alphabet \((k,\le k)\) while all transitions between states \(f_k\) and \(s_k\) occur on alphabet \((\le k, \le k)\), where \(\le k\) denotes the set \(\{0,1,\dots k\}\). So, the integer k must appear infinitely often in A and all elements occurring infinitely often in A and B are less than or equal to k. Together these ensure that \(\mathsf {LimSup(A)} =k\), and \(\mathsf {LimSup(B)} \le k\). The union of such automata \(\mathcal {A}_k\) for \(k \in \{0,1,\dots \mu \}\) for upper bound \(\mu \), results in the limsup comparator. The limit infimum (liminf, in short) of an integer sequence is the smallest integer that appears infinitely often in it; its comparator is similar.

When the comparator for an aggregate function is a Büchi automaton, we call it an \(\omega \)-regular comparator. Likewise, when the comparator for an aggregate function is a Büchi pushdown automaton, we call it an \(\omega \)-context-free comparator. As seen here, the limsup and liminf comparators are \(\omega \)-regular. Later, we see that discounted-sum comparator and prefix-average comparator are \(\omega \)-regular and \(\omega \)-context-free respectively (Sects. 4 and 5). We call an aggregate function \(\omega \)-regular when it has an \(\omega \)-regular comparator for at least one inequality relation. Due to closure properties of Büchi automata, comparators for all inequality and equality relations of an \(\omega \)-regular aggregate function are also \(\omega \)-regular.

Fig. 2.
figure 2

Weighted automaton P

Fig. 3.
figure 3

Weighted automaton Q

Motivating Example. Let weighted \(\omega \)-automata P and Q be as illustrated in Figs. 2 and 3. The word \(w = a(ab)^{\omega }\) has two runs \(\rho _1^P= q_1 (q_2)^{\omega }\), \(\rho _2^P = q_1 (q_3)^{\omega }\) in P, and four runs \(\rho _1^Q = q_1 (q_2)^{\omega }\), \(\rho _2^Q = q_1 (q_3)^{\omega }\), \(\rho _3^Q=q_1 q_1 (q_2)^{\omega }\) \(\rho _4^Q=q_1 q_1 (q_3)^{\omega }\) in Q. Their weight-sequences are \(wt_1^P = 3,(0,1)^{\omega }\), \(wt_2^P = 2,(2,0)^{\omega }\) in P, and \(wt_1^Q = (2,1)^{\omega }\), \(wt_2^Q = (0, 2)^{\omega }\), \(wt_3^Q = 1,2,(2,1)^{\omega }\), \(wt_4^Q = 1, 0, (0, 2)^{\omega }\) in Q.

To determine if w has greater weight in P or in Q, compare aggregate value of weight-sequences of runs in P and Q. Take the comparator for aggregate function f that accepts a pair (AB) of weight-sequence iff \(f(A) \le f(B)\). For \(wt_P(w) \le wt_Q(w)\), for every run \(\rho _i^P\) in P, there exists a run \(\rho _j^Q\) in Q s.t. \((\rho _i^P, \rho _j^Q)\) is accepted by the comparator. This forms the basis for quantitative inclusion.

3.1 Quantitative Inclusion

\(\mathsf {InclusionReg}\) (Algorithm 1) is an algorithm for quantitative inclusion for \(\omega \)-regular aggregate functions. For weighted \(\omega \)-automata P, Q, and \(\omega \)-regular comparator \(\mathcal {A}_f\), \(\mathsf {InclusionReg}\) returns \(\mathsf {True}\) iff \(P \subseteq _f Q\). We assume \(P \subseteq Q\) (qualitative inclusion) to avoid trivial corner cases.

Key Ideas. \(P \subseteq _f Q\) holds if for every run \(\rho _P\) in P on word w, there exists a run \(\rho _Q\) in Q on the same word w such that \(f(\rho _P)\le f(\rho _Q)\). We refer to such runs of P by diminished run. Hence, \(P \subseteq _f Q\) iff all runs of P are diminished.

\(\mathsf {InclusionReg}\) constructs Büchi automaton \( Dim \) that consists of exactly the diminished runs of P. It returns \(\mathsf {True}\) iff \( Dim \) contains all runs of P. To obtain \( Dim \), it constructs Büchi automaton \( DimProof \) that accepts word \((\rho _P, \rho _Q)\) iff \(\rho _P\) and \(\rho _Q\) are runs of the same word in P and Q respectively, and \(f(\rho _P)\le f(\rho _Q)\). The \(\omega \)-regular comparator for inequality \(\le \) for function f ensures \(f(\rho _P)\le f(\rho _Q)\). The projection of \( DimProof \) on runs of P results in \( Dim \).

figure a

Algorithm Details. \(\mathsf {InclusionReg}\) has three steps: (a). \(\mathsf {UniqueId}\) (Lines 3–4): Enables unique identification of runs in P and Q through labels. (b). \(\mathsf {Compare}\) (Lines 5–7): Compares weight of runs in P with weight of runs in Q, and constructs \( Dim \). (c). \(\mathsf {DimEnsure}\) (Line 8): Ensures if all runs of P are diminished.

  1. 1.

    \(\mathsf {UniqueId}\): \(\mathsf {AugmentWtAndLabel}\) transforms weighted \(\omega \)-automaton \(\mathcal {A}\) into Büchi automaton \(\hat{\mathcal {A}}\) by converting transition \(\tau = (s, a, t )\) with weight \(\gamma (\tau )\) in \( \mathcal {A}\) to transition \(\hat{\tau } = (s, (a, \gamma (\tau ), l), t)\) in \(\hat{\mathcal {A}}\), where l is a unique label assigned to transition \(\tau \). The word \(\hat{\rho } = (a_0,n_0,l_0)(a_1,n_1,l_1)\dots \in \hat{A}\) iff run \(\rho \in \mathcal {A}\) on word \(a_0a_1\dots \) with weight sequence \(n_0n_1\dots \). Labels ensure bijection between runs in \(\mathcal {A}\) and words in \(\hat{\mathcal {A}}\). Words of \(\hat{A}\) have a single run in \(\hat{A}\).

    Hence, transformation of weighted \(\omega \)-automata P and Q to Büchi automata \(\hat{P}\) and \(\hat{Q}\) enables disambiguation between runs of P and Q (Line 3–4).

  2. 2.

    \(\mathsf {Compare}\): The output of this step is the Büchi automaton \( Dim \), that contains the word \({\hat{\rho }}\in \hat{P}\) iff \(\rho \) is a diminished run in P (Lines 5–7).

    \(\mathsf {MakeProduct}(\hat{P}, \hat{Q})\) constructs \(\hat{P}\times \hat{Q}\) s.t. word \((\hat{\rho _P}, \hat{\rho _Q}) \in \hat{P}\times \hat{Q}\) iff \(\rho _P\) and \(\rho _Q\) are runs of the same word in P and Q respectively (Line 5). Concretely, for transition \(\hat{\tau _\mathcal {A}}=(s_\mathcal {A},(a, n_\mathcal {A}, l_\mathcal {A}),t_\mathcal {A})\) in automaton \(\mathcal {A}\), where \(\mathcal {A}\in \{\hat{P}, \hat{Q}\}\), transition \(\hat{\tau _P}\times \hat{\tau _Q}=((s_P, s_Q),(a, n_P, l_P, n_Q, l_Q),(t_P, t_Q))\) is in \( \hat{P}\times \hat{Q}\).

    \(\mathsf {Intersect}\) intersects the weight components of \(\hat{P}\times \hat{Q}\) with comparator \(\mathcal {A}_f\) (Line 6). The resulting automaton \( DimProof \) accepts word \((\hat{\rho _P}, \hat{\rho _Q})\) iff \(f(\rho _P)\le f(\rho _Q)\), and \(\rho _P\) and \(\rho _Q\) are runs on the same word in P and Q respectively. The projection of \( DimProof \) on the words of \(\hat{P}\) returns \( Dim \) which contains the word \(\hat{\rho _P}\) iff \(\rho _P\) is a diminished run in P (Line 7).

  3. 3.

    \(\mathsf {DimEnsure}\): \(P\subseteq _f Q\) iff \(\hat{P} \equiv Dim \) (qualitative equivalence) since \(\hat{P}\) consists of all runs of P and \( Dim \) consists of all diminished runs of P (Line 8).

Lemma 1

Given weighted \(\omega \)-automata P and Q with an \(\omega \)-regular aggregate function f. \(\mathsf {InclusionReg}(P,Q,\mathcal {A}_f)\) returns \(\mathsf {True}\) iff \(P \subseteq _f Q\).

Further, \(\mathsf {InclusionReg}\) is adapted for quantitative strict-inclusion \(P\subset _f Q\) i.e. for all words w, \(wt_P(w) < wt_Q(w)\) by taking the \(\omega \)-regular comparator \(\mathcal {A}_f\) that accepts (AB) iff \(f(A) < f(B)\). Similarly for quantitative equivalence \(P \equiv _f Q\).

Complexity Analysis. All operations in \(\mathsf {InclusionReg}\) until Line 7 are polytime operations in the size of weighted \(\omega \)-automata P, Q and comparator \(\mathcal {A}_f\). Hence, \( Dim \) is polynomial in size of P, Q and \(\mathcal {A}_f\). Line 8 solves a \(\mathsf {PSPACE}\)-complete problem. Therefore, the quantitative inclusion for \(\omega \)-regular aggregate function f is in \(\mathsf {PSPACE}\) in size of the inputs P, Q, and \(\mathcal {A}_f\).

The \(\mathsf {PSPACE}\)-hardness of the quantitative inclusion is established via reduction from the qualitative inclusion problem, which is \(\mathsf {PSPACE}\)-complete. The formal reduction is as follows: Let P and Q be Büchi automata (with all states as accepting states). Reduce P, Q to weighted automata \(\overline{P}\), \(\overline{Q}\) by assigning a weight of 1 to each transition. Since all runs in \(\overline{P}\), \(\overline{Q}\) have the same weight sequence, weight of all words in \(\overline{P}\) and \(\overline{Q}\) is the same for any function f. It is easy to see \(P \subseteq Q\) (qualitative inclusion) iff \(\overline{P} \subseteq _f \overline{Q}\) (quantitative inclusion).

Theorem 1

Let P and Q be weighted \(\omega \)-automata and \(\mathcal {A}_f\) be an \(\omega \)-regular comparator. The complexity of the quantitative inclusion problem, quantitative strict-inclusion problem, and quantitative equivalence problem for \(\omega \)-regular aggregate function f is \(\mathsf {PSPACE}\)-complete.

Theorem 1 extends to weighted \(\omega \)-automata when weight of words is the infimum of weight of runs. The key idea for \(P\subseteq _f Q\) here is to ensure that for every run \(\rho _Q\) in Q there exists a run on the same word in \(\rho _P\) in P s.t. \(f(\rho _P)\le f(\rho _Q)\).

Representation of Counterexamples. When \(P \nsubseteq _f Q\), there exists word(s) \(w \in \varSigma ^*\) s.t \(wt_P(w)>wt_Q(w)\). Such a word w is said to be a counterexample word. Previously, finite-state representations of counterexamples have been useful in verification and synthesis in qualitative systems [5], and could be useful in quantitative settings as well. However, we are not aware of procedures for such representations in the quantitative settings. Here we show that a trivial extension of \(\mathsf {InclusionReg}\) yields Büchi automata-representations for all counterexamples of the quantitative inclusion problem for \(\omega \)-regular functions.

For word w to be a counterexample, it must contain a run in P that is not diminished. Clearly, all non-diminished runs of P are members of \(\hat{P}\setminus Dim \). The counterexamples words can be obtained from \(\hat{P}\setminus Dim \) by modifying its alphabet to the alphabet of P by dropping transition weights and their unique labels.

Theorem 2

All counterexamples of the quantitative inclusion problem for an \(\omega \)-regular aggregate function can be expressed by a Büchi automaton.

3.2 Incomplete-Information Quantitative Games

Given an incomplete-information quantitative game \(\mathcal {G}= (S,s_ {\mathcal {I}}, O , \varSigma , \delta , \gamma , f)\), our objective is to determine if player \(P_0\) has a winning strategy \( \alpha : O ^* \rightarrow \varSigma \) for \(\omega \)-regular aggregate function f. We assume we are given the \(\omega \)-regular comparator \(\mathcal {A}_f\) for function f. Note that a function \(A^*\rightarrow B\) can be treated like a B-labeled A-tree, and vice-versa. Hence, we proceed by finding a \(\varSigma \)-labeled \( O \)-tree – the winning strategy tree. Every branch of a winning strategy-tree is an observed play \(o_{\rho }\) of \(\mathcal {G}\) for which every actual play \(\rho \) is a winning play for \(P_0\).

We first consider all game trees of \(\mathcal {G}\) by interpreting \(\mathcal {G}\) as a tree-automaton over \(\varSigma \)-labeled S-trees. Nodes \(n \in S^*\) of the game-tree correspond to states in S and labeled by actions in \(\varSigma \) taken by player \(P_0\). Thus, the root node \(\varepsilon \) corresponds to \(s_\mathcal {I}\), and a node \(s_{i_0},\ldots ,s_{i_k}\) corresponds to the state \(s_{i_k}\) reached via \(s_{\mathcal {I}},s_{i_0},\ldots ,s_{i_{k-1}}\). Consider now a node x corresponding to state s and labeled by an action \(\sigma \). Then x has children \(x s_1,\ldots x s_n\), for every \(s_i \in S\). If \(s_i\in \delta (s,\sigma )\), then we call \(x s_i\) a valid child, otherwise we call it an invalid child. Branches that contain invalid children correspond to invalid plays.

A game-tree \(\tau \) is a winning tree for player \(P_0\) if every branch of \(\tau \) is either a winning play for \(P_0\) or an invalid play of \(\mathcal {G}\). One can check, using an automata, if a play is invalid by the presence of invalid children. Furthermore, the winning condition for \(P_0\) can be expressed by the \(\omega \)-regular comparator \(\mathcal {A}_f\) that accepts (AB) iff \(f(A) > f(B)\). To use the comparator \( \mathcal {A}_f\), it is determinized to parity automaton \(D_f\). Thus, a product of game \(\mathcal {G}\) with \(D_f\) is a deterministic parity tree-automaton accepting precisely winning-trees for player \(P_0\).

Winning trees for player \(P_0\) are \(\varSigma \)-labeled S-trees. We need to convert them to \(\varSigma \)-labeled \( O \)-trees. Recall that every state has a unique observation. We can simulate these \(\varSigma \)-labeled S-trees on strategy trees using the technique of thinning states S to observations \( O \) [19]. The resulting alternating parity tree automaton \(\mathcal {M}\) will accept a \(\varSigma \)-labeled \( O \)-tree \(\tau _o\) iff for all actual game-tree \(\tau \) of \(\tau _o\), \(\tau \) is a winning-tree for \(P_0\) with respect to the strategy \(\tau _o\). The problem of existence of winning-strategy for \(P_0\) is then reduced to non-emptiness checking of \(\mathcal {M}\).

Theorem 3

Given an incomplete-information quantitative game \(\mathcal {G}\) and \(\omega \)-regular comparator \(\mathcal {A}_f\) for the aggregate function f, the complexity of determining whether \(P_0\) has a winning strategy is exponential in \({|\mathcal {G}| \cdot |D_f|} \), where \(|D_f| = |\mathcal {A}_f|^{O(|\mathcal {A}_f|)}\).

Since, \(D_f\) is the deterministic parity automaton equivalent to \(A_f, |D_f|= |\mathcal {A}_f|^{O(|\mathcal {A}_f|)}\). The thinning operation is linear in size of \(|\mathcal {G}\times D_f|\), therefore \(|\mathcal {M}| = |\mathcal {G}|\cdot | D_f|\). Non-emptiness checking of alternating parity tree automata is exponential. Therefore, our procedure is doubly exponential in size of the comparator and exponential in size of the game. The question of tighter bounds is open.

4 Discounted-Sum Comparator

The discounted-sum of an infinite sequence A with discount-factor \(d >1\), denoted by \( DS ({A}, {d})\), is defined as \(\varSigma _{i=0}^{\infty } A[i] / d^{i}\). The discounted-sum comparator (DS-comparator, in short) for discount-factor d, denoted by \( \mathcal {A}_{\succ _{DS(d)}}\), accepts a pair (AB) of weight sequences iff \( DS ({A}, {d}) < DS ({B}, {d}) \). We investigate properties of the DS-comparator, and show that the DS-comparator is \(\omega \)-regular for all integral discount-factors d, and cannot be \(\omega \)-regular when \(1<d<2\).

Theorem 4

DS-comparator for rational discount-factor \(1< d<2\) is not \(\omega \)-regular.

For discounted-sum automaton \(\mathcal {A}\) with discount factor d, the cut-point language of \(\mathcal {A}\) w.r.t. \(r \in \mathbb {R}\) is defined as \(L^{\ge r} = \{w \in L(\mathcal {A}) | DS(w, d) \ge r \}\). It is known that the cut-point language \(L^{\ge 1}\) with discount-factor \(1< d < 2\) is not \(\omega \)-regular [9]. One can show that if DS-comparator for discount-factor \(1<d<2\) were \(\omega \)-regular, then cut-point language \(L^{\ge 1}\) is also \(\omega \)-regular; thus proving Theorem 4.

We provide the construction of DS-comparator with integer discount-factor.

Key Ideas. The core intuition is that sequences bounded by \(\mu \) can be converted to their value in base d via a finite-state transducer. Lexicographic comparison of the resulting sequences renders the desired result. Conversion of sequences to base d requires a certain amount of book-keeping by the transducer. Here we describe a direct method for book-keeping and lexicographic comparison.

For natural-number sequence A and integer discount-factor \(d>1\), \( DS ({A}, {d})\) can be interpreted as a value in base d i.e. \( DS ({A}, {d}) = A[0] + \frac{A[1]}{d} + \frac{A[2]}{d^2} + \dots = (A[0].A[1]A[2]\dots )_d\) [12]. Unlike comparison of numbers in base d, the lexicographically larger sequence may not be larger in value. This occurs because (i) The elements of weight sequences may be larger in value than base d, and (ii) Every value has multiple infinite-sequence representations.

To overcome these challenges, we resort to arithmetic techniques in base d. Note that \( DS ({B}, {d}) > DS ({A}, {d}) \) iff there exists a sequence C such that \( DS ({B}, {d}) = DS ({A}, {d}) + DS ({C}, {d}) \), and \( DS ({C}, {d}) > 0\). Therefore, to compare the discounted-sum of A and B, we obtain a sequence C. Arithmetic in base d also results in sequence X of carry elements. Then, we see:

Lemma 2

Let ABCX be number sequences, \( d > 1 \) be a positive integer such that following equations holds true:

  1. 1.

    When \( i = 0 \), \( A[0] + C[0] + X[0] = B[0]\)

  2. 2.

    When \( i\ge 1 \), \(A[i] + C[i] + X[i] = B[i] + d \cdot X[i-1]\)

Then \( DS ({B}, {d}) = DS ({A}, {d}) + DS ({C}, {d})\).

Hence, to determine \( DS ({B}, {d})- DS ({A}, {d})\), systematically guess sequences C and X using the equations, element-by-element beginning with the 0-th index and moving rightwards. There are two crucial observations here: (i) Computation of i-th element of C and X only depends on i-th and \((i-1)\)-th elements of A and B. Therefore guessing C[i] and X[i] requires finite memory only. (ii) C refers to a representation of value \( DS ({B}, {d}) - DS ({A}, {d})\) in base d, and X is the carry-sequence. Hence if A and B are bounded-integer sequences, not only are X and C bounded sequences, they can be constructed from a fixed finite set of integers:

Lemma 3

Let \(d>1\) be an integer discount-factor. Let A and B be nonnegative integer sequences bounded by \(\mu \) s.t. \( DS ({A}, {d}) < DS ({B}, {d})\). Let C and X be as constructed in Lemma 2. There exists at least one pair of integer-sequences C and X that satisfy the following two equations

  1. 1.

    For all \(i \ge 0\), \(0 \le C[i] \le \mu \cdot \frac{d}{d-1}\). and

  2. 2.

    For all \(i \ge 0\), \(0 \le |X[i]| \le 1 + \frac{\mu }{d-1}\)

In Büchi automaton \(\mathcal {A}_{\succ _{DS(d)}} \) (i) states are represented by (xc) where x and c range over all possible elements of X and C, which are finite, (ii) a special start state s, (iii) transitions from the start state (s, (ab), (xc)) satisfy \(a+c+x = b\) to replicate Eq. 1 (Lemma 2) at the 0-th index, (iv) all other transitions \(((x_1, c_1), (a,b), (x_2, c_2))\) satisfy \(a+ c_2 + x_2 = b + d\cdot x_1\) to replicate Eq. 2 (Lemma 2) at indexes \(i>0\), and (v) all (xc) states are accepting. Lemma 2 ensures that \(\mathcal {A}_{\succ _{DS(d)}} \) accepts (AB) iff \( DS ({B}, {d}) = DS ({A}, {d}) + DS ({C}, {d})\).

However, \(\mathcal {A}_{\succ _{DS(d)}} \) is yet to guarantee \( DS ({C}, {d}) > 0\). For this, we include non-accepting states \((x,\bot )\), where x ranges over all possible (finite) elements of X. Transitions into and out of states \((x, \bot )\) satisfy Eqs. 1 or 2 (depending on whether transition is from start state s) where \(\bot \) is treated as \(c = 0\). Transition from \((x,\bot )\)-states to (xc)-states occurs only if \(c >0\). Hence, any valid execution of (AB) will be an accepting run only if the execution witnesses a non-zero value of c. Since C is a non-negative sequence, this ensures \( DS ({C}, {d})>0\).

Construction. Let \( \mu _C= \mu \cdot \frac{d}{d-1} \) and \( \mu _X= 1 + \frac{\mu }{d-1}\). \( \mathcal {A}_{\succ _{DS(d)}} = ( S , \varSigma , \delta _d, { Init }, \mathcal {F}) \)

  • \( S = { Init }\cup \mathcal {F}\cup S_{\bot } \) where

    \( { Init }= \{s\} \), \(\mathcal {F}= \{(x,c) ||x| \le \mu _X, 0 \le c \le \mu _C\} \), and

    \(S_{\bot } = \{(x, \bot ) | | x| \le \mu _X\}\) where \(\bot \) is a special character, and \( c \in \mathbb {N}\), \(x \in \mathbb {Z}\).

  • \( \varSigma = \{(a,b) : 0 \le a, b \le \mu \} \) where a and b are integers.

  • \(\delta _d \subset S \times \varSigma \times S \) is defined as follows:

    1. 1.

      Transitions from start state s:

      1. i

        (s, (ab), (xc)) for all \( (x,c) \in \mathcal {F}\) s.t. \( a + x + c = b \) and \( c \ne 0 \)

      2. ii

        \( (s ,(a,b), (x, \bot )) \) for all \( (x, \bot ) \in S_{\bot } \) s.t. \( a + x = b \)

    2. 2.

      Transitions within \( S_{\bot } \): \( ((x, \bot ) ,(a,b), (x', \bot ) )\) for all \((x, \bot )\), \((x', \bot ) \in S_{\bot } \), if \( a + x' = b + d\cdot x \)

    3. 3.

      Transitions within \( \mathcal {F}\): \( ((x,c) ,(a,b), (x',c') )\) for all (xc), \((x',c') \in \mathcal {F}\) where \( c' < d \), if \( a + x' + c' = b + d\cdot x \)

    4. 4.

      Transition between \( S_{\bot } \) and \( \mathcal {F}\): \( ((x, \bot ),(a,b), (x',c')) \) for all \( (x,\bot ) \in S_{\bot } \), \( (x',c') \in \mathcal {F}\) where \( 0< c' < d \), if \( a + x' + c' = b + d\cdot x \)

Theorem 5

The DS-comparator with maximum bound \(\mu \), is \(\omega \)-regular for integer discount-factors \(d >1\). Size of the discounted-sum comparator is \(\mathcal {O}(\frac{\mu ^2}{d})\).

DS-comparator with non-strict inequality \(\le \) and equality \(=\) follow similarly. Consequently, properties of \(\omega \)-regular comparators hold for DS-comparator with integer discount-factor. Specifically, DS-inclusion is \(\mathsf {PSPACE}\)-complete in size of the input weighted automata and DS-comparator. Since, size of DS-comparator is polynomial w.r.t. to upper bound \(\mu \) (in unary), DS-inclusion is \(\mathsf {PSPACE}\) in size of input weighted automata and \(\mu \). Not only does this bound improve upon the previously known upper bound of \(\mathsf {EXPTIME}\) but it also closes the gap between upper and lower bounds for DS-inclusion.

Corollary 1

Given weighted automata P and Q, maximum weight on their transitions \(\mu \) in unary form and integer discount-factor \(d > 1\), the DS-inclusion, DS-strict-inclusion, and DS-equivalence problems are \(\mathsf {PSPACE}\)-complete.

As mentioned earlier, the known upper bound for discounted-sum inclusion with integer discount-factor is exponential [6, 10]. This bound is based on an exponential determinization construction (subset construction) combined with arithmetical reasoning. We observe that the determinization construction can be performed on-the-fly in \(\mathsf {PSPACE}\). To perform, however, the arithmetical reasoning on-the-fly in PSPACE would require essentially using the same bit-level ((xc)-state) techniques that we have used to construct DS-comparator automata.

5 Limit-Average Comparator

The limit-average of an infinite sequence M is the point of convergence of the average of prefixes of M. Let \(\mathsf {Sum}(M[0,n-1])\) denote the sum of the n-length prefix of sequence M. The limit-average infimum, denoted by \(\mathsf {LimInfAvg}(M)\), is defined as \(\text {lim inf}_{n \rightarrow \infty } \frac{1}{n}\cdot \mathsf {Sum}(M[0,n-1])\). Similarly, the limit-average supremum, denoted by \(\mathsf {LimSupAvg}(M)\), is defined as \(\text {lim sup}_{n \rightarrow \infty } \frac{1}{n}\cdot \mathsf {Sum}(M[0,n-1])\). The limit-average of sequence M, denoted by \(\mathsf {LimAvg}(M)\), is defined only if the limit-average infimum and limit-average supremum coincide, and then \(\mathsf {LimAvg}(M) = \mathsf {LimInfAvg}(M)\) (\(=\mathsf {LimSupAvg}(M)\)). Note that while limit-average infimum and supremum exist for all bounded sequences, the limit-average may not.

In existing work, limit-average is defined as the limit-average infimum (or limit-average supremum) to ensure that limit-average exists for all sequences [7, 10, 11, 22]. While this definition is justified in context of the application, it may lead to a misleading comparison in some cases. For example, consider sequence A s.t. \(\mathsf {LimSupAvg}(A) = 2\) and \(\mathsf {LimInfAvg}(A) = 0\), and sequence B s.t. \(\mathsf {LimAvg}(B) = 1\). Clearly, limit-average of A does not exist. Suppose, \(\mathsf {LimAvg}(A)=\mathsf {LimInfAvg}(A) = 0\), then \(\mathsf {LimAvg}(A) < \mathsf {LimAvg}(B)\), deluding that average of prefixes of A are always less than those of B in the limit. This is untrue since \(\mathsf {LimSupAvg}(A) = 2 \).

Such inaccuracies in limit-average comparison may occur when the limit-average of at least one sequence does not exist. However, it is not easy to distinguish sequences for which limit-average exists from those for which it doesn’t.

We define prefix-average comparison as a relaxation of limit-average comparison. Prefix-average comparison coincides with limit-average comparison when limit-average exists for both sequences. Otherwise, it determines whether eventually the average of prefixes of one sequence are greater than those of the other. This comparison does not require the limit-average to exist to return intuitive results. Further, we show that the prefix-average comparator is \(\omega \)-context-free.

5.1 Limit-Average Language and Comparison

Let \(\varSigma = \{0,1,\dots , \mu \}\) be a finite alphabet with \(\mu >0\). The limit-average language \(\mathcal {L}_{LA}\) contains the sequence (word) \(A \in \varSigma ^{\omega }\) iff its limit-average exists. Suppose \(\mathcal {L}_{LA}\) were \(\omega \)-regular, then \(\mathcal {L}_{LA} = \bigcup _{i=0}^n U_i\cdot V_i^{\omega }\), where \(U_i, V_i\subseteq \varSigma ^*\) are regular languages over finite words. The limit-average of sequences is determined by its behavior in the limit, so limit-average of sequences in \(V_i^{\omega }\) exists. Additionally, the average of all (finite) words in \(V_i\) must be the same. If this were not the case, then two words in \(V_i\) with unequal averages \(l_1\) and \(l_2\), can generate a word \(w \in V_i^{\omega }\) s.t the average of its prefixes oscillates between \(l_1\) and \(l_2\). This cannot occur, since limit-average of w exists. Let the average of sequences in \(V_i\) be \(a_i\), then limit-average of sequences in \(V_i^{\omega }\) and \(U_i \cdot V_i^{\omega }\) is also \(a_i\). This is contradictory since there are sequences with limit-average different from the \(a_i\) (see appendix). Similarly, since every \(\omega \)-CFL is represented by \(\bigcup _{i=1}^n U_i \cdot V_i^{\omega }\) for CFLs \(U_i, V_i\) over finite words [13], a similar argument proves that \(\mathcal {L}_{LA}\) is not \(\omega \)-context-free.

Quantifiers \(\exists ^{\infty }i\) and \(\exists ^{f}i\) denote the existence of infinitely many and only finitely many indices i, respectively.

Theorem 6

\(\mathcal {L}_{LA}\) is neither an \(\omega \)-regular nor an \(\omega \)-context-free language.

In the next section, we will define prefix-average comparison as a relaxation of limit-average comparison. To show how prefix-average comparison relates to limit-average comparison, we will require the following two lemmas:

Lemma 4

Let A and B be sequences s.t. their limit average exists. If \(\exists ^{\infty }i, \mathsf {Sum}(A[0,i-1]) \ge \mathsf {Sum}(B[0,i-1])\) then \(\mathsf {LimAvg}(A) \ge \mathsf {LimAvg}(B)\).

Lemma 5

Let A, B be sequences s.t their limit-average exists. If \(\mathsf {LimAvg}(A) > \mathsf {LimAvg}(B)\) then \(\exists ^{f} i, \mathsf {Sum}(B[0,i-1]) \ge \mathsf {Sum}(A[0,i-1])\) and \(\exists ^{\infty } i, \mathsf {Sum}(A[0,i-1]) > \mathsf {Sum}(B[0,i-1])\).

5.2 Prefix-Average Comparison and Comparator

The previous section relates limit-average comparison with the sums of equal length prefixes of the sequences (Lemmas 4 and 5). The comparison criteria is based on the number of times sum of prefix of one sequence is greater than the other, which does not rely on the existence of limit-average. Unfortunately, this criteria cannot be used for limit-average comparison since it is incomplete (Lemma 5). Specifically, for sequences A and B with equal limit-average it is possible that \(\exists ^{\infty } i, \mathsf {Sum}(A[0,n-1]) > \mathsf {Sum}(B[0,n-1])\) and \(\exists ^{\infty } i, \mathsf {Sum}(B[0,n-1]) > \mathsf {Sum}(A[0,n-1])\). Instead, we use this criteria to define prefix-average comparison. In this section, we define prefix-average comparison and explain how it relaxes limit-average comparison. Lastly, we construct the prefix-average comparator, and prove that it is not \(\omega \)-regular but is \(\omega \)-context-free.

Definition 7

(Prefix-average comparison). Let A and B be number sequences. We say \(\mathsf {PrefixAvg}(A) \ge \mathsf {PrefixAvg}(B)\) if \(\exists ^{f} i, \mathsf {Sum}(B[0,i-1]) \ge \mathsf {Sum}(A[0,i-1])\) and \(\exists ^{\infty } i, \mathsf {Sum}(A[0,i-1]) > \mathsf {Sum}(B[0,i-1])\).

Intuitively, prefix-average comparison states that \(\mathsf {PrefixAvg}(A)\ge \mathsf {PrefixAvg}(B)\) if eventually the sum of prefixes of A are always greater than those of B. We use \(\ge \) since the average of prefixes may be equal when the difference between the sum is small. It coincides with limit-average comparison when the limit-average exists for both sequences. Definition 7 and Lemmas 4, 5 relate limit-average comparison and prefix-average comparison:

Corollary 2

When limit-average of A and B exists, then

  • \(\mathsf {PrefixAvg}(A)\ge \mathsf {PrefixAvg}(B) \implies \mathsf {LimAvg}(A)\ge \mathsf {LimAvg}(B)\).

  • \(\mathsf {LimAvg}(A)>\mathsf {LimAvg}(B) \implies \mathsf {PrefixAvg}(A)\ge \mathsf {PrefixAvg}(B)\).

Therefore, limit-average comparison and prefix-average comparison return the same result on sequences for which limit-average exists. In addition, prefix-average returns intuitive results when even when limit-average may not exist. For example, suppose limit-average of A and B do not exist, but \(\mathsf {LimInfAvg}(A) > \mathsf {LimSupAvg}(B)\), then \(\mathsf {PrefixAvg}(A) \ge \mathsf {PrefixAvg}(B)\). Therefore, prefix-average comparison relaxes limit-average comparison.

The rest of this section describes prefix-average comparator \(\mathcal {A}_{\succeq _{PA(\cdot )}}\), an automaton that accepts the pair (AB) of sequences iff \(\mathsf {PrefixAvg}(A)\ge \mathsf {PrefixAvg}(B)\).

Lemma 6

(Pumping Lemma for \(\omega \)-regular language [2]). Let L be an \(\omega \)-regular language. There exists \(p \in \mathbb {N}\) such that, for each \(w = u_1w_1u_2w_2 \dots \in L\) such that \(|w_i| \ge p\) for all i, there are sequences of finite words \((x_i)_{i\in \mathbb {N}}\), \((y_i)_{i\in \mathbb {N}}\), \((z_i)_{i\in \mathbb {N}}\) s.t., for all i, \(w_i = x_iy_iz_i\), \(|x_iy_i| \le p\) and \(|y_i| > 0\) and for every sequence of pumping factors \((j_i)_{i\in \mathbb {N}} \in \mathbb {N}\), the pumped word \(u_1 x_1 y_1^{j_1}z_1 u_2 x_2 y_2^{j_2}z_2 \dots \in L\).

Theorem 7

The prefix-average comparator is not \(\omega \)-regular.

Proof

(Proof Sketch). We use Lemma 6 to prove that \(\mathcal {A}_{\succeq _{PA(\cdot )}}\) is not \(\omega \)-regular. Suppose \(\mathcal {A}_{\succeq _{PA(\cdot )}}\) were \(\omega \)-regular. For \(p >0 \in \mathbb {N}\), let \(w = (A,B) = ((0,1)^p(1,0)^{2p})^{\omega }\). The segment \((0,1)^*\) can be pumped s.t the resulting word is no longer in \(\mathcal {L}_{\succeq _{PA(\cdot )}}\).

Concretely, \(A = (0^p 1^{2p})^{\omega }\), \(B = (1^p0^{2p})^{\omega }\), \(\mathsf {LimAvg}(A) = \frac{2}{3}\), \(\mathsf {LimAvg}(B) = \frac{1}{3}\). So, \(w = (A,B) \in \mathcal {A}_{\succeq _{PA(\cdot )}}\). Select as factor \(w_i\) (from Lemma 6) the sequence \((0,1)^p\). Pump each \(y_i\) enough times so that the resulting word is \(\hat{w} = (\hat{A}, \hat{B}) = ((0,1)^{m_i}(1,0)^{2p})^{\omega }\) where \(m_i>4p\). It is easy to show that \(\hat{w} = (\hat{A}, \hat{B})\notin \mathcal {L}_{\succeq _{PA(\cdot )}}\).

We discuss key ideas and sketch the construction of the prefix average comparator. The term prefix-sum difference at i indicates \(\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1])\), i.e. the difference between sum of i-length prefix of A and B.

Key Ideas. For sequences A and B to satisfy \(\mathsf {PrefixAvg}(A)\ge \mathsf {PrefixAvg}( B)\), \(\exists ^{f} i, \mathsf {Sum}(B[0,i-1]) \ge \mathsf {Sum}(A[0,i-1])\) and \(\exists ^{\infty } i, \mathsf {Sum}(A[0,i-1]) > \mathsf {Sum}(B[0,i-1])\). This occurs iff there exists an index N s.t. for all indices \(i>N\), \(\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1])>0\). While reading a word, the prefix-sum difference is maintained by states and the stack of \(\omega \)-PDA: states maintain whether it is negative or positive, while number of tokens in the stack equals its absolute value. The automaton non-deterministically guesses the aforementioned index N, beyond which the automaton ensure that prefix-sum difference remains positive.

Construction Sketch. The push-down comparator \(\mathcal {A}_{\succeq _{PA(\cdot )}}\) consists of three states: (i) State \(s_P\) and (ii) State \(s_N\) that indicate that the prefix-sum difference is greater than zero and or not respectively, (iii) accepting state \(s_F\). An execution of (AB) begins in state \(s_N\) with an empty stack. On reading letter (ab), the stack pops or pushes \(|(a-b)|\) tokens from the stack depending on the current state of the execution. From state \(s_P\), the stack pushes tokens if \((a-b)>0,\) and pops otherwise. The opposite occurs in state \(s_N\). State transition between \(s_N\) and \(s_P\) occurs only if the stack action is to pop but the stack consists of \(k < |a-b|\) tokens. In this case, stack is emptied, state transition is performed and \(|a-b|-k\) tokens are pushed into the stack. For an execution of (AB) to be an accepting run, the automaton non-deterministically transitions into state \(s_F\). State \(s_F\) acts similar to state \(s_P\) except that execution is terminated if there aren’t enough tokens to pop out of the stack. \(\mathcal {A}_{\succeq _{PA(\cdot )}}\) accepts by accepting state.

To see why the construction is correct, it is sufficient to prove that at each index i, the number of tokens in the stack is equal to \(|\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1])|\). Furthermore, in state \(s_N\), \(\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1])\le 0\), and in state \(s_P\) and \(s_F\), \(\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1])>0\). Next, the index at which the automaton transitions to the accepting state \(s_F\) coincides with index N. The execution is accepted if it has an infinite execution in state \(s_F\), which allows transitions only if \(\mathsf {Sum}(A[0,i-1]) - \mathsf {Sum}(B[0,i-1]) > 0\).

Theorem 8

The prefix-average comparator is an \(\omega \)-CFL.

While \(\omega \)-CFL can be easily expressed, they do not possess closure properties, and problems on \(\omega \)-CFL are easily undecidable. Hence, the application of \(\omega \)-context-free comparator will require further investigation.

6 Conclusion

In this paper, we identified a novel mode for comparison in quantitative systems: the online comparison of aggregate values of sequences of quantitative weights. This notion is embodied by comparators automata that read two infinite sequences of weights synchronously and relate their aggregate values. We showed that \(\omega \)-regular comparators not only yield generic algorithms for problems including quantitative inclusion and winning strategies in incomplete-information quantitative games, they also result in algorithmic advances. We show that the discounted-sum inclusion problem is \(\mathsf {PSAPCE}\)-complete for integer discount-factor, hence closing a complexity gap. We also studied the discounted-sum and prefix-average comparator, which are \(\omega \)-regular and \(\omega \)-context-free, respectively.

We believe comparators, especially \(\omega \)-regular comparators, can be of significant utility in verification and synthesis of quantitative systems, as demonstrated by the existence of finite-representation of counterexamples of the quantitative inclusion problem. Another potential application is computing equilibria in quantitative games. Applications of the prefix-average comparator, in general \(\omega \)-context-free comparators, is open to further investigation. Another direction to pursue is to study aggregate functions in more detail, and develop a clearer understanding of when aggregate functions are \(\omega \)-regular.