An implementation of CAD in Maple utilising problem formulation, equational constraints and truth-table invariance
AAn implementation of CAD in Mapleutilising problem formulation, equationalconstraints and truth-table invariance
Matthew EnglandDepartment of Computer Science, University of Bath, Bath, UK
Abstract
Cylindrical algebraic decomposition (CAD) is an important tool for the investigation of semi-algebraicsets, with applications within algebraic geometry and beyond. We recently reported on a new imple-mentation of CAD in
Maple which implemented the original algorithm of Collins and the subsequentimprovement to projection by McCallum. Our implementation was in contrast to
Maple ’s in-built CADcommand, based on a quite separate theory. Although initially developed as an investigative tool to com-pare the algorithms, we found and reported that our code offered functionality not currently availablein any other existing implementations. One particularly important piece of functionality is the abilityto produce order-invariant CADs. This has allowed us to extend the implementation to produce CADsinvariant with respect to either equational constraints (ECCADs) or the truth-tables of sequences offormulae (TTICADs). This new functionality is contained in the second release of our code, along withcommands to consider problem formulation which can be a major factor in the tractability of a CAD.In the report we describe the new functionality and some theoretical discoveries it prompted. Wedescribe how the CADs produced using equational constraints are able to take advantage of not justimproved projection but also improvements in the lifting phase. We also present an extension to theoriginal TTICAD algorithm which increases both the applicability of TTICAD and its relative benefitover other algorithms. The code and an introductory
Maple worksheet / pdf demonstrating the fullfunctionality of the package are freely available online.
This work is supported by EPSRC grant EP/J003247/1.
This report is the second, following [15], to describe our implementation of cylindrical algebraic decomposition(CAD) in
Maple . This report describes the functionality added to the second release of the code. Thisincludes the ability to: produce CADs invariant with respect to equational constraints following [19], producetruth-table invariant CADs (TTICADs) following [3], and derive different formulations of the input withheuristics to pick the best following [4]. The introduction continues with a brief background on CAD and asummary of the findings of [15]. Then in Section 2 we describe the new functionality in more detail.As with [15], the implementation prompted some theoretical discoveries which are also described in thisreport. In Section 3 we explain how the use of equational constraints can not only lead to the improvedprojection described in [19], but also improved lifting. Then in Section 4 we present an extension to theoriginal TTICAD algorithm of [3], allowing it to be applied to a wider variety of input formulae, includingformulae which could not be tackled by equational constraints alone. We demonstrate that this increases notjust the applicability of TTICAD, but its relative benefit over other algorithms.The second release of the
ProjectionCAD code and an introductory
Maple worksheet / pdf demonstratingthe full functionality of the package are freely available online at http://opus.bath.ac.uk/35636/ .1 a r X i v : . [ c s . S C ] J un . England An implementation of CAD in Maple utilising McCallum projection A cylindrical algebraic decomposition (CAD) is a decomposition of R n into cells, constructed with respectto an input, usually either polynomials or formulae, in n variables. Each cell describes a semi-algebraic setand the cells are cylindrically arranged, meaning the projection of any two cells is either equal or disjoint. ACAD is sign-invariant if the input polynomials have constant sign on each cell. Such a CAD allows for thesolution of many problems defined by the polynomials. Collins provided the definition and first algorithm[9, 1], motivated as a tool for quantifier elimination in real closed fields. Since their discovery they have foundmany other applications ranging from robot-motion planning [20, 12] to simplification technology [2, 13, etc.]Collins’ algorithm has two phases. The first, projection , applies a projection operator repeatedly to aset of polynomials, each time producing another set in one fewer variables. Together these sets contain the projection polynomials . The second phase, lifting , then builds the CAD incrementally from these polynomials.First R is decomposed into cells which are points and intervals corresponding to the real roots of the univariatepolynomials. Then R is decomposed by repeating the process over each cell using the bivariate polynomialsat a sample point of the cell. The output for each cell consists of sections of polynomials (where a polynomialvanishes) and sectors (the regions between these). Together these form the stack over the cell, and takingthe union of these stacks gives the CAD of R . This process is repeated until a CAD of R n is produced. Theprojection operator must be chosen in order to conclude that the CAD of R n produced using sample pointsin this way is sign-invariant. The output of a CAD algorithm depends on the ordering of the variables. Inthis paper we usually work with polynomials in Z [ x , . . . , x n ] with the variables, x , listed in ascending order;(so we first project with respect to x n and so on until we have univariate polynomials in x ). The mainvariable of a polynomial, mvar( f ), is the greatest variable present with respect to the ordering.Since Collins published the original algorithm there has been much research into improvements with asummary of the developments over the first twenty years given by [10]. A key area of work was in thedefinition of projection operators to use in the first phase. McCallum defined an operator [17, 18] whichusually produces far fewer polynomials than Collins’ and thus an algorithm which uses it produces a CADwith less cells in less time. However, unlike Collins’ operator, McCallum’s cannot be applied universally.McCallum defined the notion of input which is well-oriented [18] to describe when his operator could be used. Qepcad [6] is a dedicated CAD implementation: a command-line program which implements both Mc-Callum’s projection operator and Hong’s modification of Collins’ operator [11]). In 2009 a radically differentapproach was presented [8] where instead of projection and lifting, a cylindrical decomposition of complexspace is first produced which is then refined to a CAD of real space. That algorithm is distributed with
Maple where it is part of the
RegularChains library [16, etc.].
ProjectionCAD package
ProjectionCAD is a
Maple package developed at The University of Bath to implement CAD via projectionand lifting. It was initially developed in order to study the differences between the traditional approach toCAD and the new approach in [8] using regular chains. In [15] we described our implementation of bothMcCallum’s and Collin’s algorithms to produce sign-invariant CADs, and how we made use of commandsfrom the
RegularChains library to give output in the same format as [8].
ProjectionCAD is a theoretical tool, unoptimised, and so does not compete particularly well on timingsfor sign-invariant CADs (see [15, Section 4] for a comparison). However, it is currently the only implementa-tion which can produce order-invariant CADs, (CADs with the stronger property that each polynomial hasconstant order of vanishing on each cell). This feature is essential for the extensions to the package describedin Section 2, which in turn allow this implementation to compete with the others.
ProjectionCAD is also the only implementation of delineating polynomials [18, 7] which modify Collins’original lifting algorithm to allow McCallum’s projection operator to be applied more widely. Without these,the condition of well-orientedness has to be strengthened to thus restricting when the improved projectionoperator may be used.
Qepcad does not make use of delineating polynomials and so there are exampleswhere
ProjectionCAD can produce CADs which
Qepcad cannot (see [15, Section 2]. However,
Qepcad hasimplemented many of the the ideas in [7] in order to minimise the effect of this.2. England An implementation of CAD in Maple utilising McCallum projection
ProjectionCAD V2 In this section we describe the new functionality available in the second release of the
ProjectionCAD package.This adds to the work in the first release (described in [15]) for producing sign and order-invariant CADs. An equational constraint is an equation logically implied by a formula. Their use in CAD is based onthe observation that the formula will be false for any cell in the CAD where the equation is not satisfied.Hence, instead of a CAD sign-invariant with respect to all the polynomials, we could use one that is: (a)sign-invariant with respect to the equational constraint; and (b) sign-invariant with respect to the otherconstraints only in those cells over the sections of the equational constraint. Such a CAD is said to be invariant with respect to an equational constraint . This observation was made in [10] with the firstdetailed approach given by [19] where a new projection operator was presented to implement the idea. The background theory
Let P be the McCallum projection operator. Informally this is applied to a set of polynomials to producethe coefficients, discriminant and cross resultants (full details of the theory are presented in [17, 18] andthe implementation in ProjectionCAD is discussed in [15]). We note that most implementations including
ProjectionCAD make trivial simplifications such as removal of constants, exclusion of polynomials thatare identical to a previous entry (up to constant multiple), and only including those coefficients which arenecessary for the theory to hold. This operator may be used for CAD provided the input polynomials are well oriented . This is defined to mean that every projection polynomial has a finite number of nullificationpoints, i.e. if the main variable is x k then f ( α, x k ) = 0 for at most a finite number of α ∈ R k − .Given a problem with an equational constraint f McCallum suggested a reduced projection operator P f .Informally, this consists of the coefficients and discriminant of f together with the resultant of f taken witheach of the other polynomials. Formally, we must take more care leading to an operator P F where F isa squarefree basis for the primitive part of f (see [19] for the full details of the theory). This improvedprojection operator is used for the first projection, reverting to P for subsequent projections. To use thisnew operator in place of the original McCallum operator the polynomials in the CAD algorithm the inputmust again satisfy the well-orientedness condition The implementation in
ProjectionCAD
Algorithm 1 describes our implementation in
ProjectionCAD which builds a CAD of R n with respect toan equational constraint. While the projection phases follows the work of [19] exactly the lifting phaseis somewhat different, as discussed in detail in Section 3. The algorithm uses the sub-algorithms: CADFull (Algorithm 3 in [15]) to build an order-invariant CAD for the projection polynomials not in the main variable;
LiftingSet (Algorithm 2) to calculate the set of polynomials to use for the final lift; and
CADGenerateStack (Algorithm 4 in [15]) to then lift over cells with respect to these polynomials.It is well documented that CADs invariant with respect to equational constraints usually have fewer cellsthan those which are sign-invariant for all polynomials. Example 1 gives a simple demonstration of this.
Example 1.
Assume the variable ordering y > x . Consider the polynomials f = x + y − , and g = xy − f = 0 ∧ g <
0. We assume the variableordering y > x . The problem could be solved by means of a full sign-invariant CAD for { f, g } which ProjectionCAD would produce using 83 cells. However, it is more efficient to produce a CAD invariant withrespect to the equational constraint f , which using Algorithm 1 in ProjectionCAD , has 53 cells.The induced CADs of the real line have 15 and 13 cells respectively. The difference is that the full CADidentifies the origin on the real line, corresponding to the asymptote of the hyperbola and arising from the3. England An implementation of CAD in Maple utilising McCallum projection
Algorithm 1:
ECCAD
Input : • A polynomial f ∈ R [ x n , . . . , x ]. • A set of polynomials G ⊂ R [ x n , . . . , x ]. Output : Either: • a CAD of R n , sign-invariant with respect to f and, when f = 0, also with respectto G , or; • FAIL if the input is not well-oriented. Set E := { f } . Compute F , the finest squarefree basis for the primitive parts of E. if n = 1 then return The CAD of R formed by the decomposition of the real line according to the real roots ofthe polynomials in F . Set A := G ∪ E . Compute the set C of contents of the elements of A . Compute the set B , the finest squarefree basis for the primitive parts of A . Construct the projection set P := C ∪ P F ( B ). Attempt to construct a lower-dimensional CAD by calculating D := CADFull ( P , proj = McCallum , fcad = true). if CADFull warns about potential failure then return FAIL . for each cell c ∈ D do Set L c := LiftingSet ( c, A, E ). if L c = FAIL then return FAIL . Set S c := CADGenerateStack ( c, L c ). return (cid:83) c S c . Algorithm 2:
LiftingSet
Input : • A cell c from a CAD of R n − . • A set of polynomials A ⊂ R [ x n , . . . , x ]. • A subset of polynomials E ⊂ A . Output : Either: • a set of polynomials L ⊂ R [ x n , . . . , x ] to use for lifting over the cell, or; • FAIL if the input is not well-oriented. Set L := {} . if any polynomial in E is nullified on c then if dim( c ) > then calculate ExclP E ( A ) := P ( A \ E ) \ P E ( A ). if ExclP E ( A ) is empty or contains only constants then L := L ∪ A i . else return FAIL . else L := L ∪ A i . else L := L ∪ E i . 4. England An implementation of CAD in Maple utilising McCallum projectionFigure 1: Plots of the curvesused in Example 1.inclusion of the coefficients of g is the projection polynomials. The CAD using the equational constraintonly considers the behaviour of g on cells where f = 0, (by including the resultant of f and g in the firstprojection but not the coefficients of g individually) and thus the origin is not identified.As we discuss further in Section 3, Algorithm 1 actually offers some subtle improvements to the originalalgorithm described in [19] and implemented in Qepcad . For the example above this manifests in the cellcount of 53 produced by
ProjectionCAD comparing to a cell count of 69 with
Qepcad as described inExample 4.
Given a sequence of formulae, a truth table invariant CAD (TTICAD) is a CAD such that each formulahas constant truth value (true or false) on each cell. The idea of using truth invariance was introduced in[5] for use in simplifying sign-invariant CADs. Of course, a sign-invariant CAD is itself truth-invariant butby focusing on the second property certain cells can be merged to give a smaller CAD. Recently, in [3] analgorithm was presented allowing the efficient construction of TTICADs (without having to first build asign-invariant CAD).
The background theory
The algorithm presented in [3] makes use of the theory of equational constraints. It assumes that each formulain the sequence has a designated equational constraint (for that formula only). Then a new projection operatorwas defined which, informally, included the following polynomials. • For each formula, those obtained by applying McCallum’s projection operator for equational constraints(see [19] and Section 2.1 above). • For each formula, the polynomials obtained by taking the resultant of the designated equational con-straint and each of the other polynomials. • The cross-resultants of the set of designated equational constraints from each formula.This new projection operator is used for the first projection, with the original McCallum projection operatorused for subsequent projections. Constructing the projection set this way ensures that the CAD producedis sign-invariant with respect to equational constraints, and that for cells where an equational constraint iszero, the other polynomials from that formula are sign-invariant.As with the other projection operators, this one is only valid for use when the input sets satisfy a condition.The well-orientedness condition described above applied to the polynomials in the input would be sufficient,but instead, a finer condition is used, discussed further below.5. England An implementation of CAD in Maple utilising McCallum projectionFigure 2: Plots of the curves used in Example 2.The solid circle is f , the solid hyperbola g , thedashed circle f and the dashed hyperbola g . The implementation in
ProjectionCAD
In [3] an algorithm was provided and verified for the approach above. In Algorithm 3 we present the algorithmused in
ProjectionCAD . This extends the algorithm in [3] so that it may be applied to sequences of formulaein which not every formula has a designated equational constraint.First we formally define the projection operator used. Let A = { A i } ti =1 be a list of irreducible bases A i and let E = { E i } ti =1 be a list of non-empty subsets E i ⊆ A i . Put A = (cid:83) ti =1 A i , E = (cid:83) ti =1 E i . (We use theconvention of uppercase Roman letters for sets and calligraphic letters for sequences).Then define the reduced projection of A with respect to E , denoted by P E ( A ), as follows: P E ( A ) := (cid:83) ti =1 P E i ( A i ) ∪ RES × ( E )where P E ( A ) = P ( E ) ∪ { res x n ( f, g ) | f ∈ E, g ∈ A, g / ∈ E } ;RES × ( E ) = { res x n ( f, ˆ f ) | ∃ i, j such that f ∈ E i , ˆ f ∈ E j , i < j, f (cid:54) = ˆ f } . We say that A is well oriented with respect to E if whenever n >
1: every polynomial f ∈ E is nullifiedby at most a finite number of points in R n − , and P E ( A ) is well-oriented in the original sense. Algorithm 3shows how the projection operator may be applied more widely.The definitions above are the same as [3] but their use in Algorithm 3 differs from their use in the algorithmpresented in [3]. This is discussed further in Section 4. Experimental results in [3] show that TTICAD offershuge benefits compared to sign-invariant CADs constructed with the same technology ( ProjectionCAD ). Italso demonstrates that the TTICAD theory allows
ProjectionCAD to compete with the existing state of theart CAD technology.
Example 2.
Assume the variable ordering y > x . Consider the polynomials: f = x + y − g = xy − f = ( x − + ( y − − g = ( x − y − − which are plotted in Figure 2, and the formulaΦ = ( f = 0 ∧ g < ∨ ( f = 0 ∧ g < . Using
ProjectionCAD a full sign-invariant CAD with respect to the polynomials can be constructed using317 cells while a TTICAD can be produced using only 105 cells. The problem could also be tackled usingthe theory of equational constraints alone, (by declaring the implicit equational constraint f f = 0). UsingAlgorithm 1 in ProjectionCAD produces a CAD using 145 cells. There are more cells than the TTICADbecause the projection set will include polynomials relating to the intersection of f with g and f with g which are ignored by the TTICAD. This example was worked through and discussed in detail in [3].6. England An implementation of CAD in Maple utilising McCallum projection Algorithm 3:
TTICAD
Input : A list of quantifier-free formulae Φ = { φ i } ti =1 in variables x , . . . , x n . Each φ i may or maynot have a designated equational constraint f i = 0. Output : Either • D : A TTICAD of R n for Φ; or • FAIL : If Φ is not well oriented for i = 1 . . . t do Extract the set A i of polynomials in φ i . if φ i has a designated equational constraint f i then set E i := { f i } . else set E i := A i . Compute the finest squarefree basis F i for the primitive parts of E i . Set F := ∪ ti =1 F i . if n = 1 then return The CAD of R formed by the decomposition of the real line according to the real roots ofthe polynomials in F . for i = 1 . . . t do Compute the set C i of contents of the elements of A i . Compute the set B i , the finest squarefree basis for the primitive parts of A i . Set C := ∪ ti =1 C i , B := ( B i ) ti =1 and F := ( F i ) ti =1 . Construct the projection set: P := C ∪ P F ( B ). Attempt to construct a lower-dimensional CAD by calculating D := CADFull ( P , proj = McCallum , fcad = true) if CADFull warns about potential failure then return FAIL . for each cell c ∈ D do Set L c := LiftingSet ( c, A i , E i ). if L c = FAIL then return FAIL . Set S c := CADGenerateStack ( c, L c ). return (cid:83) c S c . The algorithms described above and in [15] can have different results for the same problem depending onhow the problem is formulated. For example, which variable ordering is used, which equational constraint isdesignated, how a formula is broken down into sub-formulae for TTICAD.In [4] these issues were studied in detail and heuristics were developed for choosing the formulations.The heuristics were based on two measures of CAD complexity which can be applied to the the projectionpolynomials. The first measure, introduced in [14], is the sum of total degrees of the each monomial in eachpolynomial, abbreviated to sotd . The second introduced in [4] in the number of distinct real roots of theunivariate projection polynomials (the number of sections in the induced CAD of R ), abbreviated to ndrr .Both measures have been implemented in ProjectionCAD , the second by first taking a square free basis of thepolynomials and then using
Maple ’s implementation of Sturm chains. Heuristic algorithms have also beenintroduced to consider possible formulations and pick the best based on the values of these measures. Theuser can specify to use either measure, a combination for successively breaking ties or a weighted average.There is also implementation of the greedy algorithm for choosing variable orderings given in [14], and theability to specify variable blocks and then let the algorithm pick the best ordering which respects these blocks(as required when using CAD for quantifier elimination).7. England An implementation of CAD in Maple utilising McCallum projection
The implementation of CAD with respect to an equational constraint described in Section 2.1 offers somesubtle improvements to the original work of [19] and implementations based on this such as
Qepcad .As discussed, the approach rests on the use of an improved projection operator P f to build a CAD, takingthe place of either the Collins or original McCallum projection operator which construct full sign-invariantCADs. When defined in [19] the author only discussed how this would improve the projection phase of CAD,by creating fewer projection polynomials. The only modification to the lifting phase described was the needto check the well-orientedness condition, as is also the case if using the original McCallum operator.Algorithm 1 makes further changes to the lifting phase, which although subtle can have a significant effecton the CADs produced. We note that these ideas are also used in Algorithm 3 for producing TTICADs. Theorem 2.3 of [19] is the key result that justifies the use of the improved projection operator for equationalconstraints. The theorem allows us to confirm that the cells in the outputted CAD which are over the sectionsof the equational constraint are sign-invariant with respect to the other polynomials. The theorem only holdswhen the equational constraint has a finite number of nullification points, a condition guaranteed by theinput being well-oriented.However, the standard well-orientedness condition is actually stronger than necessary for this situation.It requires that all projection polynomials have a finite number of nullification points, including the non-equational constraints. Algorithm 1 does not check the condition for every projection polynomial. Whenusing
CADFull in step 9 the condition is checked for all projection polynomials not in the main variable, whilein step 2 of Algorithm 2 the condition is checked for the equational constraint. However, the condition isnever checked for the non-equational constraints (in the main variable) as this is not required for the theoryof the projection operator to hold.
Qepcad appears to check for nullification of all projection polynomials,returning errors even if the theory does allow for the outputted CAD to have the requested properties.Although it has detailed checks to avoid unnecessary errors [7] Example 3 demonstrates that these falseerrors may still occur, arising from this situation.
Example 3.
Consider the polynomials f = x + y + z + w, g = zy − x w and the formula f = 0 ∧ g <
0. We could analyse the truth of the formula using a full sign-invariant CAD for { f, g } which both ProjectionCAD and
Qepcad would produce with 557 cells. However, it is far more efficientto make use of the equational constraint. Using Algorithm 1
ProjectionCAD produces a CAD with 165 cells.Declaring the equational constraint in QEPCAD results in a CAD with 221 cells (the higher number due tothe issues discussed in subsection 3.2). However,
Qepcad also returns an error message
Error! Delineating polynomial should be added over cell(2,2)! indicating that the output is not guaranteed to be correct. In fact the output is correct since the the errormessage was triggered by the nullification of g when x = y = 0 which does not invalidate the theory. Thusit is the error message which is incorrect: no delineating polynomial was required. Traditionally in CAD, the projection phase identifies a set of projection polynomials, which are then usedin the lifting phase at sample points to create the stacks. However when constructing CADs with respectto equational constraints we can be more efficient by discarding some of the projection polynomials beforelifting. The non-equational constraints (in the main variable) are part of the set of projection polynomials,required in order to produce subsequent projection polynomials through their resultant with the equationalconstraint. However, these polynomials are not then usually required for the lifting.8. England An implementation of CAD in Maple utilising McCallum projectionIn Algorithm 1 the projection polynomials are formed from the input polynomials (in the main variable)and the set of polynomials P constructed in step 8 which are not in the main variable. The lower dimensionalCAD D constructed in step 9 is guaranteed to be sign-invariant (in fact order invariant) for P . In particular, P contains the resultants of the equational constraint with the other constraints and thus D is alreadydecomposing the domain into cells such that the presence of an intersection of f and g is invariant in eachcell. Hence for the final lift we need only ensure that f is sign-invariant.As demonstrated by Examples 4 and 5, using smaller lifting sets can reduce the number of cells in a CAD. Example 4.
Consider again the circle and hyperbola in Figure 1 and the formula f = 0 ∧ g < ProjectionCAD produces a CAD invariant with respect to the equationalconstraint using 53 cells. This may be compared to
Qepcad which after declaring the equational constraintproduces a CAD with 69 cells.Both implementations give the same induced CAD of the real line but
Qepcad uses more cells for theCAD of R . In particular, ProjectionCAD has a cell where x < − y is free while Qepcad uses threecells, splitting where g changes sign. The splitting is necessary for a sign-invariant CAD but not a CAD withrespect to an equational constraint since f is non-zero for all x < − Qepcad splits the cell unnecessarilysince g is in the set of projection polynomials and thus used in the final lift. Example 5.
Consider again the polynomials and formula from Example 2. Here we explained how theproblem could be tackled using an implicit equational constraint. Using Algorithm 1 in
ProjectionCAD givesa CAD with 145 cells while declaring the equational constraint in
Qepcad results in a CAD with 249 cells.
In Subsection 3.2 above we described how smaller lifting sets are used to reduce cell counts. Actually,Algorithm 2 does sometimes use the original larger lifting sets, (in steps 6 and 10). These exceptions occurwhen an equational constraint is nullified. If this occurs over a zero dimensional cell (stet 6) then we knowthat the sample point is certainly representative of the cell and hence can proceed to make a stack of cellssuch that all the polynomials are sign-invariant trivially.The other exception is implemented in steps 4 to 6 of Algorithm 2. In step 4 we form ExclP E ( A ) := P ( A \ E ) \ P E ( A ) which is the set of projection polynomials that would have been calculated if using theoriginal McCallum projection operator, but which are ignored by the reduced operator. That is, P ( A ) = P E ( A ) ∪ ExclP E (A) . If all the polynomials in ExclP E ( A ) are constant then we can use the theory of the original projection operatorin [18] to conclude that the output of the algorithm will be a valid CAD. However, this requires the liftingset to contain all the projection polynomials.Algorithm 1 uses Algorithm 2 to identify the best lifting set to use in each cell for the final lift. Hencewhen the lifting set is extended in this way it only effects the necessary cells thus minimising the cell countwhile maximising the success of the algorithm. Example 6 demonstrates this. Example 6.
Assume the variable ordering w > z > y > x . Consider the polynomials f = z + yw, g = yx + 1 , h = w ( z + 1) + 1 , and the formula f = 0 ∧ g < ∧ h <
0. Using the
ProjectionCAD package we can build a full sign-invariantCAD for { f, g, h } with 927 cells and a CAD invariant with respect to the equational constraint with 467 cells.The induced CAD of R has 169 cells and on five of these cells the polynomial f is nullified. On these fivecells both y and z are zero, with x being either 0 , E ( A ) = { z + 1 } arising from the coefficient of h . We see that this is a constantvalue of 1 on all five of the cells above. Thus the algorithm is allowed to proceed without error, lifting withrespect to all the projection polynomials on these cells.We note that the lifting set varies from cell to cell in D . For example, the stack over the cell c ∈ D where x = y = z = 0 uses three cells, splitting when w = −
1. This is required for a CAD invariant with respect to9. England An implementation of CAD in Maple utilising McCallum projection f since f = 0 on c but h changes sign when w = −
1. Compare this with, for example, the cell c ∈ D where x = y = 0 and z < −
1. The stack over c has only one cell, with w free. The polynomial h will change signover this cell, but this is not relevant since f will never be zero. This is achieved by including h in the liftingset only for the five cells of D where f was nullified. We note that for this example Qepcad can make useof partial CAD trial evaluation techniques to build a CAD invariant with respect to f using only 203 cells. Algorithm 3 describing the implementation of TTICAD in the
ProjectionCAD package is an extended versionof the algorithm given in [3].It includes all three of the approaches for improved lifting with equational constraints discussed in Section3. The first (checking the finer well-orientedness condition) and third (adapting the lifting set as required)were already used in [3] and follow automatically from the main theorem allowing the use of the reducedprojection of A with respect to E , (Theorem 3 in [3]). The second (analysing the excluded polynomials toreduce the risk of failure from not being well-oriented) was also discussed in [3], although it was not includedin the algorithm there for simplicity. Lemma 7 in [3] validates its use in the TTICAD case.However, the most significant extension is the relaxation of the input to allow formulae which do not haveany equational constraint. Although the extension is reasonably straightforward, it actually dramaticallyincreases both the applicability and benefit of TTICAD . Algorithm 3 allows the user to input a sequence of formulae, each of which may or may not have an equationalconstraint. This is in contrast to the theory in [3] where it was assumed each formula had one. In Algorithm 3formulae without equational constraints are dealt with by treating all their polynomials with the importancereserved for equational constraints, (step 3 to 6).The main theorem of [3] validating the use of the projection operator (Theorem 3) requires no moreadjustment that the redefinition of E i (and thus E and E ) introduced by these steps. Extra polynomialshave been added to the projection set sufficient to allow the conclusion that: (a) the CAD is sign-invariantwith respect to all the equational constraints and all the other constraints belonging to a formulae withno equational constraint, and (b) in cells where an equational constraint vanishes the other constraints itsformulae are sign invariant.However, as with Theorem 3 in [3] this theorem holds when the equational constraints are not nullifiedand thus the well-orientedness condition must be extended to include the redefined E from the algorithm.This is indeed the case in the implementation since when a clause without an equational constraint has E i redefined accordingly in step 4 and this set is passed to Algorithm 2 where it is used in the check at step 2. In this final section we demonstrate how the extension dramatically increases the benefit of the TTICADtheorem. First we note that in [3] experimental results demonstrated the great benefit of TTICAD oversign-invariant CADs through much smaller cell counts. The benefits increase in proportion to the number offormulae, as in Example 7.
Example 7.
We consider a family of examples based on Example 2. Define the f , g , f , g as in thatexample and consider also f = ( x + 4) + ( y + 1) − , g = ( x + 4)( y + 1) − / . Then consider the formulaeΦ = ( f = 0 ∧ g < , Φ = ( f = 0 ∧ g < ∨ ( f = 0 ∧ g < , Φ = ( f = 0 ∧ g < ∨ ( f = 0 ∧ g < ∨ ( f = 0 ∧ g < .
10. England An implementation of CAD in Maple utilising McCallum projectionFor each formula we used
ProjectionCAD to construct a full sign-invariant CAD for the polynomials, a CADinvariant with respect to the implicit equational constraint and a TTICAD, using Algorithm 3 in [15] andAlgorithms 1 and 3 from this report respectively. The sequence of formulae for TTICAD is the obvious one(breaking the formula at the disjunctions). We also used
Qepcad to analyse the formula on both its defaultsettings and by declaring the implicit equational constraint manually. Table 1 shows the cell counts fromthese experiments.
Formula
ProjectionCAD
Qepcad
CADFull ECCAD TTICAD Default Declare Φ
83 69 53 69 83Φ
317 145 105 317 249Φ
695 237 157 695 509Table 1: Table detailing the number of cells in CADs constructed using various algorithms to analyse theformulae in Example 7.As expected, the TTICAD is the superior of these algorithms in terms of cell counts, with its advantageincreasing with the number of disjunctions (separate formulae in the sequence inputted to the algorithm.
Qepcad can also use the theory of equational constraints to avoid building a full sign-invariant CAD (al-though it requires manual input), however, the smaller lifting sets used in
ProjectionCAD (Subsection 3.2)mean that
Qepcad has higher cell counts.The benefit of the extended TTICAD over a sign-invariant CAD will now increase in proportion withthe number of the formulae that have an equational constraint . Hence, for such relaxed input, the benefitover sign-invariant CAD will be slightly less. However, for such input, the theory of equational constraintsalone is not applicable (as there is no overall implicit equational constraint). Thus in these cases TTICADis the only available theory to consider the structure given by the equations, and therefore of much greaterimportance. Example 8 demonstrates this.
Example 8.
Consider again the polynomials from Example 7 and the formulae Φ , Φ , Φ but this timewith f < f = 0. For these formulae TTICADs can be produced with 83, 183 and 283 cellsrespectively. Although a little larger than the cell counts in Table 1, these still represent great savings overthe full sign-invariant CADs. Further, for these modified formulae the ECCAD algorithm and declaring anequational constraint in
Qepcad is not applicable, making the difference between the possible cell counts foreach problem much more dramatic.
We have described the new functionality present in the second release of
ProjectionCAD . This includes analgorithm to produce a CAD invariant with respect to an equational constraint. Similar algorithms are presentin other implementations such as
Qepcad , but these usually just include improvements to the projectionphase, resulting in a smaller projection set and hence a CAD with less cells. In Section 3 we described howthe theory of equational constraints also allows for improvements to the lifting phase which can further reducethe cell counts.The second release also includes an algorithm to produce truth-table invariant CADs, the only suchalgorithm to be implemented. This is based on the theory in [3] but in Section 4 we describe how that theorycan be extended to increase the applicability of the algorithm to situations where its benefit is greatest.Throughout this report we have focussed on cell counts as the measure of the success of the implemen-tation. Of course, the actual time taken to compute the CADs is also important and it is the case that
Qepcad and the other state of the art algorithms (
RegularChains in Maple [8] and Mathematica [21]) areusually quicker to produce sign-invariant CADs. However, as reported in [3] the implementation of TTICADoffers such large reductions in cell counts that it allows
ProjectionCAD to compete on timings as well as cell11. England An implementation of CAD in Maple utilising McCallum projectioncounts. The extension to TTICAD described in this report will further increase the relative performance ofTTICAD since it can now be applied to examples where the theory of equational constraints alone is no use.Finally, we note that the second release of
ProjectionCAD includes implementations of the work in [4]on heuristics for choosing how to formulate problems for the algorithms. The problem formulation can havea dramatic effect on the computation and future work on
ProjectionCAD will include automating the use ofthese heuristics within the main algorithms.
References [1] D. Arnon, G.E. Collins, and S. McCallum. Cylindrical algebraic decomposition I: The basic algorithm.
SIAM J, Comput. ,13:865–877, 1984.[2] R. Bradford and J.H. Davenport. Towards better simplification of elementary functions. In
Proceedings of the 2002international symposium on symbolic and algebraic computation , ISSAC ’02, pages 16–22. ACM, 2002.[3] R. Bradford, J.H. Davenport, M. England, S. McCallum, and D. Wilson. Cylindrical algebraic decompositions for booleancombinations.
In Press: Proc. ISSAC 2013. Preprint at http://opus.bath.ac.uk/33926/ , 2013.[4] R. Bradford, M. England, J.H. Davenport, and D. Wilson. Optimising problem formulations for cylindrical algebraicdecomposition.
In Press: Proc, CICM-Calculemus 2013.
Preprint at http://opus.bath.ac.uk/34373/ , 2013.[5] C.W. Brown. Simplification of truth-invariant cylindrical algebraic decompositions. In
Proceedings of the 1998 internationalsymposium on Symbolic and algebraic computation , ISSAC ’98, pages 295–301. ACM, 1998.[6] C.W. Brown. QEPCAD B: A program for computing with semi-algebraic sets using CADs.
ACM SIGSAM Bulletin ,37(4):97–108, 2003.[7] C.W. Brown. The McCallum projection, lifting, and order-invariance. Technical report, U.S. Naval Academy, ComputerScience Department, 2005.[8] C. Chen, M. Moreno Maza, B. Xia, and L. Yang. Computing cylindrical algebraic decomposition via triangular decom-position. In
Proceedings of the 2009 international symposium on Symbolic and algebraic computation , ISSAC ’09, pages95–102. ACM, 2009.[9] G.E. Collins. Quantifier elimination for real closed fields by cylindrical algebraic decomposition. In
Proceedings of the 2ndGI Conference on Automata Theory and Formal Languages , pages 134–183. Springer-Verlag, 1975.[10] G.E. Collins. Quantifier elimination by cylindrical algebraic decomposition – 20 years of progress. In B. Caviness andJ. Johnson, editors,
Quantifier Elimination and Cylindrical Algebraic Decomposition , Texts & Monographs in SymbolicComputation, pages 8–23. Springer-Verlag, 1998.[11] G.E. Collins and H. Hong. Partial cylindrical algebraic decomposition for quantifier elimination.
J. Symb. Comput. ,12:299–328, 1991.[12] J.H. Davenport. A “Piano-Movers” Problem.
SIGSAM Bull. , 20(1-2):15–17, 1986.[13] J.H. Davenport, R. Bradford, M. England, and D. Wilson. Program verification in the presence of complex numbers,functions with branch cuts etc. In , SYNASC 2012, pages 83–88. IEEE, 2012.[14] A. Dolzmann, A. Seidl, and T. Sturm. Efficient projection orders for CAD. In
Proceedings of the 2004 internationalsymposium on Symbolic and algebraic computation , ISSAC ’04, pages 111–118. ACM, 2004.[15] M. England. An implementation of CAD in Maple utilising McCallum projection. Department of Computer ScienceTechnical Report series 2013-02, University of Bath. Available at http://opus.bath.ac.uk/33180/ , 2013.[16] M. Moreno Maza. On triangular decompositions of algebraic varieties. Technical report, NAG Technical Report, 1999.[17] S. McCallum. An improved projection operation for cylindrical algebraic decomposition of three-dimensional space.
J.Symb. Comput. , 5(1-2):141–161, 1988.[18] S. McCallum. An improved projection operation for cylindrical algebraic decomposition. In B. Caviness and J. Johnson,editors,
Quantifier Elimination and Cylindrical Algebraic Decomposition , Texts & Monographs in Symbolic Computation,pages 242–268. Springer-Verlag, 1998.[19] S. McCallum. On projection in CAD-based quantifier elimination with equational constraint. In
Proceedings of the 1999international symposium on Symbolic and algebraic computation , ISSAC ’99, pages 145–149. ACM, 1999.[20] J.T. Schwartz and M. Sharir. On the “Piano-Movers” Problem: II. General techniques for computing topological propertiesof real algebraic manifolds.
Adv. Appl. Math. , 4:298–351, 1983.[21] A. Strzebo´nski. Computation with semialgebraic sets represented by cylindrical algebraic formulas. In
Proceedings of the2010 International Symposium on Symbolic and Algebraic Computation , ISSAC ’10, pages 61–68. ACM, 2010., ISSAC ’10, pages 61–68. ACM, 2010.