diff --git "a/CdFQT4oBgHgl3EQf_DcV/content/tmp_files/2301.13456v1.pdf.txt" "b/CdFQT4oBgHgl3EQf_DcV/content/tmp_files/2301.13456v1.pdf.txt" new file mode 100644--- /dev/null +++ "b/CdFQT4oBgHgl3EQf_DcV/content/tmp_files/2301.13456v1.pdf.txt" @@ -0,0 +1,2140 @@ +arXiv:2301.13456v1 [cs.FL] 31 Jan 2023 +ONE DETERMINISTIC-COUNTER AUTOMATA +PRINCE MATHEW, VINCENT PENELLE, PRAKASH SAIVASAN, AND A. V. SREEJITH +Abstract. We introduce one deterministic-counter automata (odca), which +are one-counter automata where all runs labelled by a given word have the same +counter effect, a property we call counter-determinacy. odcas are an extension +of visibly one-counter automata - one-counter automata (oca) where the input +alphabet determines the actions on the counter. They are a natural way to +introduce non-determinism/weights to ocas while maintaining the decidabil- +ity of crucial problems, that are undecidable on general ocas. For example, +the equivalence problem is decidable for deterministic ocas whereas it is un- +decidable for non-deterministic ocas. We consider both non-deterministic and +weighted odcas. This work shows that the equivalence problem is decidable +in polynomial time for weighted odcas over a field and polynomial space for +non-deterministic odcas. As a corollary, we get that the regularity problem, +i.e., the problem of checking whether an input weighted odca is equivalent +to some weighted automaton, is also in polynomial time. +Furthermore, we +show that the covering and coverable equivalence problems for uninitialised +weighted odcas are decidable in polynomial time. +We also introduce a few reachability problems that are of independent +interest and show that they are in P. These reachability problems later help +in solving the equivalence problem. +Introduction +Visibly pushdown automata (vpda) was introduced by Alur and Madhusudan +in 2004 [2]. They have received a lot of attention as they are a strict subclass of +pushdown automata, suitable for program analysis. vpdas enjoy tractable decid- +able properties, which are undecidable in the general case. The visibly restriction, +in essence, is that the stack operations are input-driven, i.e., only depends on the +letter read. +In this paper, we investigate a relaxation in the visibly constraint on one-counter +automata (oca): the counter actions are no longer input-driven, but are determin- +istic. We could summarise this as: “any run on a given word has a fixed counter +effect”. We give a model satisfying this new restriction, which includes all visibly +oca. +Syntactically, one deterministic-counter automata (odca) contain two parts: +(1) Counter structure: This is a deterministic oca without epsilon transitions. +The transitions are deterministic, and the state transitions depend only on +the current state, the alphabet, and whether the counter is zero. +(2) Finite state machine: This machine has finite states and no counters. It +can be deterministic, non-deterministic, or weighted. The transitions of +Key +words +and +phrases. One +counter +automata, +Equivalence, +Reachability, +Weighted +automata. +1 + +2 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +this machine depend on its current state, current counter structure state, +input alphabet, and whether the counter value is zero. +An odca will be called deterministic, non-deterministic, or weighted depending +on the type of the finite state machine. One can observe that the class of deter- +ministic oca and the class of visibly oca are specific cases of odcas. In a visibly +oca, the input alphabet determines the counter structure. +An odca represents a function that maps words (over a finite alphabet) to a +weight. The run of a word over an odca determines its accepting weight. In the case +of weighted odca, the weights come from a field, and in the case of deterministic +and non-deterministic odca, the weights come from the boolean semiring. Hence +a deterministic or non-deterministic odca represents a language, which is the set +of all words whose weight is 1. +A non-deterministic odca can have a succinct representation compared to the +deterministic odca recognising the same language. For example, for any k ∈ N, +let Lk denote the language {an(b + c)mb(b + c)k | m, n ∈ N and m > n}. The non- +deterministic odca recognising the language Lk guesses whether a b encountered +after reading the string an(b + c)n+1 for some n ∈ N is at the kth position from the +end of the string. An example of a non-deterministic odca that recognises L2 is +shown in Figure 1. The deterministic odca that recognises the same language will +have to check whether every b encountered after reading the string an(b + c)n+1 is +at the kth position from the end. This will require an additional 2k states. +Our results. Two odcas are equivalent if the functions they represent are equal. +Observe that deterministic real-time ocas are deterministic odcas. We also note +that deterministic odcas are deterministic real-time ocas. B¨ohm et al. [5] proved +that the equivalence of deterministic oca is in non-deterministic log space. We +show that a non-deterministic odca is equivalent to an exponentially sized deter- +ministic odca. Therefore, unlike non-deterministic ocas, the equivalence of two +non-deterministic odcas is decidable and can be determined by a PSPACE machine. +This paper also presents a polynomial time algorithm for deciding the equivalence +problem of two weighted odcas. If the two odcas are non-equivalent, we output +a word (whose length is polynomial in the size of the two odcas) that the two +weighted odcas accept with different weights. +We dedicate Section 4 to prove +Theorem 1. +Theorem 1. There exists a polynomial time algorithm that decides if two weighted +odcas are equivalent and outputs a word that distinguishes them, if they are non- +equivalent. +To solve the equivalence problem for weighted odca, we introduce a few reacha- +bility problems. These problems are also of independent interest. The complement +to vector space (co-VS) reachability problem takes a weighted odca, a vector space, +and an initial configuration as input. It asks whether it is possible, starting from +the initial configuration, to reach a configuration in the complement of the given +vector space. We develop novel ideas to show that the unary (resp. binary) co-VS +reachability problem is in P (resp. NP). Let us call a word a witness if the run of +the word ‘reaches’ a configuration desired by the reachability problem. Through a +series of lemmas, we identify two interesting properties of witnesses. +(1) The witnesses satisfy a small model property - a witness that is longer than +a polynomial can be ‘cut’ to get a shorter witness. We remove parts of a + +ONE DETERMINISTIC-COUNTER AUTOMATA +3 +q0 +q1 +q2 +q3 +q4 +q5 +({a}, {0, 1}) +({b, c}, {0}) +({b, c}, {1}) +({b, c}, {0}) +({b}, {0}) +({b, c}, {1}) +({b, c}, {0}) +({b, c}, {0}) +({b, c}, {0}) +Finite state machine +Counter structure +p0 +p1 +({b, c}, {1}, −1) +({a}, {0, 1}, +1) +({b}, {0}, 0) +({b, c}, {0, 1}, 0) +Figure 1. The figure shows a non-deterministic odca recognising +the language L = {an(b + c)mb(b + c)2 | m, n ∈ N and m > n}. +Let S ⊆ Σ, R ⊆ {0, 1} and T ∈ {−1, 0, +1} are non-empty sets. +For i, j ∈ N, if a transition from qi to qj is labelled (S, R) and +(s, r) ∈ S × R, then there is a transition from qi to qj on reading +the symbol s. +The current counter value should be 0 if r = 0 +and greater than 0 if r = 1. Similarly, if a transition from pi to +pj is labelled (S, R, T ) and (s, r, t) ∈ S × R × {T }, then there is +a transition from pi to pj on reading the symbol s with counter +action t. The current counter value should be 0 if r = 0 and greater +than 0 if r = 1. +long run and join the remaining portions. The challenge is identifying cuts +that preserve the counter actions during the run. +(2) The lexicographically smallest word that witnesses the reachability is of the +form uyr1 +1 vyr2 +2 w where u, v, w, y1 and y2 are ‘small’ words and r1, r2 ∈ N. +The reachability problems, along with the ideas developed in the context of real- +time oca by B¨ohm et al. [3] (also see [4] [6]), and Valiant, Paterson [21] help us +solve the equivalence problem for odcas. +Next, we consider the regularity problem - the problem of deciding whether a +weighted odca is equivalent to some weighted automata. In Theorem 36, we show +that regularity of odca is decidable in polynomial time. This is done by showing +the existence of infinitely many equivalence classes by “pumping up” some parts of +a run. +Next, we look at uninitialised odcas - an odca without initial finite state dis- +tribution and initial counter state. We show that the “equivalence” problem for +unitialised odcas are in polynomial time. + +4 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +Related work. Extensive studies have been conducted on weighted automata with +weights from semirings. Tzeng [20] gave a polynomial time algorithm to decide +the equivalence of two probabilistic automata. The result has been extended to +weighted automata with weights over a field. On the other hand, the problem is +undecidable if the weights are over the semiring (N, min, +) [14]. Unlike the exten- +sive literature on weighted automata, the study on weighted versions of pushdown +or one-counter machines is limited [11] [12] [16]. One of the major bottlenecks is +the undecidability of many interesting problems. +Probabilistic Pushdown Automata (pPDA) is equivalent to probabilistic recur- +sive state machines (RSMs) or recursive Markov chains [8] [15]. +These models +have been studied extensively for the analysis and model checking of procedural +programs [9]. pPDAs can model probabilistic sequential programs with recursive +procedure calls. They are also a generalisation of stochastic context-free grammars +[1] used in natural language processing, molecular biology, and many variants of +one-dimensional random walks [7]. Kucera et al. [16] have looked at model-checking +of probabilistic pushdown systems and Br´azdil et al. [8] studied temporal proper- +ties of probabilistic pushdown automata. The equivalence problem of pPDA was +examined by Forejt et al. [10] and they showed that it is equivalent to the multiplic- +ity equivalence of context-free grammars. The decidability of the latter problem is +open. Kiefer et al. [13] show that the equivalence of probabilistic vpda is logspace +equivalent to polynomial identity testing. The later problem in known to be in +coRP. +The bisimilarity problem of probabilistic vpda (resp. probabilistic oca) was +shown to be EXPTIME-complete (resp. PSPACE-complete) by Forejt et al. [11]. +They also proved the decidability of the bisimilarity problem of pPDA. Etessami et +al. [9] show that probabilistic oca and Quasi-Birth-Death processes are equivalent. +Moving on to the non-weighted models, for non-deterministic pushdown au- +tomata the equivalence problem is known to be undecidable. On the other hand, +from the seminal result by S´enizergues [17], we know that the equivalence prob- +lem for deterministic pushdown automata is decidable. The lower bound, though, +is primitive recursive [18]. The equivalence problem for deterministic one-counter +automata (with and without ǫ transitions) is decidable in polynomial time. In fact, +similar to that of deterministic finite automata, the problem is NL-complete [5]. +Outline of the paper. The rest of this paper is organised as follows. Section 1 +contains the basic definitions and some lemmas from linear algebra. We also give +a formal definition of odca. In Section 2, we look at the special cases of non- +deterministic and deterministic odcas and show the decidability of their equiva- +lence problems. Section 3 analyses a few reachability problems of weighted odcas. +In Section 4, we prove Theorem 1 and show that the equivalence of weighted odcas +is in polynomial time. Section 5, gives a polynomial time algorithm for the regular- +ity problem of weighted odca, and in Section 6, we prove that the covering problem +for weighted odca is in polynomial time. Section 7 gives a short conclusion. +1. Preliminaries +1.1. Basic notations. An alphabet is a non-empty finite set of letters. In this +paper, we denote the alphabet by Σ. We use Σ∗ to denote the set of finite length +words over Σ, and for all l ∈ N, we use Σ≤l (resp. Σl) to denote the set of words +over Σ having length less than or equal to l (resp. exactly equal to l). Given a + +ONE DETERMINISTIC-COUNTER AUTOMATA +5 +word w ∈ Σ∗, we use |w| to denote the length of the word w. We use the notation +[i, j] to denote the interval {i, i + 1, . . . , j}. We say that a word u = a1 · · · ak is +a subword of a word w, if w = u0a1u1a2 · · · akuk, where ai ∈ Σ, uj ∈ Σ∗ for all +i ∈ [1, k] and j ∈ [0, k]. We call u a proper subword of w if u ̸= w. We say that a +word u is a prefix of a word w if there exists v ∈ Σ∗ such that w = uv. Given a +word w = a0 · · · an, we write w[i · · · j] to denote the factor ai · · · aj. Given d ∈ N, +sign(d) = 0 if d = 0 and is 1 otherwise. +1.2. Linear algebra. A field F = (S, +, ·, 0, 1) is a set S with operations + and +· and distinguished elements 0 and 1 such that (S, +, 0) and (S, ·, 1) are groups. +In this paper, we use x, y, z to denote row vectors over a field F, s, t, r to denote +elements in a field F and A, B, M to denote matrices over a field F. We use U, V +to denote vector spaces. We recall the following facts. +Lemma 2 ([19]). The following are true for a field F. +(1) For any set X of n vectors in Fm with n > m, there exists a vector x ∈ X +that is a linear combination of the other vectors in X. +(2) Given a set B of n vectors in Fm and a vector x ∈ Fm, we can check if x +is a linear combination of vectors in B in time polynomial in m and n. +(3) Let k, r ∈ N and M ∈ Fk×k. The matrix Mr can be computed in time +polynomial in k and log(r). +□ +The following properties of vector spaces are important. +Lemma 3. Let V be a vector space, k ∈ N and for all r ∈ [0, k] zr ∈ Fk and +Mr ∈ Fk×k. +Then, there exists an i ∈ [1, k] such that the following conditions are +true: +(1) zi is a linear combination of z0, . . . zi−1, and +(2) if ziMi /∈ V, then there exists j < i such that zjMi /∈ V. +Proof. Let k ∈ N, r ∈ [0, k], zr ∈ Fk, Mr ∈ Fk×k be matrices over F and V be a +vector space. +1. Consider the set {z0, z1, . . . , zk} of k +1 vectors of dimension k. It follows from +Lemma 2 that there are at most k independent vectors of dimension k, and hence +not all elements of the set can be independent. +2. Let i ∈ [1, k] be such that zi is a linear combination of z0, . . . zi−1 and ziMi /∈ V. +Let us assume for contradiction that zjMi ∈ V for all j ∈ [0, i − 1]. Since zi is a +linear combination on z0, . . . zi−1, there exists s0, . . . si−1 ∈ F such that +zi = s0 · z0 + s1 · z1 + · · · + si−1 · zi−1 +Since ziMi = �i−1 +j=0 sj · zjMi and V is closed under linear combinations, we get +that ziMi ∈ V contradicting our initial assumption. +□ +Lemma 4. Let V be a vector space, k ∈ N and for all r ∈ [0, k2] Ar, Mr, Br ∈ Fk×k. +Then, there exists an i ∈ [1, k2] such that for all x ∈ Fk the following conditions +are true: +(1) Mi is a linear combination of M0, . . . , Mi−1, and +(2) if xAiMiBi /∈ V, then there exists a j < i such that xAiMjBi /∈ V. + +6 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +Proof. Let Ar, Mr, Br ∈ Fk×k for r ∈ [0, k2], be matrices over F and V a vector +space. +1. Consider the set {M0, M1, . . . , Mk2} of k2 + 1 matrices of dimension k2. +It +follows from Lemma 2 that there are at most k2 independent vectors of dimension +k2, and hence not all elements of this set can be independent. +2. Let i ∈ [1, k2] be such that Mi is a linear combination of M0, . . . , Mi−1 and +xAiMiBi /∈ V. Since Mi is dependent on M0, . . . , Mi−1, we prove that there exists +j < i such that xAiMjBi /∈ V. Let us assume for contradiction that this is not the +case. Since Mi is a linear combination on M0, . . . Mi−1, there exists s0, . . . si−1 ∈ F +such that +Mi = s0 · M0 + s1 · M1 + · · · + si−1 · Mi−1 +Since xAiMjBi ∈ V for all j ∈ [0, i−1] we get that xAiMiBi = �i−1 +j=0 sj ·xAiMjBi ∈ +V, which is a contradiction. +□ +Lemma 5. Let k ∈ N, A ∈ Fk×k and V ⊆ Fk be a vector space. Then the following +set is a vector space, +U = {y ∈ Fk | yA ∈ V}. +Proof. To prove that U is a vector space, it suffices to show that it is closed under +vector addition and scalar multiplication. First, we prove that U is closed under +vector addition. Let z1, z2 ∈ U be two vectors, since z1A, z2A ∈ V, (z1 + z2)A = +z1A+z2A ∈ V. Therefore, z1 +z2 ∈ U. Now we prove that U is closed under scalar +multiplication. For any vector z1 ∈ U, we know that z1A ∈ V. Since V is a vector +space, for any scalar r ∈ F, (r · z1)A ∈ V, and therefore r · z1 ∈ U. This concludes +the proof. +□ +In particular, the above lemma holds for the vector space {0 ∈ Fk}. +1.3. One deterministic-counter automata. A one deterministic-counter au- +tomata (odca) consists of two parts, a finite state machine, which is a weighted +automaton over a semiring, and a counter structure, which is a deterministic oca. +An odca is defined as follows: +Definition 6. A one deterministic-counter automata ( odca), A over an alphabet +Σ and a semiring S is as defined below: +A = (C, δ, p0; Q, λ, ∆, η) +• C is a non-empty finite set of counter states. +• δ : C ×Σ×{0, 1} → C ×{−1, 0, +1} is the deterministic counter transition. +• p0 ∈ C is the start state for counter transition. +• Q is a non-empty finite set of states of the finite state machine. We assume +|C| = |Q| and use K to denote |Q|. +• λ ∈ SK is the initial distribution where the ith component of λ indicates +the initial weight on state qi ∈ Q. +• ∆ : C × Σ × {0, 1} → SK×K gives the transition matrix for all p ∈ C, +a ∈ Σ and d ∈ {0, 1}. The component in the ith row and jth column of +∆(p, a, d) denotes the weight on the transition from state qi ∈ Q to state +qj ∈ Q on reading symbol a from counter state p and counter value n with +sign(n) = d. + +ONE DETERMINISTIC-COUNTER AUTOMATA +7 +• η ∈ SK is the final distribution, where the ith component of η indicates the +output weight on state qi ∈ Q. +A configuration c of an odca is of the form (xc, pc, nc) ∈ SK × C × N. The +configuration (λ, p0, 0) is the initial configuration of A. +A transition is a tuple +τ = (ιτ, dτ, aτ, ceτ, Aτ, θτ) where ιτ, θτ ∈ C are counter states, dτ ∈ {0, 1} is to +denote whether the current counter value is zero or not, aτ ∈ Σ, ceτ ∈ {−1, 0, 1} is +the counter-effect, Aτ ∈ SK×K such that ∆(ιτ, aτ, dτ) = Aτ, and δ(ciτ, aτ, dτ) = θτ. +Given a transition τ and a configuration c, we denote the application of τ to c +as τ(c) = (xcAτ , θτ, nc + ceτ) if pc = ιτ and dτ = 0 if and only if nc = 0, and is +undefined otherwise. Note that the counter values always stay positive, implying +that we cannot perform a decrement operation on the counter from a configuration +with a counter value of zero. +Given a sequence of transitions T = τ0 · · · τℓ−1, we denote word(T ) = aτ0 · · · aτℓ−1 +the word labelling it, we(T ) = Aτ0 · · · Aτℓ−1 its weight-effect matrix, and ce(T ) = +ceτ0 + · · · + ceτℓ−1 its counter-effect. For all 0 ≤ i < j ≤ |ℓ − 1|, we use Ti···j to +denote the sequence of transitions τi · · · τj and |T | to denote ℓ. +We call a sequence of transition T = τ0 · · · τℓ floating if for all i ∈ [0, ℓ−1] dτi = 1 +and non-floating otherwise. We denote mince(T ) = mini(ce(τ0 · · · τi)) the minimal +effect of its prefixes and call it its decrease and maxce(T ) = maxi(ce(τ0 · · · τi)) is +the maximal effect of its prefixes. We say that the sequence of transitions T is +valid if for every i ∈ [0, ℓ − 2], θτi = ιτi+1. We will only consider valid sequences of +transitions. +A run π is an alternate sequence of configurations and transitions denoted as +π = c0τ0c1 · · · τℓ−1cℓ such that for every i, ci+1 = τi(ci). Given a sequence of +transition T and a configuration c, we denote T (c) the run obtained by applying +T to c sequentially (if it is defined). The word labelling it, its length, weight effect, +and counter-effect are those of its underlying sequence of transitions. +Observe that, for a valid floating sequence of transitions, T (c) is defined if and +only if nc > − mince(T ), and for a valid non-floating sequence of transitions, T (c) +is defined if and only if nc = − mince(T ) and for every i, dτi = 0 if and only if +ce(τ0 · · · τi−1) = mince(T ). In particular, observe that if a valid floating sequence +of transition T is applicable to a configuration (xc, pc, nc), then for every n′ ≥ nc +and vector x′ ∈ SK, it is applicable to (x′, pc, n′). +For any word w, there is at most one run labelled by w starting from a given +configuration c0. We denote this run π(w, c0). A run π(w, c0) = c0τ0c1 · · · τℓ−1cℓ is +also represented as c0 +w +−→ cℓ. We use the notation c0 →∗ cℓ to denote the existence +of some word w such that c0 +w +−→ cℓ. The counter effect of a word w on a floating +run c0 +w +−→ cℓ is ncℓ − nc0. The weight with which a word w is accepted by A along +the run c0 +w +−→ cℓ is denoted by fA(w, c0) = λwe(π(w, c0))η⊤. We use the notation +fA(w) to denote fA(w, (λ, p0, 0)). +Let A and B be two odcas. Consider the configurations c of A and d of B. We +say that c ≡l d if and only if for all w ∈ Σ≤l, fA(w, c) = fB(w, d) otherwise c ̸≡l d. +We say that the configurations c and d are equivalent if and only if c ≡l d for all +l ∈ N and we denote this by c ≡ d. We say that A and B are equivalent if for all +w ∈ Σ∗, fA(w) = fB(w). +If the odca is defined over a semiring which is also a field, then we call the +model a weighted odca, and if it is the boolean semiring then we call it a non- +deterministic/deterministic odca. +Note that the equivalence problem of odca + +8 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +defined over an arbitrary semiring is undecidable because of the undecidability of +equivalence of weighted automata over semirings. +The class of weighted odcas +includes deterministic oca, visibly weighted oca, and deterministic weighted oca. +We have to bring in known examples from literature. +Have others considered +weighted oca? +Does our model capture it? +Also, note that the δ need not be +a function and A is always a function. In that case, the control states are non- +deterministic. Like in the previous section, we can determinise it (with an expo- +nential blow-up). The question is, Is equivalence checking in this model (as well as +the weighted case) in PTIME? +Given a weighted odca A over the alphabet Σ and a field F, we define it’s +M-unfolding weighted automata AM as a finite state weighted automaton that +recognises the same function as A for all runs where the counter value does not +exceed M. A formal definition in given below. +Definition 7 (M-unfolding weighted automata). Let A = (C, δ, p0; Q, λ, ∆, η) be +a weighted odca over the alphabet Σ and a field F, let K = |Q| = |C|. For a +given M ∈ N, we define an M-unfolding weighted automata AM of A as follows, +AM = (C′, δ′, p′ +0; Q′, λ′, ∆′, η′ +F ) where, +• C′ = C × [0, M] is the finite set of counter states. +• δ′ : C′×Σ → C′ is the deterministic counter transition. Let p, q ∈ C, m ∈ N, +a ∈ Σ and d ∈ {−1, 0, +1}. δ′((p, m), a) = (q, m + d), if δ(p, a, sign(m)) = +(q, d). +• p′ +0 = (p0, 0) is the initial counter state. +• Q′ = Q × [0, M] is the finite set of states. +• λ′ ∈ F|Q′| is the initial distribution. +λ′[i] = +� +λ[i], if i < K +0, otherwise +• ∆′ : C′ × Σ → F|Q|′×|Q′| gives the transition matrix. For i, j ∈ |Q′|, p ∈ +C, m ∈ N and a ∈ Σ, +∆′((p, m), a)[i][j] = + + + + + + + + + + + + + +∆(p, a, 0)[i][j], if i, j < K +∆(p, a, 1)[i mod K][j mod +K], +if +i +K = +j +K +0, otherwise +• η′ +F ∈ F|Q′| is the final distribution. +η′ +F [i] = η[i mod K] +An uninitialised weighted odca A is a weighted odca without an initial counter +state and initial distribution. Formally, A = (C, δ; Q, ∆, η). Given an uninitialised +weighted odca A and an initial configuration c0 = (x, p, 0), we define the weighted +odca A⟨c0⟩ = (C, δ, p; Q, x, ∆, η). +Weighted automata (WA) is a restricted form of an odca where the counter value +is fixed at zero. The above notions of transitions, runs, acceptance, etc. are used +for WA also. We also use the classical notion and represent weighted automata as +A = (Q, λ, ∆, η), without counter states. + +ONE DETERMINISTIC-COUNTER AUTOMATA +9 +2. Nondeterministic / deterministic odca +A deterministic/non-deterministic odca A is an odca over the boolean semiring +S = ({0, 1}, ∨, ∧). +The language recognised by A is given by L(A) = {w | +fA(w) = 1}. +We say an odca A = (C, δ, p0; Q, λ, ∆, η) is deterministic if for +every transition sequence T = τ0 · · · τℓ−1, the vector λwe(T ) contains exactly one 1 +and non-deterministic otherwise. +The following theorem is ‘analogous’ to the case of finite automata. The idea is +a simple subset construction. +Theorem 8. For every language recognised by a non-deterministic odca, there is +a deterministic odca of at most exponential size that recognise it. +Proof. Let A = (C, δ, p0; Q, λ, ∆, η) be a non-deterministic odca. +Given a vector +x ∈ Sk for some k ∈ N, we define the function IsDet: Sk → {true, false} as follows: +IsDet(x) = +� +true, if ∃i < k s.t x[i] = 1 and ∀j ̸= i, x[i] = 0 +false, otherwise. +Given a transition matrix A corresponding to the states Q, we define its determin- +isation det(A) as follows. There are rows and columns corresponding to each set +in 2Q. For any qi ∈ Q, let M(qi, A) = {qj | A[i][j] = 1} be the set of all states in +the row of qi whose entries are 1. With the notation that det(A)[s][s′] corresponds +to the entry of the cell corresponding to the sets s, s′ ∈ 2Q, we let det(A)[s][s′] = 1 +if and only if s′ = � +q∈s M(qi, A). We claim that Adet = (C, δ, p0; Q, λ, ∆′, η′), +with η′ such that for any S ∈ 2Q,η′[S] = � +s∈S η[s] and for all p ∈ C, a ∈ Σ +and d ∈ {0, 1}, ∆′(p, a, d) = det(∆(p, a, d)) is such that it is deterministic and +L(A) = L(Adet). +For this, for any sequence of operations T = τ0 · · · τℓ−1, let vT , v′ +T be the vectors +corresponding to λwe(T ) in A and Adet respectively. Then we have IsDet(v′ +T ) = 1 +and for any S ∈ 2Q, v′ +T [S] = 1 if and only if for all qi ∈ S, vT [i] = 1. +□ +The equivalence of deterministic odcas can be decided in non-deterministic log +space [3]. From the above theorem, it follows that a PSPACE machine can decide +on the equivalence of non-deterministic odcas. +Theorem 9. Equivalence of non-deterministic odca is in PSPACE. +As a corollary, we get the following. +Corollary 10. The emptiness and the universality problems of non-deterministic +odca are in PSPACE. +3. Reachability problems in weighted odca +In this section, we examine two reachability problems of weighted odcas. In the +subsequent section, we develop the techniques that play a key role in proving the +equivalence of weighted odca. +A weighted odca A = (C, δ, p0; Q, λ, ∆, η). Without loss of generality, assume +|C| = |Q| and denote |Q| by K. We use V ⊆ FK to denote a vector space and +V = FK \ V to denote the set complement of V. Let S ⊆ C be a subset of the +set of counter states, X ⊆ N a set of counter values and w ∈ Σ∗. The notation +c +w +−→ V × S × X denotes the run c +w +−→ d where d ∈ V × S × X. We call z ∈ Σ∗ +a reachability witness for (c, V, S, X) if c +z−→ V × S × X. Moreover, we say z is a + +10 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +minimal reachability witness for (c, V, S, X) if c +z−→ V × S × X and for all u ∈ Σ∗ +with c +u−→ V × S × X, |u| ≥ |z|. We use c +∗−→ V × S × X to denote that there exists +a word u ∈ Σ∗ such that c +u−→ V × S × X. +We assume that the vector space V ⊆ FK will be provided by giving a suitable +basis for V. +(1) co-VS reachability problem: +Input: a weighted odca A, an initial configuration c, a vector space V, +set of counter states S and counter value m. +Output: Yes, if there exists a run c +∗−→ V × S × {m} in A. No, otherwise. +(2) co-VS coverability problem: +Input: a weighted odca A, an initial configuration c, a vector space V, +and set of counter states S. +Output: Yes, if there exists a run c +∗−→ V × S × N in A. No, otherwise. +Note that in the second problem, the counter value of the final configuration is not +part of the input. We consider the cases where the counter values of the initial +configuration and the final counter value, if part of the input, are given in unary +or in binary notation separately. Note that the size of the unary representation is +exponentially larger than the binary representation for the same value. +First, we look at the particular case of co-VS reachability problem for weighted +automata. +Note that for weighted automata, the counter value is always zero. +Given a weighted automata B, with k states, an initial configuration ¯c, a vector +space U ⊆ Fk and a set of counter states S, the co-VS reachability problem asks +whether there exists a run ¯c +∗−→ U × S × {0}. +Theorem 11. There is a polynomial time algorithm that decides the co-VS reach- +ability problem for weighted automata and outputs a minimal reachability witness +if it exists. +Proof. Tzeng [20] gives a polynomial time algorithm for the equivalence of two +probabilistic automata by reducing the problem to the co-VS reachability problem +where V = {0}. The same algorithm can be modified to solve the general co-VS +reachability problem. +□ +The following lemma will help us break down both the reachability problems +into smaller sub-problems. +Lemma 12. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, X). Consider +arbitrary z1z2 ∈ Σ∗ such that z = z1z2. Let d, e be configurations such that c +z1 +−→ +d +z2 +−→ e and A ∈ FK×K be such that xdA = xe. Then z1 is a minimal reachability +witness for (c, U, {pd}, {nd}), where U = {y ∈ FK | yA ∈ V}. +Proof. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, X), d, e be config- +urations such that c +z1 +−→ d +z2 +−→ e where z1, z2 ∈ Σ∗ with z = z1z2 and A ∈ FK×K +be such that xdA = xe. Let U = {y ∈ FK | yA ∈ V}. Assume for contradic- +tion that there exists z′ +1 ∈ Σ∗ smaller than z1 and c +z′ +1 +−→ f for some configuration +f ∈ U × {pd} × {nd}. Note that for all y ∈ U, the vector yA ∈ V. Since nf = nd +and pf = pd, the run c +z′ +1 +−→ f +z2 +−→ V × {pe} × {ne} is a valid run and the word z′ +1z2 +contradicts the minimality of z. +□ + +ONE DETERMINISTIC-COUNTER AUTOMATA +11 +The following subsection shows that the unary version of co-VS reachability and +coverability are in P. In the subsection after, we show that binary version of both +problems are in NP. +3.1. Unary reachability in P. In this subsection, we show that both the reacha- +bility problems of weighted odca are solvable in polynomial time when the counter +values are given in unary representation. +Theorem 13. Unary co-VS reachability and co-VS coverability problems are de- +cidable in polynomial time. +The theorem is proved by showing a small model property. i.e., the length of a +minimal witness of reachability is bounded by a polynomial in the number of states +K and the input counter value(s). This is proved by showing that the maximum +and minimum counter values encountered during the run of a minimal reachability +witness do not exceed some bound. Assume this is not true. In this case, there are +two sub-runs of the run which satisfy the following conditions. In the first part, +the counter values increases and reaches a maximum counter value. In the second +part, the counter values decreases. We show that in such a scenario, we can cut +parts from both the sub-runs by maintaining the reachability conditions. This is +proved in Lemma 15. +Now, we prove that if the number of distinct counter values encountered during +the run of a minimal reachability witness is polynomially bounded, then we can +bound the length of that witness. +Lemma 14. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, X). If the +number of distinct counter values encountered during the run c +z−→ V × S × X is t, +then |z| ≤ K2 · t. +Proof. Let c = c1 and T (c1) = c1τ1c2 · · · τh−1ch be the run on word z from c1 and +T the corresponding sequence of transitions. Let t be the number of distinct counter +values encountered during this run. Now assume for contradiction that h > K2 · t, +then by Pigeon-hole principle, there are K + 1 many configurations ci0, ci1, . . . , ciK +with the same counter state and counter value during this run. Let Aj denote the +matrix such that xcij Aj = xch for all j ∈ [0, K]. From Lemma 4 we get that there +exists r ≤ K, and t ∈ [0, r − 1] such that xcit Ar ∈ V. Consider the sequence of +transitions T ′ = τ1···itτr···ℓ−1 and v = word(T ′). The run π(v, c1) = T ′(c1) is a +valid run since nct = ncr and pct = pcr. This is a shorter run than π(z, c1) and +c1 +v−→ V × S × X. This is a contradiction since z was assumed to be minimal. +□ +It now suffices to show that the number of distinct counter values encountered +during the run of a minimal witness is polynomially bounded. We first show that if +the run of a minimal reachability witness of (c, V, S, {m}) is a floating run, then the +maximum and minimum counter values encountered during this run are bounded +by a polynomial in K and the initial and final counter values. +Lemma 15. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, {m}). If +c +z−→ V × S × {m} is a floating run, then the maximum counter value during this +run is less than max(nc, m) + K4. +Proof. Let z ∈ Σ∗ be a reachability witness for (c, V, S, {m}) and c +z−→ V ×S ×{m} +be a floating run. Let f ∈ V × S × {m}, such that c +z−→ f. We prove that the + +12 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +vj +d +c +e +gi +ui +g′ +i +wi +gj +g′ +j +word length +nc1 + M +nc1 +ngi +ngj +counter value +Figure 2. The figure shows the floating run from a configuration +c to e such that xe ∈ U. The configurations gi and gj (resp. g′ +i +and g′ +j) are where the counter values ngi and ngj are encountered +for the last (resp. first) time before (resp. after) reaching counter +value nc + M. +Also, pgi = pg′ +i = pgj = pg′ +j. +The dashed line +denotes the part of the run which can be removed to get a shorter +reachability witness for (c, U, {pe}, {ne}). +maximum counter value encountered during this run are bounded. Let us assume +that max(nc, m) = nc. The case where max(nc, m) = m can be proven analogously. +Assume for contradiction that the maximum counter value encountered during this +run is greater than nc + K4. There exists z1, z2, z3 ∈ Σ∗ such that z = z1z2z3 and +configurations d, e such that the run on z from c can be written as follows: +c +z1 +−→ d +z2 +−→ e +z3 +−→ f +where ne = nc and nd = nc + maxce(π(z, c)) (see Figure 2). Let M ∈ FK×K such +that xf = xeM. From Lemma 5 we know that the set U = {y ∈ FK | yM ∈ V} is +a vector space and hence the vector xe ∈ U. From Lemma 12 we know that z1z2 is +a minimal reachability witness for (c, U, {pe}, {ne}). We contradict the minimality +of z1z2. +Let c1 = c and T (c1) = c1τ1c2 · · · τℓ−1cℓ denote the run on word z1z2 from +the configuration c1 and T the corresponding sequence of transitions. Let M = +maxce(π(z, c)). Note that M = nd − nc. For any i ∈ [0, M], we denote by li and +di the indices such that the counter value nc1 + i is encountered for the last (resp. +first) time before (resp. after) reaching counter value nc1 + M in T (c1). That is, +ce(T1···li−1) = ce(T1···di−1) = i, and for any j ∈ [li, di − 2], ceT1···j > i. We call +gi = T1···li−1(c1) and g′ +i = T1···di−1(c1). +Let r = K2 + 1. Since M > K4, by Pigeonhole principle, there exists set of +indices X = {i1, i2, · · · , ir} ⊆ [0, M] such that for any k < r, we have ik < ir and +for all h, j ∈ X pgh = pg′ +h = pgj = pg′ +j. For all j ∈ X, let uj, vj, wj be words +such that c1 +uj +−→ gj +vj +−→ g′ +j +wj +−−→ g′ +1 as depicted in Figure 2. For all j ∈ X, let +matrix Aj and Bj be such that xg′ +j = xgjAj and xg′ +1 = xg′ +jBj. We know that +for all j ∈ X, xgjAjBj ∈ U. Now we list the matrices in the following sequence + +ONE DETERMINISTIC-COUNTER AUTOMATA +13 +Air, Air−1, . . . , Ai1. From Lemma 4, it follows that, there exists h, j ∈ X with h < j +such that xghAjBh ∈ U. +Consider the sequence of transitions T ′ = τ1···lh−1τlj···dj−1τdh···ℓ. +The word +uhvjwh = word(T ′) is a proper subword of z1z2 and the run π(uhvjwh, c1) = +T ′(c1) is a valid floating run shorter than π(w, c1) and c1 +uhvjwh +−−−−−→ e′ such that +e′ ∈ U × {pe} × {ne}. This contradicts the minimality of z1z2. +□ +Now, we prove that for any run (need not necessarily be a floating run) of a mini- +mal reachability witness z for (c, V, S, m), the maximum counter value encountered +during the run c +z−→ V ×S×{m} is bounded by a polynomial in the number of states +of the machine and the initial and final counter values. This is achieved by applying +Lemma 15 multiple times on the run of the minimal witness (refer Figure 3). +e1 +e2 e3 +c +e4 +d +word length +counter value +Figure 3. The figure shows a run from configuration c to d such +that xd ∈ V. Configurations e1, . . . , e4 denote the configurations +where counter value zero is encountered during the run. +The +dashed lines denote the portions that can be removed to get a +shorter reachability witness for (c, V, {pd}, {nd}). +Lemma 16. If z ∈ Σ∗ is a minimal reachability witness for (c, V, S, {m}) then the +maximum counter value encountered during the run c +z−→ V × S × {m} is less than +max(nc, m) + K4. +Proof. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, {m}). Consider +the run of word z from c. Let d ∈ V × S × {m} such that c +z−→ d. Assume for +contradiction that the maximum counter value encountered during the run c +z−→ d +is greater than max(nc, m) + K4. Let e1, e2, · · · , et be all the configurations in this +run such that nei = 0 for all i ∈ [1, t]. There exists words u1, u2, · · · , ut+1 ∈ Σ∗ +such that z = u1u2 · · · ut+1 and +c +u1 +−→ e1 +u2 +−→ e2 +u3 +−→ · · · +ut +−→ et +ut+1 +−−−→ d +Note that c +u1 +−→ e1, et +ut+1 +−−−→ d and ei +ui+1 +−−−→ ei+1 for all i ∈ [1, t − 1] are floating +runs (refer Figure 3). + +14 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +We show that the counter values are bounded during each of these floating runs. +First, we consider the floating run c +u1 +−→ e1. Let A ∈ FK×K be such that xd = xe1A. +From Lemma 5 we know that the set U = {y ∈ FK | yA ∈ V} is a vector space +and hence the vector xe1 ∈ U. From Lemma 12, we know that u1 is a minimal +reachability witness for (c, U, {pe1}, {0}) and therefore by Lemma 15 we know that +the maximum counter value encountered during the run π(u1, c) is less than nc+K4. +Similarly for the floating run et +ut+1 +−−−→ d, the maximum counter value is bounded +by nd + K4. Now consider the floating runs ei +ui+1 +−−−→ ei+1 for all i ∈ [1, t − 1]. Again +by applying Lemma 15 we get that the maximum counter value encountered during +each of these sub-runs is less than K4. +Therefore, the maximum counter value +encountered during the run c +z−→ V × S × {m} is less than max(nc, m) + K4. +□ +We have shown that the counter values are polynomially bounded during the +run of a minimal reachability witness for the co-VS reachability problem. Our next +objective is to prove an analogous result for the co-VS coverability problem. The +problem is similar to co-VS reachability, except that now we are not given a final +counter value. A crucial ingredient in proving this is Lemma 17 where we prove that +if the run of a minimal reachability witness z for (c, V, S, N) is a floating run, then +the number of distinct counter values encountered during the run c +z−→ V × S × N is +polynomially bounded in K and nc. Using this and the ideas presented earlier for +co-VS reachability, we can prove the existence of a polynomial length witness for +the co-VS coverability problem. +Lemma 17. If z ∈ Σ∗ is a minimal reachability witness for (c, V, S, N) and c +z−→ +V × S × {m} is a floating run then |m − nc| ≤ K2. +word length +counter value +c1 +ci0 +ci1 +cil +cik +ciK +cℓ +Ad +Figure 4. The figure shows a run from c1 to cℓ such that xcℓ ∈ V. +The configurations cil and cik are where the counter values ncil +and ncik are encountered for the last time. Also pcil = pcik . The +dashed lines denote a part that can be removed to get a shorter +reachability witness for (c, V, {pcℓ}, N). +Proof. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, N) and c +z−→ +V × S × {m} is a floating run. Assume for contradiction that m > nc + K2. The + +ONE DETERMINISTIC-COUNTER AUTOMATA +15 +case where nc > m + K2 can be proven analogously. Let c1 = c and π(z, c1) = +c1τ1c2 · · · τℓ−1cℓ be such that m = ncℓ > nc1 + K2. +Consider the sequence of +transitions T = τ0τ1 · · · τℓ−1 in π(z, c1). Since there are only K counter states, by +Pigeon-hole principle, there exists a strictly increasing sequence I = 0 < i0 < i1 < +· · · < iK ≤ ℓ such that for all j, j′ ∈ I (Condition 1) pcj = pcj′ and (Condition 2) if +j < j′ then ncj < ncj′ and for all d ∈ [j + 1, j′ − 1], ncj < ncd < ncj′ . +Consider the set of configurations ci0, ci1, . . . , ciK. For any j ∈ [0, K], let Aj +denote the matrix such that xcij Aj = xcℓ. Since xcidAd ∈ V for all d ∈ [0, K], from +Lemma 3 we get that there exists l, k ∈ [0, K] with l < k such that xcilAk ∈ V. +Consider a configuration e = (x, p, n). If π(u, e) is a valid floating run with +mince(π(u, e)) > 0, then for all m ∈ N and y ∈ FK, π(u, (y, p, m)) is a valid +run. +Consider the sequence of transitions T ′ = τik···ℓ−1 and let u = word(T ′). +Because of Condition 2, mince(π(u, cik)) > 0. Therefore the run T ′′(c1) where +T ′′ = τ1···il−1τik···ℓ−1 is a valid run shorter than π(z, c1). +This contradicts the +minimality of z. +□ +Now we show that for any run (need not be floating) of a minimal reachability +witness z for (c, V, S, N), the maximum counter value encountered during the run +c +z−→ V × S × N is bounded by a polynomial in K and the initial counter value. +Lemma 18. If z ∈ Σ∗ is a minimal reachability witness for (c, V, S, N) then the +maximum counter value encountered during the run c +z−→ V × S × N is less than +max(nc, K2) + K4. +Proof. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, N). Consider the +run of word z from c. Let d ∈ V × S × N such that c +z−→ d. If c +z−→ d is a floating +run, then by Lemma 17 the maximum counter value encountered during this run +will be less than nc + K2. Now if c +z−→ d is not a floating run, then there exists +u1, u2 ∈ Σ∗ such that z = u1u2 and c +u1 +−→ e +u2 +−→ d where, nei = 0 and e +u2 +−→ d is a +floating run. +Let A ∈ FK×K be such that xd = xeA. From Lemma 5, we know that the the +set U = {y ∈ FK | yA ∈ V} is a vector space and hence the vector xe ∈ U. Note +that for all y ∈ U, the vector yA ∈ V. From Lemma 12, we know that u1 is a +minimal reachability witness for (c, U, {pe}, {0}) and therefore by Lemma 16, we +know that the maximum counter value encountered during the run π(u1, c) is less +than nc + K4. Now since e +u2 +−→ d is a floating run and u2 is the minimal such +word, from Lemma 17, we get that nd ≤ K2, and by Lemma 15, we know that the +maximum counter value encountered during this run is less than K2+K4. Therefore, +we get that the maximum counter value encountered during the run c +z−→ d is less +than max(nc, K2) + K4. +□ +Proof of Theorem 13. For solving the co-VS reachability problem when the weighted +odca A = (C, δ, p0; Q, λ, ∆, η) with K = |Q| = |C| states, initial configura- +tion c, vector space V, set of counter states S and counter value m are given +as inputs, we first consider the max(nc, m) + K4-unfolding weighted automata +Amax(nc,m)+K4 = (C′, δ′, p′ +0; Q′, λ′, ∆′, η′ +F ) of A as described in Definition 7. From +Lemma 16, we know that the maximum counter value encountered during the run +of the minimal reachability witness z for (c, V, S, {m}) is less than max(nc, m)+K4. +We define a vector space U ⊆ F|Q′| as follows: A vector x ∈ F|Q′| is in U if there + +16 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +exists y ∈ V such that for all i ∈ [0, K − 1], x[K · m + i] = y[i] and for all n ̸= m +and i ∈ [0, K − 1], x[K · n + i] = 0. +Given a configuration c of a weighted odca, we define the vector zc ∈ F|Q′|. +zc[i] = +� +xc[i mod K], if +i +K = nc +0, otherwise +Now, consider the configuration ¯c = (zc, (pc, nc)) of Amax(nc,m)+K4 and check +whether ¯c +∗−→ U × S × {0}. +This is a co-VS reachability problem of weighted +automata. Using Theorem 11, this can be solved in polynomial time. +For solving the co-VS coverability problem when the weighted odca A with K +states, an initial configuration c, a vector space V and a set of counter states S are +given as inputs, we consider the max(nc, K2) + K4-unfolding weighted automata +Amax(nc,K2)+K4 = (C′, δ′, p′ +0; Q′, λ′, ∆′, η′ +F ) of A. From Lemma 18, we know that +the maximum counter value encountered during the run of a minimal reachability +witness z for (c, V, S, N) is less than max(nc, K2) + K4. We define a vector space +U ⊆ F|Q′| as follows: A vector x ∈ F|Q′| is in U if there exists y ∈ V and m ∈ N +such that for all i ∈ [0, K−1], x[K·m+i] = y[i] and for all n ̸= m and i ∈ [0, K−1], +x[K·n+i] = 0. Now, consider the configuration ¯c = (zc, (pc, nc)) of Amax(nc,K2)+K4 +and check whether ¯c +∗−→ U × S × {0}. This is a co-VS reachability problem of +a weighted automaton. From Theorem 11, we know that this can be solved in +polynomial time. +□ +3.2. Binary reachability in NP. Consider the case where the counter values are +specified in binary. Theorem 13 can still be applied to get an algorithm whose +running time is polynomial in the input counter values. Since the counter values +are represented in binary, their values can be exponentially large compared to their +size. Therefore, we only get an exponential time algorithm for reachability from +Theorem 13. This section shows that co-VS reachability can be tested in NP. The +technically challenging part of the proof is proved in Lemma 22. It shows that the +“lexicographically minimal” reachability witness z is of the form uyr1 +1 vyr2 +2 w, where +the length of the words u, y1, y2, v and w are polynomially bounded in K and r1, r2 +are polynomial values dependent on K and the input counter values. +This is a +polynomial sized representation of the witness (r1, r2 in binary) whose reachability +can be verified in polynomial time. A non-deterministic machine guesses the words +u, y1, y2, v, and w and verifies reachability in polynomial time. +Theorem 19. Binary co-VS reachability and co-VS coverability problems are in +NP. +We aim to show that there is an “encoding” of a minimal reachability witness of +polynomial size with respect to the input size. The following lemma shows that the +length of a minimal reachability witness is bounded by a polynomial in the input +counter values. Note that this can be exponential in size with respect to the input +size when the counter values are represented in binary. +Lemma 20. +(1) If z is a minimal reachability witness for (c, V, S, {m}) then +|z| ≤ K2 · (max(nc, m) + K4). +(2) If z is a minimal reachability witness for (c, V, S, N) then |z| ≤ K2·(max(nc, K2)+ +K4). + +ONE DETERMINISTIC-COUNTER AUTOMATA +17 +Proof. 1. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, {m}). From +Lemma 16, we know that the maximum counter value encountered during the run +c +z−→ V × S × {m} is less than max(nc, m) + K4. Therefore, there are at most +max(nc, m) + K4 many distinct counter values encountered during this run. Now +from Lemma 14 we get that |z| ≤ K2 · (max(nc, m) + K4). +2. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, N). From Lemma 18, +we know that the maximum counter value encountered during the run c +z−→ V×S×N +is less than max(nc, K2)+K4. Therefore, there are at most max(nc, K2)+K4 many +distinct counter values encountered during this run. Now from Lemma 14 we get +that |z| ≤ K2 · (max(nc, K2) + K4). +□ +We define the counter effect of a word w with respect to a counter state q ∈ C as +ce(π(w, c)) where c is any configuration with nc = |w| and pc = q. Note that for +any two configuration c, d, ce(π(u, c)) = ce(π(u, d) if nc = nd = |w| and pc = pd. +First, we consider the case of the run of a minimal reachability witness from c, +which is a floating run. The following lemma is required for the special case where +|nc − m| is bounded by a polynomial in K. +Lemma 21. If z ∈ Σ∗ is a minimal reachability witness for (c, V, S, {m}) and +c +z−→ V × S × {m} is a floating run, then +(1) the minimum counter value during this run is greater than min(nc, m)−K4, +and +(2) |z| ≤ K2 · (|nc − m| + 2K4). +Proof. Let z ∈ Σ∗ be a minimal reachability witness for (c, V, S, {m}) and c +z−→ +V × S × {m} is a floating run. We prove the claims in the lemma one by one. +1. This case is symmetric to that of Lemma 15 and can be proven analogously. +2. From Lemma 15 and Point 1, we get that the counter values encountered during +the run c +z−→ V × S × {m} lies between max(nc, m) + K4 and min(nc, m) − K4. Let +t = |nc − m|. There are at most t + 2 · K4 distinct counter values during this run. +Now from Lemma 14 we get that |z| ≤ K2 · (t + 2 · K4). +□ +We assume a total order on the symbols in Σ. Given two words u, v ∈ Σ∗, we +say that u precedes v in the lexicographical ordering if |u| < |v| or if |u| = |v| and +there exists an i ∈ [0, |u| − 1] such that u[0, i − 1] = v[0, i − 1] and u[i] precedes v[i] +in the total ordering assumed on Σ. A word z ∈ Σ∗ is called the lexicographically +minimal reachability witness for (c, V, S, {m}), if c +z−→ V × S × X and for all u ∈ Σ∗ +with c +u−→ V × S × X, z precedes u in the lexicographical ordering. We show that +the lexicographically minimal reachability witness z for (c, V, S, {m}) has a special +form. First, we consider the case of floating runs. +Lemma 22. If z ∈ Σ∗ is the lexicographically minimal reachability witness for +(c, V, S, {m}) and c +z−→ V × S × {m} is a floating run, then there exists u, y, w ∈ Σ∗ +and r ∈ N such that z = uyrw and for all configurations dk, k ∈ [0, r], where +c +uyk +−−→ dk the following conditions hold: +(1) |u|, |y| ≤ 3K7 and |w| < 6K7, +(2) either ndi > ndj for all i, j such that 0 ≤ i < j ≤ r or +ndi < ndj for all i, j such that 0 ≤ i < j ≤ r, +(3) for all i, j ∈ [0, r], pdi = pdj, and + +18 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +(4) r ∈ [0, K2 · |nc − m| + K6]. +Proof. Let z be the lexicographically minimal reachability witness for (c, V, S, {m}) +such that c +z−→ V × S × {m} is a floating run. Let t = |nc − m|. If t ≤ K4, then from +Lemma 21, Item 2, we get that |z| ≤ 3K6 and the claim is trivially true. Consider +the case where nc > m. The case where m > nc can be proven analogously. Let us +assume t > K4 and let d ∈ Z be such that d = −t + K4 + 1. +Let c = c1 and T (c1) = c1τ1c2 · · · τℓ−1cℓ denote the run on word z from the +configuration c1. For any i ∈ [0, K4], we denote by li the index such that the counter +value nc1 −i is encountered for the first time and ri the index such that the counter +value nc1 − i + d is encountered for the last time in T (c1) (see Figure 5). Since +t > K4, there are at least K4 + 1 pairs of positions (li, ri), i ∈ [0, K4] such that for +all i ∈ [0, K4] the factor z[li, ri] has counter effect d with respect to counter state +pcli . Note that these factors need not be all distinct. Let X = {(li, ri)}i∈[0,K4] be +the set containing these pairs of positions and W = {z[l, r] | (l, r) ∈ X} be the set +containing the corresponding factors. Note that |X| > K4. +z[li, ri] +c +g +ei +fi +word length +nc +m +nc − i + d +nc − i +counter value +Figure 5. The figure shows the floating run from a configuration +c to g such that xg ∈ V. The configurations cli and cri are where +the counter values nc − i and nc − i + d are encountered for the +first (resp. last) time during this run. The dashed line denotes the +part of the run due to the factor z[li, ri] and has a counter effect +d. +Claim 1. |W| ≤ K4. +Proof: Assume for contradiction that |W| > K4. Let g ∈ V × S × {m} be such +that c +z−→ g. Since number of counter states is K, by Pigeon-hole principle there +exists Y ⊆ X with |Y | = K2 + 1 such that for all (l, r), (l′, r′) ∈ Y , pcl = pcl′, +pcr = pcr′ , and z[l, r] ̸= z[l′, r′]. We say (l, r) < (l′, r′) if z[l, r] precedes z[l′, r′] in +the lexicographical order. Therefore, the elements in Y have an ordering as follows: +(l0, r0) < (l1, r1) < · · · < (lK2, rK2). +For all i ∈ [0, K2], let ui = z[1, li], xi = +z[li, ri], wi = z[ri, ℓ], configurations ei, fi be such that c +ui +−→ ei +xi +−→ fi +wi +−→ g and +matrices Ai, Mi, Bi be such that xei = xcAi , xfi = xeiMi , xg = xfiBi. +We know that for all i ∈ [0, K2], xcAiMiBi ∈ V. +Consider the sequence of +matrices M0, M1, · · · , MK2. From Lemma 4 we know that there exists an i ∈ [0, K2− + +ONE DETERMINISTIC-COUNTER AUTOMATA +19 +1] and j < i such that xcAiMjBi ∈ V. Note that the word uixjwi precedes z in +the lexicographical ordering. Therefore the run c +uixjwi +−−−−→ V × S × {m} contradicts +minimality of z. +□Claim:1 +Since |W| ≤ K4 and |X| > K4, there exists i, j ∈ [0, K4], with i < j and x ∈ Σ∗ +such that (li, ri) ∈ X, (lj, rj) ∈ X and x = w[li, ri] = w[lj, rj]. Let u1, w1, u2, w2 ∈ +Σ∗ such that z = u1xw1 = u2xw2. Since u1 ̸= u2, either u1 is a prefix of u2 or u2 a +prefix of u1. Without loss of generality, let us assume u1 is prefix of u2. Therefore, +there exists v ∈ Σ∗ such that u2 = u1v. Let e be a configuration such that c +u1 +−→ e. +Claim 2. |u1|, |v|, |w1| ≤ 3K6. +Proof: Consider the set X. For any i, j ∈ [0, K4], with i < j, ncli − nclj ≤ K4 + 1 +and ncrj − ncri ≤ K4 + 1. Therefore the counter-effect of u2 and w2 can be at +most K4. So the counter-effect of v with respect to counter state pe can be at most +K4. Since it is a minimal floating run from Lemma 21, we get that |v| ≤ 3K6. By +similar arguments, the counter-effect of u1 and w1 can be at most K4, and again +by Lemma 21, we get that their lengths are at most 3K6. +□Claim:2 +u1 +x +w1 +u2 +x +w2 +v +v +v +v +v +v +v′ +v +v +v +v +v +v +v′ +Figure 6. The figure shows the factorisation of a word z = +u1xw1 = u2xw2, where x is an overlapping factor. +The factor +v is a prefix of x such that u2 = u1v. The word z can be written +as u1viv′w2 for some i ∈ N and v′ prefix of v. +Claim 3. There exists v′ ∈ Σ∗ and r ∈ [0, K2 · |nc − m| + K6] such that x = vrv′ +with |v′| ≤ |v|. +Proof: Let r ∈ N be the largest number such that x is of the form vrv′ for some +v′ ∈ Σ∗ (see Figure 6). +We know that z = u2xw2 and u2 = u1v. +Therefore, +z = u1vxw2 = u1vvrv′w2 = u1vrvv′w2. Furthermore, z = u1xw1 = u1vrv′w1. Now +since u1vrvv′w2 = u1vrv′w1, we get that vv′w2 = v′w1. Hence, if |v′| ≥ |v|, then v +is a prefix of v′. This is a contradiction since r was chosen to be the largest number +such that x is of the form vrv′. +In order to show the bound on the value r, we observe the following. We know +that the counter effect of the run π(x, e) is d. Therefore from Lemma 21 Point 2, +we get that |x| ≤ K2 · (|d| + 2K4). Therefore, the value of r is less than or equal to +K2 · (|d| + 2K4). +□Claim:3 +From Claim 3 and Claim 2, we get that |u1v′w1| ≤ 9K6 and z = u1vrv′w1 +for some r ∈ [0, K2 · (|d| + 2K4)]. +Note that the factor v might start and end +in different counter states during the run and, therefore need not always have a +negative counter effect. However, we also know that the word vr has a negative +counter effect. For i ∈ [1, 2K], let gi be the configuration such that e +vi +−→ gi. By + +20 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +Pigeon-hole principle there exists j, k ∈ [1, 2K] with j < K and k − j ≤ K such that +pgj = pgk. Also, note that the word y = vk−j has a negative counter-effect from +the counter state pgj. Let r′ = r−j +k−j and j′ = (r − j) (mod (k − j)). Now consider +the word z = u1vjyr′vj′v′w1. Since |u1|, |w1|, |v| ≤ 3K6, j < K and k − j ≤ K, we +get that |u1vj| ≤ 3K7, |vj′v′w1| < 6K7, |y| ≤ 3K7 and r′ ∈ [0, K2 · (|d| + 2K4)]. +□ +Lemma 23. If z ∈ Σ∗ is the lexicographically minimal reachability witness for +(c, V, S, {m}), then there exists u, y1, v1, v2, v3, y2, w ∈ Σ∗ and r1, r2 ∈ N such that +(1) z = uyr1 +1 v1v2v3yr2 +2 w, +(2) |uy1v1v2v3y2w| ≤ 25K7, +(3) r1, r2 ≤ max{m, nc} · K2 + K6, +(4) π(uyr1 +1 v1, c) and π(v3yr2 +2 w, d) are floating runs for configuration d where +c +uyr1 +1 v1v2 +−−−−−−→ d. , and +(5) ce(π(uyr1 +1 v1, c)) = ce(π(uyr1 +1 v1v2, c)) = −nc. +Proof. Let z ∈ Σ∗ be the lexicographically minimal reachability witness for (c, V, S, +{m}). Consider the run of word z from c. Let d ∈ V × S × {m} such that c +z−→ d. +Let c = c1 and T (c1) = c1τ1c2 · · · τℓ−1cℓ denote the run on word z from the +configuration c1 and T the corresponding sequence of transitions. Let e1 be the first +configuration with counter value zero and e2 be the last configuration with counter +value zero during this run. Let z1, z2, z3 ∈ Σ∗ be such that c +z1 +−→ e1 +z2 +−→ e2 +z3 +−→ cℓ +and z = z1z2z3. Observe that c +z1 +−→ e1 and e2 +z3 +−→ cℓ are floating runs. +From Lemma 22, we know that there exists u1, u3, v1, v3, y1, y3 ∈ Σ∗ and r1, r3 ∈ +N such that z1 = u1yr1 +1 v1, z3 = u3yr3 +3 v3, |u1|, |u3| ≤ 3K7, |v1|, |v3| ≤ 6K7, |y1|, |y3| ≤ +3K7, r1 ∈ [0, nc · K2 + K6] and r3 ∈ [0, m · K2 + K6]. Also, from Lemma 20 we get +that |z2| ≤ K6. +□ +We now prove that the binary co-VS reachability and co-VS coverability prob- +lems are in NP. From Lemma 23 we observe there is a polynomial-size encoding +of the lexicographically minimal word (where r1 and r2 are in binary). A non- +deterministic machine can guess this encoding and verify the reachability in poly- +nomial time since Mr can be computed in log(r) time (see Lemma 2). A detailed +proof is given below. +Proof of Theorem 19. Let us first look at the binary co-VS reachability problem. +Let z ∈ Σ∗ be the lexicographically minimal reachability witness for (c, V, S, {m}). +Consider the run of word z from c. Let d ∈ V×S×{m} such that c +z−→ d. Let c = c1 +and T (c1) = c1τ1c2 · · · τℓ−1cℓ denote the run on word z from the configuration c1 +and T the corresponding sequence of transitions. Let e1 be the first configuration +with counter value zero and e2 be the last configuration with counter value zero +during this run. +Let z1, z2, z3 ∈ Σ∗ be such that c +z1 +−→ e1 +z2 +−→ e2 +z3 +−→ cℓ and +z = z1z2z3. Observe that c +z1 +−→ e1 and e2 +z3 +−→ cℓ are floating runs. +From Lemma 22, we know that there exists u1, u3, v1, v3, y1, y3 ∈ Σ∗ and r1, r3 ∈ +N such that z1 = u1yr1 +1 v1, z3 = u3yr3 +3 v3, |u1|, |u3| ≤ 3K7, |v1|, |v3| ≤ 6K7, |y1|, |y3| ≤ +3K7, r1 ∈ [0, nc · K2 + K6] and r3 ∈ [0, m · K2 + K6]. Also, from Lemma 20 we get +that |z2| ≤ K6. +Our NP algorithm starts by guessing the words u1, y1, v1, z2, u3, y3, v3, the values +r1, r2, and the configurations e1 and e2. We first show how to verify if c +u1yr1 +1 v1 +−−−−−→ e1. + +ONE DETERMINISTIC-COUNTER AUTOMATA +21 +The algorithm computes configuration f0 such that c +u1 +−→ f0. Now it constructs +the matrix My1 and computes the configuration f1 such that f0 +y1 +−→ f1 and xf1 = +xf0My1. +From Lemma 2, we know that (My1)r1 can be computed by repeated +powering in time polynomial in log(r1) and K. Let fr1 be a configuration such +that f0 +yr1 +−−→ fr1. From Lemma 22, we know that pf0 = pfr1 and nfr1 = pf0 − +r1 · (nf0 − nf1). Since xfr1 = xf0(My1)r1, we can construct the configuration fr1 +in polynomial time. We now verify in polynomial time whether fr1 +v1 +−→ e1 or not. +We can verify if e2 +u3yr3 +3 v3 +−−−−−→ d in a similar manner. The algorithm can also check +whether e1 +z2 +−→ e2 in polynomial time since |z2| ≤ K6. It finally checks whether +d ∈ V × S × {m}. Hence the binary co-VS reachability problem is decidable in NP. +As for the binary co-VS coverability problem, either the run of a minimal witness +is a floating run or is not. +In the former case where the run is floating, from +Lemma 17, we know that the difference between the final and initial counter values +is at most K2. In the latter case where the run is grounded, by Lemma 17, we get +that the final value is at most K2. In both the cases, the algorithm guesses the final +counter value, and the problem is reduced to the co-VS reachability problem, which +is in NP. Hence the binary co-VS coverability problem is decidable in NP. +□ +4. Equivalence of weighted odca +In this section, we give a polynomial time algorithm to check the equivalence of +two weighted odcas (Theorem 1). The algorithm returns a minimal distinguishing +word if the odcas are non-equivalent. We use the reachability results presented +in the previous section to show that the length of a minimal distinguishing word +is short. The idea here is to prove that the maximum counter value encountered +during the run of a minimal witness is polynomially bounded. We use this to reduce +the equivalence problem to that of weighted automata. +In the remainder of this section, we fix two weighted odcas A1 and A2 over an +alphabet Σ and a field F. For i ∈ {1, 2}, +Ai = (Ci, δi, p0i; Qi, λi, ∆i, ηi). +Without loss of generality assume K = |C1| = |Q1| = |C2| = |Q2|. We will reason +on the synchronised runs on pairs of configurations. Given two weighted odcas, +A1 and A2 and i ∈ N, we denote a configuration pair as hi = ⟨ci, di⟩ where ci is a +configuration of A1 and di is a configuration of A2. We similarly consider transition +pairs of A1 and A2, and consider synchronised runs as the application of a sequence +of transition pairs to a configuration pair. We fix a minimal word z (also called +witness) that distinguishes A1 and A2 and ℓ = |z|. Henceforth we will denote by +Π = h0τ0h1 · · · τℓ−1hℓ +the run pair of z from the initial configuration pair. We denote by T = τ0 · · · τℓ−1 +the sequence of transition pairs of this run pair. +To prove Theorem 1, we use +the following lemma, which states that the counter values in Π are bounded by a +polynomial poly0(K). +Lemma 24. There is a polynomial poly0 : N → N such that if two weighted odcas +A1 and A2 are not equivalent, then there exists a witness z such that the counter +values encountered during the run of z are less than poly0(K). + +22 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +We use Lemma 24 to show that the length of the witness z is bounded by a +polynomial poly1(K) = 2K5poly0(K). +Lemma 25. There is a polynomial poly1 : N → N such that if two weighted odcas +A1 and A2 are not equivalent, then there exists a witness z such that |z| is less than +or equal to poly1(K). +Proof. Assume for contradiction that the length of a minimal witness z is greater +than poly1(K). From Lemma 24, we know that the counter values encountered +during the run Π in less than poly0(K). Since |z| > poly1(K), by the Pigeonhole +principle, we get that there exist indices 0 ≤ i0 < i2 < · · · < i2K ≤ ℓ such that for +all configuration pairs hij, j ∈ [1, 2K], ncij = ncij−1 , ndij = ndij−1 , pcij = pcij−1 +and pdij = ndij−1 . +For all j ∈ [0, 2K] we define the vector xj ∈ F2K such that xj[r] = xcij [r], if r < +K and xdij [r − K], otherwise. We also define the vector η ∈ F2K such that η[r] = +η1[r], if r < K and η2[r − K], otherwise. For all j ∈ [0, 2K], let Aj denote the +matrix such that xjAj = xℓ. Since z is a minimal witness, we know that for all +j ∈ [0, 2K], xjAjη⊤ ̸= 0. From Lemma 4, we get that there exists r, r′ ∈ [0, 2K], +with r′ < r such that xr′Arη⊤ ̸= 0. The sequence of transitions τir+1 · · · τℓ can be +taken from hi′r since the counter values and counter states are the same for both +configurations. Consider the sequence of transitions T ′ = τ0 · · · τi′ +rτir+1 · · · τℓ and +let w = word(T ′). +The word w is a shorter witness than z and contradicts its +minimality. +□ +Lemma 25 helps us to reduce the equivalence problem of weighted odca to +that of weighted automata by “simulating” the runs of weighted odcas up to +length poly1(K) by two weighted automata. The naive algorithm will only give us +a PSPACE procedure, but there is a polynomial time procedure to do this, and the +proof is given below. +Proof of Theorem 1. We consider the two weighted odcas A1 and A2. +From +Lemma 25, we know that the length of the minimal witness z is less than poly1(K). +Let M = poly1(K). We construct the M-unfolding weighted automata AM +1 and AM +2 +as described in Definition 7. It follows that, A1 is non-equivalent to A2 if and only +if there exists a word w ∈ Σ≤M such that fAM +1 (w) ̸= fAM +2 (w). Tzeng [20, Lemma +3.4] gives a polynomial time algorithm to output a minimal word that distinguishes +two probabilistic automata. We conclude the proof by noting that the algorithm +can be extended to the case of weighted automata. +□ +The rest of this section is dedicated to proving Lemma 24. We adapt techniques +developed by B¨ohm et al. [3] for ocas. We start by labelling some configuration +pairs as background points (see Figure 7). Consider the case where there is no +background point in Π. By reducing the problem to co-VS reachability/coverability +we show that the counter values in Π are polynomially bounded. Now consider the +case where there is a background point hj in Π. We show that the counter values +encountered during the run of Π till hj is polynomially bounded. This is shown by +Lemma 29 and Lemma 35. We conclude by arguing that the length of the run from + +ONE DETERMINISTIC-COUNTER AUTOMATA +23 +hj is polynomially bounded. +counters poly-bounded +� +�� +� +h0τ0h1τ1h2 · · · hj−1τj−1 +hj = ⟨cj, dj⟩ +� +�� +� +1st configuration pair in +background space +counters +poly-bounded +� +�� +� +τj · · · τℓ−1hℓ +4.1. Configuration Space. Each pair of configuration h = ⟨c, d⟩ is mapped to a +point in the space N × N × (C1 × C2) × FK × FK, henceforth referred to as the +configuration space. Here, the first two dimensions represent the two counter val- +ues, the third dimension C1 × C2 corresponds to the pair of counter states, and the +remaining dimensions represent the weight vector. The projection of the configu- +ration space onto the first two dimensions is depicted in Figure 7. We partition +the configuration space into three: initial space, belt space, and background space. +The size of the initial space and, thickness and number of belts will be polynomially +bounded in K. This partition is indexed on two polynomials, poly2 : N → N and +poly3 : N → N chosen so that all belts are disjoint outside the initial space. We use +some properties of these partitions to show that the length of a minimal witness +is bounded. We assume poly2(K) = 516K21 and poly3(K) = 42K14. The precise +polynomials are required in the proofs of Lemma 26 and Lemma 32. +• initial space: All configuration pairs ⟨c, d⟩ such that nc, nd < poly2(K). +• belt space: Let α, β ∈ [1, 3K7] be co-prime. +A belt of slope +α +β consists +of those configuration pairs ⟨c, d⟩ outside the initial space that satisfies +|α.nc − β.nd| ≤ poly3(K). The belt space contains all configuration pairs +⟨c, d⟩ that is inside belts with slope α +β . +• background space: All remaining configuration pairs. +N +N +initial space +background space +belt space +belt space +belt space +poly2(K) +poly3(K) +Figure 7. Projection of configuration space +The proof of the following lemma is similar to that of the non-weighted case +presented in [3]. +Lemma 26. If ⟨c, d⟩ and ⟨e, f⟩ are configuration pairs inside two distinct belts and +lie outside the initial space, then there is no a ∈ Σ such that ⟨c, d⟩ +a−→ ⟨e, f⟩. + +24 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +Proof. Recall poly2(K) = 516K21 and poly3(K) = 42K14. Let B and B′ be two +distinct belts with µ being the slope of the belt B and µ′ the slope of the belt B′. +Hence µ ̸= µ′. Without loss of generality, let us assume that µ′ > µ. It suffices to +show that for all x > poly2(K), we have +µx + poly3(K) + 1 < µ′x − poly3(K) − 1. +We know that µ′ − µ ≥ +1 +3K7 and x > 516K21. +Therefore, 516K21 +6K7 +< (µ′ − µ) · x. +=⇒ µx + 86K14 +2 +< µ′x − 86K14 +2 +=⇒ µx + 42K14 + K14 < µ′x − 42K14 − K14 +=⇒ µx + 42K14 + 1 < µ′x − 42K14 − 1 +□ +Lemma 26 ensures that the belts are disjoint outside the initial space and that +no run can go from one belt to another without passing through the initial space +or background space. +4.2. Belt space. We look at two scenarios in this section. First, we show that if +a sub-run of the run of a minimal witness enters and exists a belt from the initial +space, then the counter values encountered during this sub-run are polynomially +bounded in K. Secondly, we show that if the run of a minimal witness never enters +the background space, then the counter values encountered during this run are +polynomially bounded in K. This is shown by reducing to co-VS reachability of an +odca. +Let Πb = hiτihi+1 · · · τj−1hj be a sub-run of the run of z inside a belt with slope +α +β . Similar to the technique mentioned in [5], each configuration pair hr, where +r ∈ [i, j] can alternatively be presented as ((xcr, xdr), pcr, pdr, lr) where lr denotes +a line with slope α +β inside the given belt that contains the point (ncr, ndr). Let L be +the set of all lines with slope α +β inside the given belt. Note that |L| = poly3(K). The +run Πb is similar to the run of a weighted odca D that has the tuple (pcr, pdr, lr) +as the state of the finite state machine and xr ∈ F2K as its weight vector where +xr[i] = xcr[i], if i < K and xr[i] = xdr[i − K], otherwise. A formal definition of the +odca D is given below. +Definition 27. Let Ai = (Ci, δi, p0i; Qi, λi, ∆i, ηi) for i ∈ {1, 2}, be the two +odcas given. Let L be the set of all lines with slope α +β inside the given belt. We +define the odca D = (C, δ, p0; Q, λ, ∆, η), where the initial state p0 and the initial +distribution λ are arbitrarily chosen. +• C = C1 × C2 × L is a non-empty finite set of states. +• δ : C × Σ → C × {−1, 0, +1} is the deterministic counter transition. Let +p1, q1 ∈ C1, p2, q2 ∈ C2, a ∈ Σ and d1, d2 ∈ {−1, 0, +1}. Let l1, l2 ∈ L and +m1, m2 ∈ N, such that the point (m1, m2) lies on the line l1. δ((p1, p2, l1), a) = +((q1, q2, l2), d1), if δ1(p1, a, 1) = (q1, d1) and δ2(p2, a, 1) = (q2, d2) and the +point (m1 + d1, m2 + d2) lies on the line l2. It is undefined otherwise. +• Q = Q1 ∪ Q2 is a non-empty finite set of states of the finite state machine. + +ONE DETERMINISTIC-COUNTER AUTOMATA +25 +• ∆ : C × Σ × {0, 1} → F2K×2K gives the transition matrix for all p ∈ C, +a ∈ Σ and d ∈ {0, 1}. For p1 ∈ C1, p2 ∈ C2, l ∈ L, m ∈ N and a ∈ Σ, +∆((p1, p2, l), a)[i][j] = + + + + + + + + + + + +∆(p1, a, 1)[i][j], if i, j < K +∆(p2, a, 1)[i +− +K][j +− +K], +if i, j > K +0, otherwise +• η ∈ F2K is the final distribution. +η[i] = +� +η1[i], if i < K +η2[i − K], otherwise +The sub-run Πb can now be seen as a floating run of a weighted odca D. If +the run Π ends inside a belt, then Πb = hiτi · · · τℓ−1hℓ. In this case, we show that +the difference between the counter values of the first and last configuration pairs is +smaller than a polynomial in K. +Lemma 28. There is a polynomial poly : N → N, such that if Πb = hiτi · · · τℓ−1hℓ +lies inside a belt, then |ncℓ − nci| ≤ poly(K) and |ndℓ − ndi| ≤ poly(K). +Proof. Let Πb = hiτihi+1 · · · τℓ−1hℓ be a sub-run of the run of a minimal wit- +ness inside a belt and ends in the belt. As mentioned in Definition 27, we con- +sider this as the run of the weighted odca D. Since it is the run of a witness, +xjη⊤ ̸= 0. Consider the vector space U = {y ∈ F2K | yη⊤ = 0}. Our problem +now reduces to the co-VS coverability problem in machine D and asks whether +(xi, (pci, pdi, li), nci) +∗−→ U × {(pcℓ, pdℓ, lℓ)} × N. From Lemma 20, we know that the +length of a minimal reachability witness for ((xi, (pci, pdi, li), nci), U, (pcℓ, pdℓ, lℓ), N) +is polynomially bounded in nci and K. Hence proved. +□ +In the following lemma, we show that if Πb = hiτihi+1 · · · τj−1hj is a sub-run of +Π inside a belt and either nci = ncj or ndi = ndj, then the counter values in Πb +cannot increase more than a polynomial in K from nci and ndi. +Lemma 29. There is a polynomial poly : N → N such that, if Πb = hiτihi+1 · · · τj−1hj +is a run inside a belt with nci = ncj or ndi = ndj, then the counter effect of any +sub-run of Πb is less than or equal to poly(K). +Proof. Let Πb = hiτihi+1 · · · τj−1hj be a sub-run of the run of a minimal witness +inside a belt such that nci = ncj. We consider this as the run of the weighted +odca D as mentioned in Definition 27. Since it is the run of a witness, we know +that there exists A ∈ F2K×2K such that xjAη⊤ ̸= 0. Consider the vector space +U = {y ∈ F2K | yAη⊤ = 0}. +Our problem now reduces to the co-VS reachability problem in machine D and +asks whether (xi, (pci, pdi, li), nci) +∗−→ U × {(pcj, pdj, lj)} × {nci}. From Lemma 20, +length of a minimal reachability witness for ((xi, (pci, pdi, li), nci), U, (pcj, pdj, lj), +{nci}) is bounded by a polynomial in nci and K. Hence proved. +□ +We have now shown that if the run of a minimal witness does not enter the +background space, then the counter values in this run are polynomially bounded in +K. Now we look at the case where the run enters the background space. + +26 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +4.3. Background space. In this subsection, we consider the case where the run of +a minimal witness enters the background space. We show that during the run of the +minimal witness the counter values of the first configuration pair in the background +space and the remaining length of the run is polynomially bounded in K. +Floating runs of a weighted ODCA are isomorphic to runs of a weighted au- +tomaton obtained by ignoring counter values. In order to bound the length of the +run of a minimal witness in the background space, we introduce the notion of an +underlying uninitialised weighted automaton. +Definition 30. For l ∈ {1, 2}, the underlying uninitialised weighted automaton of +A is the uninitialised weighted automaton U(Al) = (Q′ +l, ∆′ +l, η′ +l), where Q′ +l = Cl ×Ql +and η′ +l ∈ FK2 is the final distribution. +For i < K2, η′ +l[i] = ηl[i mod K]. +The +transition matrix is given by ∆′ +l : Σ → FK2×K2. Let a ∈ Σ, d ∈ {−1, 0, +1}, i, j < +K2, +∆′ +l(a)[i][j] = + + + + + +∆l(p i +K , a, 1)[i mod K][j mod K], +if δl(p i +K , a, 1) = (p j +K , d) +0 otherwise +Note that a configuration of U(Al) is a vector of dimension K2. A configuration +c of a weighted odca A is said to be k-equivalent to a configuration ¯c of an +uninitialised weighted automata B, denoted c ∼k ¯c, if for all w ∈ Σ≤k, fA(w, c) = +fB(w, ¯c). We say that c is not k-equivalent to ¯c otherwise and denote this as c ̸∼k ¯c. +As we need to test the equivalence of configurations from A1 and A2, we con- +sider the uninitialised weighted automata B, which is a disjoint union of U(A1) +and U(A2). This gives us a single automaton with which we can compare their +configurations. +Let i ∈ {1, 2} and c be a configuration of Ai. For all p ∈ Ci and +m < 2K2, we define the sets Wp,m +i +. The set Wp,m +i +contains vectors x ∈ FK such +that the configuration (x, p, m) is 2K2-equivalent to some configuration of B. The +set W +p,m +i +is the set FK \ Wp,m +i +. Formally, +Wp,m +i += {x ∈ FK|∃¯c ∈ F2K2, c = (x, p, m) ∼2K2 ¯c} +Lemma 31. For any i ∈ {1, 2}, p ∈ Ci and m < 2K2, the set Wp,m +i +is a vector +space. +Proof. To prove this, it suffices to show that it is closed under vector addition and +scalar multiplication. We fix a set Wp,m +i +. First, we prove that it is closed under +scalar multiplication. +For any vector z1 ∈ Wp,m +i +, we know that there exists a +configuration c = (z1, p, m) and ¯c ∈ F2K2 such that c ∼2K2 ¯c. Now, for any scalar +r ∈ F, the configuration (r.z1, p, m) ∼2K2 r · ¯c. Therefore r · z1 ∈ Wp,m +i +. Now, we +show that it is closed under vector addition. Let z1, z2 ∈ Wp,m +i +be two vectors. +Therefore, there exists configurations c1 = (z1, p, m), c2 = (z2, p, m), ¯c1 ∈ F2K2 +and ¯c2 ∈ F2K2, such that c1 ∼2K2 ¯c1 and c2 ∼2K2 ¯c2. Consider the configuration +c3 = (z1 + z2, p, m), c3 ∼2K2 ¯c1 + ¯c2. Therefore, z1 + z2 ∈ Wp,m +i +. +□ +The distance of a configuration c of Ai is the length of a minimal word that +takes you from c to a configuration (x, p, m) for some m < 2K2 and p ∈ Ci such +that x ∈ W +p,m +i +. We define distAi(c) as: +min{|w| | c +w +−→ (x, p, m) ∃p ∈ Ci, m < 2K2, x ∈ W +p,m +i +} + +ONE DETERMINISTIC-COUNTER AUTOMATA +27 +The notion of distance play a key role in determining which parts of the run +of a witness can be pumped out if it is not minimal. The following lemma is a +crucial component in proving the equivalence of weighted odca. By Lemma 22, +the lexicographically minimal reachability witness has a special form and this plays +a crucial role in proving Lemma 32. +Lemma 32. Let c be a configuration of weighted odca A. If distA(c) < ∞ then, +distA(c) = a +b nc + d where a, b ∈ [0, 3K7] and |d| < 42K14. +Proof. Without loss of generality, let us consider the weighted odca A1 and a +configuration c of A1. Let us assume that distA1(c) < ∞. This means that c →∗ d +with xd ∈ W +p,m +1 +for some p ∈ C1 and m < 2K2. Since nd = m, by Lemma 22, we +know that there is a word u = u1ur +2u3 (with r ≥ 0) such that that c +u−→ d where +|u| = distA1(c), |u1u3| ≤ 9K7, |u2| ≤ 3K7 and u2 has a negative counter effect ℓ. +Let g be the combined counter effect of u1, u3 and α = |u2| +ℓ . Since |u1u3| ≤ 9K7, +we have |g| ≤ 9K7. +distA1(c) = nc − nd − g +ℓ +|u2| + |u1u3| += αnc − α(nd + g) + |u1u3| +� +�� +� +d +Since 1 ≤ α ≤ 3K7 it follows that −42K14 < d < 42K14. Hence proved. +□ +The polynomials poly1 and poly2 were picked so that the configuration pairs +with equal distance always lie in the belt space. Therefore, the background space +points either have unequal or infinite distances. +Lemma 33. For any configuration pair ⟨c, d⟩, in the background space, either +distA1(c) ̸= distA2(d) or distA1(c) = distA2(d) = ∞. +Proof. Assume for contradiction that there is a configuration pair ⟨c, d⟩, in the back- +ground space such that distA1(c) = distA2(d) < ∞. Since distA1(c) = distA2(d). +From Lemma 32, there exists a1, b1, a2, b2 ∈ [0, 3K7] and d1, d2 < 42K14 such that +a1 +b1 +nc + d1 = distA1(c) = distA1(d) = a2 +b2 +nd + d2 +Therefore | a1 +b1 nc − a2 +b2 nd| ≤ |d2 −d1| < 42K14. This satisfies the belt condition and is +a configuration pair in the belt space. This contradicts our initial assumptions. +□ +The following lemma shows that the length of the run Π in the background space +is polynomially bounded in K and the counter values of the first background point +in Π. The proof is similar to that in [3] and is given below. +Lemma 34. If hj = ⟨cj, dj⟩ is the first configuration pair in the background space +during Π, then ℓ − j is bounded by a polynomial in ncj, ndj and K. +Proof. Let hj = ⟨cj, dj⟩ be the first configuration pair in the background space +during the run Π, then from Lemma 33, either distA1(cj) = distA2(dj) = ∞ or +distA1(cj) ̸= distA2(dj). We separately consider the two cases. +Case-1, distA1(cj) = distA2(dj) = ∞: then we prove that the remaining length +of the witness from ⟨cj, dj⟩ is bounded by 2K2. Assume for contradiction that this +is not the case and cj ∼2K2 dj but cj ̸≡ dj. Let v ∈ Σ>2K2 be the word which + +28 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +N +N +⟨c, d⟩ +⟨e, f⟩ +Figure 8. The figure depicts an α-β repetition inside a belt with +slope α +β . The configuration pairs ⟨c, d⟩ and ⟨e, f⟩ are α-β-related. +i.e., they line on a line with slope α +β , pc = pe and pd = pf. +distinguishes c and d. +Therefore, there exists a prefix of v, u ∈ Σ|v|−2K2, and +i = ℓ − 2K2 such that ⟨cj, dj⟩ +u−→ ⟨ci, di⟩ and ci ̸≡2K2 di. +Since v is a minimal witness ci ≡2K2−1 di and ci ̸≡2K2 di. Since distA1(cj) = +distA2(dj) = ∞, there exists configurations ¯ci and ¯di in the underlying automa- +ton B such that ci ∼2K2 ¯ci and di ∼2K2 ¯di. Since ci ≡2K2−1 di, it follows that +¯ci ∼2K2−1 ¯di. From the equivalence result of weighted automata, we know that if +two configurations of a weighted automata with k states are non-equivalent, then +there is a word of length less than k which distinguishes them. Therefore, this is +sufficient to prove that the underlying weighted automata with ¯ci and ¯di as initial +distributions are equivalent, and thus ¯ci ∼2K2 ¯di. This allows us to deduce that +ci ≡2K2 di, which is a contradiction. Therefore, the remaining length of the witness +from ⟨cj, dj⟩ is bounded by 2K2. +Case-2, distA1(cj) ̸= distA2(dj): Without loss of generality, we suppose distA1(cj) +> distA2(dj). +By definition of distA2, there exists u ∈ ΣdistA2 (dj), i > j and +a configuration ¯c of the underlying automaton B such that cj +u−→ ci, dj +u−→ di, +ci ∼2K2 ¯ci and di ̸∼2K2 ¯ci. +Therefore ci ̸≡2K2 di. +By definition, there exists +v ∈ Σ≤2K2 such that fA1(v, ci) ̸= fA2(v, di) and hence fA1(uv, cj) ̸= fA2(uv, dj). +As uv ∈ ΣdistA2(dj)+2K2, we get that cj ̸≡distA2 (dj)+2K2 dj. +Therefore, there is +w ∈ Σ≤min{distA1 (cj),distA2 (dj)}+2K2 that distinguishes cj and dj. +□ +Let α, β ∈ [1, 3K7] be co-prime. We say configuration pairs ⟨c, d⟩ and ⟨e, f⟩ are +α-β related if pc = pe, pd = pf and α·nc −β ·nd = α·ne −β ·nf. Roughly speaking, +two configuration pairs are α-β related if they have the same state pairs and lie on +a line with slope α +β . An α-β repetition is a run ¯π1 = ciτici+1τi+1 · · · τj−1cj that lies +inside a belt with slope α +β such that ci and cj are α-β related. +The following +lemma bounds the counter values of the first configuration in the background space, +if it exists, during the run Π. +Lemma 35. If hj is the first background point in Π then, counter values of hj are +less than K5 · 42K14. +Proof. Let hj be the first point in the background space during the run Π. Assume +for contradiction that ncj is greater than K5·42K14. Let Π = h0τ0 · · · hj−1τj−1hj · · · hℓ +be a run of a minimal witness. Since hj is the first point in the background space + +ONE DETERMINISTIC-COUNTER AUTOMATA +29 +N +N +Figure 9. The figure shows the run of a word that enters the +background space from the belt such that the counter values of +the first configuration pair in the background space exceed a poly- +nomial bound. +in this run and ncj > K5 · 42K14, there exists 0 < i < j such that the sub-run +Πb = hiτihi+1 · · · τj−2hj−1 lies inside a belt B with slope α +β for some α, β ∈ [1, 3K7]. +Since we are looking at the run of a minimal witness, from Lemma 33 either +cj ̸≡2K2 dj or dist(cj) ̸= dist(dj). We separately consider the two cases. +Case-1: +distA1(cj) ̸= distA2(dj): Without loss of generality, let us assume +distA1(cj) < distA2(dj). Therefore there exists t ∈ N with j < t ≤ ℓ and con- +figuration pair ht such that +m = nct < 2K2, p = pct and xct ∈ W +p,m +1 +. +We +show that we can pump some portion out from Πb to reach a configuration in the +background space with unequal distance and smaller counter values. +Since ncj > K5 · 42K14, by Pigeonhole principle, there exists indices i0 < i1 < +i2 < · · · , iK2 < i′ +0 < i′ +1 < i′ +2, · · · , < i′ +K2 such that for all r ∈ [1, K2], (1) hir−1 and +hir are α-β related and lie in belt B, (2) ncir−1 < ncir = nci′r , (3) pci′r = pci′ +r−1 , +(4) for all t ∈ N with ir < t < j, nct > ncir , and (5) for all t ∈ N with j < t < i′ +r, +nct < nci′r . +For r ∈ [0, K2] let Ar ∈ FK×K denote the matrix such that xcir Ar = xci′r and +Br ∈ FK×K denote the matrix such that xci′r Br = xct ∈ W +p,m +1 +. Therefore for all +r ∈ [0, K2], we have xcir ArBr ∈ W +p,m +1 +. From Lemma 4, we have that there exits +s, r ∈ [0, K2] with s < r such that xcisArBs ∈ W +p,m +1 +. Consider the sequence of +transitions T ′ = τ0, · · · , τis−1τir, · · · , τj−1 and let w = word(T ′). Let hj′ be the +configuration such that h0 +w +−→ hj′. Since we have removed an α-β repetitions inside +the belt, the configuration pair hj′ is a point in the background space (see Figure 9). +Moreover, ncj′ < ncj and distA1(cj′) < ∞. Since it is a point in the background +space, from Lemma 33, we get that distA1(cj′) ̸= distA2(dj′). Therefore, there is +a shorter path to a configuration in background space with smaller counter values +and unequal distance. This is a contradiction. +Case-2: cj ̸≡2K2 dj: Consider the sub-run Πb. Since it is a run inside a belt, +we can consider this as the run of the weighted odca D. Since ncj > K4 · 42K14, +by Pigeon-hole principle, there exists indices i0, i1, i2, · · · , iK2 such that for all r ∈ + +30 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +[1, K2], hir−1 and hir are α-β related with ncir−1 < ncir and for all t ∈ N with +ir < t < j, nct > ncir . +Since it is the run of a minimal witness, we know that there exists A ∈ F2K×2K +such that xj−1Aη⊤ +F ̸= 0. Consider the vector space U = {y ∈ F2K | yAη⊤ +F = 0}. +For r ∈ [0, K2], let Ar denote the matrices such that xirAr = xj ∈ U. +Since +xirAr ∈ U for all r ∈ [0, K2], from Lemma 4, we get that there exists r′ ∈ [0, r − 1] +such that xci′r Ar ∈ V. The sequence of transitions τir+1 · · · τℓ can be taken from hi′r +since the counter values always stay positive. Consider the sequence of transitions +T ′ = τ0 · · · τi′rτir+1 · · · τℓ and let w = word(T ′). The word w is a shorter witness +than z and contradicts its minimality. +□ +Finally, we prove that the counter values encountered during the run Π are +polynomially bounded in K using above lemmas. +Proof of Lemma 24. Consider the run Π. From Lemma 28, Lemma 29 and Lemma 35, +we get that the counter values of configuration pairs inside the belt space during +this run in polynomially bounded in K. Therefore, if it exists, the first background +point in Π has polynomially bounded counter values. From Lemma 34, the length +of Π after the first background point is polynomially bounded in K. Since initial +space is already bounded by a polynomial in K, the maximum counter value in Π +is polynomially bounded in K. +□ +5. Regularity of ODCA is in P +We say that a weighted odca A = (C, δ, p0; Q, λ, ∆, η) is regular if there is a +weighted automaton B that is equivalent to it. We look at the regularity problem +- the problem of deciding whether a weighted odca is regular. We fix a weighted +odca A = (C, δ, p0; Q, λ, ∆, η) and use N to denote |C| · |Q|. +The proof technique is adapted from the ideas developed by B¨ohm et al. [6] in +the context of real-time oca. The crucial idea in proving regularity is to check +for the existence of infinitely many equivalence classes. The proof relies on the +notion of distance of configurations. Distance of a configuration is the length of a +minimal word to be read to reach a configuration that does not have an N equivalent +configuration in the underlying automata. The challenge is to find infinitely many +configurations reachable from the initial configuration, so that no two of them have +same distance. Our main contribution is in designing a “pumping” like argument +to show this. +Theorem 36. There is a polynomial time algorithm to decide whether a weighted +odca is equivalent to some weighted automata. +Recall the definition of U(A) from Definition 30. +We use c to denote some +configuration of A and ¯c to denote some configuration of U(A). For a p ∈ C and +m ∈ N, we define +Wp,m = {x ∈ F|Q||∃¯c ∈ FN, c = (x, p, m) ∼N ¯c} . +The set W +p,m is F|Q|\Wp,m. The distance of a configuration c (denoted by dist(c)) +is +min{|w| | c +w +−→ (x, p, m) ∃p ∈ C, m < N, and x ∈ W +p,m} . +The following lemma shows when A is not regular. Clean up, move to appendix, +proof sketch. + +ONE DETERMINISTIC-COUNTER AUTOMATA +31 +Lemma 37. Let c be an initial configuration of an odca A. Then the following +are equivalent. +(1) A is not regular. +(2) for all t ∈ N, there exists configurations d, e s.t. ne < N,c +∗−→ d +∗−→ e, +xe ��� W +pe,ne and t < dist(d) < ∞. +(3) there exists configurations d, e and a run c +∗−→ d +∗−→ e s.t. N2 + N ≤ nd ≤ +2N2 + N, xe ∈ W +pe,ne with ne < N. +Proof. 3 → 2: Consider an arbitrary q ∈ C, m < N and vector space V = Wq,m. +Let us assume for contradiction the complement of Point 2. That is, there exists a +t ∈ N such that for all configurations d′ where c +∗−→ d′ +∗−→ V ×{q}×{m}, dist(d′) ≤ t. +Note that for all d′ where nd′ > N, dist(d′) ≥ nd′ −N. Hence there exists an M ∈ N +such that for all d′ where c +∗−→ d′ +∗−→ V × {q} × {m}, nd′ ≤ M. +Consider a configuration d where nd > N2+N and a run c +∗−→ d +∗−→ V ×{q}×{m}. +Point 3 shows the existence of such a run. For contradiction, it suffices to show +there exists a d′ such that c +∗−→ d′ +∗−→ V × {q} × {m} and nd′ > nd. +Let m = |Q|2 + 1. Since nd > N2 + N, by Pigeonhole principle, there exists set of +indices X = {i1, i2, · · · , im} such that for k, l ∈ [1, m] with k < l, we have ik < il, +and for all h, j ∈ X pch = pc′ +h = pcj = pc′ +j. Let uj, vj, wj be words such that for +all j ∈ X, c +uj +−→ cj +vj +−→ c′ +j +wj +−−→ e. For all j ∈ X, let matrix Aj and Bj be such +that xc′ +j = xcjAj and xe = xc′ +jBj. We know that for all j ∈ X, xcjAjBj ∈ V. List +the matrices Ai1, Ai2, . . . , Aim in sequence. From Lemma 4, it follows that, there +exists i, j ∈ X with i < j such that xcjAiBj ∈ V. Consider the run π(ujviwj, c1). +It contains a configuration d′ where nd′ > nd. +2 → 1: Assume for contradiction that for all t ∈ N, there exists configurations +d, e such that c +∗−→ d +∗−→ e, xe ∈ W +pe,ne, ne < N and t < dist(d) < ∞ but A is +regular. Let B be the weighted automaton equivalent to A. We use |B| to represent +the number of states of B. +Let t1, t2, . . . t|B|+1 ∈ N such that for i ∈ [1, |B|], ti < ti+1, and dti be such +that c +∗−→ dti +∗−→ (xi, pe, ne), xi ∈ W +pe,ne and ti < dist(dti) < ti+1 < ∞. Clearly +dti ̸≡ dtj for i ̸= j and hence corresponds to two different states of B. Since we +can find more than |B| pairwise non-equivalent configurations, it contradicts the +assumption that B is equivalent to A. +1 → 3: We prove the contrapositive of the statement. Let us assume that there +is no configurations d, e and a run c +∗−→ d +∗−→ e such that N2 + N ≤ nd ≤ 2N2 + N, +xe ∈ W +pe,ne with ne < N. This implies that there does not exists a configuration +d′ such that nd′ > 2N2, c +∗−→ d′ +∗−→ (y, pe, ne) for some y ∈ W +pe,ne. Assume for +contradiction that there is such a run, then there exists a portion in this run that +can be “pumped down” to get a run c +∗−→ d′′ +∗−→ (y′, pe, ne) for some configuration +d′′ such that N2 + N ≤ nd′′ ≤ 2N2 + N and y′ ∈ W +pe,ne. This is a contradiction. +Therefore all runs starting from configuration with counter value greater than or +equal to N2 + N “looks” similar to a run on a weighted automaton. This allows us +to simulate the runs of A using a weighted automaton. +□We now prove that the +regularity problem for weighted odca is decidable in polynomial time. +Proof of Theorem 36. Let A be a weighted odca. Lemma 37 shows that if A is +not regular, then there are words u, v ∈ Σ∗ and configurations d, e such that there + +32 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +is a run of the form c +u−→ d +v−→ e such that N2 + N ≤ nd ≤ 2N2 + N, xe ∈ W +pe,ne +with ne < N. The existence of such words u and v can be decided in polynomial +time since the minimal length of such a path if it exists, is polynomially bounded +in the number of states of the weighted odca by Lemma 20. This concludes the +proof. +□ +6. Covering +Let A1 and A2 be two uninitialised weighted odcas. +We say A2 covers A1 +if for all initial configurations c0 of A1 there exists an initial configuration d0 of +A2 such that A1⟨c0⟩ and A2⟨d0⟩ are equivalent. We say A1 and A2 are coverable +equivalent if A1 covers A2 and A2 covers A1. +We show that the covering and +coverable equivalence problems for uninitialised weighted odcas are decidable in +polynomial time. The proof relies on the algorithm to check the equivalence of two +weighted odcas and is given below. +Theorem 38. Covering and coverable equivalence problems of uninitialised weighted +odcas are in P. +Proof. We fix two uninitialised weighted odcas A1 = (C1, δ1; Q1, ∆1, η1) and +A2 = (C2, δ2; Q2, ∆2, η2) for this section. +Without loss of generality, assume +K = |C1| = |Q1| = |C2| = |Q2|. For i ∈ [1, K] we define the vector ei ∈ FK as +follows: +ei[j] = +� +1, if i = j +0, otherwise +For j ∈ [1, K], q ∈ C1, we use hj,q to denote the configuration (ej, q, 0) of A1 and +for i ∈ [1, K], p ∈ C2, we use gi,p to denote the configuration (ei, p, 0) of A2. +Claim 1. There is a polynomial time algorithm to decide whether A2 covers A1⟨hj,q⟩ +for any j ∈ [1, K] and q ∈ C1. +Proof: First, we check, in polynomial time (equivalence with a zero machine), +whether A1⟨hj,q⟩ accepts all words with weight 0 ∈ F. If that is the case, then +A1⟨hj,q⟩ and A2⟨g0⟩ are equivalent for the configuration g0 = ({0}K, p, 0), for any +p ∈ C2. Otherwise, there is some word w0 accepted by A1⟨hj,q⟩ with non-zero +weight s (returned by the previous equivalence check). Without loss of generality, +we consider the smallest one, whose size is polynomial in K. +We pick a p ∈ C2 and check whether there exists an initial distribution from +counter state p that makes the two machines equivalent. +Assume that such an +initial distribution exists and for all i ∈ [1, K], let αi denote the initial weight on +state qi ∈ Q2. We use α to denote the resultant initial distribution. We initialise +an empty set B to store a system of linear equations. +The following steps will be repeated at most K times to check the existence of an +initial distribution with initial state p ∈ C2. Let w be the counter-example returned +by the equivalence query in the previous step. +For all i ∈ [1, K], we compute +fA2⟨gi,p⟩(w). We add the linear equation �K +i=1 αi · fA2⟨gi,p⟩(w) = fA1⟨hj,q⟩(w) to +B and compute values for αi, i ∈ [1, K], such that it satisfies the system of linear +equations in B. We check whether A1⟨hj,q⟩ and A2⟨(α, p, 0)⟩ are equivalent or not. +If they are not equivalent, we get a new counter example that distinguishes them. +Now we repeat the procedure to compute a new initial distribution. + +ONE DETERMINISTIC-COUNTER AUTOMATA +33 +Note that the above procedure is executed at most K times to find an initial dis- +tribution if it exists. This is because we can find only K many linearly independent +linear equations in K variables. Suppose the above procedure fails to find an initial +distribution for which the machines are equivalent. In that case, there is an initial +distribution of A1 with initial counter state q, for which A2 with initial counter +state p does not have an equivalent initial distribution. We now pick a different +counter state of C2 and repeat the process until we find a p ∈ C2 for which the +algorithm finds an equivalent initial distribution. If for all p ∈ C2, the algorithm +returns false, then A2 does not cover A1⟨hj,q⟩. +□Claim:1 +First, we show the existence of a polynomial time procedure to check whether A2 +covers A1. For all j ∈ [1, K], we check whether there exists an initial state p ∈ C2 +such that A2 with initial counter state p has an initial distribution that makes it +equivalent to A1⟨hj,q⟩ using Claim 1. If we fail to find such a state in C2 then +we return false. We repeat this procedure for all q ∈ C1. If for all q ∈ C1 there +exists a p ∈ C2 such that A2 with initial counter state p has an initial distribution +that makes it equivalent to A1⟨hj,q⟩ for all j ∈ [1, K], then we say that A2 covers +A1 otherwise we say that A2 does not cover A1. Let us see why this is true. For +simplifying the arguments we fix a q ∈ C1. Assume that for all j ∈ [1, K], there +exits p ∈ C2 such that A1⟨hj,q⟩ is equivalent to the configuration (xj,q, p, 0) for +some xj,q ∈ FK. Now, any initial configuration (λ, q, 0) of A1 is equivalent to the +configuration (�K +j=1 λ[j] · xj,q, p, 0) of A2. +The coverable equivalence problem can now be solved by checking whether A1 +covers A2 and A2 covers A1, which can be done in time polynomial in K. +□ +7. Conclusion +We introduced a new model called odca. The equivalence problem for non- +deterministic odcas is in PSPACE. This is in contrast to non-deterministic oca, +where the equivalence problem is undecidable. +We observe that undecidability +is a consequence of non-determinism occurring in counter actions. In the case of +weighted odcas, we show that the reachability, equivalence, regularity, and covering +problems are in P. +The natural way to extend the work is to consider epsilon transitions in the +odca. We conjecture that the equivalence, regularity, and covering problems will +be polynomial time decidable. Another possible direction is to look at pushdown +systems partitioned into a deterministic stack and a finite state machine. In this +case, a non-deterministic model can be determinized (similar to Theorem 8). Even +though all our algorithms are in polynomial time, they may not be ‘practical’. Con- +siderable effort is required to find faster algorithms. We also leave open questions +on learning and approximate equivalence of odcas. +Acknowledgment +The authors would like to thank Dr. Rahul C S, School of Mathematics and +Computer Science, IIT Goa, for his valuable and intuitive suggestions which helped +us in solving the binary Co-VS reachability problem. Sreejith would like to thank +DST Matrics grant for the project “Probabilistic Pushdown Automata”. + +34 +P. MATHEW, V. PENELLE, P. SAIVASAN, AND A.V. SREEJITH +References +[1] Steven P. Abney, David A. McAllester, and Fernando Pereira. Relating probabilistic gram- +mars and automata. In Robert Dale and Kenneth Ward Church, editors, 27th Annual Meet- +ing of the Association for Computational Linguistics, University of Maryland, College Park, +Maryland, USA, 20-26 June 1999, pages 542–549. ACL, 1999. +[2] Rajeev Alur and P. Madhusudan. Visibly pushdown languages. In L´aszl´o Babai, editor, Pro- +ceedings of the 36th Annual ACM Symposium on Theory of Computing, Chicago, IL, USA, +June 13-16, 2004, pages 202–211. ACM, 2004. +[3] Stanislav B¨ohm and Stefan G¨oller. Language equivalence of deterministic real-time one- +counter automata is nl-complete. In Filip Murlak and Piotr Sankowski, editors, MFCS, vol- +ume 6907 of Lecture Notes in Computer Science, pages 194–205. Springer, 2011. +[4] Stanislav B¨ohm, Stefan G¨oller, and Petr Jancar. Bisimilarity of one-counter processes is +pspace-complete. In Paul Gastin and Fran¸cois Laroussinie, editors, CONCUR, volume 6269 +of Lecture Notes in Computer Science, pages 177–191. Springer, 2010. +[5] Stanislav B¨ohm, Stefan G¨oller, and Petr Jancar. Equivalence of deterministic one-counter +automata is nl-complete. In Dan Boneh, Tim Roughgarden, and Joan Feigenbaum, editors, +Symposium on Theory of Computing Conference, STOC’13, Palo Alto, CA, USA, June 1-4, +2013, pages 131–140. ACM, 2013. +[6] Stanislav B¨ohm, Stefan G¨oller, and Petr Jancar. Bisimulation equivalence and regularity for +real-time one-counter automata. J. Comput. Syst. Sci, 80(4):720–743, 2014. +[7] Tom´as Br´azdil, Javier Esparza, Stefan Kiefer, and Anton´ın Kucera 0001. Analyzing proba- +bilistic pushdown automata. Formal Methods Syst. Des, 43(2):124–163, 2013. +[8] Tom´aˇs Br´azdil, Anton´ın Kuˇcera, and Oldˇrich Straˇzovsk´y. On the decidability of temporal +properties of probabilistic pushdown automata. In Volker Diekert and Bruno Durand, editors, +STACS 2005, pages 145–157, Berlin, Heidelberg, 2005. Springer Berlin Heidelberg. +[9] Kousha Etessami, Dominik Wojtczak, and Mihalis Yannakakis. Quasi-birth-death processes, +tree-like qbds, probabilistic 1-counter automata, and pushdown systems. Perform. Evalua- +tion, 67(9):837–857, 2010. +[10] Vojtech Forejt, Petr Jancar, Stefan Kiefer, and James Worrell 0001. Language equivalence of +probabilistic pushdown automata. Inf. Comput, 237:1–11, 2014. +[11] Vojtech Forejt, Petr Jancar, Stefan Kiefer, and James Worrell. Bisimilarity of probabilistic +pushdown automata. Technical report, October 08 2012. Comment: technical report accom- +panying an FSTTCS’12 paper. +[12] Juraj Hromkoviˇc and Georg Schnitger. On probabilistic pushdown automata. Information +and Computation, 208(8):982–995, 2010. +[13] Stefan Kiefer, Andrzej S. Murawski, Jo¨el Ouaknine, Bj¨orn Wachter, and James Worrell. +On the complexity of equivalence and minimisation for q-weighted automata. Log. Methods +Comput. Sci., 9(1), 2013. +[14] Daniel Krob. The equality problem for rational series with multiplicities in the tropical semir- +ing is undecidable. In Proceedings of the 19th International Colloquium on Automata, Lan- +guages and Programming, ICALP ’92, page 101–112, Berlin, Heidelberg, 1992. Springer- +Verlag. +[15] Anton´ın Kucera. Methods for quantitative analysis of probabilistic pushdown automata. In +Jir´ı Srba and Scott A. Smolka, editors, Proceedings of the 7th International Workshop on +Verification of Infinite-State Systems, INFINITY 2005, San Francisco, CA, USA, August + +ONE DETERMINISTIC-COUNTER AUTOMATA +35 +27, 2005, volume 149 of Electronic Notes in Theoretical Computer Science, pages 3–15. +Elsevier, 2005. +[16] Anton´ın Kucera, Javier Esparza, and Richard Mayr. Model checking probabilistic pushdown +automata. Log. Methods Comput. Sci., 2(1), 2006. +[17] G´eraud S´enizergues. The equivalence problem for deterministic pushdown automata is de- +cidable. In Pierpaolo Degano, Roberto Gorrieri, and Alberto Marchetti-Spaccamela, editors, +Automata, Languages and Programming, pages 671–681, Berlin, Heidelberg, 1997. Springer +Berlin Heidelberg. +[18] Stirling. Deciding dpda equivalence is primitive recursive. In ICALP: Annual International +Colloquium on Automata, Languages and Programming, 2002. +[19] Gilbert Strang. Linear algebra and its applications. Thomson, Brooks/Cole, Belmont, CA, +2006. +[20] Wen-Guey Tzeng. A polynomial-time algorithm for the equivalence of probabilistic automata. +SIAM J. Comput, 21(2):216–227, 1992. +[21] Valiant and Paterson. Deterministic one-counter automata. JCSS: Journal of Computer and +System Sciences, 10, 1975. +Indian Institute of Technology Goa +Email address: prince@iitgoa.ac.in +Universit´e de Bordeaux +Email address: vincent.penelle@u-bordeaux.fr +The Institute of Mathematical Sciences, HBNI +Email address: prakashs@imsc.res.in +Indian Institute of Technology Goa +Email address: sreejithav@iitgoa.ac.in +