Regular Separability of Parikh Automata

We investigate a subclass of languages recognized by vector addition systems, namely languages of nondeterministic Parikh automata. While the regularity problem (is the language of a given automaton regular?) is undecidable for this model, we surprisingly show decidability of the regular separability problem: given two Parikh automata, is there a regular language that contains one of them and is disjoint from the other? We supplement this result by proving undecidability of the same problem already for languages of visibly one counter automata. 1998 ACM Subject Classiﬁcation D.2.2 [Design Tools and Techniques] Petri Nets, F.1.1 [Theory of Computation] Models of Computation, F.2.2 [Nonnumerical Algorithms and Problems] Com-putations on Discrete Structures, F.3.1 [Specifying and Verifying and Reasoning about Programs] Mechanical veriﬁcation


Introduction
We investigate separability problems for languages of finite words.We say that a language U is separated from a language V by S if U ⊆ S and V ∩ S = ∅.In the sequel we also often say that U and V are separated by S. For two families of languages F and G, the F separability problem for G asks for two given languages U, V ∈ G whether U is separated from V by some language from F. The same notion of separability makes clearly sense if F and G are classes of sets of vectors instead of classes of languages.In this paper, we consider the case where F are regular languages and G languages recognized by Parikh automata, and the case where F are the unary sets and G the semilinear sets.
Motivation.Separability is a classical problem in theoretical computer science.It was investigated most extensively in the area of formal languages, for G being the family of all regular word languages.Since regular languages are effectively closed under complement, the F separability problem is a generalization of the F characterization problem, which asks whether a given language belongs to F. Indeed, L ∈ F if and only if L is separated from its complement by some language from F. Separability problems for regular languages attracted recently a lot of attention, which resulted in establishing the decidability of F separability for various families F such as the piecewise testable languages [7,15] (recently generalized to finite ranked trees [9]), the locally and locally threshold testable languages [14], the languages definable in first order logic [17], and the languages of certain higher levels of the first order hierarchy [16], among others.Separability of nonregular languages attracted little attention till now.The reasons for this may be twofold.First, for regular languages one can use standard algebraic tools, like syntactic monoids, and indeed most of the results have been obtained with the help of such techniques.Second, some strong intractability results have been known already since 70's, when Szymanski and Williams proved that regular separability of context-free languages is undecidable [18].Later Hunt [10] generalized this result for every class F closed under finite boolean combinations and containing all languages of the form wΣ * for w ∈ Σ * .This is a very weak condition, so it seemed that nothing nontrivial can be done outside regular languages with respect to separability problems.Furthermore, Szymanski and Williams's negative result has recently been strengthened by considering two incomparable subclasses of pushdown automata.First, Kopczyński has shown that regular separability is undecidable for languages of visibly pushdown automata [13], and then Czerwiński and Lasota have shown that the same problem is undecidable for one counter automata [6].
On the positive side, piecewise testable separability has been shown decidable for contextfree languages, languages of vector addition systems (VAS languages), and some other classes of languages [8].Another surprising result has been recently obtained by Czerwiński and Lasota [6] who show that regular separability is decidable (and PSPACE-complete) for languages recognized by one counter nets (i.e., one counter automata without zero test).Notice that in all these examples regularity (resp.piecewise testability) is undecidable, but regular (resp.piecewise testable) separability is decidable, and until recently there were not many results of this kind.
Finally, in [5] we have shown decidability of unary separability of reachability sets of vector addition systems (VASes).By unary sets we mean Parikh images of commutative regular languages, and thus the latter problem is equivalent to commutative regular separability of (commutative closures of) VAS languages.The decidability status of the regular separability problem for the whole class of VAS languages remains open.
Our contribution.This paper is a continuation of the line of research trying to understand the regular separability problem for language classes beyond regular languages.We report a further progress towards solving the open problem mentioned above by providing a positive decidability result and a new negative undecidability result: As our first (positive) result, we show decidability of the regular separability problem for the subclass of VAS languages where we allow negative counter values during a run.This class of languages is also known as languages of integer VASSes, and it admits many different characterizations; for instance, it coincides with languages of one-way reversal-bounded counter machines [11], Parikh automata [12] (cf.also [2,Proposition 11]), which in turn are equivalent to the very similar model of constrained automata [3].In this paper, we present our results in terms of constrained automata, but given the similarity with Parikh automata (and in light of their equivalence), we overload the name Parikh automata for both models.
Notice that PA languages are not closed under complement, and thus our decidability result about regular separability does not imply decidability of the regularity problem (is the language of a given Parikh automaton regular?).Moreover, the regularity problem for PA languages is actually undecidable [2] 1 , which makes our decidability result one of few instances where regularity is undecidable but regular separability is decidable; cf.Fig 1.
Parikh automata are finite nondeterministic automata where accepting runs are further restricted to satisfy a semilinear condition on the multiset of transitions appearing in the run.Our decidability result is actually stated in the more general setting of C-Parikh automata, where C ⊆ d∈N P(N d ) is a class of sets of vectors used as an acceptance condition.We prove that the regular separability problem for languages of C-Parikh automata effectively reduces to the unary separability problem for the class C itself, provided that C is effectively closed under inverse images of affine functions.Two prototypical classes C satisfying the latter closure condition are semilinear sets and VAS reachability sets.Moreover, unary separability of semilinear sets is known to be decidable [4], and as recalled before the same result has recently been extended to VAS reachability sets [5].As a consequence of our reduction, we deduce decidability of regular separability of C-Parikh automata languages where the acceptance condition C can be instantiated to either the semilinear sets, or the VAS reachability sets.
We complement our decidability result by a new negative undecidability result subsuming simultaneously Kopczyński's undecidability for visibly pushdown languages [13] and Czerwiński and Lasota's undecidability of one counter languages [6]: We show that regular separability is undecidable for (deterministic 2 ) visibly one counter languages.Inside the proof we use the result from [6], but actually in order to only reprove [13] it would be sufficient to use the old work by Szymanski and Williams [18].

Preliminaries
Vectors  Notice that we allow ε-transitions in the definition of Parikh automata.A run of a Parikh automaton over a word w = a 1 . . .a n ∈ Σ * is a sequence of transitions ρ = t 1 . . .t n ∈ T * , where t i = (q i−1 , a i , q i ), starting in an initial state q 0 .A run ρ is accepting if its ending state q n is final and Π(ρ) ∈ S (we assume here that the set of transitions T is totally ordered).The language of a Parikh automaton, denoted L(A, S), contains all words w admitting an accepting run; it is thus a subset of the language L(A) of the underlying ε-NFA.
One can generalize Parikh automata by using some other family of vector sets in the place of semilinear sets.For a class C ⊆ d∈N P(N d ) of vector sets, a C-Parikh automaton is a pair (A, S), where A is an ε-NFA and S ∈ C. The language L(A, S) is defined as above.
A C-Parikh automaton (A, S) is deterministic if the underlying automaton A is so; here, we assume that a deterministic automaton does not have ε-transitions.The languages of (non)deterministic C-Parikh automata are shortly called (non)deterministic C-Parikh languages below.

Main results
We call a function f : N k → N affine if it is of the form f (v) = M v + u for an integer non-negative matrix M of dimension × k and a vector u ∈ N .In a special case when u = 0 we call the function f linear.A class of vector sets C ⊆ d∈N P(N d ) is called robust if it fulfills the following two conditions: C is effectively closed under inverse images of affine functions, the unary separability problem is decidable for C.
Our first main result is decidability of the regular separability problem for C-Parikh automata.

Theorem 1. The regular separability problem is decidable for C-Parikh automata, for every robust class C of vector sets.
The proof of Theorem 1 is split into two parts.In Section 4 we provide a reduction of the regular separability problem for nondeterministic C-Parikh automata to the same problem for deterministic ones; this step is crucial for understanding how the regular separability problem differs from the regularity problem, which does not admit a similar reduction.Then in Section 5 we reduce the regular separability problem for deterministic C-Parikh automata to the unary separability problem for vector sets in C.
In Section 6 we consider two instantiations of the class C. First, taking C to be the semilinear sets we derive decidability for (ordinary) Parikh automata.Second, we consider the class C SEC-VAS of sections of reachability sets of VASes (detailed definitions are deferred to Section 6), which allows us to obtain decidability for C SEC-VAS -Parikh automata.Note that the latter model properly extends Parikh automata.
Before proceeding with the rest of the proof for our decidability result, we present a generic reduction of the regular separability problem from which we can immediately derive a new undecidability result, which is our second main contribution.

A generic reduction
We observe that regular separability of homomorphic images of a class of languages G reduces to regular separability for G itself (cf.Lemma 2 below).Since nondeterministic Parikh automata are the homomorphic image of deterministic ones, we reduce regular separability for the nondeterministic class to the deterministic one (shown in Sec.4); together with the decidability result for the deterministic class presented in Sec. 5, this proves Theorem 1.
Our reduction can also be used to derive undecidability results.Since context-free languages are the homomorphic image of (deterministic) visibly pushdown languages (cf.[1, Theorem 5.2]), and since regular separability is undecidable for the former class [18], we concisely reprove the recent LICS'16 result by Kopczyński [13] about undecidability of regular separability of visibly pushdown languages.Moreover, this result can be further strengthened to (deterministic) visibly one counter languages using the same observation and the recent result by Czerwiński and Lasota [6] about undecidability of regular separability for one counter automata (cf.Sec.3.2).
We now present our generic reduction.Given two alphabets Σ and Γ, a homomorphism is a function h : Σ → Γ * which extends homomorphically to a function from Σ * to Γ * , and thus to languages.For G a class of languages and H a class of homomorphisms, let H(G) be the class of languages obtained by applying some homomorphism from H to some language in G.

Lemma 2. If G and H(G) are effectively closed under inverse images of homomorphisms from H, then the regular separability problem in H(G) reduces to the same problem in G.
In statements of this form, "effective" means that for given finite computational model representing L ∈ G and h ∈ H, one can effectively find a representation with a finite computational model for h −1 (L) ∈ G, and similarly for H(G).The reduction above is a consequence of the following fundamental relationship between separators and (inverse) images of functions.(We do not exploit the further structure of homomorphisms here.)Lemma 3. Let L ⊆ Σ * , K ⊆ Γ * be two languages, and let h : Σ * → Γ * be a function.
Proof.The proof is elementary and it is given for completeness.For the first point, L ⊆ h −1 (R) follows from the inclusion h(L) ⊆ R since L ⊆ h −1 (h(L)), and the disjointness of h −1 (R) and h −1 (K) follows from disjointness of R and K.For the second point, the inclusion h(L) ⊆ h(R) follows by the inclusion L ⊆ R, and the disjointness of h(R) and K follows from the disjointness of R and h −1 (K).
Since regular languages are closed under images and inverse images of homomorphisms, we immediately obtain the following corollary.Since regular languages are closed under complement, the regular separability problem is in fact symmetric.Combining this observation with the corollary above, we can now prove correctness of our generic reduction.
Proof of Lemma 2. Let h(L), K be two languages in H(G).By Corollary 4, regular separability for h(L), K is the same as for L, h −1 (K).Since H(G) is closed under inverse images by assumption, h −1 (K) equals the image g(K 1 ) of language K 1 in G for some g from H. We have thus reduced to regular separability for L, g(K 1 ), where now both L and K 1 are in G. Since regular languages are closed under complement, regular separability for L, g(K 1 ) is the same for g(K 1 ), L. Applying once more Corollary 4, the latter statement is equivalent to regular separability for K 1 , g −1 (L).Since G closed under inverse images by assumption, g −1 (L) is itself in G. Since every step was effective, this concludes the proof.

A new undecidability result
A one counter automaton is a finite-state device manipulating a single natural counter, which can be incremented, decremented, and tested for zero; it is visible if the input symbol uniquely determines which counter operation will be performed.Therefore, languages recognized by visible one counter automata are a strict subclass of visibly pushdown languages [1].It was recently proved that regular separability for one counter automata is undecidable [6], which is incomparable with undecidability for visibly pushdown languages [13].
As a consequence of Lemma 2 we obtain undecidability of regular separability for visible one counter automata, which is our second main result, strengthening both [6] and [13].

Theorem 5. Regular separability of languages recognised by (deterministic) visible one counter automata is undecidable.
Let G be the class of languages recognized by visible one counter automata, and let H be the class of letter-to-letter (non-erasing) homomorphisms, i.e., functions of the form h : Σ → Γ.In order to apply Lemma 2, it suffices to show that languages recognized by one counter automata are the effective homomorphic image of those recognized by the visible subclass, and that both classes are effectively closed under inverse images of letter-to-letter homomorphisms.We begin with the second result.

Lemma 6. One counter languages and visibly one counter languages are effectively closed under inverse images of letter-to-letter homomorphisms.
Proof.Given one counter automaton A over Σ and a letter-to-letter homomorphism h : Γ → Σ, one computes an automaton B over Γ of the same kind s.t.L(B) = h −1 (L(A)) as follows.The automaton B is obtained by replacing a transition reading a ∈ Σ in A by corresponding transitions reading b ∈ Γ performing the same counter operation, for every b ∈ h −1 (a).Is it easy to check that L(B) = h −1 (L(A)), as required.Moreover, if A was visible, since the counter operation is preserved, B will be visible too.
Proof of Theorem 5.It remains to show that one counter languages are the effective homomorphic image of visible one counter languages.This is easy to show.Let L ⊆ Σ * be a one counter language.Each symbol a ∈ Σ is split into three symbols a inc , a dec , a =0? .The corresponding homomorphism h just forgets the new annotation, i.e., h(a inc ) = h(a dec ) = h(a =0? ) = a; notice that h is letter-to-letter and non-erasing.Counter operations for the new automaton are made visible by replacing an increment operation over a by the same operation over a inc , and similarly for decrements and tests.Clearly, we obtain a visible one counter automaton recognizing a language M s.t.L = h(M ).Thus, by Lemma 2, Lemma 6, and the undecidability of regular separability of one counter languages [6, Theorem 2], we obtain that regular separability for visibly one counter languages is undecidable.

4
From nondeterministic to deterministic PA The aim of this section is to prove the following lemma: As a consequence of Lemma 7, we can focus on separability of deterministic PA languages in the rest of the paper.Let G be the class of deterministic C-Parikh automata languages, and let H be the class of letter-to-letter erasing homomorphism, i.e., functions of the form h : Σ → (Γ ∪ {ε}) extended homomorphically to Σ * → Γ * .The proof of the lemma follows immediately from Lemma 2 once we prove that nondeterministic languages are the effective images of deterministic ones (cf.Lemma 8), and that both classes are closed under inverse images (cf.Lemma 9).In the rest of the section, we assume that the class C is closed under inverse images of linear mappings, which is the case for a robust class C (cf. Sec. 3).Proof.Fix a nondeterministic C-Parikh automaton (A, S) over the alphabet Σ, and let T be the set of transitions of A. Consider the letter-to-letter erasing homomorphism h : T → (Σ ∪ {ε}) that maps a transition (p, a, q) to a. Let (B, S) be the deterministic C-Parikh automaton over the alphabet T which is obtained from A by relabelling every transition of t = (p, a, q) ∈ T of A as a (unique) transition (p, t, q) of B. Notice that the acceptance condition of B is the same as that for A, since we only relabelled transitions.One easily verifies that L(A, S) = h(L(B, S)), as required.

Lemma 9. Deterministic and nondeterministic C-Parikh languages are effectively closed under inverse images of letter-to-letter erasing homomorphisms.
Proof.Given a deterministic C-Parikh automaton (A, S) over Σ and a letter-to-letter erasing homomorphism h : Γ → (Σ ∪ {ε}), one computes a deterministic C-Parikh automaton (B, T ) s.t.L(B, T ) = h −1 (L(A, S)) as follows.The automaton B is obtained by replacing every transition (p, a, q) in A by transitions (p, b, q), one for every b ∈ h −1 (a).Moreover, each state p in the automaton B has a self-loop (p, b, p) for every b ∈ h −1 (ε).The constraint T ∈ C is the inverse image of S under the linear function obtained by counting a transition (p, b, q) as a transition (p, h(b), q) if h(b) = ε, and by counting (p, b, q) as zero (i.e., ignoring it) otherwise.Finally, the constraint T , and hence also the automaton (B, T ) can be computed.Is it easy to check that L(B, T ) = h −1 (L(A, S)), as required.Moreover, if A is deterministic, and h is a function, then the resulting automaton B is also deterministic.

Regular separability reduces to unary separability
In this section we reduce regular separability of deterministic C-Parikh languages to unary separability of vector sets in C. The rest of this section is devoted to the proof of the lemma.Let L 1 , L 2 ⊆ Σ * be languages of deterministic C-Parikh automata (A 1 , S 1 ) and (A 2 , S 2 ), respectively.There are three steps: 1.As the first step, we show that w.l.o.g.we may assume A 1 = A 2 .2. In the second step, we partition Σ * into finitely many regular languages K 1 , . . ., K m and we reduce regular separability of L 1 and L 2 to regular separability of L 1 ∩ K i and L 2 ∩ K i for every i ∈ {1, . . ., m}.These subproblems turn out to be easier than the general one, due to the additional structural information encoded in the languages K i 's. 3.In the last step, we reduce regular separability of L 1 ∩ K i and L 2 ∩ K i to unary separability of vector sets in C.
Step 1: Unifying the underlying automaton.As the input languages are subsets of regular languages recognised by their underlying finite automata, L 1 = L(A 1 , S 1 ) ⊆ L(A 1 ) and Proof.The "only if" direction is trivial as every language separating L 1 and L 2 separates L 1 ∩ L(A 2 ) and L 2 ∩ L(A 1 ) as well.For the opposite direction, we observe that if a regular language S separates L 1 ∩ L(A 2 ) and L 2 ∩ L(A 1 ), then S = (S ∩ L(A 1 )) ∪ L(A 2 ) is a regular language separating L 1 and L 2 .
Let A be the product automaton of A 1 and A 2 , and thus L(A) = L(A 1 ) ∩ L(A 2 ).It is deterministic since both A 1 and A 2 are so.We claim that one can compute sets . The set T of transitions of A is a subset of the product T 1 × T 2 of transitions of A 1 and A 2 , and thus there are obvious projections functions π 1 : T → T 1 and π 2 : T → T 2 .If we enumerate the transition sets, say T 1 = {t 1  1 , . . ., t m 1 }, T 2 = {t 1 2 , . . ., t n 2 }, and T = {t 1 , . . ., t } with ≤ m • n, we obtain π 1 : {1, . . ., } → {1, . . ., m} and π 2 : {1, . . ., } → {1, . . ., n}.We use these projections to define two linear (and in particular, affine) functions ψ 1 : N → N m and ψ 2 : N → N n which instead of counting transitions in T , count the corresponding transitions in T 1 or in T 2 , respectively; formally, Finally, we set U 1 := ψ −1 1 (S 1 ) and U 2 := ψ −1 2 (S 2 ).Intuitively, U 1 and U 2 are as S 1 and S 2 , except that instead of single transitions of A 1 or A 2 they are seeing pairs of transitions, and simply ignore one of them.Since C is closed under inverse images of affine mappings by assumption, U 1 , U 2 ∈ C. For the rest of the proof we may thus assume that the input automata are (A, U 1 ) and (A, U 2 ).
Step 2: Regular partitioning using skeletons.We finitely partition Σ * s.t.words belonging to the same partition behave similarly with respect to automaton A. We use the notion of skeleton of a run, defined already in [3], where it was used to solve the regularity problem of unambiguous Parikh automata.The idea is to traverse a run from left to right while removing (and counting) simple cycles visiting states that have already appeared.
A simple cycle is a sequence of transitions c = t 1 . . .t n ∈ T * , where t i = (q i−1 , a i , q i ), starting and ending in the same state q 0 = q n where q 1 , . . ., q n are pairwise distinct.Two simple cycles c, d are equivalent if one is a cyclic permutation of the other.Let [c] denote the equivalence class of c, and let [c 1 ], . . ., [c m ] be a fixed enumeration of all such equivalence classes.(Since a simple cycle cannot visit the same state twice, except the initial state, it has length at most n, and thus the number of simple cycles, and also of equivalence classes thereof, is m ≤ d n , where d is the number of transitions of the automaton.)The skeleton is an inductively defined function from runs to pairs consisting of a run and a vector v ∈ N m .In the base case, skel(ε) = (ε, 0).For the induction step, suppose that skel(t 1 . . .t k−1 ) = (u 1 . . .u , v) is already defined, and let q be the ending state of the new transition t k .If q does not appear in the run u 1 . . .u , then we put skel(t 1 . . .t k ) = (u 1 . . .u t k , v).Otherwise, let u h , for h < , be the last transition that ends in state q, and consider the cycle c = u h+1 . . .u t k ∈ [c j ] (for some 1 ≤ j ≤ m).We have two cases to consider.If all states visited by this cycle appeared before in u 1 . . .u h , then we call this cycle absorbed and we remove it by putting skel(t , where e j is the vector which is 1 in coordinate j, and 0 everywhere else.Otherwise, we just put We remove only simple cycles visiting states that have already appeared before in order to have the following useful property.Proposition 2. If skel(ρ) = (ρ, v), then ρ and ρ visit the same set of states.
By abusing nomenclature, we call a run ρ a skeleton if skel(ρ) = (ρ, v), for some v ∈ N m .It is easy to see that the length of a skeleton is at most n 2 , where n is the number of states in the automaton A. (Assume towards a contradiction that the length of the skeleton is longer than n 2 .By the pigeonhole principle, some state is thus visited more than n times, so there are at least n cycles in between two consecutive occurrences of this state in the skeleton.Therefore it is impossible that each loop contains some new state not present in all the previous loops, and thus one of these loops should be removed during the process of creating the skeleton, a contradiction.)Consequently, if d is the total number of transitions of A, then there are at most d n 2 skeletons.Let ρ 1 , . . ., ρ h be all the skeletons, with h ≤ d n 2 .We define K i to be the set of all words w having an accepting run ρ in automaton A with skel(ρ) = ρ i .Since A is deterministic we know that K i ∩ K j = ∅ for i = j.Therefore K 1 , . . ., K h and K h+1 = Σ * \ ( 1≤i≤h K i ) form a partition of Σ * .All languages K i are necessarily regular, since the skeleton can be computed by a finite automaton.The following lemma can be seen as a generalization of Proposition 1 and it is immediate to prove.Lemma 11.Let Σ * be partitioned into regular languages K 1 , . . ., K k .Two languages L 1 , L 2 ⊆ Σ * are regular separable if, and only if, L 1 ∩ K i and L 2 ∩ K i are regular separable for every i ∈ {1, . . ., k}.
It remains to decide regular separability for the languages L(A, U 1 ) ∩ K i and L(A, U 2 ) ∩ K i .In the following, fix a skeleton ρ and the set of words K with skeleton ρ.Since we have fixed a skeleton, we assume w.l.o.g. that the acceptance conditions U 1 , U 2 are included in Π(K).
) is well-defined.Notice that µ is affine, and not linear, since we must take into account the initial cost of the skeleton Π(ρ).Let V 1 = µ −1 (U 1 ) and V 2 = µ −1 (U 2 ) be the corresponding sets counting cycles instead of transitions.Since we assumed U 1 , U 2 ⊆ Π(K), every vector v ∈ V 1 is realizable by an accepting run ρ s.t.skel(ρ) = (ρ, v).Since C is closed under the inverse image of affine mappings, V 1 , V 2 ∈ C.

Lemma 12.
The following two conditions are equivalent: ( It is easy to see that for every regular language R such ω exists.The simplest way of showing this is to consider the syntactic monoid M of R and to let ω be its idempotent power, i.e., a number such that m ω = (m ω ) 2 for every m ∈ M .
Recall n-unary equivalence: Suppose, towards a contradiction, that there are some There are runs ρ 1 , ρ 2 s.t.skel(ρ 1 ) = (ρ, v 1 ) and skel(ρ 2 ) = (ρ, v 2 ).We extend the equivalence ≡ R on runs by saying that ρ 1 ≡ R ρ 2 if their two labellings are ≡ R -equivalent.Since the labelling of ρ 1 is in L(A, U 1 ) ∩ K, and similarly for ρ 2 , if ρ 1 ≡ R ρ 2 , then we derive a contradiction since R was supposed to separate L(A, U 1 ) ∩ K and L(A, U 2 ) ∩ K.While in general ρ 1 ≡ R ρ 2 does not hold, we can construct two canonical runs ρ1 and ρ2 s.t.(1) skel(ρ 1 ) = (ρ, v 1 ) (thus the labelling of ρ1 is also in L(A, U 1 ) ∩ K), (2) skel(ρ 2 ) = (ρ, v 2 ) (similarly), and (3) ρ1 ≡ R ρ2 (thus bringing the contradiction).We show the construction for ρ1 ; the one for ρ2 is similar.By Proposition 2, states visited by the run ρ 1 are among those visited by the skeleton ρ, and in particular every absorbed cycle (i.e., v 1 [j] = 0) also has this property.While in general a simple cycle d ∈ [c j ] starting (and ending) at some state q cannot be reintroduced in the skeleton ρ at any position labelled by q (because not all states in d need to have appeared before this position), there always is a position i j in the skeleton labelled by some state q j and a simple cycle ĉj ∈ [c j ] starting (and ending) at q j s.t.all states in ĉj have appeared already before position i j in the skeleton.Assume w.l.o.g. that i 1 ≤ • • • ≤ i m .It is possible to split the skeleton ρ as α 0 • • • α m s.t., for every 0 ≤ j ≤ m, α j ∈ T * is a sequence of transitions, and the prefix α 0 • • • α j−1 has length i j (thus ends in q j ).Then, define ρ1 and similarly ρ2 as (This is well-defined since 1) and ( 2) above are guaranteed by construction.For Property (3), since v 1 ≡ ω v 2 , by repetitive use of Equation ( 1) we have ρ1 ≡ R ρ2 .This concludes the proof of the first implication.
For proving the implication (2) ⇒ (1), suppose that a unary set S separates V 1 and V 2 .We claim that the language R = L(A, µ(S)) ∩ K is regular and separates L(A, U 1 ) ∩ K and L(A, U 2 ) ∩ K.We first verify that R separates these two languages.Clearly, U 1 ⊆ µ(V 1 ) ⊆ µ(S), so L(A, U 1 ) ∩ K ⊆ L(A, µ(S)) ∩ K = R.The disjointness of L(A, U 2 ) ∩ K and R is shown by contradiction.Suppose that there is a word w ∈ K belonging both to L(A, µ(S)) and to L(A, U 2 ), let ρ be the run of A over w and let v = Π(ρ).We have v ∈ µ(S) ∩ U 2 , which implies v = µ(s) for some s ∈ S ∩ µ −1 (U 2 ) = S ∩ V 2 .In consequence S ∩ V 2 is nonempty, thus contradicting the assumption that S separates V 1 and V 2 .
In order to prove that R is regular it suffices to prove that L(A, µ(S)) is regular.The finite nondeterministic automaton recognizing this language simulates a run ρ = t i1 . . .t i of A, and accepts when Π(ρ) ∈ µ(S).Since S is unary, the automaton can evaluate this condition using finite memory.For every cycle c j , the automaton stores a vector x j < Π(c j ), and a number n j up to the unary equivalence ≡ n , with the following meaning: the vector Π(c i ) has been already executed n j times, and x i is the current "remainder".Additionally, the automaton stores a vector x ≤ Π(ρ) which is counting those transitions on the skeleton which have not been counted as cycles.At every input letter the automaton guesses nondeterministically one of cycles c i or the skeleton and updates x j , n j and x accordingly.The automaton accepts when x = Π(ρ i ), x j = 0 for all j, and (n 1 , . . ., n m ) ∈ S.

Applications
We derive two corollaries of Theorem 1.By a projection we mean a function π k,I : N k → N |I| , for I ⊆ {1 . . .k}, that drops coordinates not in I.We start with a simple but useful lemma: Lemma 13.If a class C ⊆ d∈N P(N d ) contains all semilinear sets and is effectively closed under intersections, projections, and inverse images of projections, then it is effectively closed under inverse images of affine maps.
Proof.Let S be a set in C and f : N k → N be an affine map defined by f (u) = M u + v for M = (m i,j ) a matrix of dimension × k and v a vector of dimension .Let e j ∈ N k be the vector s.t. e j [j] = 1 and 0 otherwise, and let m j = (m 1,j , m 2,j , . . ., m ,j ) be the (transpose of) the j-th column of M .First remark that the set E 1 = {(x, f (x)) | x ∈ N k } ⊆ N k+ is linear with base (0 k , v) and periods {p 1 , . . ., p k }, where p j = (e j , m j ) ∈ N k+ .Thus, E 1 ∈ C. Therefore the set E 2 = E 1 ∩ π −1 k+ ,I (S) is also in C, for I = {k + 1, . . ., k + }.Finally, we conclude since π k+ ,J (E 2 ) = f −1 (S) with J = {1, . . ., k}.

Corollary 14. Regular separability is decidable for nondeterministic Parikh automata.
Proof.In order to apply Theorem 1 for C being semilinear sets, we need to know that the class of semilinear sets is robust.First, Lemma 13 yields effective closure under inverse images of affine maps, as semilinear sets are effectively closed under boolean combinations, images, and inverse images of projections.Second, decidability of the unary separability problem for semilinear sets is a corollary of the main result in [4].This theorem states that separability of rational relations in Σ * × N m by recognizable relations is decidable.If we ignore the Σ * component we get the same result for rational and recognizable relations in N m , which are exactly semilinear sets and unary sets, respectively.
For the second corollary we have to introduce vector addition systems and sections thereof.A d-dimensional vector addition system (VAS) is a pair V = (s, T ), where s ∈ N d is a source configuration and T ⊆ fin Z d is a finite set of transitions.A run is a sequence

117:12 Regular Separability of Parikh Automata
such that for all i ∈ {0, . . ., n − 1} we have v i + t i = v i+1 and v 0 = s.The target of this run is the configuration v n .The reachability set of a VAS V is the set of targets of all its runs.
In order to ensure robustness, we slightly enlarge the family of VAS reachability sets to sections thereof.The intuition about a section is that we fix values on a subset of coordinates in vectors, and collect all the values that can occur on the other coordinates.Proof.We apply Theorem 1 for C = C SEC-VAS ; we thus need to show that class C SEC-VAS is robust.Decidability of unary separability of sets from C SEC-VAS is shown in Theorem 9 in [5].Effective closure of C under inverse images of affine functions will follow by Lemma 13 once we prove all its assumptions.First, C SEC-VAS contains all semilinear sets.Effective closure under intersections is shown in Proposition 7 in [5].Effective closure under inverse images of projections is easy: extend the VAS with additional coordinates, and allow it to arbitrarily increase these coordinates.Finally, to see that C SEC-VAS is effectively closed under projections consider a section S ⊆ N d of the reachability set of a VAS V , and a subset of coordinates I ⊆ {1, . . ., d}.We construct a VAS V which is like V , but additionally allows to decrease every coordinate from {1, . . ., d} \ I.The projection π d,I (S) of S onto I is a section of the reachability set of V defined similarly as S, but with an additional requirement that all coordinates from {1, . . ., d} \ I have value 0.

Conclusions
We have shown that the regular separability problem for C-Parikh automata is decidable, for every class C of acceptance conditions satisfying mild assumptions.In particular, we have shown decidability for C being either the semilinear sets or sections of VAS reachability sets.
We have complemented our positive result by proving undecidability for visibly one counter languages, which sharpens two existing undecidability results.The complexity of our algorithm depends on two factors: the complexity of unary separability for C, and the complexity of computing inverse images of sets in C under affine mappings.The first factor is the dominant one here, since computing inverse images can be shown to be in PTIME for both semilinear sets and sections of VAS reachability sets (cf.[5]).Under this assumption, it can be seen that our reduction from nondeterministic to deterministic automata in Sec. 4 is also PTIME.Moreover, when reducing to unary separability in Sec. 5, since there are at most exponentially many skeletons and simple cycles, we obtain exponentially many unary separability instances, each of exponential size.Therefore, all together our reduction can be performed in exponential space.
On the other hand, the complexity of unary separability for semilinear sets and VAS sections is much higher.For semilinear sets, no upper bounds have been published for this problem, but an analysis of the algorithm of [4] yields an elementary bound4 .For VAS sections, one can easily see that unary separability is at least as hard as the VAS reachability problem [5], which is hard for exponential space and not known to be primitive recursive.

Figure 1
Figure 1The regularity and the regular separability problems.
i ∈ Σ, by # ai (w) we denote the number of letters a i in w.The Parikh image of a word w ∈ Σ * is the vector Π(w) = (# a1 (w), . . .,# a k (w)) ∈ N k .The Parikh image of a language L ⊆ Σ * is Π(L) = {Π(w) | w ∈ L},the set of Parikh images of all words belonging to L. Parikh automata.A nondeterministic finite automaton with ε-transitions (ε-NFA) A = (Q, I, F, T ) over a finite alphabet Σ consists of a finite set of states Q, two distinguished subsets of initial and final states I, F ⊆ Q, and a set of transitions T ⊆ Q × Σ ε × Q, where Σ ε = Σ ∪ {ε}.A nondeterministic Parikh automaton 3 is a pair (A, S) consisting of an ε-NFA A and a semilinear set S ⊆ N d , where d = |T | is the number of transitions of A.

4 .
Let h be a homomorphism.Languages h(L), K are regular separable if, and only if, L, h −1 (K) are so.

Lemma 7 .
If C is effectively closed under inverse images of linear mappings, then the regular separability problem of nondeterministic C-Parikh automata effectively reduces to the same problem for deterministic ones.

Lemma 8 .
Every nondeterministic C-Parikh language is the effective image of a letter-toletter erasing homomorphism of a deterministic C-Parikh language.

Lemma 10 .
Let C be a class of vectors effectively closed under inverse images of affine mappings.The regular separability problem for deterministic C-Parikh automata reduces to the unary separability problem for vector sets in C.

Step 3 :
Reduction to unary separability for C. Let the set of transitions of the automaton be T = {t 1 , . . ., t d } (thus ρ ∈ T * ), and let µ : N m → N d be the following affine function that I C A L P 2 0 1 7 117:10 Regular Separability of Parikh Automata transforms counting cycles into counting transitions: For a subset I ⊆ {1, . . ., d}, the projection π d,I extends element-wise to sets of vectors S ⊆ N d , denoted π d,I (S).For a vector u ∈ N d−|I| , the section of S w.r.t.I and u is the set π d,I ({v ∈ S | π d,{1,...,d}\I (v) = u}) ⊆ N |I| .We denote by C SEC-VAS the family of all sections of VAS reachability sets.Corollary 15. t Regular separability is decidable for nondet.C SEC-VAS -Parikh automata.

A L P 2 0 1 7 117:4 Regular Separability of Parikh Automata set
. A set S ⊆ N d is linear if there exist a base b ∈ N d and periods p 1 , . . ., p k ∈ N d s.t.S = {b + n 1 p 1 + . . .+ n k p k | n 1 , . . ., n k ∈ N}, and it is semilinear if it is a finite union of S ⊆ N d is unary if for some n, S is a union of equivalence classes of ≡ n .Intuitively, to decide membership in a unary set S it is enough to count on every coordinate exactly up to some threshold n, and modulo n for values larger than n.Unary sets are semilinear.Let Σ = {a 1 , . . ., a k } be a totally ordered alphabet.For a word w ∈ Σ * and a letter a [3]ter shown decidable for unambiguous PA[3].2Determinism he is irrelevant because this class can be determinized.I C