Cylindrical Algebraic Sub-Decompositions

Cylindrical algebraic decompositions (CADs) are a key tool in real algebraic geometry, used primarily for eliminating quantifiers over the reals and studying semi-algebraic sets. In this paper we introduce cylindrical algebraic sub-decompositions (sub-CADs), which are subsets of CADs containing all the information needed to specify a solution for a given problem. We define two new types of sub-CAD: variety sub-CADs which are those cells in a CAD lying on a designated variety; and layered sub-CADs which have only those cells of dimension higher than a specified value. We present algorithms to produce these and describe how the two approaches may be combined with each other and the recent theory of truth-table invariant CAD. We give a complexity analysis showing that these techniques can offer substantial theoretical savings, which is supported by experimentation using an implementation in Maple.


Motivation
A cylindrical algebraic decomposition (CAD) is a decomposition of R n into cells arranged cylindrically (so the projections of any pair of cells are either equal or disjoint) each of which is describable using polynomial relations. They are produced to answer a problem, originally sign-invariance with respect to a list of polynomials, meaning each polynomial had constant sign on each cell. First introduced by Collins in [14], CAD has become a key tool in real algebraic geometry for studying semi-algebraic sets and eliminating quantifiers. Other applications include robot motion planning [35], parametric optimisation [24], epidemic modelling [11], theorem proving [33] and programming with complex functions [18].
However, it has often been noted that CAD usually produces far more information that required to solve the underlying problem. Often it will produce thousands of superfluous cells which are not relevant to the solution set. Many techniques have been developed to try and reduce the number of cells produced for a CAD, some of which we discuss later. However, the key focus of this paper is the development of methods to return a subset of a CAD sufficient to solve the underlying problems. We find that such subsets can often be identified from the structure of the problem. This motivates our main definitions which now follow.

Definition 1.
Let D be a CAD of R n . A subset of cells E ⊆ D is called a cylindrical algebraic sub-decomposition (sub-CAD).
Let F ⊂ Q[x 1 , . . . , x n ]. If D is a sign-invariant CAD for F , then we call E a sign-invariant sub-CAD. We define sub-CADs with other invariance properties in an analogous manner.
If ϕ(x 1 , . . . , x n ) is a Tarski formula for which D is a CAD, and E contains all cells of D where ϕ is satisfied then we say that E is a ϕ-sufficient sub-CAD.
Quantifier elimination is a key application of (and the original motivation for) CAD. It is achieved by constructing a CAD for the polynomials in a quantified formula ϕ, testing the truth of ϕ at a sample point of each cell (sufficient to draw conclusion for the whole cell due to sign-invariance), and thus forming an equivalent quantifier free formulaφ from the algebraic description of the cells on which ϕ is true. Such an application makes no use of the cells on which ϕ is false and so a ϕ-sufficient sub-CAD is appropriate.
For a given problem we would ideally like the smallest possible ϕ-sufficient sub-CAD. While it may not be possible to pre-identify this we have developed techniques which restrict the output of CAD algorithms to provide sub-CADs sufficient for certain general classes of problems. These will offer savings on any subsequent computations on the cells (such as evaluating polynomials or formulae) and in some cases savings in the CAD construction itself. We will introduce these techniques and demonstrate how some can be used in conjunction with each other. We continue the introduction by giving the reader a reminder of the theory of CAD before outlining the contributions of this paper.

Background to CAD
A complete description of Collins' original algorithm is given in [1]. While there have been many improvements and refinements to this algorithm the structure has remained largely the same. In the first phase, projection, a projection operator is repeatedly applied to a set of polynomials, each time producing another set in one fewer variables. Together these sets contain the projection polynomials. These are then used in the second phase, lifting, to build the CAD incrementally. First R is decomposed into cells: points corresponding to the real roots of the univariate polynomials, and the open intervals defined by them. Then R 2 is decomposed by repeating this process over each cell using the bivariate polynomials. The output for each cell consists of sections (where a polynomial vanishes) and sectors (the regions between). Together these form a stack over the cell, and taking the union of these stacks gives the CAD of R 2 . This is repeated until a CAD of R n is produced.
All cells are equipped with a sample point and a cell index. The index is an n-tuple of positive integers that corresponds to the location of the cell relative to the rest of the CAD. Cells are numbered in each stack during the lifting stage (from most negative to most positive), with sectors having odd numbers and sections having even numbers. Therefore the dimension of a given cell can be easily determined from its index: simply the number of odd indices in the n-tuple. Our algorithms in this paper will produce sub-CADs that are index-consistent, meaning a cell in a sub-CAD will have the same index as if it was produced in the relevant full CAD.
To conclude that a CAD produced in this way is sign-invariant Collins defined the concept of delineability. A polynomial is delineable over a cell if the portion of its zero set over the cell consists of disjoint sections. A set of polynomials is delineable over a cell if each is delineable and, furthermore, the sections of different polynomials over the cell are either identical or disjoint. The projection operator used must be defined so that over each cell of a sign-invariant CAD for projection polynomials in r variables, the polynomials in r + 1 variables are delineable. Important developments to this algorithm include refinements to the projection operator [25,30,7], reducing the number of projection polynomials and hence cells; Partial CAD [15] where the structure of the input formula is used to simplify the lifting stage; the theory of equational constraints and truth-table invariance [31,4] where the presence of equalities in the input can be used to further refine the projection operator; the use of certified numerics in the lifting phase [38,26]; and CAD via Triangular Decomposition [13] which first constructs a decomposition of complex space and then refines this to a CAD.
Constructing a CAD is known to be doubly exponential in the number of variables [10,19]. While none of the improvements described above (or introduced in this paper) can circumvent this they do make a great impact on the practicality of using CAD. We also note that the output of CAD algorithms may depend heavily 1 on the variable ordering.
We usually work with polynomials in Q[x 1 , . . . , x n ] with the variables, x, in ascending order (so we first project with respect to x n and continue until we reach univariate polynomials in x 1 ). The main variable of a polynomial (mvar) is the greatest variable present with respect to the ordering. Heuristics to assist with making the choice of variable ordering (and other choices involved in CAD) were discussed in [20,5].

New Contributions
In Section 2 we present some new algorithms to produce sub-CADs, as well as surveying the literature to demonstrate other examples of sub-CADs.
We start in Section 2.1 by defining a Manifold sub-CAD (M-sub-CAD). This idea combines two previously separate ideas: equational constraints [31], where the presence, explicit or implicit, of an equation implied by the input formula improves the projection operator; and partial CAD [15], where the logical structure of the input allows one to truncate the lifting process when the truth value can already be ascertained. We observe that if the input formula contains an equational constraint, then all valid cells must lie on the manifold defined by that equation and therefore it is unnecessary to produce any cells not on this manifold. We give an algorithm to produce an M-sub-CAD and thus obtain savings from this observation.
In Section 2.2 we define another algorithm to minimise the number of CAD cells returned. We define a Layered sub-CAD (L-sub-CAD) as the cells in a CAD of a prescribed dimension or higher. It has been noted previously [28,37] that a problem involving only strict inequalities would require only the cells in a CAD of full-dimension. We generalise this idea and explain when it may be of use, for example to solve problems whose solution sets are of known dimension or in applications like robot motion planning where only cells of a certain dimension are of use.
Both of these ideas follow from almost trivial observations yet they can have significant impact on the practicality of CAD. Their power can be increased further by combining them, which is discussed in Section 3.1. For example, consider the case where a formula has the structure f = 0 ∧ ϕ(g i ) and all the g i are in strict inequalities. By identifying the cells of full dimension on the manifold we can identify the generic families of solutions: we find these cells can be produced by using a Layered Manifold Sub-CAD (LM-sub-CAD).
Similarly, the new ideas may be combined with existing aspects of CAD theory. It is obvious to combine the restricted output of a manifold CAD with the theory of reduced projection with respect to equational constraints. It is also possible to combine with the recent advance of truth-table invariant CAD (TTICAD) [4] which produces a CAD for which each cell is truth invariant for a list of formulae, utilising any equational constraints to reduce the projection phase. This is discussed in Section 3.2. We explain how to combine to form Manifold Sub-TTICAD (M-sub-TTICADs), Layered Sub-TTICADs (L-sub-TTICADs) or even Layered Manifold Sub-TTICADs (LM-sub-TTICADs). In Example 5 we examine a problem where a LM-sub-TTICAD can be used to identify the majority of solutions (the set of missed solutions has measure zero). This approach produces almost 90% fewer cells than using TTICAD alone, while trying to tackle the problem with a sign-invariant CAD is infeasible.
Although none of these theories avoid the doubly exponential nature of CAD they can have a considerable impact on the practicality of problems, corresponding to drops in the constant terms which may be ignored by the asymptotic analysis (although note that 2 2 n = O(2 2 n−1 ) so such savings can have a substantial effect). We present new complexity results in Section 4. We then give details of our implementation and examples demonstrating the benefit of using these ideas in Section 5 before concluding and discussing future directions in Section 6.

Sub-CADs
Examples of sub-CADs may be found in the literature but to the best of our knowledge the concept has never been formalised and unified before. Until recently, there was an implicit emphasis on constructing all cells of a CAD, and producing a decomposition for the whole of R n .
Generally a CAD will produce a large number of cells that are unnecessary for the solution of a given problem. We propose a larger emphasis on returning, wherever possible, only those cells necessary to solve the problem at hand.
Trying to identify a minimal sub-CAD for a problem can be costly, as doing so essentially solves the entire problem. Instead of looking for minimal sub-CADs, we aim to identify sets of valid or invalid cells during the projection and lifting stage at minimal cost. Indeed, the two main forms of sub-CAD we will discuss, layered and manifold sub-CADs, require only simple checks on cell-dimensions (easily obtained via the cell-index). Building sub-CADs this way saves on subsequent work on cells (such as evaluation of polynomials) and can also give savings in CAD construction time.

Manifold sub-CAD
To discuss manifold sub-CADs we first recall the definition of an equational constraint.

Definition 2.
Let ϕ be a quantifier free formula of polynomial relations over Q[x 1 , . . . , x n ]. An equational constraint is an equation, f = 0, logically implied by ϕ.
Equational constraints may be given explicitly as in f = 0 ∧ ϕ, or implicitly as . The presence of an equational constraint can be utilised in the first projection stage by refining the projection operator [31] and also in the final lifting stage by reducing the amount of polynomials used to construct the stacks [22]. If more than one equational constraint is present then further savings may be possible [32,6]. We restrict ourselves to a single equational constraint, and if multiple equational constraints are present we assume that one has been designated.
Another key development in CAD theory is partial CAD where the logical structure of the input formula is used to truncate lifting whenever possible. For example, if the truth of an entire cell c can be determined from only some of the cells in the stack over c, it is unnecessary to continue lifting over c.
We combine the idea of utilising equational constraints with the ideas behind partial CAD to define a manifold sub-CAD. Algorithm 1 describes how in general a manifold sub-CAD could be constructed for a formula ϕ containing a set of polynomials A and subset of polynomials E (defining the equational constraint). We assume for now that all factors of polynomials in E contain the main variable x n . In Algorithm 1 ProjOp refers to a suitable projection operator (a good choice would be one which utilises the idea of equational constraints such as P E (A) from [31]). The sub-algorithms CADAlgo and GenerateStack are suitable algorithms for CAD construction and stack generation over a cell with respect to the sign of given polynomials, which must be compatible with the projection operator choice. We note that some of the choices for these sub-algorithms may return FAIL if the input does not satisfy certain conditions checked during stack construction. These conditions are usually referred to as the input being well-oriented (see for example [30]). In these cases Algorithm 1 must also return FAIL.
The correctness of the algorithm follows from the correctness (and compatibility) of the choice made for the projection operator and sub-algorithms. The additional analysis is the final inner loop where only the even indexed cells are returned. This ensures that only sections defined by the equational constraint are returned, which are exactly those cells lying on the manifold. As we are dealing with equational constraints that are in the main variable, this final lifting stage does not save any root isolation computations. It will, however, clearly reduce the output size and so there will be savings on any further computation on the CAD (such as formula evaluation or calculation of adjacency information). The saving will be amplified if the equational constraint is not in the main variable of the system. This corresponds to the manifold appearing at a lower dimension. For example, suppose the equational constraint has main variable x k where k < n. To take advantage of this we would modify Algorithm 1 to perform the restriction at level k instead of the top level. Then the sub-CAD of R k would need to be lifted to a sub-CAD of R n by repeatedly using the GenerateStack subalgorithm but this time on all projection polynomials and with all cells being appended. This early restriction will have a cumulative effect on the remainder of the algorithm, lifting only over the cells on the manifold. We demonstrate these ideas with a simple example.

Example 1.
Assume variable ordering x ≺ y and define the polynomials which are graphed with solid curves in each of the images in Figure 1. This first of these images also represents the simplest sign-invariant CAD for the polynomials, which has 23 cells each indicated by a solid box. If the box is at the intersection of two curves (including the dotted lines) then the cell it represents is a point. Otherwise, if the box is on a curve then the cell represented is that portion of the curve and if the box is not on a curve then the cell represented is that portion of the plane. Suppose these polynomials originated from a problem involving the formula ϕ 1 := f = 0 ∧ g < 0. Then 3 of the cells describe the solution (those on the circle to the left of the y-axis). Using Algorithm 1 a manifold sub-CAD would be returned with all 8 of the cells on the circle. The other cells have been recognised as not being on the manifold to which all solutions belong and hence have been discarded. The middle image in Figure 1 shows the sub-CAD produced with the cells represented by solid boxes. In this case little CAD computation time has been saved since the most of the work required to define the discarded cells had to be performed, (these computed but discarded cells are shown as empty boxes). However, there will be savings for any further work, such as only having to evaluate the polynomials on 8 cells instead of 23 in order to describe the solutions. Now suppose the problem involves instead the formula ϕ 2 := f < 0 ∧ g = 0. In this case there is only one cell for which the formula is true (the cell describing the y-axis inside the circle). By adapting Algorithm 1 as described above, we can produce a manifold sub-CAD with 5 cells (those describing the y-axis) as shown in the third image of Figure 1. This time there has been savings in CAD construction time as the manifold restriction occurred when building the CAD of R 1 . No lifting (and hence real root isolation) was performed over any of the six cells in R 1 which were not on the manifold and so these have not been represented in the image.
The cell counts in this toy example were modest, but we will see later in Section 5 that for more complicated examples the savings offered by using a manifold sub-CAD can be substantial.
We note that in the case where the equational constraint is not in the main variable of the system building a manifold sub-CAD will not only reduce the size of the output but may also avoid unnecessary failure. That is, if the input is not well-oriented but the problem only occurs away from the manifold the outputted sub-CAD will still be valid. However, it is now no longer a subset of a CAD we know how to produce algorithmically.
We have discussed the case of a single declared equational constraint and we are therefore working on a manifold of (real) co-dimension 1. If there are two or more equational constraints, as in f 1 = 0∧f 2 = 0∧. . ., we are in the area of bi-equational constraints [32] and manifolds of higher co-dimension. We have not currently investigated this.
There are various options for utilising the presence of multiple equational constraints in different clauses of the formula, the simplest being to multiply them together to form a single overall constraint. Another option is to split the formula up into sub-formulae each with a single equational constraint and use a manifold TTICAD [4] as discussed in Section 3. In both cases, a problem's tractability can differ with the choice of equational constraint, and heuristics for choosing the most efficient equational constraint were discussed in [5], but have not yet been investigated with manifold CAD.

Layered sub-CAD
The idea of returning cells of certain dimensions was first discussed in [28] and revisited in [37,9]. All these papers discuss the idea of returning only CAD cells of full-dimension, noting that this is sufficient to solve problems involving only strict polynomial inequalities. This idea was extended in the technical report [41] to the case of returning cells with dimension above a prescribed value. We reproduce some of this unpublished work here, including the key algorithms.

Definition 4.
We refer to all cells of a given dimension in a CAD as a layer.
Let ℓ be an integer with 1 ≤ ℓ ≤ n + 1. Then an ℓ-layered CAD is the subset of a CAD of dimension n consisting of all cells of dimension n − i for 0 ≤ i < ℓ.
We refer to a CAD consisting of all cells of all dimensions as a complete CAD.

Remark 1.
An ℓ-layered CAD consists of the top ℓ layers of cells in a CAD. The dimensions of these cells will depend on the dimension of the space the CAD decomposes.
In the literature the idea of returning only full-dimensional cells has been referred to as open CAD, full CAD and generic CAD, (all terms that may be open to misinterpretation). We use layered CAD for the more general idea and refer to a CAD with only full-dimensional cells as a 1-layered CAD. Note also that a complete CAD of R n has (n + 1)-layers.
An ℓ-layered CAD returns the ℓ layers of maximal dimension, whilst a manifold CAD will in the process of restricting to a manifold, discarding the full-dimensional layer of cells, and returning a subset of the remaining layers.
Algorithm 2 describes how an ℓ-layered CAD may be produced. The main idea is that during the lifting process we check cell dimension before each stack construction. Then if a cell is found to have too low a dimension to lead to cells in R n of dimension ℓ or higher it is discarded. As before, we give a general algorithm which can be used with any suitable (and compatible) projection operator and stack generation procedure.
Consider the polynomials f = x 2 + y 2 − 1, g = x introduced by Example 1 and assume again the variable ordering x ≺ y. The first image in Figure 1 demonstrated that the simplest sign-invariant complete CAD for the polynomials would have 23 cells. Figure 2 shows the same CAD, this time with the dimensions of each cell indicated. Suppose that the polynomials arise from a problem involving the formula ϕ 3 := f < 0 ∧ g < 0. The solution is then given by the single cell inside the circle to the left of the y-axis. In this case we can conclude at the start that the solutions must all be cells of full-dimension and so know a 1-layered CAD produced by Algorithm 2 would suffice. The algorithm would return only the 8 cells of dimension 2 (the solid boxes in Figure 2). Example 2 shows a simple situation where using a 1-layered sub-CAD is sufficient. This is a case where strict inequalities indicate clearly that the solutions have full-dimension (as noted previously in [28,37]). More generally there are classes of problems with known solution dimension for which the layered CAD technology will be beneficial. For example, recall the cyclic n-polynomials (the set of n symmetric polynomials in n variables). In [2] it is shown that if there exists m > 0 such that m 2 |n then there are an infinite number of roots and they are, at least, of dimension (m − 1). A CAD containing cells of dimension (m − 1) and higher would therefore be sufficient to identify the largest families of solutions, and so layered CAD could be an appropriate tool.
Other situations calling for layered sub-CAD would include motion planning. Here it is likely that we only want to identify paths through cells of full-dimension, but to analyse the adjacency of such paths we may need the cells of dimension one lower. We consider a motion planning example later in Section 5.
Note the following key property of certain layered CADs.

Theorem 1 ([41]).
Let F ⊂ Z[x 1 , . . . , x n ] and let D be a 1-layered or 2-layered CAD of R n sign-invariant with respect to F . Then D is F -order-invariant.
Order-invariance is a stronger property than sign-invariance, but the extra knowledge it gives allows for the validated use of smaller projection operators (see for example [30]). Hence this property is important and useful, allowing for the avoidance of some well-orientedness checks during stack generation and also the unnecessary failure declarations that can sometimes follow (see for example [8,21]).
We now explain how Algorithm 2 may be adapted to a recursive procedure. The general principle behind our method of constructing layered CADs is to stop lifting over a cell if it cannot lead to cells of sufficient dimensions. This will always occur when the cell in question was produced as a section of a stack, rather than a sector. Let us call these terminating sections. The idea behind the recursive algorithm is that rather than discarding these sections after they are produced we store them in a separate output variable for use later if required.
For example, when constructing a 1-layered CAD these terminating sections will have dimension m − 1 where m is the number of variables lifted at the level the section is constructed, i.e. they are deficient by one dimension. Therefore when reaching the final lifting stage the terminating sections will have dimension n − 1. Now suppose we wish to extend to a 2-layered CAD. If we take one of these terminating sections of any dimension and construct a stack over it we will construct cells that are of dimension n − 1 and terminating sections that are deficient (with respect to their level) by two dimensions. Combining these n − 1-dimensional cells with the 1-layered CAD produces a 2-layered CAD. If we again store the remaining (and new) terminating sections then they can be used again with a recursive call to construct a 3-layered CAD if desired. In this manner we can recursively produce ℓ-layered CADs, useful if the numbers of layers required is not known at the start of the computation.
The method is described by Algorithm 3. Implementation is not quite as straightforward as Algorithm 2. We need to use a global variable containing the projection polynomials and unevaluated functions calls which we denote using % (following the syntax in Maple).
Input : A formula ϕ, a list of ordered variables vars, a list of lists of cells, C, ordered by dimension and a list of cells LD for a layered CAD that has already been constructed. The lists C and LD may be empty. Output: A layered CAD D for ϕ, built from the cells in LD and the cells of appropriate dimension gained by lifting over C. Also a recursive call to CADOneLayeredRecursive to construct the consecutive layer.
global P ; // To avoid recomputing projection polynomials if P is undefined then P ← output from applying ProjOp repeatedly to ϕ ; // Full projection phase for i = 1, . . . , n do Set P[i] to be the projection polynomials with mvar x i ; // Base case -construct R 1 Set Base to be the CAD of R 1 obtained by isolating the roots of P We note that computing a complete CAD by using this recursive algorithm takes only marginally longer than using the non-layered approach.

Sub-CADs in the literature
We have described two new types of sub-CAD. However, we note that many other examples from the CAD literature could be described as, or be easily adapted to produce, sub-CADs.
For example, in [29], whilst trying to solve a motion planning problem in the plane described by a formula ϕ, the author identifies a subset of cells in the decomposition of R 1 for which any valid cell for ϕ must lie over, and then proceeds to lift over only these cells thus giving a ϕ-sufficient sub-CAD. Similar ideas were described in [26].
In [9] an algorithm is presented which accepts polynomials F and a point α, returning a single cell containing α and on which F is sign-invariant. The cell may be viewed as belonging to a CAD (although not necessarily one that would be produced by any known algorithm) and so the cell can be seen as an extreme example of a sub-CAD.
Partial CAD [15] works by avoiding splitting cylinders into stacks when lifting over cells when the truth value is already known. If cells over which the truth value is false were instead simply discarded then what is left would be a sub-CAD sufficient to analyse the input formula.
In [36] an algorithm is described which takes polynomials F and returns a CAD D and theory Θ (set of negated equations). The CAD is sign-invariant for F for all points which satisfy Θ. Rather than a sub-CAD of R n this is actually a CAD of R n Θ = {x ∈ R | x ∈ Θ}, that is all those points in R n except the set of measure zero which do not satisfy Θ.
In [39], an algorithm is given for solving systems over cylindrical cells described by cylindrical algebraic formulae. This allows cells produced from a CAD to be used easily in further computation, which may implicitly be used to produce either sub-CAD or CADs of a sub-space.

Interactions of sub-CADs
Whilst the ideas of layered and manifold sub-CADs are powerful on their own, it is possible to combine them to even greater effect.

Combining layered and manifold sub-CADs
The ideas behind layered and manifold sub-CADs are similar: we wish to filter out only those cells of relevance to us. A manifold sub-CAD does this in one step during a single stage of the lifting phase, whereas a layered sub-CAD stratifies the cells throughout the whole lifting process. There is no reason why these two ideas cannot be combined, we discuss this in the case where all factors of the equational constraint defining the manifold have main variable x n . Consider the following simple result.

Lemma 1.
Let D be a CAD of R n−1 for some formula ϕ and let c be a cell in D of dimension k. Further, suppose f = 0 is an equational constraint of ϕ, with each factor of f having main variable x n .
Then any section of the stack lifted over c with respect to f will have dimension k.
This tells us that if we lift over a layered CAD onto a manifold, then the resulting cells will have the same dimension as the layered CAD. Therefore lifting over an ℓ-layered CAD of R n−1 (which contains cells of dimension n−ℓ, . . . , n−1) will produce a sub-CAD containing all the cells of dimensions n − ℓ, . . . , n − 1 on the manifold. This can be thought of as an ℓ-layered sub-CAD with respect to the manifold.

Definition 5.
Let ϕ be a boolean combination of polynomial equations, inequations, and inequalities. Let ϕ have an equational constraint f ∈ Q[x 1 , . . . , x n ] with main variable x n in all its factor, and let 1 ≤ ℓ ≤ n. A sub-CAD consisting of all cells of dimension n − 1 − i for 0 ≤ i < ℓ resting on the manifold defined by f = 0 is called a ℓ-Layered Manifold Sub-CAD (ℓ-LM-sub-CAD).

Remark 2.
Note that a ℓ-layered manifold sub-CAD consists of the top ℓ layers of cells on the manifold. This can be thought of as the intersection of an (ℓ + 1)-layered CAD of R n with the manifold (as the layer of n-dimensional cells is discarded when lifting to the manifold).
Using Lemma 1 we have a simple way to build a LM-sub-CAD. We may construct a ℓ-layered manifold sub-CAD by replacing CADAlgo in Algorithm 1 by Algorithm 2 (or alternatively repeatedly use Algorithm 3). The algorithm will then first construct an ℓ-layered CAD of R n−1 with respect to the projection polynomials before lifting to the manifold resulting in a ℓ-layered manifold sub-CAD.
We now give a simple example which uses both the layered and manifold ideas together.

Example 3.
Consider again the polynomials from Examples 1 and 2: Suppose we are considering the formula ϕ 1 := f = 0 ∧ g < 0. In Example 1 we saw that with variable ordering x ≺ y a manifold sub-CAD could be produced with 8 cells, 3 of which described the solutions. Instead let us build a 1-layered manifold sub-CAD as represented on the left of Figure 3. The output would now be only 4 cells (those indicated with solid boxes). Two of these describe the generic solution sets {x ∈ (−1, 0), y = ± √ 1 − x 2 } but the third and final cell in the solution set {x = −1, y = 0} has been lost. Note that in this case (unlike the manifold sub-CAD) there will be a reduction in CAD computation time as there will be no lifting over cells of dimension zero in the CAD of R 0 . The cells which have been computed but discarded are shown by empty boxes. Consider now the alternative variable ordering y ≺ x. In this case a minimal complete signinvariant CAD must have 19 cells, as represented by the middle image in Figure 3. A manifold sub-CAD would return the 4 cells describing the circle and a 1-layered manifold sub-CAD only the 2 cells of these which have full-dimension on the manifold. This sub-CAD is represented by the final image in Figure 3. Again, there has been a saving in CAD construction time (the constructed but discarded cells are shown with empty boxes) but in this case the cells returned include the full solution set (the single cell describing the upper half of the circle.

Truth table invariant Sub-CADs
The new ideas of manifold and layered sub-CADs can be further adapted to problems by combining with other CAD techniques. We shall discuss here the interaction with the idea of truth table invariant CADs (TTICADs) introduced recently by [4]. We recall the definition of a TTICAD.

Definition 6 ([4]).
Let {φ i } t i=1 be a list of quantifier-free formulae (QFFs). We say a cylindrical algebraic decomposition D is a Truth Table Invariant CAD for Φ (TTICAD) if the Boolean value of each φ i is constant (either true or false) on each cell of D.

It was shown in [4] that truth table invariance is a very useful and important concept. Given a problem defined by a parent formula Φ built by a boolean combination of {φ
, a TTICAD is sufficient and more efficient than either a sign-invariant CAD for all the polynomials or a CAD built using the theory of equational constraints (when applicable). Further, there are classes of problems for which a TTICAD is exactly the desired structure, such as the problem of decomposing a complex domain according to the branch cuts of multivariate functions [3,34,23].
In [4] an algorithm was given for when each φ i contains an explicit equational constraint. This has recently been extended to allow for φ i 's without an equational constraint [22], but for ease of exposition we will consider only the original algorithm. The algorithm involves a new projection operator which encapsulates the interaction between the equational constraints of the φ i 's whilst ignoring interactions between polynomials that have no effect on the truth value of φ i .
In the case where there is a parent formula Φ and all the φ i have their own equational constraint we can create a M-sub-TTICAD. We would use Algorithm 1 replacing ProjOp by the TTICAD projection operator in A and using a GenerateStack algorithm which checks for the necessary wellorientedness properties of TTICAD. The equational constraint set will contain all the equational constraints for the individual φ i 's. Their product is an implicit equational constraint for the whole formula and the sub-CAD produced will be for the manifold this product defines. We note that although the manifold considered is that of the implicit equational constraint the TTICAD projection theory is more efficient that the equational constraint theory applied to this case (as described in [4]).
Creating layered TTICADs L-sub-TTICAD is also possible, again by adapting Algorithms 2 and 3 with the TTICAD projection operator and appropriate GenerateStack algorithm. (See the technical report [41] for some further details and examples.) Further, we can combine the ideas of Section 3.1 with TTICAD to produce layered manifold sub-TTICADs.  As with ML-sub-CADs, a ℓ-layered manifold sub-TTICAD consists of the top ℓ-layers of cells on the manifold t i=1 f i = 0. Again, this can be thought of as the intersection of an (ℓ + 1)-layered CAD of R n with the manifold (as the layer of n-dimensional cells is discarded when lifting to the manifold).
We can construct LM-sub-TTICADs by using Algorithm 1 and substituting the TTICAD projection operator for ProjOp and the layered TTICAD algorithm for CADAlgo. Example 5 in Section 5 demonstrates the use of a LM-sub-TTICAD and the benefits of choosing to do so.

Complexity analysis
We provide a complexity analysis of the algorithms to compute sign-invariant manifold sub-CADs and 1-layered manifold sub-CADs. We need to study three parts of the complexity: Projection. The complexity of the equational constraint projection set needs to be analysed. In particular the number of polynomials, the maximum degree and size of their coefficients. Calculation of (n − 1) dimension CAD. These values then can be used to estimate the complexity of the (n − 1)-dimensional CAD. Lifting. Finally the complexity of the lifting stage can be combined with the previous step to describe the complexity of the manifold CAD. We recall the previous comprehensive work on CAD complexity by Collins [14] and McCallum [28]. We first standardise some notation for a CAD with respect to a set of polynomials A: let n be the number of variables, m the number of polynomials in A, d the maximum degree in any variable of the polynomials in A, and l the maximum norm length of the polynomials in A (where the norm length, |f | 1 , is the sum of the absolute values of the integer coefficients of a polynomial).
Let A 1 := A and let A i+1 = Proj(A i ). In general the projection operator used will be clear; most of the following complexity analysis is with respect to Collins' projection operator and, therefore, is a 'worst case scenario' compared to the improved operators of McCallum [30] and Brown [6]. Let m k be the number of polynomials in A k , d k the maximum degree of A k , and l k the maximum norm length.

Collins' algorithm
Collins [14] works through the original CAD algorithm in great detail to analyse the complexity, and this methodology is followed in [28]; we will recall some key results. These could all be uniformly improved with ideas from papers such as [12,16], but that is not the aim of this paper.
In the projection stage we can bound the properties of the projection sets as follows: Combining these bounds gives us an idea of the projection phase. Collins shows that it is dominated by (2d) 3 n+1 m 2 n l 2 . The base case and lifting algorithm requires the isolation of real roots of univariate polynomials. Collins bounds this procedure as follows. Let A be a set of univariate polynomials with degree bounded by d and norm length bounded by l. Then for a given f ∈ A withd := deg(f ) andl := |f | 1 we can lower bound the distance between two roots by Collins uses his analysis of Heindel's algorithm for real root isolation to show that isolating the roots is dominated byd 8 +d 7l3 .
(2) Therefore the operations needed to isolate all roots in A, with m := |A|, is dominated by: For a given h, refining a root interval to 2 −h is dominated by d 2 h 3 + d 2 l 2 h. Collins multiplies all polynomials in A and uses (1) to show that all roots are separated by: If we take h to be log(δ) we can refine all intervals of the polynomials in Combining this with (3) tells us that the necessary refinement of intervals for all the polynomials is dominated to md 8 + m 7 d 7 l 3 .
(4) Collins uses (4) along with the size of the full projection set to show that the base phase is dominated by (2d) 3 n+3 m 2 n+2 l 3 . We also need to consider the polynomials involved in the lifting stage. This involves looking at the univariate polynomials created after substituting sample points, along with the polynomials required to define the algebraic extensions of Q that the sample points are contained in.
We follow [14,28] in using primitive elements to calculate the costs of operations, even though implementers are extremely unlikely to use them. For each sample point β = (β 1 , . . . , β k ) ∈ R k there is a real algebraic number α ∈ R such that Q(β 1 , . . . , β k ) = Q(α). Let A α be the polynomial in Q[x] defining α, that is A(α) = 0, along with an isolating interval I α . Let d * k be the maximum degree of these A α , and l * k the maximum norm length. Each coordinate β i is represented in Q(α) by another polynomial, and let l ′ k be the maximum norm length of these polynomials. Then d * k ≤ (2d) 2 2n−1 ; l * k , l ′ k ≤ (2d 2 ) 2 2n+3 m 2 n+1 l. Let u k be the number of univariate cells (after substitution) and c k the number of cells at level k. Then Finally, Collins combines all these results to give a complexity bound for the full algorithm. The Collins Algorithm is dominated by (2d) 4 n+4 m 2 n+6 l 3 .

McCallum's Cadmd algorithm
In [28], McCallum gives a complexity bound, using the same methodology as [14], for his Cadmd algorithm which produces a 1-layered CAD. Thanks to the avoidance of algebraic numbers (all sample points in a 1-layered CAD can be produced directly in Q) the exponents are lower than in (6). The complexity is dominated by (2d) 3 n+4 m 2 n+4 l 3 .

Analysis of P E (A) and (n − 1)-dimensional CADs
To have an accurate complexity we must consider some properties of the projection set: the size, maximum degree, and maximum norm length. Let E be the subset of A containing the factors of the designated equational constraint. Let m A := |A|, m E := |E|, m A\E := |A \ E|, and let d A , d E , d A\E , l A , l E , and l A\E be defined similarly.
When constructing a CAD with respect to equational constraints, we use a projection operator, P E (A), defined by McCallum [31]: where P (E) is an application of the operator as defined in [30]: the coefficients, discriminants and resultants of E. We will denote the resultant set, P E (A) \ P (E), by ResSet E (A).
The size of P (E) is bounded by the number of coefficients (m E d E ), discriminants (m E ), and resultants ( mE ). Therefore we have The maximum degree of P E (A) is the greater of the maximum degrees of P (E) and the resultant set. We also have a bound on the degree of a resultant with respect to x: deg y f, deg y g)).
Using our overall degree bounds gives We also have max deg( Combining (9) and (10) gives a degree bound for P E (A) Finally, if we denote the maximum norm length of P E (A) by l, then we know l ≤ l 2 (as P E (A) ≤ Proj(A)) so Using the bounds from (8), (11) and (12) to substitute into (6) and (7) to get estimates for the complexity of the (n − 1)-dimensional CAD. The complexity of a complete (n − 1)-dimensional P E (A)-invariant Collins CAD is dominated by   Table 1.

Comparison of complexities
In Theorem 2 we have emboldened the exponents to highlight the difference between (16) and (17), but it can be difficult to visualise the comparison. Therefore we offer computations for the scale of the complexities for sample parameter sets. These are shown in Table 1. For each set of parameters given we provide the complexity estimates for a CAD of R n (CAD), an M-CAD of R n (M-CAD), a 1-layered CAD of R n (1-L CAD), and a 1-layered manifold sub-CAD of R n (1-L M-CAD).
To visualise how the coefficient of n in the double exponential has changed, we plot the double logarithm of the complexities for parameters d A = 3, d E = 2, m A = 3, m E = 1, m A\E = 2, l A = 2, l E = 2 whilst n varies from 1 to 5. This is shown in Figure 4. The diagram shows visibly the drop in the constant in the exponents of (16) and (17), but the scaling factor of the exponent remains the same between manifold and non-manifold versions of each algorithm.

Examples and Implementation
The procedures described in this paper are all implemented in the Maple package ProjectionCAD [21,22], within the subpackages ManifoldCAD and LayeredCAD. More details of the implementation of layered CAD are given in [41].
All experiments were run on a Linux desktop (3.1GHz Intel processor, 8.0Gb total memory) with Maple 16 (command line interface) and Qepcad-B 1.69. For Qepcad the options +N500000000 and +L200000 were provided and the initialisation included in the timings.
We provide some demonstrative examples showing how LM-sub-CAD and LM-sub-TTICAD are useful for studying problems.

Example using 1-layered manifold sub-CAD Example 4.
Assume variable ordering x ≻ y ≻ z and consider the following formula involving 3 random polynomials of degree 2 (generated using Maple's randpoly function): We wish to describe the valid regions of R 3 in which Φ is satisfied. As can be seen in Figure 5, there are multiple intersections and, importantly, a lot of interaction between the two non-equational constraints away from the manifold defined by the equational constraint. This suggests that M-sub-CAD could be beneficial. Further, if only generic solution sets are of interest then a 1-layered manifold sub-CAD could offer further savings.
To solve the problem we construct a variety of CADs and sub-CADs with the results shown below. MapleCAD refers to the the algorithm to produce sign-invariant CADs via triangular decomposition built into Maple [13] and Qepcad the default use of Qepcad-B to build a partial CAD [7]. The other algorithms are all implemented in our Maple package ProjectionCAD [22]: CADFull builds a sign-invariant CAD, ECCAD a CAD invariant with respect to an equational constraint, and the final three algorithms are those described in this paper applied with the same projection operator as ECCAD.
MapleCAD As can be clearly seen, making use of the equational constraint dramatically reduces the computation involved. A manifold sub-CAD further reduces the size of the output which will lead to time savings on any future work. Indeed, Qepcad evaluates Φ on each cell in the process of constructing an equivalent quantifier-free formula (in this case, Φ cannot be simplified). Of the 17047 cells constructed, Φ is only valid on 290 of them. The 16757 false cells that are constructed and on which Φ is evaluated will be a significant contribution to the computation time, (other factors will be the improved lifting performed by ECCAD as described in [22]).
If we are concerned only with finding the generic solution sets rather than all solutions then a 1-layered manifold sub-CAD may be used offering further time-savings. This replaces an output of around 17,000 cells which took 45 minutes to compute with another of only 138 cells computed in less than 4 seconds. If solutions of lower dimension are also needed then the 2-layered manifold sub-CAD (348 cells) or the complete manifold sub-CAD (422 cells) can be used instead.
We can evaluate Φ on all the cells produced in the 1-LM-sub-CAD almost instantly to find that there are 36 cells on which Φ is satisfied (although the equation is by definition true for all of them the other constraints vary). The space described by these cells differ only from the space described by the 290 valid cells of Qepcad by cells of dimension 1 and 0. Whilst not defining all possible solutions, those missed are of measure zero and may not be needed to solve the problem at hand.
In general, a 1-layered manifold sub-CAD can be used to find the generic solutions (those differing only by a set of measure zero from the full-solution set) for any problem of the form f = 0 ∧ Ψ(g i ) where f = 0 defines a manifold of real co-dimension 1 and Ψ is a quantifier-free formula involving only strict inequalities for the g i . In general, we may find that there are no solutions of full dimension on the manifold, and can use the recursive approach for layered CAD to incrementally build extra layers as required.

Example using 1-layered manifold sub-TTICAD
We now consider a problem suitable for using a combination of our new sub-CAD ideas and TTICAD.

Example 5.
Let us define the following quantifier free formulae: The surfaces defined by the polynomials in ϕ 1 are shown in Figure 6, while those in ϕ 2 are the same but shifted. Assume the variable ordering x ≻ y ≻ z and consider the problem of finding all regions of R 3 satisfying the following formula: We can attack this problem naïvely and input the 6 polynomials in Φ to a CAD algorithm. Leaving either Maple's RegularChains CAD implementation or our ProjectionCAD implementation running for 72 hours fails to produce a CAD, while using Qepcad results in a "prime list exhausted" error (a memory constraint) after two hours. We can explicitly tell Qepcad to utilise the implicit equational constraint (the product of the two equations) and then obtain a CAD with 6165 cells in 35304.364 seconds (around 10 hours). This problem is well suited for TTICAD and applying the ProjectionCAD implementation on the two formulae ϕ 1 and ϕ 2 produces 4861 cells in 608 seconds.
We now consider how a 1-Layered Manifold Sub-TTICAD may be constructed. Each formula ϕ i contains an equational constraint, and so can only be true on the manifold it defines. Therefore we may first project using the TTICAD operator applied to ϕ 1 and ϕ 2 and construct a 1-layered sub-CAD of R 2 with respect to this projection set. This takes 573 seconds and produces 249 cells in R 2 . We then lift with respect to both of the equational constraints onto the manifold defined by their product. This takes a further 2 seconds and produces 528 2-dimensional cells on the 2-dimensional manifold in R 3 . Whilst there is only a 5% saving in time from TTICAD, there is a 89% saving in cells. If we then evaluate Φ on each cell we can identify the cells of full dimension (with respect to the manifold) where Φ is valid. Any other cells on which Φ is true would have to be of lower dimension, and so a 1-layered manifold sub-TTICAD is sufficient up to a set of measure zero.
If solutions of lower dimension are needed then we can also produce a 2-layered manifold sub-TTICAD and the full manifold sub-TTICAD which contain 1514 cells and 1976 cells, respectively. Both take under 10 minutes to construct (quicker than constructing the full TTICAD). Note also that over half the cells produced in a complete TTICAD do not lie on either of the manifolds defined by the equational constraints of ϕ 1 and ϕ 2 .
We combine with Φ to form a new overall formula: Given the above results for Φ it would be foolish to attempt to solve this problem without utilising the presence of the equational constraints. We repeat the approach used for Φ. This time the 1-layered sub-CAD of R 2 takes 3200.389 seconds (just under an hour) and produces 488 cells. It takes a further 7.250 seconds to construct the 1-layered manifold sub-TTICAD, resulting in 1096 cells. Attempting to construct a sign-invariant CAD is not going to be feasible, but we can construct a TTICAD. This takes 4488.764 seconds (an hour and a quarter) and produces 10033 cells; nearly 10 times the number of cells a 1-layered manifold sub-TTICAD has. Although the TTICAD will contain all valid cells for Φ, the 1-layered manifold sub-TTICAD will provide descriptions of general families of solutions.
If solutions of lower dimensions are needed then a 2-layered manifold sub-TTICAD or the complete manifold sub-TTICAD can be constructed. A 2-layered manifold sub-TTICAD contains 3153 cells, whilst the manifold sub-TTICAD contains 4117 cells. This again highlights the fact that over half the cells produced in the TTICAD do not satisfy any of the equational constraints and are thus unnecessary to describe the solution.

A piano movers' problem
An application of CAD of great interest is motion planning. Given a semi-algebraic object, an initial and desired position, and semi-algebraic obstacles, a CAD can be constructed of the valid configuration space of the object. The connectivity of this space can then be used to determine if a feasible path from the initial position of the object to the desired endpoint is possible.
A well-studied problem in this area is the movement of a ladder through a right-angled corridor, as proposed in [17]. The problem consists of a ladder of length 3 inside a right-angled corridor of width 1 with the aim of moving from from position 1 to position 2 in Figure 7.  Figure 7. The piano movers problem considered in [17] Although in 2-dimensional real space the problem lies in a 4-dimensional configuration space which makes it far more difficult to describe with a CAD. It is still not feasible to build a CAD for the formulation of the problem given in [17] but recently progress was made in [40] by reformulating the problem. We can now construct a CAD of the configuration space using Qepcad with 285,419 cells in around 5 hours (without Qepcad's partial CAD techniques this increases to 1,691,473 cells and over 24 hours computation time). A representation of the 2-dimensional CAD produced on route to the full 4-dimensional CAD is given in Figure 8.
The formulation of the ladder includes an explicit equational constraint. Denoting the endpoints of the ladder as (x, y) and (x ′ , y ′ ), the length of the ladder becomes the equational constraint: The problem is therefore suited to treatment with a M-sub-CAD. Indeed, we can see from Figure 8 that there is a great deal of information computed which is of no use in describing the suitable paths. It would be of great use if partial CAD techniques can be adapted to restrict a CAD or sub-CAD to a sub-CAD of just the corridor highlighted. Figure 8. A representation of the 2-dimensional induced CAD produced for the new formulation of the piano movers problem in [40].
Within this three-dimensional manifold (embedded within R 4 ) the important cells are those that are three-dimensional. This is as cells of lesser dimension correspond to physically infeasible situations (i.e. one dimensional subspaces of R 2 ). Therefore a LM-sub-CAD could be used as an overview of the problem.
Constructing the 1-layered sub-CAD of R 3 produces 64,764 cells in around four and a half hours, and lifting to the manifold takes a further 15 minutes and produces 101,924 cells. This is a saving (both in terms of cells and timing) on the partial CAD produced by Qepcad. Adjacency information will have to be computed for a full solution to the problem (which will possibly require a 2-layered manifold sub-CAD) and thus any savings in cells will be of huge advantage to the feasibility of these computations.

Conclusions and further work
We have formalised the idea of a cylindrical algebraic sub-decomposition. Whilst a simple idea, it can be hugely powerful and the examples presented show that massive cell reductions are possible. The time reductions in computing the CADs are less dramatic, but since most problems using CAD will require some further computation on the cells (such as polynomial evaluation) the overall time savings will be much greater. Applications involving complicated calculation on the cells will benefit even more. For example, the calculation of adjacency information for use in motion planning or the evaluation of multi-valued functions at possibly algebraic sample points for branch cut analysis.
We provided examples of sub-CADs in the literature, along with two new concepts (and algorithms to produce them): manifold sub-CADs and layered sub-CADs. While each has its own interest, we find that savings may be magnified through the interaction between different concepts. We provided examples of this involving layered manifold sub-CADs, manifold sub-TTICADs and layered manifold sub-TTICADs This final type of sub-CAD can be used to partially solve problems having a particular structure, identifying large regions of valid cells, and it was shown this enables us to tackle problems previously infeasible.
There is great scope for future work with some important questions we are working on as follows.
• Can we identify classes of problems where a layered manifold sub-CAD or sub-TTICAD is sufficient to entirely solve a problem? • How the interaction of the layered and manifold theories should be implemented when the polynomials defining the manifold do not contain x n . • How best to adapt existing techniques (such as partial CAD) to output sub-CADs.
• Can we develop heuristics (or adapt existing ones [20,5]) on when and how we should use which theories? • Can we keep track of where cells arise when constructing a manifold sub-TTICAD so that over each cell we lift only to the manifolds for relevant φ i ? This can be thought of as an analogue of partial CAD for TTICAD. This may alter the output significantly (it may not be a sub-CAD of a CAD that can be constructed by current technology) but could allow for even smaller output for given problems. • Can we parallelise the algorithms? The idea mentioned in [29] of lifting over sets of cells independently could be generalised. (Preprocessing CAD problems to allow for parallelisation was discussed in [27] but this involved only the boolean logic of the problem).
There are also many interesting questions arising from whether certain properties of CADs transfer over to their sub-CADs. For example, any existing adjacency algorithms require CADs to be particularly 'well-behaved', and it may be possible to avoid problematic cells through sub-CADs, extending the use of such algorithms. The idea of a well-oriented CAD needed for many modern CAD algorithms [30,6] may also be problematic on a CAD, but not an issue on certain sub-CADs. These ideas need further investigation. An overarching aim is to develop a general CAD framework which would allow for identification of when certain kinds of sub-CADs should be used, automatically combining appropriate methods when possible and making choices automatically when required based on heuristic information. This would identify, for a given problem, an efficient way to produce a φ-sufficient sub-CAD and thus describe the solution set.