Deciding whether the ordering is necessary in a Presburger formula

We characterize the relations which are ﬁrst-order deﬁnable in the model of the group of integers with the constant 1 . This allows us to show that given a relation deﬁned by a ﬁrst-order formula in this model enriched with the usual ordering, it is recursively decidable whether or not it is ﬁrst-order deﬁnable without the ordering.


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, namely quantifier elimination, holds when the structure is enriched with the binary relation "<".In (1), which is the main reference on the subject, Presburger arithmetic is defined as the elementary theory of integers with equality, addition and having 0 and 1 as constant symbols and "<" as binary predicate, see also (20).On the other hand, the majority of the "modern" papers referring to Presburger arithmetic is concerned with the natural numbers where the order relation is unnecessary as it is first-order expressible in N; + .
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 Z; +, 0, 1 which we call the weak Presburger arithmetic, for a given relation defined in Z; +, <, 0, 1 .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 (9; 10; 11; 12) in the sixties for n-ary relations on N. Other problems of definability in substructures of Presburger arithmetic introduced in (15) have been solved positively in (4): given a formula in the Presburger arithmetic, it is recursively decidable whether or not it can be expressed in the structure with domain Z (resp.N) and with the unique predicates of the form x − y > a and x > a for all a ∈ Z (resp.a ∈ N).
Despite its simplicity, Presburger arithmetic is central in many areas of theoretical and applied computer science.From a theoretical point of view, it has many remarkable properties: 1) it admits quantifier elimination (1; 19; 20) 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, (18); the claim of a polynomial time algorithm can be found in (17).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 (2; 7; 9).The concept is also widely used in many application areas, such as program analysis and model-checking and more specifically timed automata since it models infinite systems, see for example (3).
The paper is organized as follows.Section 1 recalls known results which are necessary for the rest of the paper, essentially around the notion of linear sets in Z n .Section 2 investigates the closure properties of the linear sets.This allows us to give in Section 3 a characterization of the subsets of Z n which are definable in the weak Presburger arithmetic, along with a decision procedure.

Variants of Presburger arithmetic
In this paper we deal with first-order languages with equality, i.e., the signature of a structure implicitly contains the symbol "= ".As observed in the introduction, 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 = Z; +; 0, 1 originally studied in (19) (see also (21) for an English translation and commentary), while with Z we mean the (standard) Presburger arithmetic Z; +, <, 0, 1 .Observe that the predicate <, as restriction of the order on Z to N, is already definable in N; + .These structures are decidable in the sense that given a closed formula, it is recursively decidable whether or not it holds in that structure.In particular Z W admits quantifier elimination in the augmented language with the additional unary functional symbol "− " and the (recursive) set of binary relations {≡ m } m∈N\{0,1} , having the usual meaning of opposite and modulo.As for Z, quantifier elimination is obtained in the same augmented language enriched with the binary relation <.

Logical definability
Here we are concerned with the definability issue.Consider a structure D with domain D and a first-order formula on this structure, say φ(x 1 , . . ., x n ), where x 1 , . . ., x n are its free variables.Then the n-ary relation R defined by φ is the set of n-tuples (a 1 , . . ., a n ) such that φ holds true when the variable x i is assigned the value a i , i.e., R = {(a 1 , . . ., a n ) ∈ D n | D |= φ(a 1 , . . ., a n )}.A relation is D-definable or simply definable when the structure is understood, if it can be defined by a first-order formula on D.
The following is the main result on the integer arithmetic without multiplication.It proves that it admits quantifier elimination and it is due to Presburger, cf.(19).
Theorem 1.1 (Presburger) A subset X of Z n is Z-definable if and only if it is a Boolean combination of relations defined by predicates of the form t < t and t ≡ t (mod b) where t and t are linear expressions on the integer variables x i of the form a 0 + n i=1 a i x i with a i ∈ Z, and b ∈ N, b > 1.
A subset X of Z n is Z W -definable if and only if it is a Boolean combination of relations defined as in (1) where the binary relation < is replaced by the equality.

Linear sets
The following definitions could be given for arbitrary finitely generated commutative monoids but we are mainly interested in the free commutative group Z n .We consider it as a subset of the Q-vector space Q n and view its elements as row vectors.The operation of addition is extended from elements to subsets: if X, Y ⊆ Z n , then the sum X + Y ⊆ Z n is the set of all sums x + y where x ∈ X and y ∈ Y .When X is a singleton {x} we simply write x+Y .Given x in Z n , the expression Nx represents the subset of all vectors nx where n range over N and similarly for Zx.For example, Zx + Zy represents the subgroup generated by the vectors x and y.We extend also the matricial notation to subsets, e.g., if A is an (n × p)-matrix with integer or rational entries, then Q n A stands for the set of all p-row vectors of the form xA for some n-row vector x ∈ Q n .
We now briefly recall the classical theory of the linear and semilinear subsets of Z n as exposed in (7).
It is N-simple if the vectors b i are linearly independent as vectors of Q n .It is N-semilinear if it is a finite union of linear sets.
Ginsburg and Spanier proved (11) the following equivalent statements for N n , but it can readily be seen to hold for Z n .Together with Theorem 1.1, it can be interpreted as saying that the first-order definable sets in Z; +, 0, 1, < are exactly the rational subsets of Z n .Actually Eilenberg and Schützenberger in (7), and independently Ito in (14), strengthened the third condition by proving that the simple sets may be assumed disjoint.
Theorem 1.3 Given a subset X of Z n , the following assertions are equivalent: Furthermore, each of the specifications can be effectively transformed into another.
When dealing with a linear subset, this result allows us to assume that it is given as a finite union of simple subsets.
The following notion of dimension will be useful in the sequel.It is defined on linear sets but extended to arbitrary sets in a natural way.Definition 1. 4 The dimension of the simple set a + m i=1 Nb i is the integer m.More generally, the dimension of an arbitrary nonempty subset X ⊆ Z n is the minimum integer m, denoted dim(X), such that X is included in a finite union of simple sets of dimension at most m.The dimension of the empty set is equal to −1.
Observe that the dimension of a finite union of simple sets does not depend on the specific expression which defines it.This is seen by observing that an expression of a simple set of dimension m as a finite union of simple sets contains a simple set of dimension m and no simple set of dimension greater than m and that equality dim(A ∪ B) = max{dim(A), dim(B)} holds.Indeed, since dimension is a nondecreasing operator, we have dim(A ∪ B) ≥ dim(A) and dim(A ∪ B) ≥ dim(B) and therefore dim(A ∪ B) ≥ max{dim(A), dim(B)}.The other direction is trivial.As a result we have the following proposition.
Proposition 1.5 Given a subset X ⊆ Z n specified by some first-order formula in Z and some integer 0 ≤ d ≤ n, it is recursively decidable whether or not it has dimension at most d.
Proof: Indeed, using Ginsburg and Spanier's construction in (11, Theorem 1.3.), an expression as a finite union of simple sets for X can be effectively computed from the first-order formula specifying it.A simple inspection suffices to determine whether or not the linear sets composing it have dimension less than or equal to d. 2

Z-linear sets
We now extend the notion of N-linear subsets defined in Section 1.3 to Z-linear subsets by allowing the coefficients of expression (2) to be in Z.
The notions of Z-simple and Z-semilinear sets are defined with the obvious modifications of Definition 1.2.
There exists a notion which is halfway between that of simple and that of arbitrary disjoint unions of simple sets.We use the standard geometric notion of translation, restricted to Z n , which is a mapping of the form x → a + x for some given vector a ∈ Z n .A translate of a subset is its image in a translation.
Definition 1.7 A subset is quasi-simple if it is a finite union of translates of a given simple set S. This is equivalent to saying that it is a set of the form A + S, where A ⊆ Z n is finite and S is a subgroup of Z n .The set S is called template.
Clearly, a finite union of Z-linear subsets is also a finite union of N-linear subsets.
Proposition 1.8 Every Z-linear subset of Z n is a finite union N-linear subsets.
Proof: Indeed, a Z-linear subset as in expression ( 3) is equal to the union of all a + k i=1 N( i b i ) where ( 1 , . . ., k ) ranges over the set {±1} k . 2 The converse does not hold, e.g., the subset N is not expressible as a finite union of Z-linear subsets (this is a direct consequence of Theorem 1.1 and Theorem 1.3 but can be worked out directly too).
2 Closure properties

Properties of Z-linear sets
Our decidability result is based on the equivalence between definable subsets in the structure Z W and the family of finite unions of subset differences of Z-semilinear subsets, see subsection 2.2.This characterization is obtained by a careful study of the closure properties of the family of Z-linear sets carried out here.
We will show that the class of Z-linear sets enjoys many properties such as closure under finite sum as defined in subsection 1.3, projection, direct product and even more interestingly intersection, making it a more robust family than the family of N-linear sets since N-linear sets are not closed under intersection.On the opposite, the family of N-semilinear sets is more robust than that of Z-semilinear sets, in fact while the first is closed under all Boolean operations, the second is not.The sets belonging to the Boolean closure of the Z-linear sets have a more complex representation (see Theorem 3.1).
We start with a property which shows how different the N-and the Z-linear subsets are.In the case of the nonnegative integers, every linear set is a finite disjoint union of simple sets.For Z, we have a stronger property which is a direct consequence of a classical algebraic result.
It suffices to consider the case where a is null.Then X is a subgroup of Z n and therefore it is free, (16, Theorem 4, (I, §9))), i.e., there exists h ≤ n linearly independent vectors b i ∈ Z n such that X = h i=1 Zb i . 2 Using standard manipulations we get the following proposition.

Proposition 2.2
The family of Z-linear sets is closed under projection, direct product and finite sum.
Observe that N-linear sets are closed under direct product and finite sum but they are not closed under projection.Indeed, consider the N-linear (actually N-simple) set N(2, 1) + N(3, 1).Its projection onto the first component is the set The following is a kind of closure property under composition.
is Z-linear.
Proof: Indeed, denote by B the (p × n)-matrix consisting of the p row-vectors b i and by D the (m × p)matrix consisting of the m row-vectors d j .Then the set defined in ( 4) is equal to The intersection of two N-linear subsets is a finite union of N-linear subsets, not necessarily an N-linear subset.Here we have a stronger property: the intersection of two Z-linear subsets is a Z-linear subset.We prove this result by resorting to a different approach from that in (7) which is purely combinatorial and proceeds by induction on the dimension of the space while we make use of a classical theorem of linear algebra.We recall that GL n (Z) represents the unimodular group which consists of all the invertible n × n-matrices with entries in Z.We denote by rank(A) the rank of the matrix A.
Theorem 2.4 (Smith normal form (6, §2.4.4))Let A ∈ Z n×m be an integer matrix of rank s.Then there exist two unique invertible matrices U ∈ GL n (Z) and V ∈ GL m (Z), such that The matrix A is called the Smith normal form of A. The following is a preparatory result.
Proposition 2.5 Given A ∈ Z n×m and b ∈ Z n , the set of solutions in Z m of the linear system Ax = b is a Z-simple set of dimension m − rank(A).
Proof: Let rank(A) = s and A = U AV be the Smith normal form of A. The given system is equivalent to Ze i , where c j = b j /a jj for 1 ≤ j ≤ s and c j = 0 for s < j ≤ m and the e i are the vectors of the canonical basis (observe that the system admits solutions in Z m if and only if a jj divides b j , for 1 ≤ j ≤ s).Then the set of solutions of the equation Ax = b is equal to S = V S , and so if ĉ = V c and êi = V e i , we have S = ĉ + m i=s+1 Zê i .Because V is unimodular, the vectors êi are again linearly independent, so the set has dimension equal to m − rank(A). 2 Consequently, we have the following theorem.
Theorem 2.6 If P and Q are Z-simple sets of Z n of dimension p and q respectively, then P ∩ Q is a Zsimple set of dimension less than or equal to min{p, q}.Furthermore, an expression for this intersection can be computed effectively. Proof: Zd j be two Z-simple sets in Z n with p ≤ q and suppose that P ∩ Q = ∅.Let us consider the linear system p i=1 b i x i + p+q i=p+1 d i−q x i = c − a and let S be its set of solutions in Z p+q .Then S is a Z-simple set in Z p+q and so, its projection T on the first p components is a Z-linear set in Z p , say T = e + i=1 Zf i , for some e, f i ∈ Z p and ≤ p. Considering the first p components of S, we have the following expression for P ∩ Q: It then suffices to apply Proposition 2.3.Concerning the complexity of the computation, it directly follows from the fact that Smith normal form of A can be computed in polynomial time, see (22). 2 We now turn to the union operation.Its is clear that the union of two Z-simple sets in Z n is not necessarily simple, e.g., in Z, the singletons {0} and {1} are simple but their union is not.However, when the simple sets have maximal dimension, i.e., when their dimension equals n, the union is almost simple.This is expressed rigorously in the next result.
Proposition 2.7 Every finite union of Z-simple sets of maximal dimension is a Z-quasi-simple set.
Proof: Let S ⊆ Z n be a Z-semilinear set of the form j is a Z-simple set.Since for each fixed i = 1, . . ., m, the vectors b (i) j , 1 ≤ j ≤ n, are linearly independent, these vectors generate a subgroup of Z n of finite index.In particular X i − a (i) is the inverse image of the unit of a finite commutative group.In other words there exists a surjective morphism ϕ i of Z n into a finite commutative group G i such that Then S = ϕ −1 (K), which means that S is a union of cosets of the subgroup ϕ −1 (e) where e is the unit of the direct product The following proposition expresses also an interesting property.
Observing that for A, B ⊆ Z n , v ∈ Z n , we have (A + v) ∩ (B + v) = (A ∩ B) + v, we can suppose without loss of generality that c = 0, so that S = m i=1 Zb i and T = m i=1 Zd i .Then S and T are additive groups of finite index and moreover T is a subgroup of S, so S \ T can be written as a finite union of cosets of T , which completes the proof. 2 Corollary 2.9 Let S and T be Z-simple sets of maximal dimension n in Z n .Then X = S \ T is a Z-quasi-simple set of dimension n with template T .
Proof: Observe that S \ T = S \ (S ∩ T ).From Theorem 2.6, S ∩ T is again a Z-simple set of dimension n.Then (S ∩ T ) ⊆ S holds so that we can apply Proposition 2.8. 2 The following proposition provides us with a remarkable family of Z-simple sets which are the traces of the affine Q-spaces in Z n .Proposition 2.10 Let H = a + p i=1 Qb i ⊆ Q n with 0 ≤ p ≤ n and a, b i ∈ Z n , i = 1, . . ., p. Then H = H ∩Z n is a Z-simple set of Z n of the same dimension as that of H. Moreover a Z-simple expression for H is effectively computable.
Proof: Without loss of generality we can suppose that 0 ∈ H and that dim(H) = p < n holds so that H = Q p A, where A is the (p × n)-matrix whose rows are the p vectors b i .From Theorem 2.4 there exist two integer invertible matrices U ∈ GL p (Z) and V ∈ GL n (Z) such that where all the coefficients d i are integers.Since U and V are invertible we have and, from the unimodularity of U and V , Z n V = Z n and Q p U −1 = Q p .Furthermore, we clearly have so we we obtain Denote by V the matrix obtain from V −1 by substituting 0 for all entries in the last n − p rows, we finally get: As a rephrasing of the previous proposition we obtain the following result which involves a notion of saturation.
Corollary 2.11 For all Z-simple sets X = a + p i=1 Zb i , the set is Z-simple and has the same dimension as X.

Boolean closure
The previous results show that the Z-linear subsets enjoy stronger closure properties than the N-linear subsets but that they still fail to form a Boolean algebra.As the family of finite unions of N-linear sets is closed under the Boolean operations, we may wonder whether or not so is the family of finite unions of Z-linear subsets.This is not so and here is how it can be seen.Consider the singleton {0} in Z.Its complement cannot be expressed as a finite union of Z-linear subsets.Indeed, such a finite union would consist of a finite subset of Z and, by Proposition 2.7, a union of cosets of a subgroup of the form pZ, i.e., it would be cofinite if and only if it were equal to Z, contradiction.So, we are led to consider the family of finite unions of differences of Z-semilinear sets.Definition 2.12 We denote by F the family of finite unions of subsets of the form A \ B where A and B are Z-semilinear sets.
We shall see that F is the Boolean closure of the Z-linear subsets.In the meantime, we show that these subsets may be written in different relatively simple ways.Proposition 2.13 Let X ⊆ Z n .Then the following conditions are equivalent: (i) the set X belongs to F; (ii) the set X is a finite union of subsets of the form where T 1 , . . ., T m and S 1 , . . ., S m are Z-simple sets and T i ⊆ S i for 1 ≤ i ≤ m; (iii) the set X is a finite union of subsets of the form where T 1 , . . ., T m and S are Z-simple sets and T i ⊆ S for 1 ≤ i ≤ m; (iv) the set X is a finite union of subsets of the form where T 1 , . . ., T m and S are Z-simple sets and dim(T i ) < dim(S), for 1 ≤ i ≤ m.
Proof: We prove that condition (i) implies (ii).It suffices to start with a subset of the form where the sets S 1 , . . ., S l , T 1 , . . ., T m are Z-simple.Applying the three rules of set differences so the first implication is proved.Now let us prove that condition (ii) implies condition (iii).It suffices to start with a subset of the form where the sets S 1 , . . ., S m , T 1 , . . ., T m are Z-simple and T i ⊆ S i for all 1 ≤ i ≤ m.Then the set in (10) can be written as where Observe that the set m i=1 S i is Z-simple by Theorem 2.6 and that so is each of the sets T i for the same reason.To prove the implication from condition (iii) to condition (iv), it suffices to show that each Z-linear subsets T i may be furthermore assumed of dimension less than s where s = dim(S).Indeed, after possible renumbering of the sets T i , we may assume that the p first of them are of dimension s and that the remaining are of lesser dimension.Write By Proposition 2.8 the set i . . .S \ T 1 \ . . .\ T p is a finite union of Z-simple set of dimension s, say S 1 , . . ., S r .Since the set difference distributes over the union the above expression (11) is the union over i j = 1, . . ., r of the subsets which completes the verification of this implication.The implication from condition (iv) to condition (i) is trivial. 2 We are now in a position to prove the main result of this section.
Theorem 2.14 The family F is an effective Boolean algebra, i.e., given two subsets X, Y ⊆ Z n specified as in Definition 2.12, there exists a procedure that computes the specification of the subsets X ∪ Y , X ∩ Y and Z n \ X.
Proof: Since F is defined as a collection of finite unions of sets, in order to prove the closure under complement we first have to prove the closure under intersection.Remembering that intersection distributes over union, it suffices to consider intersections of the form P ∩ Q with where all the sets S, S , T 1 , . . ., T l , T 1 , . . ., T m are Z-simple.Applying the general set theoretical equivalence and then applying Theorem 2.6 to S ∩ S , we get the required form for the intersection P ∩ Q.
Concerning the complement, and due to the fact that F is trivially closed under union and, as we have proved, also intersection, is suffices to consider the complement of the set T i , defined as above.Then its complement P can be equivalently written as namely in the required form.Effectiveness follows from Theorem 2.6 since intersection between Z-simple sets is the only real operation we have to perform. 2 We can interpret the previous result as a bound for nested Boolean operations, in the sense that no matter what Boolean combination of Z-simple sets, it can be always written in such way that its derivation tree has no more than three levels.
For our decision procedure we will need more detailed information about Boolean operations between sets belonging to the family F. In particular we can be more precise when simple subsets of maximal dimension are involved.Proposition 2.15 Let X a subset of Z n such that where the S 1 , . . ., S m are Z-simple of maximal dimension n, each T 1 , . . ., T m belongs to the family F and is included into a finite union of Z-simple of dimension strictly less than n.Moreover if we have that T i ⊆ S i for all 1 ≤ i ≤ n, then X can be written in the form where T belongs to the family F and is included in a finite union of Z-simple sets of dimension strictly less than n.
Observe that we may not assume that T is a finite union of simple sets of dimension less than n, even if this is true for all sets T i .Indeed, consider for example the set X defined as where and we already know that the set (Z \ {0}) × {0} is not Z-semilinear.
Proof: Without loss of generality we can suppose n = 2. Then from set theoretical rules, we have the equivalence From Proposition 2.7 it follows that S 1 ∪ S 2 is a Z-quasi-simple set of maximal dimension n.From Proposition 2.8, the subsets S 1 and S 2 are again Z-quasi-simple.Finally from Theorem 2.6 it follows that the union of the last three terms of the above expression is included into a finite union of Z-simple sets of dimension less than n and moreover belongs to F as an immediate consequence of Theorem 2.14. 2 3 The weak Presburger arithmetic

Definable sets in the weak Presburger arithmetic
We are now in a position to prove the main result of this section which gives an algebraic characterization of the Z W -definable sets.
Theorem 3.1 The family F coincides with the family of Z W -definable sets.
Proof: Since F is the Boolean closure of the family of Z-simple sets, in order to prove that each element of F is Z W -definable, it suffices to prove that an arbitrary Z-simple set We now prove the converse.To that order, we use Presburger's elimination of quantifiers which asserts that every formula ϕ(x 1 , . . ., x n ) with n free variables is equivalent to a Boolean combination of formulas of the form n i=1 a i x i + b = 0 and of the form n i=1 a i x i ≡ m b, with a i , b ∈ Z. Concerning the first type of predicate, Proposition 2.5 where the matrix A is reduced to a unique row, guarantees that the set of solutions is linear.As for the second type, we prove by induction on n that it defines a Z-semilinear set.For n = 1, we get ax ≡ m b.If the equation ax = b has no solution in the finite cyclic group Z/mZ, then the relation defined by ϕ is empty.Otherwise, let 0 ≤ c 1 < • • • < c s < m be the set of solutions in Z/mZ (we identify the nonnegative integers less than m with their natural image in the group Z/mZ).Then the formula ϕ defines the subset of integers x such that x = c + mZ, for some c ∈ {c 1 , . . ., c s }, i.e., the Z-semilinear set s i=1 By induction hypothesis, the subformula n−1 i=1 a i x i ≡ m j defines a Z-semilinear subset, say T j ⊆ Z n−1 , and a n x n ≡ m (b − j), as proved above, another Z-semilinear subset, say R j ⊆ Z.Because of Proposition 2.2, the family of finite union of Z-simple sets is closed under direct product, so the relation is equal to The last result asserts, loosely speaking, that a Presburger (resp.weak Presburger) definable subset of Z n included in a simple set, is a Presburger (resp.weak Presburger) definable subset of that subspace.Proposition 3.2 Let X = a + p i=1 Zb i ⊆ Z n be a simple set and let τ : X → Z p be the mapping of X onto Z p which assigns to each a + p i=1 λ i b i the element (λ 1 , . . ., λ p ) ∈ Z p .Then a subset Y of X is Z-definable (resp.Z W -definable) if and only if the set τ (Y ) is Z-definable (resp.Z W -definable).
Proof: Observe that the function τ is well-defined since the vectors b i are linearly independent.Now, if ϕ(x 1 , . . ., x n ) is a Z-(resp.Z W -) formula defining a subset Y ⊆ X, then the subset τ (Y ) is defined by the Z-(resp.Z W -) formula

Decidability of weak Presburger logic in Presburger logic
We recall that the problem of deciding whether or not a relation definable in Büchi arithmetic can be actually defined in Presburger arithmetic has been positively answered in (18).Here instead of considering Presburger arithmetic with a superstructure, we consider it with a substructure: we prove that it is decidable whether or not a given formula of the structure Z; +, <, 0, 1 is equivalent to some formula in the structure Z; +, 0, 1 .
The procedure for deciding weak Presburger definability proceeds by induction on the dimension of the subsets.To that purpose, we introduce the following notation.Let X and Y be two subsets of Z n .If dim(X) = dim(Y ) = k > 0, we write X ∼ Y if the symmetric difference X∆Y = X \ Y ∪ Y \ X has dimension less than k.Otherwise, i.e., if dim(X), dim(Y ) ≤ 0, we put X ∼ Y if and only if X = Y .The relation is clearly an equivalence relation and plays an important role in our decision procedure.

A special case
Our decision procedure relies on the following structural characterization of the Z-definable subsets of maximal dimension.The general case, i.e., when no assumption is made on the dimension, is, as we shall see, a reduction to this special case.Therefore, the following theorem can be considered as the crux of the algorithm.Given an N-simple set S = a + m i=1 Nb i we denote by S Z the Z-simple set a + m i=1 Zb i and we extend this notation to finite unions of N-simple sets.Also we denote by S Q the Z-simple sets a + m i=1 Qb i ∩ Z n , cf.Corollary 2.11.Theorem 3.3 Let X ⊆ Z n be a Z-definable set, where the sets Y i are N-simple sets of dimension n and where T is a finite union of N-simple sets of dimension less than n.
Then X is Z W -definable if, and only if, the sets X \ P and P \ X are Z W -definable subsets of dimension less than n.
Proof: The subset P is clearly Z W -definable. Now we have X = X \ P ∪ P \ (P \ X) (13) which shows that the condition is sufficient.Let us prove that it is necessary.If X is Z W -definable so are X \ P and P \ X.Since (13) always holds, it suffices to prove that X \ P and P \ X are of dimension less than n and since X \ P ⊆ T holds, we prove that P \ X has dimension

Proposition 2 . 8
Let S, T be Z-simple sets in Z n .If dim(S) = dim(T ) and T ⊆ S, then X = S \ T is a Z-quasi-simple set with template T .Proof: Let dim(S) = dim(T ) = m ≤ n, then S = a + m i=1 Zb i and T = c + m i=1 Zd i , with a, c, b i , d i ∈ Z n for 1 ≤ i ≤ m.From T ⊆ S we have c = a + m i=1 γ i b i , so

∃x 1 .
. .∃x n   ϕ(x 1 , . . ., x n ) ∧ n j=1 x j = a j + p i=1 b ij y j   ,where a j and b ij represent the j-th component of the vectors a and b i .Conversely, if for some subset Y of X the set τ (Y ) is definable by some Z-(resp.Z W -) formula ψ(y 1 , . . ., y p ) , then Y is definable by the Z-(resp.Z W -) formula ∃y 1 . . .∃y p   ψ(y 1 , . . ., y p ) ∧

2
. Denote by a j and b ij respectively the j-th component of the vectors a and b i .For simplicity, identify assignments of variables with variables themselves.Then (x 1 , . . ., x n ) belongs to X if and only if the variables x 1 , . . ., x n satisfy the formula ϕ with ϕ(x 1 , . . ., x n ) ≡ ∃y 1 . . .∃y m