May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 1 Definable sets in the weak Presburger arithmetic ∗ CHRISTIAN CHOFFRUT LIAFA, Université Paris 7 & CNRS, 2, pl. Jussieu – 75251 Paris Cedex – 05, France E-mail: cc@liafa.jussieu.fr www. liafa. jussieu. fr/ ~cc ACHILLE FRIGERI Dipartimento di Matematica, Politecnico di Milano & LIAFA, Université Paris 7 via Bonardi, 9 – 20133 Milano, Italia E-mail: achille.frigeri@polimi.it We show the following: given a relation defined by a first order formula on the structure hZ; +, <i, it is recursively decidable whether or not it is first order definable in the structure hZ; +i. Keywords: Presburger arithmetic, arithmetical definability. Introduction Presburger arithmetic is the fragment of arithmetic concerning the integers with addition and order. Presburger’s supervisor considered the decidability of this fragment too modest a result to deserve a Ph.D. degree and he accepted it only as a Master’s Thesis in 1928. Looking at the number of citations, we may say that history revised this depreciative judgment long ago. There still remains, at least as far as we can see, some confusion concerning the domain of the structure: Z or N? with or without the order relation? (the main popular mathematical web sites disagree on that respect). The original paper deals with the additive group of positive and negative integers with no binary relation, but in a final remark of the original communication the author asserts that the same result, to wit quantifier elimination, holds on the structure of the “whole” integers, i.e., the natural ∗ Partially ... ... supported by . . . May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 2 numbers with the binary relation <. In ?, which is the main reference on the subject, Presburger arithmetic is defined as the elementary theory of integers with equality, addition, having 0 and 1 as constant symbols and < as binary predicate, see also ?. On the other hand, the majority of the “modern” papers referring to Presburger arithmetic is concerned with the natural numbers where order relation is unnecessary as it is first order expressible. The origin of the present work is the simple remark that concerning the set of integers Z, the binary relation matters. Here we study the decidability of the definability in the structure hZ; +i for a given relation defined in hZ; +, <i. We show that it is indeed recursively decidable and we prove this result by revisiting the notion of linear subsets introduced by Ginsburg and Spanier? in the sixties. Despite of its simplicity, this arithmetic is central in many areas of theoretical and applied computer science. From a theoretical point of view, it has many surprising properties: 1) it admits quantifiers elimination?,?,? and therefore it is decidable, 2) given a formula on the expansion of the structure obtained by adding the function which to each integer assigns the maximal power of 2 which divides it, it is decidable whether or not it is definable by a Presburger formula over N (Cobham-Semënov theorem? , improved in ? with a polynomial time algorithm), and 3) Presburger arithmetic is self-definable (i.e. there is Presburger definable criterion for definability? ). Moreover, there is a strong and old connection between language theory, Presburger definable sets and rational relations on Z and N dating back to the sixties?,?,? . The concept is also widely used in many application areas, such as program analysis and model-checking and more specifically timed automata: roughly speaking, the main idea is that we can describe an infinite system with unbounded integer variables using Presburger formulas as guards? (see also the introduction of ? for some historical remarks on the role of Presburger arithmetic in the development of theoretical and applied computer science). 1. Preliminaries 1.1. Variants of Presburger arithmetic As observed above, a source of confusion is the lack of agreement in the definition of Presburger arithmetic itself. We make the convention of calling weak Presburger arithmetic the structure Z W = hZ; +; 0, 1i originally studied in ?, while with Z we mean the (standard) Presburger arith- May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 3 metic hZ; =, <; +; 0, 1i. The positive Presburger arithmetic is the structure N = hN; =; +; 0, 1i and we observe that in this case the < predicate (as restriction of the order on Z to N) is already definable in N . All these three structures are decidable in the sense that given a closed formula, it is recursively decidable whether or not it holds. In particular Z W and Z admit quantifier elimination in the augmented languages with the additional unary functional symbol − and the (recursive) set of binary functional symbols (≡m )m∈N\{0,1} , having the usual meaning of opposite and modulo, while for N it suffices to add the binary functional symbols (<m )m∈N\{0} , where x <m y if and only if x < y ∧ x ≡m y ?,? . 1.2. Logical definability Here we are concerned with the definability issue. We recall that given a logical structure D with domain D and a first order formula on this structure, say φ(x1 , . . . , xn ) where x1 , . . . , xn is the set of free variables, the n-ary relation R defined by φ is the set of n-tuples (a1 , . . . , an ) such that φ holds true when the variable xi is assigned the value ai , i.e., R = {(a1 , . . . , an ) ∈ Dn | D |= φ(a1 , . . . , an )}. Example 1.1. E.g., the formula (x1 + x2 = 0) ∨ (x1 = x2 + 1) defines, in the structure Z, the union of a point and of a line in the discrete plane. 2. N-linear and Z-linear sets 2.1. Some notations The free abelian monoid and the free abelian group on k generators are respectively identified with Nk and Zk with the usual additive structure. The addition is extended from elements to subsets: if X, Y ⊆ Nk (resp. X, Y ⊆ Zk ), X + Y ⊆ Nk (resp. X + Y ⊆ Zk ) is the set of all sums x + y where x ∈ X and y ∈ Y . It might be convenient to consider the elements of Nk and Zk as vectors of the Q-vector space Qk . Given v in Nk or in Zk , the expression Nv represents the subset of all vectors nv where n range over N. This expression can be extended to Zv in a natural way whenever v is in Zk . Thus Zu + Zv represents the subgroup generated by the vectors u and v. 2.2. Linear sets The following discussion requires (the adaptation of) few definitions. The symbol K stands either for N or for Z when concerning the free abelian May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 4 group Zk or for N when concerning the free abelian monoid Nk . Definition 2.1. A subset of Zk (resp. Nk ) is K-linear if it is of the form a+ n X Kbi , a, bi ∈ Zk (resp. Nk ), i = 1, . . . , n. (1) i=1 It is K-simple if the bi ’s are linearly independent as vectors of Qk . It is K-semilinear if it is a finite union of K-linear sets and K-semisimple if it is a finite disjoint union of K-simple sets. A subset of Zk is Z-quasisimple Pn if it is of the form A + i=1 Zbi , where A is a finite set such that for all a, a0 ∈ A the vector (a − a0 ) belongs to the Q-vector space spanned by the bi ’s. Example 2.1. The subset Z(1, 0) ∪ Z(0, 1) is Z-semilinear. It is also Nsemilinear and N-semisimple (it is equal to the union of N(1, 0), (−1, 0) + N(−1, 0), N(0, 1) and (0, −1) + N(0, −1)). The subset {(0, 1), (1, 0)} + Z(2, 0)+Z(0, 2) is Z-quasilinear. The subset {(0, 1, 0), (1, 1, 1)}+Z(2, 0, 0)+ Z(0, 2, 0) is Z-semilinear but not Z-quasilinear. Ginsburg and Spanier proved? the following result for Nk , but it can readily be seen to hold for Zk . Theorem 2.1. Given a subset X of Nk (resp. Zk ) the following assertions are equivalent: (i) X is first order definable in N (resp. Z); (ii) X is N-semilinear; (iii) X is N-semisimple. Example 2.2. The binary relation of Example 1.1 is the union of the two Z-linear subsets: {(1, 1)} ∪ Z(1, −1). Clearly, a finite union of Z-linear subsets is also a finite union of N-linear subsets but the converse does not hold, e.g., a moment’s reflection will convince the reader that the subset N is not expressible as a finite union of Z-linear subsets. Still every Z-linear set is Z W -definable. Indeed, given Pn X = a + i=1 Zbi , then x = (x1 , . . . , xk ) ∈ X if, and only if, the following May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 5 (i) formula holds (where bj means the i-th component of the vector bj ): P(x) = ∃z1 . . . ∃zn k ^ (xi = a(i) + i=1 n X (i) zj b j ) . (2) j=1 Would the family of finite unions of Z-linear subsets by chance capture the notion of subsets which are definable in the structure Z W ? This is not the case, since this family is not closed under taking the complement. Actually we will see that the Boolean closure of the family of Z-linear subsets is precisely the class of Z W definable sets, see Theorem 4.1. 3. Properties of Z-linear sets Our decidability result is based on the equivalence between definable subsets in the structure Z W and the Boolean closure of the Z-linear subsets. This characterization is obtained, in particular, by proving that the class of Z-linear sets enjoys many properties such as closure under finite sum, projection, direct product, and, more interestingly, intersection. 3.1. Closure properties We start with an elementary technical result. Lemma 3.1. Let S be a Z-simple set in Zk . Then, for every v ∈ Zk , S +Zv is Z-simple. Pn Proof. We argue by induction and assume that S = i=1 Zbi , for some bi ∈ Zk such that {b1 , . . . , bn } is a linearly independent set of vectors in Zk . We may further assume that {b1 , . . . , bn , v} is linearly dependent since Pn otherwise we are done. We have hv ∈ i=1 Zbi for some h ∈ N which implies v ∈ R = hb1 /h, . . . , bn /hi as a lattice in (Z/h)k . In particular R is a free abelian group on n generators and S + Zv is a free subgroup of R. Pn There exist c1 , . . . , cn ∈ (Z/h)k such that S + Zv = hc1 , . . . , cn i = i=1 Zci (see [?, Theorem 4, (I,§10)]). But S + Zv ⊆ Zk , so that ci ∈ Zk , for every 1 ≤ i ≤ k. Finally, if the vectors ci ∈ Zk are independent in (Z/h)k , they are certainly free in Zk and so S + Zv is a Z-simple set. As a consequence we have the following two Corollaries which show a first important departure from the N-linear and Z-linear sets. Corollary 3.1. Every Z-linear set is Z-simple. May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 6 Corollary 3.2. The family of Z-simple set is closed under projection, direct product and finite sum. Pn The dimension of a simple set a + i=1 Zbi is the integer n and the dimension of a union of simple sets is the maximum dimension of these sets. E.g., the dimensions of the example in 2.2 is equal to 1 and those of example 2.1 are equal to 2. In order to prove the closure under intersection, we recall a classical and useful theorem of linear algebra (for each integer n, GLn (Z) represents the group of all n × n invertible matrices with entries in Z). Theorem 3.1 (Smith normal form, [?, p. 74]). Let A ∈ Zm×n be a matrix of rank s. Then there exist two matrices U ∈ GLm (Z) and V ∈ GLn (Z), such that D0 A0 = U AV = 0 0 where D = (dij ) ∈ Zs×s is an integer diagonal matrix such that dii divides djj for 1 ≤ i ≤ j ≤ s. Proposition 3.1. Let A ∈ Zm×n and b ∈ Zm . The set S of solutions in Zn of the linear system Ax = b is an effective Z-simple set of dimension equal to n − s where s is the rank of A. Proof. If A0 = U AV is the Smith normal form of A, then the given system is equivalent to U AV V −1 x = U b. Put V −1 x = y and U b = b0 . The set Pm of solutions of A0 y = b0 is the Z-simple set S 0 = c + i=s+1 Zei , where cj = b0j /ajj for 1 ≤ j ≤ s and cj = 0 for s < j ≤ n and the ei are the vectors of the canonical basis. Observe that the matrix V −1 has integer entries, thus y is a vector with integer entries and therefore the system admits solutions in Zn if and only if ajj divides b0j for 1 ≤ j ≤ s. The vectors ĉ = V c and êi = V ei have integer entries and the V ei ’s are linearly independent because V is unimodular (i.e. |V | = ±1). Since equality S = V S 0 holds, we Pm have S = ĉ + i=s+1 Zêi . The effectiveness should be clear, knowing that obtaining the Smith normal form is effective? . This leads us to the main property of this section. Theorem 3.2. The intersection of two simple subsets of dimension n and m is a simple subset of dimension less than or equal to min{n, m}. In particular the family of Z-simple sets is closed under finite intersection. May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 7 Pn Pm Proof. Let P = a + i=1 Zbi and Q = c + j=1 Zdj be two Z-simple sets in Zk and assume without loss of generality that n ≤ m. Consider Pn Pn+m the linear system i=1 bi xi − i=n+1 di−m xi = c − a and let S be the set of solutions in Zm+n obtained by applying Theorem 3.1, with A = [b1 , . . . , bn , −d1 , . . . , −dm ]. Observe that its rank is greater than or equal to m so that S is Z-simple with dimension is ` ≤ n. Its projection on the first n P` coordinates S 0 = πn (S) is Z-linear: S 0 = u+ i=1 Zvi , for some u ∈ Zn and vi ∈ Zn , i = 1, . . . , `. Now, considering for example the first n components Pn of S, P ∩ Q can be written as {a + i=1 xi bi | (x1 , . . . xn ) ∈ S 0 }. Define B as the k × n matrix whose columns vectors are b1 , . . . , bn and V as the n × ` matrix whose columns vectors are v1 , . . . , v` . Then the intersection can be obtained as a composition of two affine transformations φ : Zn → Zk defined by α 7→ a + αB and ψ : Z` → Zn defined by β 7→ u + βV (the matrices operate to the left on row vectors) P ∩ Q = φ(ψ(Z` )) = a + (u + Z` V )B = (a + uB) + Z` (V B). This prove that P ∩ Q is Z-linear, and via Corollary 3.1, that it is actually Z-simple. 3.2. Quasisimple sets The following two results deal with quasisimple sets which are slight generalizations of simple sets, see Definition 2.1. They will be used in the next section. Proposition 3.2. Let S, T be Z-simple sets in Zk . Suppose dim S = dim T and T ⊂ S. Then X = S \ T is a Z-quasisimple set of basis T . Pn Pn Proof. Let S = a + i=1 Zbi and T = c + i=1 Zdi , with a, c, bi , di ∈ Zk . Pn By T ⊆ S, we have c = a + i=1 γi bi , for some γi ∈ Z, so S = c + Pn Pn Pn Pn i=1 (−γi )bi + i=1 Zbi = c+ i=1 (Z−γi )bi = c+ i=1 Zbi . After possibly translating both subsets, we may suppose without loss of generality that Pn Pn c = 0, so that S = i=1 Zbi and T = i=1 Zdi . Consider the isomorphism φ which maps the subgroup generated by the bi ’s onto the free group Zn . Then φ maps T onto a subgroup of Zn of finite index and Zn \ φ(T ) is a (finite) union of cosets, so T = φ−1 (Zn \ φ(T )) is a finite union of linear Pn Pn sets of the form g + i=1 Zdi where g ∈ i=1 Zbi . In the same spirit we have the following: Proposition 3.3. Let S a finite union of Z-simple sets of dimension k in Zk . Then S is Z-quasisimple. May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 8 Proof. Let us suppose S = Sm i=1 Xi , (i) bj ’s, 1 ≤ where Xi = a(i) + Pk j=1 (i) Zbj is a Z- simple set. Since all vectors j ≤ k, are linearly independent, they generate a subgroup of Zk of finite index, in particular for every Xi there exists a morphism φi of Zk into a finite group Gi and a subset Fi ⊆ Gi such that Xi = φ−1 (Fi ). Let φ be the morphism of Zk into the direct product G = G1 × · · · × Gm defined by φ(x) = (φ1 (x), . . . , φm (x)) and let H be the set of m-tuples (g1 , . . . , gm ) ∈ G for which gi belongs to Fi for some 1 ≤ i ≤ m. Then S = φ−1 (H) which shows that S is a union of cosets of the kernel of φ. As such, it is Z-quasisimple set of dimension k. The last result of this paragraph concerns a weak condition of equality of two quasisimple sets of maximum dimension. Intuitively, it means that it suffices for two quasisimple sets to be equal almost everywhere (in some precise sense) in order to be equal. Proposition 3.4. Two quasilinear subsets of maximum dimension k are equal if, and only if, for all integers n there exists an hypercube [α1 , α1 + n] × · · · × [αk , αk + n] ⊆ Zk on which they agree. Proof. The condition is clearly necessary. In order to prove that it is sufficient, consider a morphism φ : Zk → G onto some finite group recognizing two Z-semilinear subsets X and Y , i.e., φ−1 φ(X) = X and φ−1 φ(Y ) = Y . Let n be a common multiple of degrees of the k elements φ(1, 0, . . . , 0), φ(0, 1, . . . , 0), . . . , φ(0, . . . , 0, 1). Then a vector (v1 , . . . , vk ) belongs to X if, and only if, so does the vector ([v1 ], · · · , [vk ]) where [vi ] is the remainder of the division of vi by n. Corollary 3.3. Let X and Y be two quasilinear subsets of maximum dimension k and let Z be a finite union of linear subsets of dimension less than k. Then X = Y if, and only if, X \ Z = Y \ Z. 4. Definable sets in weak Presburger arithmetic 4.1. An algebraic characterization of definable subsets The Boolean closure of the linear sets enjoys some properties which we will take advantage of when characterizing the definable sets in Z W . In particular, condition (iii) of the following Lemma is useful when designing a decision procedure. ¿From now on, “linear” and “simple” means Z-linear and Z-simple. Lemma 4.1. The following families of subsets of Zk are equal: May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 9 (i) the Boolean closure of linear sets; TJ (ii) the family of all finite unions of the form S ∩ j=1 T j where S, Tj are Z-simple; SJ (iii) the family of all finite unions of the form S \ j=1 Tj where S, Tj are Z-simple with Tj ⊂ S, and dim Tj < dim S. Proof. Clearly the families (ii) and (iii) are included in the Boolean closure of the linear sets. The family (ii) contains all linear sets (take J = 0) and all complements of linear sets (take S = Zk for S and J = 1). FurTJ thermore the complement of a subset of the form S ∩ j=1 T j is a finite union of linear sets and complements of linear set, thus the complement of a finite union of such subsets is a finite union of intersections of linear sets and complements of linear sets. Since the intersection of linear sets is again linear, this shows that the family (ii) is closed under complement, and thus coincides with the Boolean closure. We now show that each subset of the form (ii) is equivalent to a union S of subsets of the form (iii). Indeed, because of equality S \ ( i Ti ) = S S \ ( 1≤i≤r (S ∩ Ti )), without loss of generality we may assume that all Ti ’s are Z-simple subsets of S. Assume further that the p ≤ r first subsets Ti ’s have the same dimension as S, with p = 0 if no Ti has the same dimension as S. Then by repeatedly applying Lemma 3.2 to S S S S \( i Ti ) = (. . . ((S \T1 )\T2 ) . . . Tp )( i>p Ti ) we may transform S \( i Ti ) into a finite union of subsets of the form required. Theorem 4.1. The family of Z W -definable sets is the Boolean closure of the family of Z-linear sets. Proof. Clearly, all linear sets are Z W -definable, see expression (2). Let us verify the converse. Using the quantifier elimination result, all Z W definable subsets belong to the Boolean closure of the relations which are solutions of a system of linear equations or of modular equations of the type Pn i=1 ai xi ≡m b. In the former case, this is a consequence of Proposition 3.1. As for the latter case, let us proceed by induction on n. Let n = 1, then we must solve the equation ax ≡m b. If b is not a multiple of the greatest common divisor d of a and m then there is no solution. Otherwise a/d has an inverse modulo m/d and the set of solutions is defined by Pn−1 (a/d)−1 (b/d) + Z(m/d). Now if n > 1, then set t = i=1 ai xi . The con Pn Wm−1 gruence i=1 ai xi ≡m b is equivalent to j=0 t ≡m j ∧ an xn ≡m (b − j) , and so by the induction hypothesis, we may conclude. May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 10 4.2. A special case The case studied here can be considered as the top level case in the recursive procedure of the next paragraph. The following notation is useful. Given Pm a N-simple set S = a + i=1 Nbi , we denote by S Z the Z-simple set a + Pm i=1 Zbi . Theorem 4.2. Let X ⊆ Zk be a Z-definable set of the form X=T ∪ m [ Yi , i=1 Pk (i) (i) where Yi = a(i) + j=1 Nbj for some linearly independent vectors bj (i.e. it is a N-simple set of dimension k) and T is a finite union of N-simple sets of dimension less than k. Then X is Z W -definable if, and only if, it can be decomposed as S ∪ (P \ R), where: Pk S S (j) (1) P = 1≤i≤m (a(i) + j=1 Zbj ) = 1≤i≤m YiZ ; (2) R and S are Z W -definable sets which are included in a finite union of Z-simple sets of dimension less than k; (3) R ⊆ P and S ∩ P = ∅. Proof. Clearly the condition is sufficient. Suppose X is Z W -definable and express it as in (ii) of Lemma 4.1. Isolate all the simple sets of dimension k. By the set-theoretic equality ! [ [ [ [ E i \ Fi = Ei \ (Ej \ Fj ) , Fi \ i i i j6=i if the Ei ’s are simple sets of maximal dimension, by Proposition 3.3 their union is a quasisimple set and we may write X=S∪ A+ k X Zdj \ R , j=1 where A ⊆ Zk is finite, the vectors dj are linearly independent, S and R are Z W -definable sets included in a finite union of Z-simple sets of dimension less than k. Now we prove the following, which means that the symmetric difference of the two subsets is included in a finite union of linear subsets of dimension less than k: m [ i=1 a(i) + k X j=1 (i) Zbj ∼ A+ k X j=1 Zdj . May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 11 Pk Clearly, if we take a vector in A + j=1 Zdj not belonging to R ∪ T (which is contained in R ∪ T Z , that is, in a finite union of Z-simple sets of dimension less than k), it must belong to one of the Yi , and thus to Sm Pk (i) (i) + j=1 Zbj . Conversely, consider one of the sets Yi , namely i=1 a Pk Y = a + j=1 Nbj (we drop the upper indices to simplify the notation), Pk then we show Y Z ⊆ A + j=1 Zdj except for a union of Z-simple sets of dimension less than k. We observe that S is in particular Z-definable, S so S = 1≤i≤m Si , where every Si is a N-simple set of dimension less than k. For each Si , let Ji ⊆ I = {1, . . . , k} be the maximal ordered set of indices 1 ≤ j1 < · · · < jp ≤ k, such that Si is not parallel to the vectors bj , j ∈ Ji , and let πi : Zk → Z|Ji | be the projection defined by πi ((xj )j∈I ) = ((xj )j∈Ji ). So, we can define Sbi = πi−1 (Si ), if Ji 6= I, and Sbi = ∅ otherwise. E.g., if S consists of the unique simple subset (1, 0, 1) + N(0, 2, 2) + N(3, 0, 0) = {(1 + 3p, 2n, 2n + 1) | n, p ∈ N}, then it is parallel to the vector (1, 0, 0) and we have Sb = {(p, 2n, 2n + 1) | p ∈ Z, n ∈ N}. We want to show by induction on i that the subset ! [ c Wi = (Zb1 + · · · + Zbi−1 + Nbi + · · · + Nbk ) \ Sj 1≤j≤m P is included in A+ 1≤j≤k Zdj . This is clear for i = 1. Now assume 1 < i ≤ k and consider a vector v ∈ Wi . Since it does not belong to any subset Sj parallel to bi , the subset v + Nbi is included in A + Zd1 + · · · + Zdk except maybe for finitely elements which are the possible intersections of this linear set with the subsets Sj parallel to none of the vectors b1 , . . . , bk . This implies (k) (1) for sufficiently large n, v + nbi = an + λn d1 + · · · + λn dk . Since the set A is finite, the elements an ∈ A start to repeat and for some integer r the following holds for all integers m and 0 ≤ r0 < r: v + (mr + r0 )bi = ar0 + mλ(1) d1 + · · · + mλ(k) dk . For all integers `r + j ∈ Z where 0 ≤ j < r we have v + (`r + j)bi = aj + `λ(1) d1 + · · · + `λ(k) dk which shows that v + Zbi ⊆ A + Zd1 + · · · + Zdk . Because of Corollary 3.3, X can be written as S ∪ (P \ R), where S and R are Z W -definable sets which are included is simple sets of dimension less than k and which are computable from T and form the Yi ’s. To end the proof we must verify the last item; indeed, we have: S ∪ P \ (R \ S) = S ∪ (P ∩ (R ∪ S)) = S ∪ (P ∩ S) ∪ (P \ R) = S ∪ P \ R, May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 12 and observe that since R is included in P so is R \ S which shows that we may assume S ∩ R = ∅. Furthermore, we have S ∪ P \ R = (S ∩ P ) ∪ (S \ P ) ∪ (P ∩ R) = S \ P ∪ (P ∩ (S ∪ R)). Since S ∩ R = ∅ holds we have S ∪ R = R which shows that without loss of generality we may suppose that S ∩ P = ∅ holds. This implies X \ P = S, P \ X = R. 4.3. The procedure We recall our problem. Given a subset X ⊆ Zk which is Z-definable, i.e., specified as a finite union of N-simple sets, decide whether or not it is actually Z W -definable and, in the affirmative case, give a representation as Boolean combination of Z-simple sets. We cannot directly use Theorem 4.2, because it requires that one of the simple sets in the specification have dimension k. So we proceed as follow: (1) Let X ⊆ Zk be the union of the sets Xi = a(i) + Ji X (i) Nbj , 1 ≤ i ≤ m. j=1 PJ Consider all the affine subspaces of Qk , Hi = ha(i) + j=1 Qbj ∩ Zk , and suppose (after possibly changing some indices) H1 , . . . , Hr , r ≤ m, are the maximal (for the inclusion) elements of the collection H = {Hi | 1 ≤ i ≤ m}. (2) Compute all the sets Hi0 = Hi ∩ Zk and observe that they are ZW PJ definable. Indeed for a subset of the form H = a + j=1 Qbj ∩ Zk , where a, bj ∈ Zk , there exist k − J linear equations F1 (y) = 0, . . . , Fk−J (y) = 0 whose set of solutions is exactly the subspace generated by the vectors bj . Then H is defined by the Presburger formula ∃y (x = y + a) ∧ (F1 (y) = 0) ∧ . . . ∧ (Fk−J (y) = 0) . Clearly, X is Z W -definable if, and only if, all the intersections Yi = X ∩ Hi0 are Z W -definable. (3) For all 1 ≤ i ≤ r, consider an isomorphism τi : Hi → QJi such that τi (Hi0 ) = ZJi . Such isomorphism clearly exists and moreover it can be expressed, relatively to Hi0 , in the structure Z W , so that τi (Yi ) is again a Z W -definable set if, and only if, Yi is Z W -definable. May 31, 2007 19:47 WSPC - Proceedings Trim Size: 9in x 6in ictcs 13 (4) Finally we can apply Theorem 4.2 to τi (Yi ), since it has at least one component of maximal dimension J, obtaining the sets Pi , Si , and Ri that satisfy all conditions of 4.2. Now Yi = τi−1 (Si ) ∪ τi−1 (Pi ) ∩ τi−1 (Ri ) , and observe that the inverse images of Pi , Si , and Ri by τ again satisfy the three conditions, in particular τi−1 (Pi ) is Z-simple. (5) Now apply the procedure recursively to the sets τi−1 (Si ) and τi−1 (Ri ). (6) It only remains to observe that if we fail to apply Theorem 4.2, this means that the set X actually was not Z W -definable.