A polynomial time algorithm to compute geodesics in CAT(0) cubical complexes

This paper presents the first polynomial time algorithm to compute geodesics in a CAT(0) cubical complex in general dimension. The algorithm is a simple iterative method to update breakpoints of a path joining two points using Owen and Provan's algorithm (2011) as a subroutine. Our algorithm is applicable to any CAT(0) space in which geodesics between two close points can be computed, not limited to CAT(0) cubical complexes.


Introduction
Computing a shortest path in a polyhedral domain in Euclidean space is a fundamental and important algorithmic problem, which is intensively studied in computational geometry [15]. This problem is relatively easy to solve in the two-dimensional case; it can generally be reduced to a discrete graph searching problem where some combinatorial approaches can be applied. In three or more dimensions, however, the problem becomes much harder; it is not even discrete. In fact, it was proved by Canny and Rief [6] that the shortest path problem in a polyhedral domain is NP-hard. Mitchell and Sharir [16] have shown that the problem of deciding if there exists an obstacle-avoiding path of length at most L is NP-complete even for the case of a region with obstacles that are disjoint axis-aligned boxes. On the other hand, there are some cases where one can obtain polynomial time complexity. For instance, it was shown by Sharir [23] that a shortest obstacle-avoiding path among k disjoint convex polyhedra having altogether n vertices, can be found in n O(k) time, which implies that this problem is polynomially solvable if k is a small constant.
What determines the tractability of the shortest path problem in geometric domains? One of promising answers to this challenging question is global non-positive curvature, or CAT(0) property [13]. CAT(0) spaces are metric spaces in which geodesic triangles are "thinner" than those in the Euclidean plane, and enjoy various fascinating properties generalizing those in Euclidean and hyperbolic spaces. As Ghrist and LaValle [11] observed, no NP-hard example in [16] is a CAT(0) space. One of the significant properties of CAT(0) spaces is the uniqueness of geodesics: Every pair of points can be joined by a unique geodesic. Algorithmic theory on CAT(0) spaces is itself a challenging research field [3].
One of fundamental and familiar CAT(0) spaces is a cubical complex. A cubical complex is a polyhedral complex where each cell is isometric to a unit cube of some dimension and the intersection of any two cells is empty or a single face. Gromov [13] established a purely combinatorial condition that characterizes cubical complexes of non-positive curvature. This simple criterion is one of the main reasons why CAT(0) cubical complexes frequently appear in mathematics, having applications, for instance, in geometric group theory [21,22], in theory of reconfigurable systems [1,12], and in phylogenetics [4].
There has been several polynomial time algorithms to find shortest paths in some CAT(0) cubical complexes. A noteworthy example is for a tree space, introduced by Billera, Holmes and Vogtmann [4] as a continuous space of phylogenetic trees. This space is shown to be CAT(0), and consequently provides a powerful tool for comparing two phylogenetic trees through the unique geodesic. Owen and Provan [19,20] gave a polynomial time algorithm for finding geodesics in tree spaces, which was generalized by Miller et al. [14] to CAT(0) orthant spaces, i.e., complexes of Euclidean orthants that are CAT(0). Chepoi and Maftuleac [8] gave an efficient polynomial time algorithm to compute geodesics in a two dimensional CAT(0) cubical complex. These meaningful polynomiality results naturally lead to a question: What about in an arbitrary CAT(0) cubical complex?
Ardila, Owen and Sullivant [2] gave a combinatorial description of CAT(0) cubical complexes, employing a poset endowed with an additional relation, called a poset with inconsistent pairs (PIP). This can be viewed as a generalization of Birkhoff's theorem that gives a compact representation of distributive lattices by posets. In fact, they showed that there is a bijection between CAT(0) cubical complexes and PIPs. This relationship enables us to express an input CAT(0) cubical complex as a PIP: For a poset with inconsistent pairs P , the corresponding CAT(0) cubical complex K P is realized as a subcomplex of the |P |-dimensional cube [0, 1] P in which the cells of K P are specified by structures of P . Adopting this embedding as an input, they gave the first algorithm to compute geodesics in an arbitrary CAT(0) cubical complex. Their algorithm is based on an iterative method to update a sequence of cubes that may contain the geodesic, where at each iteration it solves a touring problem using second order cone programming [18]. They also showed that the touring problem for general CAT(0) cubical complexes has intrinsic algebraic complexity, and geodesics can have breakpoints whose coordinates have nonsolvable Galois group. This implies that there is no exact simple formula for the geodesic and therefore in general, one can only obtain an approximate one. Unfortunately, even if the touring problem could be solved exactly, it is not known whether or not their algorithm is a polynomial one; that is, no polynomial time algorithm has been known for the shortest path problem in a CAT(0) cubical complex in general dimension.
Main result. In this paper, we present the first polynomial time algorithm to compute geodesics in a CAT(0) cubical complex in general dimension, answering the open question suggested by these previous work; namely we show that: Given a CAT(0) cubical complex K represented by a poset with inconsistent pairs P and two points p, q in K, one can find a path joining p and q of length at most d(p, q) + in time polynomial in |P | and log(1/ ). The algorithm is quite simple, without depending on any involved techniques such as semidefinite programming. To put it briefly, our algorithm first gives a polygonal path joining p and q with a fixed number (n, say) of breakpoints, and then iteratively updates the breakpoints of the path until it becomes a desired one. To update them, we compute the midpoints of the two close breakpoints by using Owen and Provan's algorithm. The resulting number of iterations is bounded by a polynomial in n. Key tools that lead to this bound are linear algebraic techniques and the convexity of the metric of CAT(0) spaces, rather than inherent properties of cubical complexes. Due to its simplicity, our algorithm is applicable to any CAT(0) space where geodesics between two close points can be found, not limited to CAT(0) cubical complexes. We believe that our result will be an important step toward developing computational geometry in CAT(0) space. Application. A reconfigurable system [1,12] is a collection of states which change according to local and reversible moves that affect global positions of the system. Examples include robot motion planning, non-collision particles moving around a graph, and protein folding; see [12]. Abrams, Ghrist and Peterson [1,12] considered a continuous space of all possible positions of a reconfigurable system, called a state complex. Any state complex is a cubical complex of nonpositively curved [12], and it becomes CAT(0) in many situations. In the robotics literature, geodesics (in the l 2 -metric) in the CAT(0) state complex corresponds to the motion planning to get the robot from one position to another one with minimal power consumption. Our algorithm enables us to find such an optimal movement of the robot in polynomial time.
Organization. The rest of this paper is organized as follows. In Section 2, we devise an algorithm to compute geodesics in general CAT(0) spaces. In Section 3, we present a polynomial time algorithm to compute geodesics in CAT(0) cubical complexes, using the result of Section 2. Section 2.1 and Section 3.1 to 3.3 are preliminary sections, where CAT(0) metric spaces, CAT(0) cubical complexes, PIPs and CAT(0) orthant spaces are introduced.

Computing geodesics in CAT(0) spaces
In this section we devise an algorithm to compute geodesics in general CAT(0) spaces, not limited to CAT(0) cubical complexes.

CAT(0) space
Let (X, d) be a metric space. A geodesic joining two points x, y ∈ X is a map γ : [0, 1] → X such that γ(0) = x, γ(1) = y and d(γ(s), γ(t)) = d(x, y)|s − t| for all s, t ∈ [0, 1]. The image of γ is called a geodesic segment joining x and y. A metric space X is called (uniquely) geodesic if every pair of points x, y ∈ X is joined by a (unique) geodesic. For any triple of points x 1 , x 2 , x 3 in a metric space (X, d), there exists a triple of pointsx 1 ,x 2 ,x 3 in the Euclidean plane E 2 such that d(x i , x j ) = d E 2 (x i ,x j ) for i, j ∈ {1, 2, 3}. The Euclidean triangle whose vertices arex 1 ,x 2 andx 3 is called a comparison triangle for x 1 , x 2 , x 3 . (Note that such a triangle is unique up to isometry.) A geodesic metric space (X, d) is called a CAT(0) space if for any x 1 , x 2 , x 3 ∈ X and any p belonging to a geodesic segment joining x 1 and x 2 , the inequality Figure 1.

Algorithm
Let X be a CAT(0) space. We shall refer to an element x in the product space X n+1 as a chain, and write x i−1 to denote the i-th component of x, i.e., x = (x 0 , x 1 , . . . , x n ). For any chain x ∈ X n+1 , we define the length of x by n−1 i=0 d(x i , x i+1 ) and denote it by d(x). We consider the following problem: Given a chain x ∈ X n+1 and a positive parameter > 0, find a chain y ∈ X n+1 such that y 0 = x 0 , y n = x n and d(y) ≤ d(x 0 , x n ) + , (2.1) under the situation where we are given an oracle to perform the following operation for some D > 0: Given two points p, q ∈ X with d(p, q) ≤ D, compute the geodesic joining p and q in arbitrary precision.
To explain our algorithm to solve this problem, we need some definitions. Since X is uniquely geodesic, every pair of points p, q ∈ X has a unique midpoint w satisfying 2d(w, p) = 2d(q, w) = d(p, q). For a nonnegative real number δ ≥ 0, a δ-midpoint of p and q is a point w ∈ X satisfying d(w , w) ≤ δ, where w is the midpoint of p and q. Definition 2.3. (δ-halved chain). Let δ be a nonnegative real number. For any chain x ∈ X n+1 , a chain y ∈ X n+1 is called a δ-halved chain of x if it satisfies the following: y 0 = x n , y n = x 0 and y i is a δ-midpoint of y i+1 and x n−i for i = 1, 2, . . . , n − 1. For an integer k ≥ 0, we say that Our algorithm can be described as follows. To put it briefly, the algorithm just finds a k-th δ-halved chain of a given chain x for some large k and small δ; see Figure 2 for an illustration. For any chain x ∈ X n+1 , define the gap of x by gap(x) := max{d(x 0 , x 1 ), max 1≤i≤n−1 2d(x i , x i+1 )}. The following theorem states that Algorithm 1 solves problem (2.1).
In particular, for gap(x) ≤ D/2 − , one can find a chain y ∈ X n+1 such that y 0 = x 0 , y n = x n and d(y) ≤ d(x 0 , x n ) + , with O(n 3 log(nD/ )) calls of an oracle to perform (2.2).
Example 2.5. We give an example of CAT(0) spaces to which our algorithm is applicable. A B 2 -complex is a two dimensional piecewise Euclidean complex in which each 2-cell is isomorphic to an isosceles right triangle with short side of length one [10]. A CAT(0) B 2 -complex is called a folder complex [7]; see Figure 3 for an example. One can show that for a folder complex F, computing the geodesic between two points p, q ∈ F with d(p, q) ≤ 1 can be reduced to an easy calculation on a subcomplex of F having a few cells. This implies that our algorithm enables us to find geodesics between two points in a folder complex F in time bounded by a polynomial in the size of F.

Analysis
For any chain x ∈ X n+1 , we define the reference chainx ∈ X n+1 of x as follows:x 0 := x 0 and Figure 4. Note that the reference chainx of x is determined just by its end components x 0 , x n , and therefore for any chain x and any 2nd δ-halved chain x (2) of x their reference chains coincide:x (2) =x. A key observation that leads to Theorem 2.4 is that: For any chain x ∈ X n+1 and any k-th δ-halved chain x (k) of x with k sufficiently large and δ sufficiently small, the distance between x (k) and its reference chainx (k) is small enough for its length d(x (k) ) to approximate well d(x 0 , x n ); moreover, the value of such a k can be bounded by a polynomial in n. The next lemma states this fact.
where e is the base of the natural logarithm.
Proof. Let {x (j) } j≥0 be a sequence of chains in X n+1 such that x (0) = x and x (j) is a δ-halved chain of x (j−1) for j ≥ 1. Fix an integer 1 ≤ i ≤ n−1 and an integer k ≥ 0. Note that by definition x n−i . Hence, by Lemma 2.1 and the triangle inequality, we have Figure 5 for intuition. Let v (k) be a column vector of dimension n − 1 whose i-th entry equals d(x i ) for i = 1, 2, . . . , n − 1. Let J be a square matrix of order n − 1 whose (i, j) entry equals 1 if i + j = n and 0 otherwise. Let K be a square matrix of order n − 1 whose (i, j) entry equals 1 if j = i + 1 and 0 otherwise. Then, by (2.3) we have 2v (k+1) ≤ Kv (k+1) + Jv (k) + 2δ1 for each k ≥ 0, where 1 is a column vector with all entries equal to 1. Let A n−1 be a square matrix of order n − 1 whose (i, j) entry equals (1/2) n+1−i−j if i + j ≤ n and 0 otherwise. Then one can easily see that Figure 5: To the proof of Lemma 2.6. The chain x (j) is a j-th δ-halved chain of x for j = k, k + 1. Lemma 2.7. This implies that (A n−1 ) k 1 ≤ (5/4)e −k/n 2 1 for n ≥ 2. This proves (2.5) and therefore completes the proof of the lemma.
Let us now prove Theorem 2.4.
We end this section by showing the lemma used in the proof of Lemma 2.6. Let A n be an n × n matrix whose (i, j) entry is defined by for i, j = 1, 2, . . . , n. Since A n is a nonnegative matrix, its spectral radius ρ(A n ) is at most the maximum row sum of A n , which immediately yields that ρ(A n ) ≤ 1 − (1/2) n . This inequality, however, is not tight unless n = 1. In fact, one can obtain a more useful upper bound of ρ(A n ).

Computing geodesics in CAT(0) cubical complexes
In this section we give an algorithm to compute geodesics in CAT(0) cubical complexes, with an aid of the result of the preceding section. In Section 3.1 to 3.3, we recall CAT(0) cubical complexes, PIPs and CAT(0) orthant spaces. Section 3.4 is devoted to proving our main theorem.

CAT(0) cubical complex
A cubical complex K is a polyhedral complex where each k-dimensional cell is isometric to the unit cube [0, 1] k and the intersection of any two cells is empty or a single face. The underlying graph of K is the graph G(K) = (V (K), E(K)), where V (K) denotes the set of vertices (0-dimensional faces) of K and E(K) denotes the set of edges (1-dimensional faces) of K.
A cubical complex K has an intrinsic metric induced by the l 2 -metric on each cell. For two points p, q ∈ K, a string in K from p to q is a sequence of points p = x 0 , x 1 , . . . , x m−1 , x m = q in K such that for each i = 0, 1, . . . , m − 1 there exists a cell C i containing x i and x i+1 , and its length is defined to be is measured inside C i by the l 2 -metric. The distance between two points p, q ∈ K is defined to be the infimum of the lengths of strings from p to q.
Gromov [13] gave a combinatorial criterion which allows us to easily decide whether or not a cubical complex K is non-positively curved. The link of a vertex v of K is the abstract simplicial complex whose vertices are the edges of K containing v and where k edges e 1 , . . . , e k span a simplex if and only if they are contained in a common k-dimensional cell of K. An abstract simplicial complex L is called flag if any set of vertices is a simplex of L whenever each pair of its vertices spans a simplex.

Poset with inconsistent pairs (PIP)
Ardila et al. [2] gave a combinatorial description of CAT(0) cubical complexes. An antichain of a poset P is a subset of P that contains no two comparable elements. A subset I of P is called an order ideal of P if a ∈ I and b a imply b ∈ I. A poset P is locally finite if every interval [a, b] = {c ∈ P | a ≤ c ≤ b} is finite, and it has finite width if every antichain is finite. For a CAT(0) cubical complex K and a vertex v of K, the pair (K, v) is called a rooted CAT(0) cubical complex. Given a poset with inconsistent pairs P , one can construct a cubical complex K P as follows: The underlying graph G(K P ) is a graph G P whose vertices are consistent ideals of P and where two consistent order ideals I, J are adjacent if and only if |I∆J| = 1; replace all cube-subgraphs (i.e., subgraphs isomorphic to cubes of some dimensions) of G P by solid cubes. See Figure 7 for an example. In fact, the resulting cubical complex K P is CAT(0), and moreover: Theorem 3.3. (Ardila et al. [2]). The map P → K P is a bijection between posets with inconsistent pairs and rooted CAT(0) cubical complexes.
Given a poset with inconsistent pairs P , one can embed K P into a unit cube in the Euclidean space as follows, which we call the standard embedding of P [2]: corresponds to a unique |M |-dimensional cell of K P .

CAT(0) orthant space
Let R + denote the set of nonnegative real numbers. Let L be an abstract simplicial complex on a finite set V . The orthant space O(L) for L is a subspace of |V |-dimensional orthant R V + constructed by taking a union of all subcones {O S | S ∈ L} associated with simplices of L, where O S is defined by The distance between two points x, y ∈ O(L) is defined in a similar way as in the case of cubical complexes. An orthant space is a special instance of cubical complexes. A typical example of CAT(0) orthant spaces is a tree space [4]. Owen and Provan [19,20] gave a polynomial time algorithm to compute geodesics in tree spaces, which was generalized to CAT(0) orthant spaces by Miller et al. [14]. Theorem 3.5. ([14,19,20]). Let L be a flag abstract simplicial complex on a finite set V and O(L) be the CAT(0) orthant space for L. Let x, y ∈ O(L), and let S 1 and S 2 be the inclusion-wise minimal simplices such that x ∈ O S 1 and y ∈ O S 2 . Then one can find the explicit description of the geodesic joining x and y in O(( An interesting thing about their algorithm is that it solves as a subproblem a combinatorial optimization problem: a Maximum Weight Stable Set problem on a bipartite graph whose color classes have at most |S 1 |, |S 2 | vertices, respectively. We should note that the above explicit descriptions of geodesics are radical expressions. Computationally, for a point p on a geodesic, one can compute a rational point p ∈ O(L) such that d(p , p) ≤ δ and the number of bits required for each coordinate of p is bounded by O(log(|V |/δ)).

Main theorem
We now consider the following problem. It should be remarked that as stated in [2] there are no simple formulas for the breakpoints in geodesics in CAT(0) cubical complexes due to their algebraic complexity, and hence one can only compute them approximately. Computationally, we adopt the standard embedding as an input CAT(0) cubical complex.
Problem 3.7. Given a poset with inconsistent pairs P , two points p, q in the standard embedding K P of P , and a positive parameter > 0, find a sequence of points p = x 0 , x 1 , . . . , x n−1 , x n = q in K P with n−1 i=0 d(x i , x i+1 ) ≤ d(p, q) + and compute the geodesic joining x i and x i+1 for i = 0, 1, . . . , n − 1.
Our main result is: (a) Given two points p, q ∈ K P , one can find a sequence of points p = x 0 , x 1 , . . . , x n−1 , x n = q in K P such that n = O(m) and d(x i , x i+1 ) ≤ 1/4 − for i = 0, 1, . . . , n − 1. (b) Given two points p, q ∈ K P with d(p, q) ≤ 1, one can compute the geodesic joining p and q in O(m 4 ) time and find a δ-midpoint w of p and q with O(log(m/δ)) bits enough for each coordinate of w.
It is relatively easy to show (a), by considering a curve issuing at p, going through an edge geodesic (a shortest path in the underlying graph of K P ) between some vertices of cells containing p, q, and ending at q. Since such a curve has length at most O(m), dividing it into parts appropriately, one can get a desired sequence of points. To show (b), we need the following two lemmas, whose proofs are given in Section 3.5. Lemma 3.9. Let K be a CAT(0) cubical complex. Let v be a vertex of K and let K v be the union of cells which contain v. Then K v is a convex subcomplex of K. Lemma 3.10. Let K be a CAT(0) cubical complex. Let p, q be two points in K with d(p, q) ≤ 1 and R 1 , R 2 be the minimal cells of K containing p, q, respectively. If R 1 ∩ R 2 = ∅, then R 1 and R 2 have the same dimension and there exists a cell of K that contains both R 1 and R 2 as its opposite facets.
Using these lemmas, we show (b). Suppose that we are given two points p, q ∈ K P with d(p, q) ≤ 1. First notice that one can find in linear time the minimal cells R 1 and R 2 of K P that contain p and q, respectively, just by checking their coordinates. (Indeed, one has R 1 = C I M for I = {i ∈ P | p i > 0} and M = {i ∈ P | 0 < p i < 1}.) Since d(p, q) ≤ 1, from Lemma 3.10 we know that R 1 ∩ R 2 = ∅ or there is a cell containing R 1 and R 2 as its opposite facets. The latter case being easy to find the geodesic joining p and q, suppose that R 1 ∩ R 2 = ∅. Let v be a vertex of R 1 ∩ R 2 . Then p and q are contained in (K P ) v , where (K P ) v is the subcomplex of K P that consists of all cells containing v. Since (K P ) v is convex by Lemma 3.9, we only have to compute the geodesic in (K P ) v . Obviously, (K P ) v is a truncated CAT(0) orthant space, and hence one can compute the geodesic between p and q in (K P ) v in O(m 4 ) time, by Theorem 3.6. In addition, one can find a δ-midpoint w ∈ (K P ) v of p and q such that the number of bits required for each coordinate of w is bounded by O(log(m/δ)). This implies (b) and therefore completes the proof of Theorem 3.8.

Proof of Lemmas 3.9 and 3.10
We end this paper by giving proofs of Lemmas 3.9 and 3.10, which were used in proving Theorem 3.8. To prove these lemmas, we often make recourse to properties of median graphs.

Median graph
Let G = (V, E) be a simple undirected graph. The distance d G (u, v) between two vertices u and v is the length of a shortest path between u and v. The interval I G (u, v) between u and v is the u) contains exactly one element, called the median of u, v, w. A median complex is a cubical complex derived from a median graph G by replacing all cube-subgraphs of G by solid cubes. It has been shown independently by Roller [21] and Chepoi [7] that median complexes and CAT(0) cubical complexes constitute the same objects: Theorem 3.11. (Roller [21], Chepoi [7]). The underlying graph of every CAT(0) cubical complex is a median graph, and conversely, every median complex is a CAT(0) cubical complex.
For a cubical complex K and any S ⊆ V (K), we denote by K(S) the subcomplex of K induced by S. The following property of CAT(0) cubical complexes is particularly important for us.

Proof of Lemma 3.9
Let G = G(K) be the underlying graph of K, and let S v be the subset of V (K) such that K(S v ) = K v . In other words, S v consists of all vertices u for which there exists a cube-subgraph of G that contains both u and v. According to Theorem 3.12, it suffices to show that S v is a convex set of G. Let N (v) be the set of neighbors of v. Let us write H u := H(u, v) and H u := H(v, u) for each u ∈ N (v).
Let T := u∈N (v) H u ∪ ∂H u . We prove that S v = T . This will prove this lemma, since the intersection of convex sets is convex as well. The part S v ⊆ T being trivial, we prove the inverse inclusion. We show that if a ∈ T then a ∈ S v , by induction on d G (v, a). The case d G (v, a) = 1 being trivial, suppose that d G (v, a) ≥ 2. Take a neighbor u of v which lies on I G (v, a). Then a belongs to ∂H u ; otherwise, a should belong to H u and hence u ∈ I G (v, a) ⊆ H u as H u is convex, contradicting u ∈ H u . Take a neighbor b of a which belongs to H u . Since b lies on I G (v, a) (as d G (v, b) + 1 = d G (v, a) by Lemma 3.13 (i)) and T is convex, we have b ∈ T . Hence the induction gives b ∈ S v . This implies that there exists a subgraph Q of G which is isomorphic to a cube of dimension d G (v, b) and contains both v and b. Note that Q is contained in ∂H u ; indeed, I G (v, b) ⊆ ∂H u (as v, b ∈ ∂H u ) and Q = I G (v, b) (as Q is convex and all vertices of Q belong to I G (v, b)). Lemma 3.13 (ii) ensures that there exists a cube-subgraph Q in ∂H u isomorphic to Q and that Q ∪ Q induces a cube-subgraph of G which contains u, v, a and b. This implies a ∈ S v and hence completes the induction.

Proof of Lemma 3.10
In a median graph G = (V, E), any convex set S of G is gated, i.e., for every vertex v ∈ V , there exists a unique vertex v ∈ S, called the gate of v in S, such that v ∈ I G (u, v) for all u ∈ S. (Indeed, for each v ∈ V one can take a vertex v ∈ S such that I G (v , v) ∩ S = {v }. Then for any u ∈ S the median m of u, v, v should be v , as m ∈ I G (u, v ) ⊆ S and m ∈ I G (v , v). This implies that v is the gate of v in S.) We denote the resulting map by gate S : V → S, i.e., we write gate S (v) to denote the gate of v in S for all v ∈ V .
For two convex sets U, W of G and for two vertices u ∈ U and w ∈ W , we say that the pair (u, w) is a gated pair of U and W if u = gate U (w) and w = gate W (u).
(i) For any two vertices u ∈ U and w ∈ W , the pair (u, w) is a gated pair of U and W if and  (i) A vertex v ∈ S is the gate of a vertex u ∈ V in S if and only if u belongs to all halfspaces of G that traverse S and contain v. (ii) A vertex subset U ⊆ V satisfies S = gate S (U ) if and only if every halfspace of G that traverses S also traverses U .
Proof. (i) To show necessity, suppose that v = gate S (u). Suppose to the contrary that there exists a halfspace H that traverses S and contains v, but not u. Take an arbitrary vertex w ∈ S\H. Then v = gate S (u) ∈ I G (w, u) ⊆ V \H (as V \H is sonvex), which contradicts the fact that v ∈ H.
To show sufficiency, suppose that u belongs to all halfspaces that traverse S and contain v. Let N S (v) be the set of neighbors of v that belong to S. For all w ∈ N S (v), the halfspace H(v, w) traverses S and contains v, and hence contains u as well. Since gate S (u) ∈ I G (u, v) ⊆ H(v, w) for all w ∈ N S (v), the gate of u in S should belong to T := w∈N S (v) H(v, w).
Note that S ∩ T = {v}. This can be seen as follows. Suppose to the contrary that there exists a vertex z = v in S ∩ T . Then one can take a vertex w ∈ N S (v) that lies on I G (v, z), as S is convex. Since w / ∈ H(v, w ), we have z / ∈ H(v, w ), which contradicts the fact that z ∈ T . Therefore we have gate S (u) ∈ S ∩ T = {v}, which completes the proof of (i).
(ii) Note that S = gate S (U ) if and only if every vertex v ∈ S is the gate of some u ∈ U in S. From (i), this is equivalent to that for any v ∈ S all the halfspaces H that traverse S and contain v intersect U . This is also equivalent to that all the halfspaces H that traverse S also traverse U .  Figure 8: To the proof of Lemma 3.16. Taking some s ∈ [0, 1] such that p := γ(s) lies on K(∂H), and "projecting" the point γ(t) onto K(∂H) for all t ∈ [s, 1], one can get a path γ joining x and some point on C H with its length at most that of γ.
We recall some basic properties of CAT(0) spaces. Let X be a CAT(0) space, and let Y be a complete closed convex subset of X. Then for every x ∈ X, there exists a unique point π(x) ∈ Y such that d(x, π(x)) = d(x, Y ) := inf y∈Y d(x, y). The resulting map π : X → Y is called the orthogonal projection onto Y ; see [5] for details.
Let K be a CAT(0) cubical complex. For a cell C of K and a halfspace H of G(K) that traverses V (C), we shall write C H to denote the face of C induced by H ∩ V (C); namely, C H = K(H) ∩ C. and R 1 ∩ R 2 = ∅. Then for any gated pair (u, v) of V 1 and V 2 , the two vertices u and v are distinct, and hence d(R 1 , R 2 ) = d(u, v) ≥ 1. Since d(R 1 , R 2 ) ≤ d(p, q) ≤ 1, we have d(R 1 , R 2 ) = d(p, q) = 1. This implies that for any gated pair (u, v) of V 1 and V 2 , the two vertices u and v are adjacent.
We now show that a halfspace H of G(K) traverses V 1 if and only if H traverses V 2 . Suppose to the contrary that there exists a halfspace H that traverses V 1 and satisfies V 2 ⊆ H. Since d(p, q) = d(R 1 , R 2 ), we know that p coincides with the orthogonal projection of q onto R 1 . Hence according to Lemma 3.16 we have p ∈ (R 1 ) H ⊆ R 1 , which contradicts the minimality of R 1 .
Therefore we have V 1 = gate V 1 (V 2 ) and V 2 = gate V 2 (V 1 ) by Lemma 3.15 (ii), which together with Lemma 3.14 (ii), implies that V 1 and V 2 are isomorphic cube-subgraphs of G(K). Since the two vertices of each gated pair of V 1 and V 2 are adjacent, V 1 ∪ V 2 induces a cube-subgraph of G(K). This completes the proof of Lemma 3.10.