Distance Constraint Satisfaction Problems1footnote 11footnote 1An extended abstract of this paper appeared at MFCS 2010 BodDalMarPin ().

# Distance Constraint Satisfaction Problems111An extended abstract of this paper appeared at MFCS 2010 BodDalMarPin ().

Manuel Bodirsky222Manuel Bodirsky and Antoine Mottet have received support from the European Research Council under the European Community’s Seventh Framework Programme (FP7/2007-2013 Grant Agreement no. 257039). Victor Dalmau333Victor Dalmau has been supported by the MCINN grant TIN2010-20967-C04-02. Barnaby Martin444Barnaby Martin is supported by EPSRC grant EP/L005654/1. Antoine Mottet555Manuel Bodirsky and Antoine Mottet have received support from the European Research Council under the European Community’s Seventh Framework Programme (FP7/2007-2013 Grant Agreement no. 257039). Michael Pinsker666Michael Pinsker is grateful for support through Erwin-Schrödinger-Fellowship J2742-N18 and projects P21209 and P27600 of the Austrian Science Fund (FWF), as well as through an APART-fellowship of the Austrian Academy of Sciences. Institut für Algebra, TU Dresden, Dresden, Germany Universitat Pompeu Fabra, Barcelona, Spain. Department of Computer Science, Middlesex University, London, UK. Department of Algebra, MFF UK, Sokolovska 83, 186 00 Praha 8, Czech Republic.
###### Abstract

We study the complexity of constraint satisfaction problems for templates over the integers where the relations are first-order definable from the successor function. In the case that is locally finite (i.e., the Gaifman graph of has finite degree), we show that is homomorphically equivalent to a structure with one of two classes of polymorphisms (which we call modular max and modular min) and the CSP for can be solved in polynomial time, or is homomorphically equivalent to a finite transitive structure, or the CSP for is NP-complete. Assuming a widely believed conjecture from finite domain constraint satisfaction (we require the tractability conjecture by Bulatov, Jeavons and Krokhin in the special case of transitive finite templates), this proves that those CSPs have a complexity dichotomy, that is, are either in P or NP-complete.

###### keywords:
constraint satisfaction problems, complexity dichotomy, integers with successor, reducts, primitive positive definability, endomorphisms
###### Msc:
[2010] 03D15
\newdefinition

Definition[Theorem]Definition

## 1 Introduction

Constraint satisfaction problems appear naturally in many areas of theoretical computer science, for example in artificial intelligence, optimization, computer algebra, computational biology, computational linguistics, and type systems for programming languages. Such problems are typically NP-hard, but sometimes they are polynomial-time tractable. The question as to which CSPs are in P and which are hard has stimulated a lot of research in the past 15 years. For pointers to the literature, there is a collection of survey articles CSPSurveys ().

The constraint satisfaction problem CSP for a fixed (not necessarily finite) structure with a finite relational signature is the computational problem of deciding whether a given primitive positive sentence is true in . A formula is primitive positive if it is of the form where each is an atomic formula over , that is, a formula of the form or for a relation symbol of a relation from . The structure is also called the template of the CSP.

The class of problems that can be formulated as a CSP for a fixed structure is very large. It can be shown that for every computational problem there is a structure such that the CSP for is equivalent to this problem under polynomial-time Turing reductions BodirskyGrohe (). This makes it very unlikely that we can give good descriptions of all those where the CSP for is in P. In contrast, the class of CSPs for a finite structure is quite restricted, and indeed it has been conjectured that the CSP for is either in P or NP-complete in this case FederVardi (). So it appears to be natural to study the CSP for classes of infinite structures that share good properties with finite structures.

In graph theory and combinatorics, there are two major concepts of finiteness for infinite structures. The first is -categoricity: a countable structure is -categorical if and only if its automorphism group has for all only finitely many orbits in its natural action on -tuples Oligo (); Marker (); Hodges (). This property has been exploited to transfer techniques that were known to analyze the computational complexity of CSPs with finite domains to infinite domains BodirskyNesetrilJLC (); tcsps-journal (); BodPin-Schaefer-both (); see also the introduction of BodChenPinsker ().

The second concept of finiteness is the property of an infinite graph or structure to be locally finite (see Section 8 in diestel ()). A graph is called locally finite if every vertex is contained in a finite number of edges; a relational structure is called locally finite if its Gaifman graph (definition given in Section 2) is locally finite. Many conjectures that are open for general infinite graphs become true for locally finite graphs, and many results that are difficult become easy for locally finite graphs.

In this paper, we initiate the study of CSPs with locally finite templates by studying locally finite templates that have a first-order definition in , that is, has the domain and all relations of can be defined by a first-order formula over the successor relation on the integers, .

As an example, consider the directed graph with vertex set which has an edge between and if the difference, , between and is either or . This graph is the structure where , which has a first-order definition over since if and only if

 succ(x,y)∨∃u,v(succ(x,u)∧succ(u,v)∧succ(v,y)).

Another example is the undirected graph with vertex set where two integers are linked in if the distance, , is one or two.

Structures with a first-order definition in are particularly well-behaved from a model-theoretic perspective: all of those structures are strongly minimal Marker (); Hodges (), and therefore uncountably categorical. Uncountable models of their first-order theory will be saturated; for implications of those properties for the study of the CSP, see BodHilsMartin (). In some sense, constitutes one of the simplest infinite structures that is not -categorical.

The corresponding class of CSPs contains many natural combinatorial problems. For instance, the CSP for the structure is the computational problem of labeling the vertices of a given finite directed graph such that if is an arc in , then the difference between the label for and the label for is one or three. It follows from our general results that this problem is in P. The CSP for the undirected graph is exactly the -coloring problem, and thus NP-complete. This is readily seen if one observes that any homomorphism of a graph into the template modulo gives rise to a -coloring of . In general, the problems that we study in this paper have the flavor of assignment problems where we have to assign integers to variables such that various given constraints on differences and distances (and Boolean combinations thereof) between variables are satisfied. We therefore call the class of CSPs whose template is locally finite and definable over distance CSPs. Our main result is the following classification result for distance CSPs.

###### Theorem 1

Let be a locally finite structure with a first-order definition in . Then at least one of the following applies.

• has an endomorphism with finite range, and the CSP for equals the CSP for a finite structure;

• the CSP for is NP-complete;

• is homomorphically equivalent to a structure with a first-order definition in which has a binary modular max or modular min polymorphism, and the CSP for is in P.

If a locally finite structure with a first-order definition in has a finite core, then a widely accepted conjecture about finite domain CSPs implies that the CSP for is either NP-complete or in P. In fact, for this we only need the (open) special case of the conjecture of Feder and Vardi FederVardi () that states that the CSP for finite templates with a transitive automorphism group is either in P or NP-complete (see Section 7 for details).

To show our theorem, we prove that if the first two items of the statement do not apply, then is homomorphically equivalent to a structure with a first-order definition in that has one of two specific classes of polymorphism which we call modular max and modular min (defined in Section 5). Using these polymorphisms, we further show that the CSP for , and hence also that for , can be solved in polynomial time by certain arc consistency techniques. Polynomial-time tractability results based on arc consistency were previously known for finite or -categorical templates; using the local finiteness assumption we manage to apply such techniques to templates which are not -categorical.

On the way to our classification result we derive several facts about structures definable in , and automorphisms and endomorphisms of these structures, which might be of independent interest in model theory, universal algebra, and combinatorics. For example, we show that every injective endomorphism of a connected locally finite structure with a first-order definition in is either of the form or of the form for some (see Theorem 2).

## 2 Preliminaries

A relational signature is a set of relation symbols , each of which has an associated arity . A -structure consists of a set (the domain) together with a relation for each relation symbol from . We consider only finite signatures in this paper.

For , let be the distance between and , that is, . The relation is denoted by , and the relation is denoted by . It will be convenient to represent binary relations with a first-order definition in by sets of integers as follows.

 DiffS:= {(x,x+k)|k∈S} DistS:= {(x,x+k)||k|∈S}

A -ary relation is said to be first-order (fo) definable in a -structure if there is a first-order -formula such that . A structure is said to be fo-definable in if has the same domain as , and each of its relations is fo-definable in . For example, is fo-definable in (though the converse is false).

The structure induced by a subset of the domain of is denoted by . When and are two -structures with disjoint domains and , then the disjoint union of and is the structure with domain where for each . We say that a structure is connected if it cannot be written as the disjoint union of two non-empty structures. The Gaifman graph of a relational structure with domain is the following undirected reflexive graph: the vertex set is , and there is an edge between elements when or there is a tuple in one of the relations of that has both and as entries. A structure is readily seen to be connected if and only if its Gaifman graph is connected. The degree of a structure is defined to be the degree of the Gaifman graph of . The degree of a relation is defined to be the degree of the structure . The notation indicates the expansion of with the new relation .

A first-order formula is primitive positive (pp) if it is of the form

 ∃x1,…,xn(ψ1∧⋯∧ψm)

where is an atomic formula over , i.e., a formula of the form or of the form for a relation symbol of a relation from . A pp-sentence is a pp-formula with no free variables. For a structure with a finite relational signature, is the computational problem of deciding whether a given pp-sentence is true in . It is not hard to see that for any and with the same domain such that each of the relations of is pp-definable in (see JeavonsClosure ()); here, indicates polynomial-time many-to-one reduction (though in fact, logspace reductions may be used).

Suppose is a finite structure with finite relational signature and domain . Let be the conjunction of the positive facts of , where the variables correspond to the elements . That is, appears as an atom in iff . Define the pp-sentence to be the canonical query of . Conversely, for a pp-sentence over the relational signature we define the canonical database as follows. Consider the undirected graph with vertices where two vertices are connected if contains the conjunct . The domain of the canonical database is the set of connected components of this graph, and for iff there are such that has a conjunct .

Let and be -structures. A homomorphism from to is a function from the domain of to the domain of such that, for each -ary relation symbol in and each -tuple from , if , then . In this case we say that the map preserves the relation . Injective homomorphisms that also preserve the complement of each relation are called embeddings. Surjective embeddings are called isomorphisms; homomorphisms and isomorphisms from to itself are called endomorphisms and automorphisms, respectively. The set of automorphisms of a structure forms a group under composition. A (-ary) polymorphism of a structure over domain is a function such that, for all -ary relations of , if , for all , then .

A unary function over domain is in the local closure of a set of unary functions over domain if for every finite there is a function such that and agree on all elements in . We say that generates if is in the local closure of the set of all functions that can be obtained from the members of by repeated applications of composition. It is well-known and easy to see that functions that are in the local closure of, or generated by, the endomorphisms of a structure are again endomorphisms of .

If there exist homomorphisms and then and are said to be homomorphically equivalent. It is a basic observation that CSP CSP if and are homomorphically equivalent. A structure is a core if all of its endomorphisms are embeddings Cores-journal () – a core of a structure is an induced substructure that is itself a core and is homomorphically equivalent to . It is well-known that if a structure has a finite core, then that core is unique up to isomorphism (the same is in general not true for infinite cores).

We could have equivalently defined the class of distance CSPs as the class of CSPs whose template is locally finite and first-order definable in , where is the unary successor function, since and fo-define the same structures. The structure admits quantifier elimination; that is, for every fo-formula there is a quantifier-free (qf) (possibly equal to true or false) such that ; this is easy to prove, and can be found explicitly in ModelTheoryShawn (). Thus we may have atomic formulas in of the form , where is the successor function composed on itself times. Let be a finite signature structure, fo-definable in , i.e., qf-definable in its functional variant . Let be the largest number such that appears as a term in the qf definition of a relation of . Consider now CSP, the problem of evaluating , where is a conjunction of atoms, on . Let . It is not hard to see that iff . It follows that CSP will always be in NP.

### Convention.

From now on we assume that is a relational structure with domain which is first-order definable over and is locally finite.

## 3 Endomorphisms

The main result of this section is the following theorem.

###### Theorem 2

Let be connected. Then:

• has either the same automorphisms as , or the same automorphisms as .

• Either has a finite range endomorphism, or it has an endomorphism whose range induces in a structure that is isomorphic to a structure which is fo-definable in and all of whose endomorphisms are automorphisms.

The proof of this theorem can be found at the end of this section, and makes use of a series of lemmata.

Before beginning the proof, we remark the following. If has a first-order definition in , then it is easy to see that the automorphisms of are also automorphisms of , and hence the two structures have the same automorphisms by Theorem 2. Now it is tempting to believe that also the converse holds, i.e., that if has the same automorphisms as , then is fo-definable in (this would be true for -categorical structures). However, this is not true: Let

 R:={(x,y,u,v)∈Z4|(succ(x,y)∧succ(u,v))∨(succ(v,u)∧succ(y,x))},

and set . The function which sends every to is an automorphism of , so the automorphism group of equals that of , by Theorem 2. However, is not fo-definable in . To see this, suppose it were definable. Then is also definable in , and even with a quantifier-free formula since this structure has quantifier-elimination. Let be the maximal natural number such that occurs in . We claim that holds iff holds. To see this, we show that any atom of the formula , i.e., any occurrence of , where and , evaluates to true upon insertion of for the variables if and only if it evaluates to true upon insertion of for . This is obvious when since and have identical values for . If then the atom becomes false in both evaluations, so the only remaining case is where ; but then the atom becomes true in both evaluations if and only if and , so we are done. Now since holds iff holds, we have a contradiction since is an element of whereas is not.

Denote by the edge-relation of the Gaifman graph of . It is clear that every endomorphism of preserves . We claim that there are such that holds iff . To see this, observe that if and are so that , then also , because there is an automorphism of (and hence of ) which sends to and this automorphism also preserves . Hence, the relation is determined by distances. Moreover, there are only finitely many distances since is assumed to have finite degree.

###### Notation 3

We will refer to the distances defining the Gaifman graph of as . We also write for the largest distance .

The following basic claim characterizes when is connected in terms of the distance set.

###### Lemma 4

is connected if and only if the greatest common divisor of is .

Proof: If is the greatest common divisor of it is clear that all the nodes accessible from a node are of the form where . Conversely, every node of the form is accessible from because for some , by the extended Euclidean algorithm. ∎

In order to lighten the notation we might use to denote , where is an endomorphism of and .

###### Lemma 5

Suppose that is connected. Then there exists a constant such that for all endomorphisms of we have for all .

Proof: We first claim that for every , there exists a number such that for all endomorphisms of and all with . To see this, pick with and a path between and in the Gaifman graph of ; say this path has length . Then, since this path is mapped to a path under any endomorphism, we have for all endomorphisms . Since an isomorphic path exists for all with the same distance, our claim follows by setting . Set to be the maximum of the , and let an endomorphism and be given. Assume without loss of generality that . There exists and such that . Set , for all . Since and are adjacent in the Gaifman graph of for all , so are and , and hence . Therefore,

 d(ex,ey)≤∑0≤r

Observe that a constant not only exists, but can actually be calculated given the distances : by the proof of Lemma 5, it suffices to calculate a constant for all . To do this, one must find a path of length between two numbers with ; this again amounts to solving the equation (with variables ) over , which can be achieved by the extended Euclidean algorithm.

In the following, we will keep the symbol reserved for the minimal constant guaranteed by the preceding lemma.

###### Lemma 6

Suppose that is connected, and let be an endomorphism of with the property that for all there exist with and . Then generates an endomorphism whose range has size at most .

Proof: Let be finite. We claim that generates a function which maps into a set of diameter at most . The lemma then follows by the following standard local closure argument: Let be the set of all those functions whose domain is a finite interval and whose range is contained in the interval , and which have the property that there exists a function generated by which agrees with on . By our claim, is infinite. For functions in , write iff is an extension of . Clearly, the set , equipped with this order, forms a finitely branching tree; since the tree is infinite, it has an infinite branch (this easily verified fact is called König’s lemma) . The branch defines a function from into the interval ; since generates functions which agree with on arbitrarily large intervals of the form , we have that is generated by , too. This completes the proof.

Enumerate the pairs with by . Now the hypothesis of the lemma implies that by successive applications of and shifts we can map to a pair of distance at most ; in other words, there exists generated by such that . Similarly, there exists generated by such that . Continuing like this we arrive at a function generated by such that . Now consider . Set and , for all ; so . Then, since by construction , we have that for all

 d(txj,tyj)= d(fj(gj(xj)),fj(gj(yj)) ≤ d(gj(xj),gj(yj))+c (Lemma 5) ≤ 2c+1

and our claim follows. ∎

###### Lemma 7

Suppose that is connected with an endomorphism that does not satisfy the hypothesis of the preceding lemma, i.e., there exists such that for all with . Then either for all or for all .

Proof: Let be so that for all with . Let be arbitrary. Then, since , we have . We furthermore assume that ; the situation where can be treated symmetrically. We claim that for all . Suppose not, and say without loss of generality that there exists contradicting our claim. Then, since , we have . Take the minimal with satisfying this property. Then, by minimality, we have . Since by Lemma 5 we have , we get that . On the other hand, . Inserting this into the previous inequality, we obtain , which yields . By our assumption on , we obtain , which yields , a contradiction.

Set . We next claim that for all . First observe that points at distance cannot be mapped by to points at larger distance since is by definition the largest distance in the Gaifman graph of . Since is a multiple of , we get that . On the other hand, since is also a multiple of and since for all , we obtain , proving the claim.

We now prove that for all . This is because

 e(v)+kD= e(v)+b=e(v+b)=e(v+kD) = e(v+D+(k−1)D) ≤ e(v+D)+(k−1)D

the latter inequality holding since is the maximal distance in the relation and cannot be increased. Subtracting on both sides, our claim follows.

Since points at distance cannot be mapped to points at larger distance under , we have for all , and we have proved the lemma. ∎

The following lemma summarizes the preceding two lemmas.

###### Lemma 8

Suppose that is connected. The following are equivalent for an endomorphism of :

• There exists such that for all with .

• does not generate a finite range operation.

• satisfies either for all , or for all .

Proof: Lemma 7 shows that (i) implies (ii) and (iii). It follows from Lemma 6 that (ii) implies (i). Finally, it is clear that (iii) implies (ii). ∎

We know now that there are two types of endomorphisms of : Those which are periodic with period , and those which generate a finite range operation. We will next provide examples showing that both types really occur.

###### Example 9

Set . Set , , and , for all . Then is an endomorphism of that does not generate any finite range operations since it satisfies for all .

Observe that in the previous example, we checked that is of the non-finite-range type by virtue of the easily verifiable Item (iii) of Lemma 8 and without calculating , which would be more complicated.

###### Example 10

For the structure from Example 9, let be the function which maps every to its value modulo . Then is an endomorphism which has finite range.

###### Example 11

The structure has the endomorphism from Example 9. However, it does not have any finite range endomorphism. To see this, consider the set . If were a finite range endomorphism, it would have to map this set onto a finite set. By composing with automorphisms of , we may assume that and . Then as preserves . We claim for all . Suppose to the contrary that is the minimal positive counterexample (the negative case is similar). We have and hence because preserves . If we had , then and yields a contradiction.

###### Example 12

Let , and let be the function that maps every to its absolute value. Then does not have finite range, but generates with a function with finite range (namely, the function which sends the even numbers to and the odd numbers to ).

The proof of Lemma 7 generalizes canonically to a more general situation.

###### Lemma 13

Suppose that is connected. Let be an endomorphism of satisfying the various statements of Lemma 8. Let be so that implies that . Then satisfies either for all , or for all .

Proof: This is the same argument as in the proof of Lemma 7, with replaced by . ∎

{Definition}

Given an endomorphism of , we call all positive integers with the property that for all or for all stable for .

Observe that if satisfies the various statements of Lemma 8, then is stable for . Note also that if are stable for , then they must have the same “direction”: We cannot have and for all .

###### Lemma 14

Suppose that is connected. Let satisfy the various statements of Lemma 8, and let be the minimal stable number for . Then the stable numbers for are precisely the multiples of . In particular, divides .

Proof: Clearly, all multiples of are stable. Now for the other direction suppose that is stable but not divisible by . Write , where are positive numbers and . Since is not stable, composing and shifts we can build a function such that and . By the property of we should have or . But this is impossible since then , a contradiction. ∎

###### Lemma 15

Suppose that is connected and has an endomorphism satisfying the statements of Lemma 8. Let be its minimal stable number. Then there is an endomorphism of which can be written as a functional composite using automorphisms of and which has the following properties:

• satisfies either or

• .

Proof: Assume (otherwise can be chosen to be the identity and there is nothing to do). We claim that generates a function such that and . To see this, observe that since and since is the smallest positive number with the property that implies (Lemma 13), there exist with and . Write . If is not a multiple of , then there exist with and . Again, if is not a multiple of , then there exist with and . Consider the sequence of pairs of distance (setting ). By exchanging and if necessary, we may assume that iff , for all . There exist automorphisms of such that . Set . Then the endomorphism sends to , a pair of distance . Thus the sequence must end at some finite , by Lemma 5. By construction of the sequence, this happens only if is a multiple of . Therefore, . By applying shifts we may assume , , and . Set .

Now if , then consider the number . We claim that generates a function such that and is a multiple of . If already is a multiple of , then we can choose to be the identity. Otherwise, we can increase the distance of from successively by applying shifts and just as before, where we moved away from . After a finite number of steps, we arrive at a function such that is a multiple of . Applying a shift one more time, we may assume that , and so has the desired properties.

We continue inductively, constructing for every a function such that and is a multiple of for all . At the end, we set . Since satisfies either or , so does , as it is composed of and automorphisms of . It is also clear from the construction that holds. These two facts together imply that contains the set . For the other inclusion, let be arbitrary, and write , where and . Then or , which is a multiple of since is a multiple of by construction. ∎

Observe that we did not need local closure in the preceding lemma.

###### Lemma 16

Suppose that is connected and has an endomorphism which is not an automorphism of . Then is not injective.

Proof: If generates a finite range operation then the lemma follows immediately, so assume this is not the case. Then has a minimal stable number . Since is not an automorphism of , we have . But now the statement follows from the preceding lemma, since the function is not injective (e.g., maps surjectively to , so for some ). ∎

###### Lemma 17

Suppose that is connected and has an endomorphism which is not an automorphism of such that does not generate a finite range operation. Then is not surjective.

Proof: This is a direct consequence of Lemma 15, since being surjective is preserved under composition (and we used just composition in Lemma 15 and not local closure). ∎

Define to be the substructure of induced by . Note that when is fo-definable in , then is isomorphic to a structure that is fo-definable in via the map which sends an element of to . From a defining quantifier-free formula for a relation of over , we obtain a definition for over as follows. For all not divisible by , replace every occurrence of by . For all other , replace every occurrence of by .

Proof: (of Theorem 2) We prove the first statement. It is a direct consequence of Lemma 16 that the automorphism group of is contained in that of . Since is fo-definable in , its automorphism group contains that of . The statement now follows from the easily verifiable fact that there are no permutation groups properly between the automorphism groups of and .

For the second statement, suppose that has no finite range endomorphism. If all of its endomorphisms are automorphisms, then we are done. Otherwise, has an endomorphism as in Lemma 15, with . Let be a structure that is isomorphic to and first-order definable in . In , two points are adjacent iff ; moreover, is divisible by . Therefore, the remaining relevant distances are those divisible by . In other words, if are those distances from which are divisible by , then the Gaifman graph of is isomorphic to the graph on defined by the distances . Since before, from Lemma 4, the greatest common divisor of all possible distances was , we must have lost at least one distance, i.e., .

Observe that (and hence ) is connected as it is the image of an endomorphism of . Note moreover that (and hence cannot have a finite range endomorphism: If were such an endomorphism, then would be a finite range endomorphism for , contrary to our assumption. If all endomorphisms of are automorphisms, then we are done. Otherwise satisfies all assumptions that we had on , and we may repeat the argument. Since in every step we lose a distance for the Gaifman graph, this process must end, meaning that we arrive at a structure all of whose endomorphisms are automorphisms. ∎

## 4 Definability of Successor

In this section we show how to reduce the complexity classification for distance constraint satisfaction problems with template to the case where either has a finite core, or the relation is pp-definable in . We make essential use of the results of the previous section; but note that in this section we do not assume that is connected.

###### Theorem 18

Suppose that does not have an endomorphism of finite range. Then is homomorphically equivalent to a connected finite-degree structure with a first-order definition in which satisfies one of two possibilities: (and, hence, ) is NP-hard, or is definable in .

The following lemma demonstrates how the not necessarily connected case can be reduced to the connected case.

###### Lemma 19

is homomorphically equivalent to a connected finite-degree structure with a first order definition in .

Proof: If all edges of the Gaifman graph of are self-loops, then the statement is clear. Otherwise, let be the greatest common divisor of (the distances in the Gaifman graph, see Section 3, Notation 3). If is connected, there is nothing to prove.

Otherwise, if is disconnected, by Lemma 4, we have . Then must be a disjoint union of copies of a connected structure (and these copies are isomorphic to each other by an isomorphism of the form , for appropriate constant ). In particular, is homomorphically equivalent to . Moreover, itself has a first-order definition in . The proof here is as in the proof of Theorem 2, with taking the role of . ∎

The following is obvious.

###### Lemma 20

Let . Then there is an automorphism of with for all if and only if for all .

###### Lemma 21

Suppose that is connected. Then there is an such that the structure is connected for all .

Proof: Let be the smallest distance of the distances defining the Gaifman graph of (as in Section 3). By connectivity of , for each pair of elements from there is a path from to in . Fix such a path for each pair . Let be the smallest number such that all vertices on those paths are smaller than . We claim that