TOKEN GAMES AND HISTORY-DETERMINISTIC QUANTITATIVE AUTOMATA

. A nondeterministic automaton is history-deterministic if its nondeterminism can be resolved by only considering the prefix of the word read so far. Due to their good compositional properties, history-deterministic automata are useful in solving games and synthesis problems. Deciding whether a given nondeterministic automaton is history-deterministic (the HDness problem) is generally a difficult task, which can involve an exponential procedure, or even be undecidable, as is the case for example with pushdown automata. Token games provide a PTime solution to the HDness problem of B¨uchi and coB¨uchi automata, and it is conjectured that 2-token games characterise HDness for all ω -regular automata. We extend token games to the quantitative setting and analyse their potential to help deciding HDness of quantitative automata. In particular, we show that 1-token games characterise HDness for all quantitative (and Boolean) automata on finite words, as well as discounted-sum ( DSum ), Inf and Reachability automata on infinite words, and that 2-token games characterise HDness of LimInf and LimSup automata, as well as Sup automata on infinite words. Using these characterisations, we provide solutions to the HDness problem of Safety , Reachability , Inf and Sup automata on finite and infinite words in PTime , of DSum automata on finite and infinite words in NP ∩ co-NP , of LimSup automata in quasipolynomial time, and of LimInf automata in exponential time, where the latter two are only polynomial for automata with a logarithmic number of weights.


Introduction
History-determinism. A nondeterministic [quantitative] automaton is historydeterministic (HD) [11,8] if its nondeterministic choices can be resolved by only considering the word read so far, uniformly across possible suffixes (see Fig. 2 for examples of HD and non-HD automata). More precisely, there should be a function (strategy), sometimes called a resolver, that maps the finite prefixes of a word to the transition to be taken at the last letter. The run built in this way must, in the Boolean setting, be accepting whenever the word is in the language of the automaton, and in the more general, quantitative, setting, attain the value of the automaton on the word (i.e., the supremum of all its runs' values).
History-determinism lies in between determinism and nondeterminism, enjoying in some aspects the best of both worlds: HD automata are, like deterministic ones, useful for solving games and reactive synthesis [16,11,17,18,12,15,8], yet can sometimes be more expressive and/or succinct. For example, HD coBüchi and LimInf automata can be exponentially more succinct than deterministic ones [19], and HD pushdown automata are both more expressive and at least exponentially more succinct than deterministic ones [20,15]. In the (ω-)regular setting, history-determinism coincides with good-for-gameness [7], while in the quantitative setting it is stronger [8]. The problem of deciding whether a nondeterministic automaton is HD is interreducible with deciding the best-value synthesis problem of a deterministic automaton [14,8]. In this quantitative version of the reactive synthesis problem, the system must guarantee a behaviour that matches the value of any global behaviour compatible with the environment's actions. The witness of HDness corresponds exactly to the solution system of this synthesis problem, providing another motivation for this line of research.
Deciding history-determinism -a difficult task. History-determinism is formally defined by a letter game played on the automaton A between Adam and Eve, where Adam produces an input word w, letter by letter, and Eve tries to resolve the nondeterminism in A so that the resulting run attains A's value on w. Then A is HD if Eve has a winning strategy in the letter game on it. The difficulty of deciding who wins the letter game stems from its complicated winning condition -Eve wins if her run has the value of the supremum over all runs of A on w.
The naive solution is to determinise A into an automaton D, and consider a game equivalent to the letter game that has a simple winning condition and whose arena is the product of A and D [16]. The downside with this approach, however, is that it requires the determinisation of A, which often involves a procedure exponential in the size of A and sometimes is even impossible due to an expressiveness gap. Note that deciding whether an automaton is good-forgames, which is closely related to whether it is HD [7,8], is also difficult, as it requires reasoning about composition with all possible games.
Token games -a possible aid. In [3], Bagnol and Kuperberg introduced token games on ω-regular automata, which are closely related to the letter game, but easier to decide. In a k-token game on an automaton A, denoted by G k (A), like in the letter game, Adam generates a word w letter by letter, and Eve builds a run on w by resolving the nondeterminism. In addition, Adam also has to resolve the nondeterminism of A to build k runs letter-by-letter over w. The winning condition for Eve in these games is that either all runs built by Adam are rejecting, or Eve's run is accepting. Such games, as they compare concrete runs, are easier to solve than the letter game.
Then, to decide HDness for a class of automata, one can attempt to show that the letter game always has the same winner as a k-token game, for some k, and solve the k-token game. (If Eve wins the letter game then she wins the k-token game, for every k, by using the same strategy, ignoring Adam's runs. However, it might be that she wins a k-token game, taking advantage of her knowledge of how Adam resolves the nondeterminism, but loses the letter game.) Bagnol and Kuperberg showed in [3] that on Büchi automata, the letter game and the 2-token game always have the same winner, and in [6], Boker, Kuperberg, Lehtinen and Skrzypczak extended this result to coBüchi automata. In both cases, this allows for a PTime procedure for deciding HDness. Furthermore, Bagnol and Kuperberg suggested in [3,Conclusion] that 2-token games might characterise HDness also for parity automata (and therefore for all ω-regular automata); a conjecture (termed later the G2 conjecture) that is still open.
Our contribution. We extend token games to the quantitative setting, and use them to decide HDness of some quantitative automata. We define a k-token game on a quantitative automaton exactly as on a Boolean one, except that Eve wins if her run has a value at least as high as all of Adam's runs.
We show first, in Section 4, that the 1-token game, in which Adam just has one run to build, characterises history-determinism for all quantitative (and Boolean) automata on finite words, and for discounted-sum (DSum) automata on infinite words. This results in a PTime decision procedure for checking HDness of Inf and Sup automata on finite words, and an NP∩coNP procedure for DSum automata on finite and infinite words. Note that the complexity for DSum automata on finite words was already known [14], but on infinite words it was erroneously believed to be NP-hard [17,Theorem 6].
Towards getting the above results, we analyse key properties of value functions of quantitative automata, and show that the 1-token game characterises HDness for every Val automaton, such that Val is present-focused (Definition 3), which is in particular the case for all Val automata on finite words [8,Lemma 16], as well as DSum automata on infinite words [8, Lemma 22].
We then show, in Section 5, that the 2-token game, in which Adam builds two runs, characterises history-determinism for both LimSup and LimInf automata. The approach here is more involved: it decomposes the quantitative automaton into a collection of Büchi or coBüchi automata such that if Eve wins the 2-token game on the original automaton, she also wins in the component automata. Since the 2-token game characterises HD for Büchi and coBüchi automata, the component automata are then HD and the witness strategies can be combined with the 2-token strategy of the original automaton to build a letter-game strategy for Eve. The general flow of our approach is illustrated in Fig. 1.
We further present, in Section 5.1, algorithms to decide the winner of the twotoken games on LimInf and LimSup automata via reductions to solving parity games. The complexity of the procedure for a LimSup automaton A is the same as that of solving a parity game of size polynomial in the size of A with twice as many priorities as there are weights in A, which is in quasipolynomial time. For LimInf automata the procedure is in exponential time. In both cases, it is only in polynomial time if the number of weights is logarithmic in the automaton size.
For some variants of the synthesis problem, the complexity of the witness of history-determinism is also of particular interest (while for other variants it is not), as it corresponds to the complexity of the implementation of the solution system [8,Section 5]. We give an exponential upper bound to the complexity of the witness for LimSup and LimInf automata, which, for LimInf, is tight. As a corollary, we obtain that HD LimSup automata are as expressive as deterministic LimSup automata and at most exponentially more succinct.
Related work. In the ω-regular setting (where HDness coincides with good-forgameness), [16,Section 4] provides an exponential scheme for checking HDness of all ω-regular automata, based on determinisation and checking fair simulation. HDness of Büchi automata is resolved, as mentioned above, in PTime, using 2-token games [3]. The coBüchi case is also resolved in PTime, originally via an indirect usage of "joker games" [19], and later by using 2-token games [6].
In the quantitative setting, deciding HDness coincides with best-value partial domain synthesis [14], 0-regret synthesis [18] and, for some value functions, 0-regret determinisation [13,8]. There are procedures to decide HDness (which is sometimes called good-for-gameness due to erroneously assuming them equivalent) of Sum, Avg, and DSum automata on finite words, as follows.
For Sum and Avg automata on finite words, a PTime solution combines [1, Theorem 4.1], which provides a PTime algorithm for checking whether such an automaton is "determinisable by pruning", and [8, Theorem 21], which shows that such an automaton is HD if and only if it is determinisable by pruning. Proposition 1. Deciding whether a Sum or Avg automaton on finite words is history-deterministic is in PTime.
For DSum automata on finite words, [14, Theorem 23] provides an NP∩co-NP solution, using a game that is quite similar to the one-token game, differing from it in a few aspects-for example, Adam is asked to either copy Eve with his token or move into a second phase where he plays transitions first-and uses a characterisation of HD strategies resembling our notion of cautious strategies (Definition 2) specialised to DSum automata.

Preliminaries
Words. An alphabet Σ is a finite nonempty set of letters. A finite (resp. infinite) word u = σ 0 . . . σ k ∈ Σ * (resp. w = σ 0 σ 1 . . . ∈ Σ ω ) is a finite (resp. infinite) sequence of letters from Σ; ε is the empty word. We write Σ ∞ for Σ * ∪ Σ ω . We Games. We consider a variety of turn-based zero-sum games between Adam (A) and Eve (E). Formally, a game is played on an arena of which the positions are partitioned between the two players. A play is a maximal (finite or infinite) path. The winning condition partitions plays into those that are winning for each player. In some of the technical developments we use parity games, in which moves are coloured with integer priorities and a play is winning for Eve if the maximal priority that occurs infinitely often along the play is even.
A strategy for a player P ∈ {A, E} maps partial plays ending in a position belonging to P to a successor position. A (partial) play π agrees with a strategy s P of P , written π ∈ s P , if whenever its prefix p ends in a position of P , the next move is s P (p). A strategy of P is winning from a position v if all plays starting at v that agree with it are winning for P . A strategy is positional if it maps all plays that end in the same position to the same successor. A game is determined if for every position, one of the players has a winning strategy.
Quantitative Automata. A nondeterministic quantitative 3 automaton (or just automaton from here on) on words is a tuple A = (Σ, Q, ι, δ), where Σ is an alphabet; Q is a finite nonempty set of states; ι ∈ Q is an initial state; and δ : Q × Σ → 2 (Q×Q) is a transition function over weight-state pairs.
A transition is a tuple (q, σ, x, q ′ ) ∈ Q×Σ×Q × Q, also written q σ:x − − → q ′ . (There might be several transitions with different weights over the same letter between the same states.) We write γ(t) = x for the weight of a transition t = (q, σ, x, q ′ ). A is deterministic if for all q ∈ Q and a ∈ Σ, δ(q, a) is a singleton. We require that the automaton A is total, namely that for every state q ∈ Q and letter σ ∈ Σ, there is at least one state q ′ and a transition q As each transition t i carries a weight γ(t i ) ∈ Q, the sequence ρ provides a weight sequence γ(ρ) = γ(t 0 )γ(t 1 ) . . .. A Val (e.g., Sum) automaton is one equipped with a value function Val : Q * → R or Val : Q ω → R, which assigns real values to runs of A. The value of a run ρ is Val(γ(ρ)). The value of A on a word w is the supremum of Val(ρ) over all runs ρ of A on w. Two automata A and A ′ are equivalent, if they realise the same function. The size of an automaton consists of the maximum among the size of its alphabet, state-space, and transition-space.

Value functions.
For finite sequences v 0 v 1 . . . v n−1 of rational weights: For finite and infinite sequences v 0 v 1 . . . of rational weights: ω-regular automata (with acceptance on transitions) can be viewed as special cases of quantitative automata. In particular, a Büchi (resp. coBüchi) automaton can be seen as a quantitative one, in which a rejecting transition has weight 0, an accepting transition has weight 1, and whose value function is 1 if the sequence of weighs has infinitely many 1's and 0 otherwise (resp. 1 if the sequence of weights has finitely many 0). See more on ω-regular automata, e.g., in [4].
History-determinism. Intuitively, an automaton is history-deterministic if there is a strategy to resolve its nondeterminism according to the word read so far such that for every word, the value of the resulting run is the value of the word.
Definition 1 (History-determinism [11,8]). A Val automaton A is historydeterministic (HD) if Eve wins the following win-lose letter game, in which Adam chooses the next letter and Eve resolves the nondeterminism, aiming to construct a run whose value is equivalent to the generated word's value.
Letter game: A play begins in q 0 = ι (the initial state of A) and at the i th turn, from state q i , it progresses to a next state as follows: -Adam picks a letter σ i from Σ and -Eve chooses a transition t i = q i σi:xi − −− → q i+1 . In the limit, a play consists of an infinite word w that is derived from the concatenation of σ 0 , σ 1 , . . ., as well as an infinite sequence π = t 0 , t 1 , . . . of transitions. For A over infinite words, Eve wins a play in the letter- Consider for example the LimSup automaton A in Fig. 2. Eve loses the letter game on A: Adam can start with the letter a; then if Eve goes from s 0 to s 1 , Adam continues to choose a forever, generating the word a ω , where A(a ω ) = 3, while Eve's run has the value 2. If, on the other hand, Eve chooses on her first move to go from s 0 to s 2 , Adam continues with choosing b forever, generating the word ab ω , where A(ab ω ) = 2, while Eve's run has the value 1.
Families of value functions. We will provide some of our results with respect to a family of Val automata based on properties of the value function Val.
We first define cautious strategies for Eve in both the letter game and token games (Section 3), which we use to define present-focused value functions. Intuitively, a strategy is cautious if it avoids mistakes: it only builds run prefixes that can achieve the maximal value of any continuation of the current word prefix.
Definition 2 (Cautious strategies [8]). Consider the letter game on a Val automaton A, in which Eve builds a run of A transition by transition. A move (transition) t = q σ:x − − → q ′ of Eve, played after some run ρ ending in a state q, is non-cautious if for some word w, there is a run π ′ from q over σw such that Val(ρπ ′ ) is strictly greater than the value of Val(ρπ) for any π starting with t.
A strategy is cautious if it makes no non-cautious moves.
A winning strategy for Eve in the letter game must of course be cautious; Whether all cautious strategies are winning depends on the value function. We call a value function present-focused if, morally, it depends on the prefixes of the value sequence, formalised by winning the letter game via cautious strategies.
Definition 3 (Present-focused value functions [8]). A value function Val, on finite or infinite sequences, is present-focused if for all automata A with value function Val, every cautious strategy for Eve in the letter game on A is also a winning strategy in that game.
Value functions on finite sequences are present-focused, as they can only depend on prefixes, while value functions on infinite sequences are not necessarily present-focused [8,Remark 17], for example LimInf and LimSup.

Token Games
Token games were introduced by Bagnol and Kuperberg [3] in the scope of resolving the HDness problem of Büchi automata. In the k-token game, known as G k , the players proceed as in the letter game, except that now Adam has k tokens that he must move after Eve has made her move, thus building k runs. For Adam to win, at least one of these must be better than Eve's run. In the Boolean setting, this run must be accepting, thus witnessing that the word is in the language of the automaton. Intuitively, the more tokens Adam has, the less information he is giving Eve about the future of the word he is building.
We generalise token games to the quantitative setting, defining that the maximal value produced by Adam's runs witnesses a lower bound on the value of the word, and Eve's task is to match or surpass this value on her run.
In the Boolean setting, G 2 has the same winner as the letter game for Büchi [3,Corollary 21] and coBüchi [6, Theorem 28] automata (the case of parity and more powerful automata is open). Since G 2 is solvable in polynomial time for Büchi and coBüchi acceptance conditions, this gives a PTime algorithm for deciding HDness, which avoids the determinisation used to solve the letter game directly. In the following sections we study how different token games can be used to decide HDness for different quantitative automata.
On finite words, G k is defined as above, except that the winning condition is a safety condition for Eve: for all finite prefixes of a play, it must be the case that the value of Eve's run is at least the value of each of Adam's runs.
Cautious strategies (Definition 2) immediately extend to Eve's strategies in G k (A). Note that unlike in the letter game, a winning strategy in G k (A) must not necessarily be cautious, since Adam's run prefixes might not allow him to build an optimal run over the word witnessing that Eve's move was non-cautious.

Deciding History-Determinism via One-Token Games
Bagnol and Kuperberg showed that the one-token game G 1 does not suffice to characterise HDness for Büchi automata [3, Lemma 8]. However, it turns out that G 1 does characterise HDness for all quantitative (and Boolean) automata on finite words and some quantitative automata on infinite words.
We can then use G 1 to decide history-determinism of some of these automata, over which the G 1 game is simple to decide. In particular, Inf and Sup automata on finite words and DSum automata on finite and infinite words. Proof. One direction is easy: if A is HD, Eve can use her HD strategy to win G 1 by ignoring Adam's token. For the other direction, assume that Eve wins G 1 .
We consider the following family of copycat strategies for Adam in G 1 : a copycat strategy is one where Adam moves his token in the same way as Eve until she makes a non-cautious move t = q σ:x − − → q ′ after building a run ρ; that is, there is some word w and run π ′ from q on σw, such that for every run π on σw starting with t, we have Val(ρπ ′ ) > Val(ρπ). Then the copycat strategy stops copying and directs Adam's token along the run π ′ and plays the word w. If Eve plays a noncautious move in G 1 against a copycat strategy, she loses. Then, if Eve wins G 1 with a strategy s, she wins in particular against all copycat strategies and therefore s never makes a non-cautious move against such a strategy.
Eve can then play in the letter game over A with a strategy s ′ that moves her token as s would in G 1 (A) assuming Adam uses a copycat strategy. Then, s ′ never makes a non-cautious move and is therefore a cautious strategy. Since Val is present-focused, any cautious strategy, and in particular s ′ , is winning in the letter game, so A is HD. Note that s ′ requires no more memory than s. ⊓ ⊔ The case of Inf automata is similar, except that instead of keeping Eve's maximal value along her run, we need to keep the minimal value along Adam's run in some variable x A , and the safety condition for Eve is that her current value must always be at least as big as x A and Adam's next move. Since Adam plays after Eve in each round of the game, we also need to keep Eve's last value, thus having 3|Σ|n 2 k 2 positions.
⊓ ⊔ Next, we show that solving G 1 is in NP∩co-NP for DSum automata.
Proof. Consider a λ-DSum automaton A = (Σ, Q, ι, δ), where the weight of a transition t is denoted by γ(t). From Propositions 2 and 3 and Theorem 1, Eve wins G 1 (A) if and only if A is HD. It therefore suffices to show that solving G 1 (A) is NP∩co-NP. We achieve this by reducing solving G 1 (A) to solving a discounted-sum threshold game, which Eve wins if the DSum of a play is nonnegative. It is enough to consider infinite games, as they also encode finite games, by allowing Adam to move to a forever-zero-position in each of his turns. The reduction follows the same pattern as that in the proof of Theorem 2: we represent the arena of the game G 1 (A) as a finite arena, and encode its winning condition, which requires the difference between the DSum of two runs to be nonnegative, as a threshold DSum winning condition. Note first that the difference between the λ-DSum of the two sequences x 0 x 1 ... and x ′ 0 x ′ 1 ... of weights is equal to the λ-DSum of the sequence of differences . We now describe the DSum arena G in which Eve wins with a non-strict 0-threshold objective if and only if she wins G 1 (A). The arena has positions in (σ, q, q ′ , t, m) ∈ Σ ∪ {ε} × Q 2 × δ ∪ {ε} × {L, E, A} where σ is the potentially empty last played letter, starting with ε, the states q, q ′ represent the positions of Eve and Adam's tokens, t is the transition just played by Eve if m = A and ε otherwise, and m denotes the move type, having L for Adam choosing a letter, E for Eve choosing a transition and A for Adam choosing a transition.
A move of Adam that chooses a transition t ′ = q ′ σ:x − − → q ′′ , namely a move (σ, q, q ′ , t, A) → (σ, q, q ′′ , ε, L), is given weight γ(t) − γ(t ′ ), that is, the difference between the weights of the transitions chosen by both players. Other transitions are given weight 0. Observe that we need to compensate for the fact that only one edge in three is weighted. One option to do it is to take a discount factor λ ′ = λ 1 3 for the DSum game G. Yet, λ ′ can then be irrational, which somewhat complicates things. Another option is to consider discounted-sum games with multiple discount factors [2] and choose three rational discount factors λ ′ , λ ′′ , λ ′′′ ∈ Q ∩ (0, 1), such that λ ′ · λ ′′ · λ ′′′ = λ. Since the first two weights in every triple are 0, only the multiplication of the three discount factors toward the third weight is what matters. For λ = p q , where p < q are positive integers, one can choose λ ′ = 4p 4p+1 , λ ′′ = 4p+1 4p+2 , and λ ′′′ = 2p+1 2q . Plays in G 1 (A) and in G are in bijection. It now suffices to argue that the winning condition of G, namely that the (λ ′ , λ ′′ , λ ′′′ )-DSum of the play is nonnegative, correctly encodes the winning condition of G 1 (A), meaning that the difference between the λ-DSum of Eve's run and of Adam's run is non-negative.

⊓ ⊔
DSum games are positionally determined [22,23,2] so this algorithm also computes a finite-memory witness of HDness for A that is of polynomial size in the state-space of A. However, a positional witness also exists [17, Section 5].

Deciding History-Determinism via Two Token Games
In this section we solve the HDness problem of LimSup and LimInf automata via two-token games. As is the case with Büchi and coBüchi automata, one-token games do not characterise HDness of LimSup and LimInf automata. For LimInf, a possible alternative approach is to try to solve the letter game directly: we can use an equivalent deterministic LimInf automaton to track the value of a word, and the winning condition of the letter game corresponds to comparing Eve's run to the one of the deterministic automaton. Unfortunately, determinising LimInf automata is exponential in the number of its states [10, Theorem 13], so the new game is large, and, in addition, its winning condition, which compares the LimInf value of two runs, is non-standard and needs additional work to be encoded into a parity game. For LimSup automata the situation is even worse, as they are not necessarily equivalent to deterministic LimSup automata, so it is not obvious whether the winner of the letter game is decidable at all.
Here we show that the 2-token-game approach, used to resolve HDness of Büchi and coBüchi automata, can be generalised to LimSup and LimInf automata. While the proof that G 2 has the same winner as the letter game is quite different for the Büchi and coBüchi cases, our proofs for the LimSup and LimInf cases follow the same structure, while relying on the Büchi and coBüchi results respectively. However, the argument that G 2 (A) is solvable differs according to whether A is a LimSup or LimInf automaton. In particular, perhaps surprisingly (since the naive approach to solving the letter game seems harder for LimSup), we show that G 2 is solvable in quasipolynomial time for LimSup while for LimInf our algorithm is exponential in the number of weights (but not in the number of states).
Without loss of generality, we assume the weights to be {1, 2, . . .}. We start, in Section 5.1, with analysing the 2-token game on LimSup and LimInf automata, and show, in Section 5.2, that it characterises their HDness.

G 2 on LimSup and LimInf Automata
We first observe that G 2 (A), for both a LimSup and a LimInf automaton A, can be solved via a reduction to a parity game. The G 2 winning condition for LimSup automata can be encoded by adding carefully chosen priorities to the arena of G 2 (A), while for LimInf the encoding requires additional positions. Lemma 1. Given a nondeterministic LimSup automaton A of size n with k weights, the game G 2 (A) can be solved in time quasipolynomial in n, and if k is in O(log n), in time polynomial in n.
Proof. We encode the game G 2 (A), for a LimSup automaton A = (Σ, Q, ι, δ), into a parity game as follows. The arena is simply the arena of G 2 (A), seen as a product of the alphabet and three copies of A, to reflect the current letter and the current position of each of the three runs (one for Eve, two for Adam).
Adam's letter-picking moves are labelled with priority 0, Eve's choices of transition q σ:x − − → q ′ are labelled with priority 2x and Adam's choices of transition q σ:x − − → q ′ are labelled with priority 2x − 1.
We claim that Eve wins this parity game if and only if she wins G 2 (A), that is, the priorities correctly encode the winner of G 2 (A). Observe that the even priorities seen infinitely often in a play of the parity game are exactly priorities 2x, where x is a weight seen infinitely often in Eve's run in the corresponding play in G 2 (A). The odd priorities seen infinitely often on the other hand are 2x − 1, where x > 0 occurs infinitely often on one of Adam's runs in the corresponding play of G 2 (A). Hence, Eve can match the maximal value of Adam's runs in G 2 (A) if and only if she can win the parity game that encodes G 2 (A).
The number of positions in this game is polynomial in the size n of A; the maximal priority is linear in the number of weights. It can be solved in quasipolynomial time, or in polynomial time if the number of weights is in O(log n), using the reader's favourite state-of-the-art parity game algorithm, for instance [9].
⊓ ⊔ Lemma 2. Given a nondeterministic LimInf automaton A of size n with k weights, the game G 2 (A) can be solved in time exponential in n, and if k is in O(log n), in time polynomial in n.
Proof. As in the proof of Lemma 1, we can represent G 2 (A) as a game on an arena that is the product of three copies of A, one for Eve and two for Adam. The winning condition for Eve is that the smallest weight seen infinitely often on the run built on her copy of A should be at least as large as both of the minimal weights seen infinitely often on the runs built on Adam's copies. We will encode this winning condition as a parity condition, but, unlike in the LimSup case, we will need to use an additional memory structure, which we describe now. Intuitively, the weights on Eve's run will be encoded by odd priorities, with smaller weights corresponding to higher priorities, as in LimInf the lowest weight seen infinitely often is the one that matters, while weights on Adam's runs will be encoded by even priorities, but only once both of Adam's runs have seen the corresponding weight or a lower one. This is the role of the memory structure, which encodes which of Adam's runs has seen which weight recently.
More precisely, let k be the number of weights in A. Moves corresponding to Eve choosing a transition of weight i have priority 2(k − i + 1) − 1, that is, an odd priority that is larger the smaller i is. Further, for each weight, we use a three-valued variable x i ∈ {0, 1, 2}, initiated to 0, which gets updated as follows: if x i = 0 and the game takes a transition with a weight w ≤ i on one of Adam's runs, x i is updated to 1 or 2 according to which of Adam's run saw this weight; if x i = 1 (resp. 2) and Adam's second (resp. first) run takes a transition with weight w ≤ i, then x i is reset to 0. Transitions that reset variables to 0 have priority 2(k −i+1) for the minimal i such that the transition resets x i to 0; other transitions have priority 1. Other moves do not affect x i , and have priority 1.
We now argue that the highest priority seen infinitely often along a play is even if and only if the LimInf value of Eve's run is at least as high as that of both of Adam's runs. Indeed, the maximal odd priority seen infinitely often on a play is 2(k − i + 1) − 1 such that i is the minimal priority seen on Eve's run infinitely often, and the maximal even priority seen infinitely often is 2(k − j + 1) where j is the minimal weight such that both of Adam's runs see j or a smaller priority infinitely often. In particular, 2( This parity game is of size exponential in k due to the memory structure ({0, 1, 2} k ) and has 2k priorities. As the number of priorities is logarithmic in the size of the game, it can be solved in polynomial time [9]. If the number of weights is in O(log n), then the algorithm is polynomial in the size n of A. ⊓ ⊔

G 2 Characterises HDness for LimSup and LimInf Automata
The rest of the section is dedicated to proving that a LimSup or LimInf automaton is HD if and only if Eve wins the 2-token game on it. In both cases, the structure of the argument is similar. One direction is immediate: if an automaton A is HD, then Eve can use the letter-game strategy to win in G 2 (A), ignoring Adam's tokens. The other direction requires more work. We use an additional notion, that of k-HDness, also known as the width of an automaton [21], which generalises HDness, in the sense that Eve maintains k runs, rather than only one, and needs at least one of them to be optimal. We will then show that if Eve wins G 2 (A), then A is k-HD for a finite k (namely, the number of weights in A minus one). Finally, we will show that for automata that are k-HD, for any finite k, a strategy for Eve in G 2 (A) can be combined with the k-HD strategy to obtain a strategy for her in the letter game.
Many of the tools used in this proof are familiar from the ω-regular setting [3,6]. The main novelty in the argument is the decomposition of the LimSup (LimInf) automaton A with k weights into k − 1 Büchi (coBüchi) automata A 2 , . . . , A k that are HD whenever Eve wins G 2 (A). (The converse does not hold, namely A 2 , . . . , A k can be HD even if Eve loses G 2 (A) -see Fig. 2.) The HD strategies for A 2 , . . . , A k can then be combined to prove the k-HDness of A. Fig. 1 illustrates the flow of our arguments. We first generalise to quantitative automata Bagnol and Kuperberg's key insight that if Eve wins G 2 , then she also wins G k for all k [3, Thm 14].  (In A, if Eve goes from s0 to s1, Adam goes from s0 to s2 and continues with an a, and if she goes from s0 to s2, Adam goes from s0 to s1 and continues with a b. In A2 Eve goes from s0 to s1 and in A3 from s0 to s2.) Proof. This is the generalisation of [3, Thm 14]. The proof is similar to Bagnol and Kuperberg's original proof, but without assuming positional strategies for Eve in G k (A). If Eve wins G 2 (A) then she obviously wins G 1 (A), using her G 2 strategy with respect to two copies of Adma's single token in G 1 . We thus consider below G k (A) for every k ∈ N \ {0, 1, 2}. Let s 2 be a winning strategy for Eve in G 2 (A). We inductively show that Eve has a winning strategy s i in G i (A) for each finite i. To do so, we assume a winning strategy s i−1 in G i−1 (A). The strategy s i maintains some additional (not necessarily finite) memory that maintains the position of one virtual token in A, a position in the (not necessarily finite) memory structure of s i−1 , and a position in the (not necessarily finite) memory structure of s 2 . The virtual token is initially at the initial state of A. The strategy s i then plays as follows: at each turn, after Adam has moved his i tokens and played a letter (or, at the first turn, just played a letter), it first updates the s i−1 memory structure, by ignoring the last of Adam's tokens, and, treating the position of the virtual token as Eve's token in G i−1 (A), it updates the position of the virtual token according to the strategy s i−1 ; it then updates the s 2 memory structure by treating Adam's last token and the virtual token as Adam's 2 tokens in G 2 (A), and finally outputs the transition to be played according to s 2 .
We now argue that this strategy is indeed winning in G i (A). Since s i−1 is a winning strategy in G i−1 (A), the virtual token traces a run of which the value is at least as large as the value of any of the runs built by the first i − 1 tokens of Adam. Since s 2 is also winning, the value of the run built by Eve's token is at least as large as the values of the runs built by the virtual token and by Adam's last token. Hence, Eve is guaranteed to achieve at least the supremum value of Adam's i runs, making this a winning strategy in G i (A).
As for the memory size of a winning strategy for Eve in G k (A), let m be the memory size of her winning strategy in G 2 (A) and n the number of states in A. Then, by the above construction of her strategy in G k (A), the memory of her strategy in G 3 (A) is n for the virtual token times m for the copy of her memory in G 2 (A) times m for the copy of her memory in G i−1 (A) = G 2 (A), namely n · m · m = n · m 2 . Then for G 4 (A) it is n · m · (n · m 2 ) = n 2 · m 3 ; for G 5 (A) it is n · m · (n 2 · m 3 ) = n 3 · m 4 , and for G k (A) it is n k−1 · m k .

⊓ ⊔
We proceed with the definition of k-HDness, also known as width [21], based on the k-runs letter game (not to be confused with G k , the k-token game), which generalises the letter game.
Definition 5 (k-HD and k-runs letter game). A configuration of the game on a LimSup (LimInf) automaton A = (Σ, Q, ι, δ) is a tuple q k ∈ Q k of states of A, initialised to ι k .
If Eve has a winning strategy, we say that A is k-HD, or that HD k (A) holds.
Notice that the standard letter game (Definition 1) is a 1-run letter game and standard HD (Definition 1) is 1-HD. Next, we use HD k (A) to show that G 2 characterises HDness.

Proposition 4 ([3]
). Given a quantitative automaton A, if HD k (A) for some k ∈ N, and Eve wins G k , then A is HD.
Proof. The argument is identical to the one used in [3], which we summarise here. The strategy τ for Eve in HD k (A) provides a way of playing k tokens that guarantees that one of the k runs formed achieves the automaton's value on the word w played by Adam. If Eve moreover wins G k (A) with some strategy s k , she can, in order to win in the letter game, play s k against Adam's letters and k virtual tokens that she moves according to τ . The winning strategy τ guarantees that one of the k runs built by the k virtual tokens achieves Val(w); then her strategy s k guarantees that her run also achieves Val(w).

⊓ ⊔
It remains to prove that if Eve wins G 2 (A), then HD k (A) for some k. Given a LimSup automaton A, with weights {1, . . . , k}, we define k − 1 auxiliary Büchi automata A 2 , . . . , A k with acceptance on transitions, such that each A x is a copy of A, where a transition is accepting if its weight i in A is at least x. Each A x recognises the set of words w such that A(w) ≥ x. (See Fig. 2.) Given a LimInf automaton A, we similarly define auxiliary coBüchi automata: A x is a copy of A where transitions with weights smaller than x are rejecting, while those with weights x or larger are accepting. Again, A x recognises the set of words w such that A(w) ≥ x.
We now use these auxiliary automata to argue that if G 2 (A) then HD k−1 (A). Proof. Since A x is identical to A except for the acceptance condition or value function, Eve can use in G 2 (A x ) her winning strategy in G 2 (A). For the LimSup case, if one of Adam's runs sees an accepting transition infinitely often, the underlying transition of A visited infinitely often has weight at least x. Then, Eve's strategy guarantees that her run also sees infinitely often a value at least as large as x, corresponding to an accepting transition in G 2 (A x ). Similarly, for the LimInf case, if one of Adam's runs avoids seeing a rejecting transition infinitely often in A x , then this run's value in A is at least x, and Eve's strategy guarantees that her run's value in A is at least x, meaning that it avoids seeing a rejecting transition in A x infinitely often, and accepts. Proof. If A is HD then Eve can use the letter-game strategy to win in G 2 (A), ignoring Adam's moves. If Eve wins G 2 (A) then by Lemma 3 and Lemma 4 she wins HD k−1 (A), where k is the number of weights in A. By Theorem 4 she also wins G k−1 (A) and, finally, by Proposition 4 we get that A is HD. ⊓ ⊔ Theorem 6. Given a nondeterministic LimSup (resp. LimInf) automaton A of size n with k weights, the HDness problem of A can be solved in time quasipolynomial (resp. exponential) in n. In both cases, if k is in O(log n), it can be solved in time polynomial in n.
Proof. It directly follows from Theorem 5 and Lemmas 1 and 2; the former reducing the HDness problem to solving G 2 (A), and the latter two showing that G 2 (A) can be solved in the stated complexity.

⊓ ⊔
In contrast to the cases considered in the Section 4, where strategies in G 1 immediately induce HD strategies of the same complexity, for Büchi and coBüchi automata, a winning G 2 strategy does not necessarily induce an HD strategy (even though it implies the existence of such a strategy). We now analyse the size of the HD strategies which our proofs show exist whenever Eve wins G 2 , and discuss the implications for the determinisability of HD LimSup automata.
Corollary 2. Given an HD LimSup or LimInf automaton A of size n, there is an HD strategy for A with memory exponential in n. If A is a LimSup automaton with O(log n) weights then the memory is only polynomial in n.
Proof. Let n be the size of A and k + 1 the number of weights. We construct an HD strategy for A, by combining an HD k strategy and a G k strategy for it.
The HD k strategy-which, like the HD strategy, is hard to compute directlycombines the HD strategies of the k auxiliary Büchi or coBüchi automata for A, as constructed in Lemma 3. For HD Büchi automata, which are equivalent to deterministic automata of quadratic size [19], there always exists a polynomial resolver: indeed, the letter game can be represented as a polynomial parity game, in which a positional strategy for Eve corresponds to a resolver. For HD coBüchi automata on the other hand, these auxiliary strategies might have exponential memory in the number of states of A [19].
The G k strategy on the other hand is positional for LimSup, since it can be encoded as a parity game directly on the G k (A) arena, similarly to the reduction in Lemma 1; the size of the G k (A) arena is O(n k+1 ). The overall HD strategy for LimSup therefore needs memory exponential in the number of weights.
For LimInf on the other hand, by Lemma 2 and Theorem 4, the G k strategy can do with memory of size n k−1 · 3 k 2 . The overall HD strategy therefore has memory exponential in the size of A.

⊓ ⊔
We leave open whether this can be improved upon. Already for coBüchi automata, it is known that deciding whether an automaton is HD is polynomial despite there being automata for which the optimal HD strategy is exponential. Hence, at least for the LimInf case, we cannot expect to do much better. However, for the LimSup case, it might be that polynomial, or even positional HD strategies could suffice. However, positionality is already open for the Büchi case.
Our proof does however imply that if a LimSup automaton A is HD, then there is a finite memory HD strategy, which implies that A is determinisable, without increasing the number of weights, by taking a product of A with the finite HD strategy. (Recall that every LimInf automaton can be determinised, while not every LimSup automaton can.) Corollary 3. Every HD LimSup automaton is equivalent to a deterministic one with at most an exponential number of states and the same set of weights.

Conclusions
We have extended the token-game approach to characterising history-determinism from the Boolean (ω-regular) to the quantitative setting. Already 1-token games turn out to be useful for characterising history-determinism for some quantitative automata. For LimSup and LimInf automata, one token is not enough, but the 2-token game does the trick. Given the correspondence between deciding history-determinism and the best-value synthesis problem, our results also directly provide algorithms both to decide whether the synthesis problem is realisable and to compute a solution strategy.
This application further motivates understanding the limits of these techniques. Whether the 2-token game G 2 characterises more general Boolean classes of automata beyond Büchi and coBüchi automata is already an open question. Similarly, we leave open whether the G 2 game also characterises historydeterminism for limit-average automata and other quantitative automata. At the moment we are not aware of examples of automata of any kind (quantitative, pushdown, register, timed, . . . ) for which Eve could win G 2 despite the automaton not being history-deterministic, yet even for parity automata, a proof of characterisation remains elusive.
23. Uri Zwick and Mike Paterson. The complexity of mean payoff games on graphs.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made. The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.