Truth Table Invariant Cylindrical Algebraic Decomposition

When using cylindrical algebraic decomposition (CAD) to solve a problem with respect to a set of polynomials, it is likely not the signs of those polynomials that are of paramount importance but rather the truth values of certain quantifier free formulae involving them. This observation motivates our article and definition of a Truth Table Invariant CAD (TTICAD). In ISSAC 2013 the current authors presented an algorithm that can efficiently and directly construct a TTICAD for a list of formulae in which each has an equational constraint. This was achieved by generalising McCallum's theory of reduced projection operators. In this paper we present an extended version of our theory which can be applied to an arbitrary list of formulae, achieving savings if at least one has an equational constraint. We then explain how the theory of reduced projection operators can allow for further improvements to the lifting phase of CAD algorithms, even in the context of a single equational constraint. The algorithm is implemented fully in Maple and we present both promising results from experimentation and a complexity analysis showing the benefits of our new contributions.


Introduction
A cylindrical algebraic decomposition (CAD) is a decomposition of R n into cells arranged cylindrically (meaning the projections of any pair of cells are either equal or disjoint) each of which is (semi-)algebraic (describable using polynomial relations).CAD is a key tool in real algebraic geometry, both for the original motivation of solving quantifier elimination problems and a range of other applications that have been found since.These include robot motion planning (Schwartz and Sharir, 1983), parametric optimisation (Fotiou et al., 2005), epidemic modelling (Brown et al., 2006), theorem proving (Paulson, 2012) and programming with complex functions (Davenport et al., 2012).
Traditionally CADs are produced sign-invariant to a given set of polynomials, (the signs of the polynomials do not vary on the cells).However, this gives far more information than required for most problems.Usually a more appropriate object is a truth-invariant CAD (the truth of a logical formula does not vary on each cell).
In this paper we generalise to define truth table-invariant CADs (the truth values of a list of quantifier-free formulae do not vary within cells) and give an algorithm to compute these directly.This can be a tool to efficiently produce a truth-invariant CAD for a larger parent formula (built from the input list), or indeed the required object for solving a problem involving the input list.Examples of both such uses are provided following the formal definition in Section 1.2.We continue the introduction with some background on CAD, before defining our object of study and introducing some examples to demonstrate our ideas which we will return to throughout the paper.We then conclude the introduction by clarifying the contributions and plan of this paper.
Given a quantified Tarski formula (where Q i ∈ {∀, ∃} and F is a QFF) the quantifier elimination problem is to produce ψ(x 1 , . . ., x k ), an equivalent QFF to (1).
Collins developed CAD as a tool for quantifier elimination over the reals.He proposed to decompose R n cylindrically such that each cell was sign-invariant for all polynomials f i occurring in F .Then ψ would be the disjunction of the defining formulae of those cells c i in R k such that (1) was true over the whole of c i , which due to sign-invariance is the same as saying that (1) is true at any one sample point of c i .
A complete description of Collins' original algorithm is given in Arnon et al. (1984a).The first phase, projection, applies a projection operator repeatedly 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 which are points and intervals corresponding to the real roots of the univariate polynomials.Then R 2 is decomposed by repeating the process over each cell using the bivariate polynomials at a sample point.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.
To conclude that a CAD produced in this way is sign-invariant we need delineability.A polynomial is delineable in a cell if the portion of its zero set in the cell consists of disjoint sections.A set of polynomials are delineable in a cell if each is delineable and the sections of different polynomials in 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.
The output of this and subsequent CAD algorithms (including the one presented in this paper) depends heavily on the variable ordering.We usually work with polynomials in Z[x 1 , . . ., x n ] with the variables, x, in ascending order (so we first project with respect to x n and continue to reach univariate polynomials in x 1 ).The main variable of a polynomial (mvar) is the greatest variable present with respect to the ordering.
Developments to CAD since Collin's original treatment include the following: • Refinements to the projection operator (Hong, 1990;McCallum, 1988McCallum, , 1998;;Brown, 2003), reducing the number of projection polynomials and hence cells in the CAD.• Algorithms to identify the adjacency of cells in a CAD (Arnon et al., 1984b(Arnon et al., , 1988) ) and following from this the idea of clustering (Arnon, 1988) to minimise the lifting.• Partial CAD, introduced by Collins and Hong (1991), where the structure of F is used to lift less of the decomposition of R k to R n , if it is sufficient to deduce ψ. • The theory of equational constraints, (McCallum, 1999(McCallum, , 2001;;Brown and McCallum, 2005), also aiming to deduce ψ itself, this time using more efficient projections.• The complexity theory of CAD (Brown and Davenport, 2007;Davenport and Heintz, 1988) demonstrating that it is doubly exponential in the number of variables.• The use of certified numerics in the lifting phase to minimise the amount of symbolic computation required (Strzeboński, 2006;Iwane et al., 2009).• CAD via Triangular Decomposition (Chen et al., 2009b) (which is used for Maple's inbuilt CAD command).This algorithm first constructs a decomposition of complex space and then refines to a CAD.A recent improvement (Chen and Maza, 2012), proceeds incrementally (by polynomial) allowing also for the use of equational constraints.

TTICAD
Brown (1998) defined a truth-invariant CAD as one for which a formula had invariant truth value on each cell, constructed by refining sign-invariant CADs whilst maintaining this property.Some of the developments discussed in the previous section such as partial CAD and the use of equational constraints can be viewed as methods to produce truthinvariant CADs directly.We now define a new and related type of CAD, the topic of this paper.Definition 1.Let {φ i } t i=1 be a list of QFFs.We say a cylindrical algebraic decomposition D is a Truth Table Invariant CAD for the list (TTICAD) if the Boolean value of each φ i is constant (either true or false) on each cell of D.
A sign-invariant CAD for the set of polynomials occurring in a list of formulae would clearly be a TTICAD for the list.However, we aim to produce an algorithm that will construct smaller TTICADs for many input lists of formulae.We will achieve this using the theory of equational constraints, first suggested by Collins (1998) with the key theory developed by McCallum (1999).
Definition 2. Suppose some quantified formula is given: where the Q i are quantifiers and φ is quantifier free.An equation f = 0 is an equational constraint of φ * if f = 0 is logically implied by φ (the quantifier-free part of φ * ).Such a constraint may be either explicit (an atom of the formula) or otherwise implicit.
In Sections 2 and 3 we will develop a theory allowing the construction of TTICADs which can use the presence of equational constraints to reduce the number of cells required in comparison to a sign-invariant CAD.There are two reasons to use this theory.
(1) As a tool to build a truth-invariant CAD efficiently: If a parent formula φ * is built from the formulae {φ i } then any TTICAD for {φ i } is also a truth-invariant for φ * .We note that for such a formula a TTICAD may need to contain more cells than a truth-invariant CAD.For example, consider a cell in a truth-invariant CAD for φ * = φ 1 ∨ φ 2 within which φ 1 is always true.If φ 2 changed truth value in such a cell then it would need to be split in order to achieve a TTICAD, but this is unnecessary for a truth-invariant CAD of φ * .
Nevertheless, we find that our TTICAD theory is often able to produce smaller truth-invariant CADs than any other available approach.We demonstrate the savings offered via worked examples introduced in the next subsection.
(2) When given a problem for which truth table invariance is required: That is, a problem for which the list of formulae are not derived from a larger parent formula and thus there is no truth-invariant CAD which would suffice.For example, decomposing complex space according to a set of branch cuts for the purpose of algebraic simplification (Bradford and Davenport, 2002;Phisanbut et al., 2010, etc.).The idea is to represent each branch cut as a semi-algebraic set to give input admissible to CAD, (recent progress on this has been described by England et al. (2013)).Then a TTICAD for the list of formulae these sets define provides the necessary decomposition.Examples 19 and 21 are from this class.

Worked examples
To demonstrate our ideas we will provide details for the following worked examples.Assume we have the variable ordering x ≺ y (meaning 1-dimensional CADs are with respect to x) and consider the following polynomials, graphed in Figure 1.
We first wish to find the regions of R 2 where the following formula is true: Both Qepcad (Brown, 2003) and Maple 16 (Chen et al., 2009b) produce a sign-invariant CAD for the polynomials with 317 cells.At first glance it seems that the theory of equational constraints is not applicable here as neither f 1 = 0 nor f 2 = 0 is logically implied by Φ.However, while there is no explicit equational constraint we can observe that f 1 f 2 = 0 is an implicit constraint of Φ.Using Qepcad with this declared gives a CAD with 249 cells.Later, in Section 2.4 we demonstrate how a TTICAD with 105 cells can be produced.We also consider the related problem of identifying where is true.As above, we could use a sign-invariant CAD with 317 cells.But this time there is no implicit equational constraint and so the previous approach is not applicable.In Section 2.4 we demonstrate how a TTICAD with 183 cells can be produced.

Contributions and plan of the paper
In (Bradford et al., 2013a) the authors of the present paper derived an algorithm to efficiently produce TTICADs for a list of formulae in which each had an explicit equational constraint.In the present paper we have extended that work to apply for a general list of formulae, i.e. it is no longer required that each formula has an equational constraint.The new algorithm is able to take advantage of any equational constraints which are present, and in general will produce smaller CADs than the previous theory so long as at least one is present.This means that a TTICAD can now be produced for Ψ in Section 1.3 as well as Φ.This extension is important since if at least one sub-formula does not have an equational constraint then there can be no overall implicit equational constraint meaning that the previous theory of equational constraints is not applicable and hence the comparative benefit of TTICAD is greatly increased.
In Section 2 we develop the theory of a reduced projection operator for producing TTICADs and in Section 3 we present our new algorithm and a proof of its correctness.These sections are structured similarly to Sections 2 and 3 in (Bradford et al., 2013a) but with the theory extended to consider the wider class of problems.In Section 4 we give details of our Maple implementation of this theory.Next in Section 5 we discuss how the theory of reduced projection operators can also be used to make improvements in the lifting phase, which is also true for the theory of a single equational constraint but had not been noted before.Then in Section 6 we discuss the issues of problem formulation for the TTICAD algorithm and present heuristics to assist with this, work that was previously discussed by Bradford et al. (2013b) which looked at the wider issues of formulating problems for CAD.In Section 7 we present experimental results for this implementation, extending the results in (Bradford et al., 2013a) to include a wider set of problems.Finally in Section 8 we give our conclusions and ideas for future work.

The theory of reduced projection operators
We use two key theorems from McCallum's work on projection and equational constraints.Both theorems use CADs which are not just sign-invariant but have the stronger property of order-invariance.A CAD is order-invariant with respect to a set of polynomials if each polynomial has constant order of vanishing within each cell.
Let P be the projection operator defined by McCallum (1988), which extracts coefficients, discriminant and cross resultants from a set of polynomials.We assume the usual trivial simplifications such as removal of constants, exclusion of entries identical to a previous entry (up to constant multiple), and using only the necessary coefficients.Recall that a set A ⊂ Z[x] is an irreducible basis if the elements of A are of positive degree in the main variable, irreducible and pairwise relatively prime.
The main theorem underlying the use of P follows.
Theorem 3 (McCallum (1998)).Let A be an irreducible basis in Z[x] and let S be a connected submanifold of R n−1 .Suppose each element of P (A) is order-invariant in S.
Then each element of A either vanishes identically on S or is analytic delineable on S, (a slight variant on traditional delineability, see (McCallum, 1998)).Further, the sections of A not identically vanishing are pairwise disjoint, and each element of A not identically vanishing is order-invariant in such sections.
Theorem 3 means that we can use this projection operator in place of that of Collins to produce order-invariant CADs so long as none of the projection polynomials with main variable x k vanishes on a cell of the CAD of R k−1 ; a condition that can be checked when lifting.
The main mathematical result underlying the reduction of P in the presence of an equational constraint f is as follows.
Theorem 4 (McCallum (1999)).Let f (x), g(x) be integral polynomials with positive degree in x n , let r(x 1 , . . ., x n−1 ) be their resultant, and suppose r = 0. Let S be a connected subset of R n−1 such that f is delineable on S and r is order-invariant in S.
Then g is sign-invariant in every section of f over S.
Figure 2 gives a graphical representation of the question answered by Theorem 4.Here we consider polynomials f (x, y, z) and g(x, y, z) of positive degree in z whose resultant r is non-zero, and a connected subset S ⊂ R 2 in which r is order-invariant.We further suppose that f is delineable on S (noting that Theorem 3 with n = 3 and A = {f } provides sufficient conditions for this).We ask whether g is sign-invariant in the sections of f over S. Theorem 4 answers this question affirmatively: the real variety of g either aligns with a given section of f exactly (as for the bottom section of f in Figure 2), or has no intersection with such a section (as for the top).The situation at the middle section of f cannot happen.
Theorem 4 thus suggests a reduction of the projection operator P relative to an equational constraint f = 0 for the first projection step, i.e. for the first step it is sufficient to take only the P (f ) together with the resultants of f with the non-equational constraints.This operator was presented in (McCallum, 1999) along with a generalisation of Theorem 3 (which followed from Theorems 3 and 4) verifying its use.We call CADs produced this way invariant with respect to an equational constraint.

A projection operator for TTICAD
In (McCallum, 1999) the central concept is the reduced projection of a set A of integral polynomials relative to a nonempty subset E ⊆ A (where A is derived from the input polynomials and E from those which are equational constraints).The operator was where P is the original McCallum projection operator given by We will use an extension of this idea to define a projection of a list of sets of polynomials (derived from a list of formulae), some of which may have subsets (derived from equational constraints).For simplicity in (McCallum, 1999) the concept is first defined for the case when A is an irreducible basis and we emulate this approach, generalising for use in other cases by considering contents and irreducible factors of positive degree when describing the algorithm in Section 3. Let A = {A i } t i=1 be a list of irreducible bases A i and let E = {E i } t i=1 be a list of subsets E i ⊆ A i .Put A = t i=1 A i and E = t i=1 E i .Note that we use the convention of uppercase Roman letters for sets of polynomials and calligraphic letters for lists of these.
Definition 5. We define the reduced projection of A with respect to E as where RES × (E) is the cross resultant set For later use, we define the set of the polynomials in P (A) but excluded from P E (A).
Definition 6.We define the excluded projection polynomials of (A i , E i ) by The total set of excluded polynomials from P (A) will not only include all the entries of the ExclP Ei (A i ) but also the missing cross resultants of polynomials in A i \ E i with polynomials from A j = A i .However, this larger set is not used in this paper.
The following is an analogue of Theorem 2.3 of (McCallum, 1999) and provides the foundation for Algorithm 1.
Theorem 7. Let S be a connected submanifold of R n−1 .Suppose each element of P E (A) is order invariant in S. Then each f ∈ E either vanishes identically on S or is analytically delineable on S, the sections over S of the f ∈ E which do not vanish identically are pairwise disjoint, and each element f ∈ E which does not vanish identically is orderinvariant in such sections.
Moreover, for each i, in 1 ≤ i ≤ t every g ∈ A i \ E i is sign-invariant in each section over S of every f ∈ E i which does not vanish identically.
Proof.The crucial observation is that P (E) ⊆ P E (A).To see this, recall equation ( 6) and note that we can write We can therefore apply Theorem 3 to the set E and obtain the first three conclusions immediately.There remains the final conclusion to prove.Let i be in the range 1 ≤ i ≤ t, let g ∈ A i \ E i and let f ∈ E i ; suppose f does not vanish identically on S. Now res xn (f, g) ∈ P E (A), and so is order-invariant in S by hypothesis.Further, we already concluded that f is delineable.Therefore by Theorem 4, g is sign-invariant in each section of f over S. 2 In Section 3 we use Theorem 7 as the key tool for our implementation of TTICAD, so long as no f ∈ E vanishes identically on the lower dimensional manifold, S. A polynomial f in r variables that vanishes identically at a point α ∈ R r−1 is said to be nullified at α.
The theory of this subsection appears identical to the work in (Bradford et al., 2013a).The difference is in the application of the theory to build a TTICAD algorithm (as described in full in Section 3).We suppose that the input is a list of QFFs, {φ i }, with each A i defined from the polynomials in each φ i .In (Bradford et al., 2013a) there was an assumption that each of these formulae had a designated equational constraint f i = 0 from which the subsets E i are defined.This assumption does not apply in this paper.Instead we define E i to be a basis for {f i } if there is such a designated equational constraint and otherwise define E i = A i to ensure information is taken from QFFs which have no equational constraint.That is, to extend our TTICAD algorithm for such cases we needed to treat all the polynomials in QFFs with no equational constraint with the importance otherwise reserved for equational constraints.

Comparison with using a single implicit equational constraint
It is clear that the reduced projection P E (A) will lead to fewer (or the same) projection polynomials than using the full projection P .However, a comparison with the existing theory of equational constraints requires a little analysis.
First, we note that the TTICAD theory is applicable to a sequence of formulae while the equational constraints theory is applicable only to a single formula.Hence if the truth value of each QFF is needed then TTICAD is the only option; a truth-invariant CAD for a parent formula will not necessarily suffice.Second we note that even if the sequence do form a parent formula then it must be this parent formula which has an overall equational constraint logically implied (not just each sub-formulae) to apply (McCallum, 1999) while the TTICAD theory is applicable even if this is not the case.Now we consider the situation where both theories are applicable.Suppose we have a sequence of formulae which belong to a parent formula for which a truth-invariant CAD is desired.Further suppose each of these has an equational constraint and thus the parent formula has an implicit equational constraint, (their product).In the context of Section 1.2 this corresponds to using i f i as the equational constraint.Such a CAD is sufficient to solve the problem so it is natural to ask if the TTICAD theory is required.
The implicit equational constraint approach would correspond to using the reduced projection P E (A) of (McCallum, 1999), with E = ∪ i E i and A = ∪ i A i .We make the simplifying assumption that A is an irreducible basis.In general P E (A) will still contain fewer polynomials than P E (A) since P E (A) contains all resultants res(f, g) where f ∈ E i , g ∈ A j (and g / ∈ E), while P E (A) contains only those with i = j (and g / ∈ E i ).Thus even in situations where the previous theory applies there is advantage in using the new theory.These savings are made clear when considering the worked examples in the next subsection.

Worked Examples
In Section 3 we define an algorithm for producing TTICADs.First we illustrate the savings with our worked examples from Section 1.3, which satisfy the simplifying assumptions made in Section 2.2.
First we consider Φ from equation ( 2).In the notation introduced above we have: We construct the reduced projection sets for each φ i , and the cross-resultant set is then the union of these three sets.In Figure 3 we plot the polynomials (solid curves) and identify the 12 real solutions of P E (A) (solid vertical lines).We can see the solutions align with the asymptotes of the f i 's and the important intersections (those of f 1 with g 1 and f 2 with g 2 ).
If we were to instead use a projection operator based on an implicit equational constraint f 1 f 2 = 0 then in the notation above we would construct This set provides an extra 4 solutions (the dashed vertical lines) which align with the intersections of f 1 with g 2 and f 2 with g 1 .Finally, if we were to consider P (A) then we gain a further 4 solutions (the dotted vertical lines) which align with the intersections of g 1 and g 2 and the asymptotes of the g i 's.In Figure 4 we magnify a region to show explicitly that the point of intersection between f 1 and g 1 is identified by P E (A), while the intersections of g 2 with both f 1 and g 1 are ignored.The 1-dimensional CAD produced using P E (A) has 25 cells compared to 33 when using P E (A) and 41 when using P (A).However, it is important to note that this reduction is amplified after lifting (using Theorem 7 and and Algorithm 1).The 2-dimensional TTI-CAD has 105 cells and the sign-invariant CAD has 317.Using Qepcad to build a CAD invariant with respect to the implicit equational constraint we have 249 cells   Next we consider determining the truth of Ψ from equation (3).This time and so P E1 (A 1 ) is as above but P E2 (A 2 ) contains an extra polynomial x−4 (the coefficient of y in g 2 ).The cross-resultant set RES × (E) also contains an extra polynomial, . These two extra polynomials provide three extra real roots and hence the 1-dimensional CAD produced using P E (A) this time has 31 cells.
In Figure 5 we again graph the four curves this time with solid vertical lines highlighting the real solutions of P E (A).By comparing with Figure 3 we see that more points in the CAD of R 1 have been identified for the TTICAD of Ψ than the TTICAD of Φ (15 instead of 12) but that there is still a saving over the sign-invariant CAD (which had 20, the five extra solutions indicated by dotted lines).The lack of an equational constraint in the second clause has meant that the asymptote of g 2 and its intersections with f 1 have been identified.However, note that the intersections of g 1 with f 2 and g 2 and have not been identified.Figure 6 magnifies a region of Figure 5 to make this clearer (in comparison with Figure 4 the dashed line has become solid, while the dotted line remains unidentified by the TTICAD).
Note that we are unable to use the original theory of equational constraints for this problem as there is no polynomial logically implied (either explicitly or implicitly) by Ψ. Hence there are no dashed lines and the comparison is between the sign-invariant CAD with 317 cells or the TTICAD, which for this example has 183 cells.

Description and Proof
We describe carefully Algorithm 1.This will create a TTICAD of R n for a list of quantifier free formulae , where each φ i has at most one designated equational constraint, (although there may be other nondesignated equational constraints), f i = 0 of positive degree.
It uses a subalgorithm CADW, which was validated by McCallum (1998).The input of CADW is: r, a positive integer and A, a set of r-variate integral polynomials.The output is a boolean w which if true is accompanied by an order-invariant CAD for A (represented as a list of indices I and sample points S).
Let A i be the set of all polynomials occurring in φ i .If φ i has a designated equational constraint then put E i = {f i } and if not put E i = A i .Let A and E be the lists of the A i and E i respectively.Our algorithm effectively defines the reduced projection of A with respect to E in terms of the special case of this definition from the previous section.The definition amounts to the following: where C is the set of contents of all the elements of all the A i , B is the list {B i } t i=1 , such that B i is the finest squarefree basis for the set prim(A i ) of primitive parts of elements of A i which have positive degree, and F is the list {F i } t i=1 , such that F i is the finest squarefree basis for prim(E i ).(The reader will notice that this notation and the definition of P E (A) here is analogous to the work in Section 5 of (McCallum, 1999).) We shall prove that, provided the input satisfies the condition of well-orientedness given in Definition 9, the output of Algorithm 1 is indeed a TTICAD for {φ i }.We first recall the more general notion of well-orientedness from (McCallum, 1998).The boolean output of CADW is false if the input set was not well-oriented in this sense.Definition 8.A set A of n-variate polynomials is said to be well oriented if whenever n > 1, every f ∈ prim(A) is nullified by at most a finite number of points in R n−1 , and (recursively) P (A) is well-oriented.This condition is required for CADW since the validity of this algorithm relies on Theorem 3 which holds only when polynomials do not vanish identically.The conditions allows for a finite number of these nullifications since this indicates a problem on a zero cell, that is a single point.In such cases it is possible to replace the nullified polynomial by a so called delineating polynomial which is not nullified and can be used in place to ensure the delineability of the other.The use of these is part of the verified algorithm CADW (McCallum, 1998) and they are studied in detail in (Brown, 2005).
We now define our new notion of well-orientedness for the lists of sets A and E.
Definition 9. We say that A is well oriented with respect to E if, whenever n > 1, every polynomial f ∈ E is nullified by at most a finite number of points in R n−1 , and P F (B) is well-oriented in the sense of Definition 8.
It is clear than Algorithm 1 terminates.We now prove that it is correct using the theory developed in Section 2.
Theorem 10.The output of Algorithm 1 is as specified.
Proof.We must show that when the input is well-oriented the output is a TTICAD, (each φ i has constant truth value in each cell of D), and FAIL otherwise.
If the input was univariate then it is trivially well-oriented.The algorithm will construct a CAD D of R 1 using the roots of the irreducible factors of the polynomials in E (steps 6 to 7).At each 0-cell all the polynomials in each φ i trivially have constant signs, and hence every φ i has constant truth value.In each 1-cell no equational constraint can change sign and so every φ i has constant truth value f alse, unless there are no equational constraints in any clause.In this second case the algorithm would have constructed a CAD using all the polynomials and hence on each 1-cell no polynomial changes sign and so each clause has constant truth value.
From now on suppose n > 1.If P = C ∪ P F (B) is not well-oriented in the sense of Definition 8 then CADW returns w as false.In this case the input is not well oriented in the sense of Definition 9 and Algorithm 1 correctly returns FAIL in step 17.Otherwise, we have w = true with I and S specifying a CAD, D , which is order-invariant with respect to P (by the correctness of CADW, as proved in (McCallum, 1998)).Let c, a submanifold of R n−1 , be a cell of D and let α be its sample point.
We suppose first that the dimension of c is positive.If any polynomial f ∈ E vanishes identically on c then the input is not well oriented in the sense of Definition 9 and the algorithm correctly returns FAIL at step 24.Otherwise, we know that the input list was certainly well-oriented.Since no polynomial f ∈ E vanishes then no element of the basis Algorithm 1: TTICAD Algorithm Input : A list of quantifier-free formulae {φ i } t i=1 in variables x 1 , . . ., x n .Each φ i has at most one designated equational constraint f i = 0. Output: Either • D : A CAD of R n (described by lists I and S of cell indices and sample points) which is truth table invariant for the list of input formulae; or • FAIL: If A is not well-oriented with respect to E) (Def 9).
If there is no designated equational constraint then set E i := A i and otherwise set E i := {f i }; 3 Compute the finest squarefree basis F i for prim(E i ); Isolate the real roots of the polynomials in F and thus form cell indices and sample points for a CAD of R ; Compute the set B i , the finest squarefree basis for prim(A i ); Construct the projection set P := C ∪ P F (B) ; Attempt to construct a lower-dimensional CAD: w , I , S := CADW(n − 1, P) ; if w = f alse then return FAIL (since P is not well oriented) ; for each cell c ∈ D do L c ← {}; Generate a stack over c using L c : construct cell indices and sample points for the stack over c of the polynomials in L c , adding them to I and S ; return I and S for D; F vanishes identically on c either.Hence, by Theorem 7, applied with A = B and E = F, each element of F is delineable on c, and the sections over c of the elements of F are pairwise disjoint.Thus the sections and sectors over c of the elements of F comprise a stack Σ over c.Furthermore, the last conclusion of Theorem 7 assures us that, for each i, every element of B i \ F i is sign-invariant in each section over c of every element of F i .Let 1 ≤ i ≤ t.We shall show that each φ i has constant truth value in both the sections and sectors of Σ.
If φ i has a designated equational constraint then let f i denote the constraint polynomial; otherwise let f i denote an arbitrary element of A i .
Consider first a section σ of Σ.Now f i is a product of its content cont(f i ) and some elements of the basis F i .But cont(f i ), an element of P, is sign-invariant (indeed orderinvariant) in the whole cylinder c × R and hence, in particular, in σ.Moreover all of the elements of F i are sign-invariant in σ, as was noted previously.Therefore f i is signinvariant in σ.If φ i has no constraint (and so f i denotes an arbitrary element of A i ) then this implies that φ i has constant truth value in σ.So consider from now on the case in which f i = 0 is the designated constraint polynomial of φ i .
If f i is positive or negative in σ then φ i has constant truth value f alse in σ.So suppose that f i = 0 throughout σ.It follows that σ must be a section of some element of the basis F i .Let g ∈ A i \ E i be a non-constraint polynomial in A i .Now, by the definition of B i , we see g can be written as But cont(g), in P, is sign-invariant (indeed order-invariant) in the whole cylinder c × R, and hence in particular in σ.Moreover each h j is sign-invariant in σ, as was noted previously.Hence g is sign-invariant in σ. (Note that in the case where g does not have main variable x n then g = cont(g) and the conclusion still holds).Since g was an arbitrary element of A i \E i , it follows that all polynomials in A i are sign-invariant in σ, hence that φ i has constant truth value in σ.
Next consider a sector σ of the stack Σ, and notice that at least one such sector exists.As observed above, cont(f i ) is sign-invariant in c, and f i does not vanish identically on c. Hence cont(f i ) is non-zero throughout c.Moreover each element of the basis F i is delineable on c. Hence f i is nullified by no point of c.It follows from this that the algorithm does not return FAIL during the lifting phase.It follows also that f i = 0 throughout σ.Hence φ i has constant truth value f alse in σ.
It remains to consider the case in which the dimension of c is 0. In this case the roots of the polynomials in the lifting set L c constructed by the algorithm determine a stack Σ over c.Each φ i trivially has constant truth value in each section (0-cell) of this stack, and the same can routinely be shown for each sector (1-cell) of this stack.2

TTICAD via the ResCAD Set
In Algorithm 1 the lifting stage (steps 18 to 29) varies according to whether any f ∈ E is nullified.When this does not occur there is an alternative implementation of TTICAD which would be simple to introduce into existing CAD algorithms.
Define the ResCAD Set of {φ i } as Theorem 11.Let A = (A i ) t i=1 be a list of irreducible bases A i and let E = (E i ) t i=1 be a list of non-empty subsets E i ⊆ A i .Then we have The proof is straightforward and so omitted here.
Corollary 12.If no f ∈ E is nullified by a point in R n−1 then inputting R({φ i }) into any algorithm which produces a sign-invariant CAD using McCallum's projection operator, will result in the TTICAD for {φ i } produced by Algorithm 1.
Hence Corollary 12 gives us a simple way to compute TTICADs using existing CAD implementations based on McCallum's approach, such as Qepcad.However, this cannot be applied as widely as Algorithm 1.

Our implementation in Maple
There are various implementations of CAD already available including: Mathematica (Strzeboński, 2006(Strzeboński, , 2010)), Qepcad (Brown, 2003), Redlog (part of the Reduce system) (Seidl and Sturm, 2003), RegularChains (Chen et al., 2009b) (in Maple), and SyNRAC (Yanami and Anai, 2006) (third party package for Maple).However, none of these can (currently) be used to build CADs which guarantee order-invariance, a property required for proving the correctness of our TTICAD algorithm.Hence we have constructed our own CAD implementation in order to obtain experimental results for our ideas.

ProjectionCAD
Our implementation is a third party Maple package which we call ProjectionCAD.It gathers together algorithms for producing CADs via projection and lifting to complement the existing CAD commands in Maple which use an alternative approach based on the theory of regular chains and triangular decomposition.
All the projection operators discussed in Section 2 have been implemented and so ProjectionCAD can produce CADs which are sign-invariant, order-invariant, invariant with respect to a declared equational constraint, and truth table invariant.Stack generation (step 29 in Algorithm 1) is achieved by making use of existing commands in Maple from the RegularChains package.The RegularChains command for stack generation is described fully in Section 5.2 of (Chen et al., 2009b).Stack generation in ProjectionCAD uses this, but first processes the input in order to satisfy the assumptions that algorithm has.Namely that the polynomials are co-prime and square-free when evaluated on the cell, (separate above the cell in the language of regular chains).This is achieved using other commands from the RegularChains library.
Utilising the RegularChains code like this means that ProjectionCAD can represent and present CADs in the same way.In particular this allows for easy comparison of CADs from the different implementations, the use of existing commands for studying the CADs and the ability to display CADs to the user in the easy to understand piecewise representation (Chen et al., 2009a).
A simple example of using the code is shown in Figure 7.The output is as displayed in a Maple worksheet, except that the sample points have been replaced by SP for brevity.
Unlike Qepcad, ProjectionCAD has an implementation of delineating polynomials (actually the minimal delineating polynomials discussed by Brown (2005)), which means it can solve certain problems not admissible to Qepcad (see (England, 2013a) for details).It is hence the only implementation that can reproduce the theoretical algorithm CADW.
Other notable features of ProjectionCAD include commands to present the different formulations of problems for the algorithms and heuristics to help choose between these.For more details on ProjectionCAD and the algorithms implemented within see the technical reports (England, 2013a,b).The webpages hosting these also contain the Maple code described which may be downloaded for free along with an introductory worksheet demonstrating the functionality.However, to run the code users will need a version of Maple with the RegularChains CAD implementation (version 16 and up).

Minimising failure of TTICAD
Algorithm 1 was kept simple to aid readability and understanding.Our implementation does make some refinements not presented formally in Algorithm 1.Most of these are trivial, such as removing constants from the set of projection polynomials or when taking coefficients in order of degree, stopping if the ones already included can be shown not to vanish simultaneously.It is known that the well-orientedness conditions can often be overly cautious.In (Brown, 2005), several cases where non-well oriented input can still lead to an order-invariant CAD are discussed.Similarly here, we can sometimes allow the nullification of an equational constraint on a positive dimensional cell.Lemma 13.Let f i be an equational constraint which vanishes identically on a cell c ∈ D constructed during Algorithm 1.If all polynomials in ExclP Ei (A i ) are constant on c then any g ∈ A i \ E i will be delineable over c.
Proof.Suppose first that A i and E i satisfy the simplifying conditions from Section 2.2.Rearranging (7) we see P (A i ) = P Ei (A i ) ∪ ExclP Ei (A i ).However, given the conditions of the lemma, this is equivalent (after the removal of constants which do not affect CAD construction) to P Ei (A i ) on c.So here P (A i ) is a subset of P E (A) and we can conclude by Theorem 3 that all elements of A i vanish identically on c or are delineable over c.
In the more general case we can still draw the same conclusion because Hence Lemma 13 allows us to extend Algorithm 1 to deal safely with such cases.Although we cannot conclude sign-invariance we can conclude delineability and so instead of returning failure we can proceed by extending the lifting set L c to the full set of polynomials in such cases (similar to the case of nullification on a cell of dimension zero dealt with in step 26 of Algorithm 1).In particular, this allows for equational constraints f i which do not have main variable x n .Our implementation makes use of this.
Note that the widening of the lifting step here (and also in the case of the zero dimensional cell) is for the generation of the stack over a single cell.The extension is only performed for the necessary cells thus minimising the cell count while maximising the success of the algorithm, as demonstrated in Example 14.Of course, since a polynomial cannot be nullified everywhere such case distinction will certainly decrease the amount of lifting.
Using the ProjectionCAD package we can build a TTICAD with 467 cells for this formula.The induced CAD of R 3 , D, has 169 cells and on five of these cells the polynomial f is nullified.On these five cells both y and z are zero, with x being either fixed to 0, 4 or belonging to the three intervals splitting at these points.
In this example ExclP E (A) = {z + 1} arising from the coefficient of h.This is a constant value of 1 on all five of those cells.Thus the algorithm is allowed to proceed without error, lifting with respect to all the projection polynomials on these cells.
The lifting set varies from cell to cell in D. For example, the stack over the cell c 1 ∈ D where x = y = z = 0 uses three cells, splitting when w = −1.This is required for a CAD invariant with respect to f since f = 0 on c but h changes sign when w = −1.Compare this with, for example, the cell c 2 ∈ D where x = y = 0 and z < −1.The stack over c 2 has only one cell, with w free.The polynomial h will change sign over this cell, but this is not relevant since f will never be zero.This occurs because h is included in the lifting set only for the five cells of D where f was nullified.
In theory, we could go further and allow this extension to apply when the polynomials in ExclP Ei (A i ) are not necessarily all constant, but have no real roots within the cell c.However, identifying such cases would, in general, require answering a separate quantifier elimination question, which may not be trivial, and so this has not yet been implemented.

Utilising the existing theory for improved lifting
Consider the case when the input to Algorithm 1 is a single QFF {φ} with a declared equational constraint.In this case the reduced projection operator P E (A) produces the same polynomials as the operator P E (A) defined in (McCallum, 1999) and so one may expect the TTICAD produced to be the same as the CAD invariant with respect to an equational constraint produced by an implementation of (McCallum, 1999) such as Qepcad.In practice this is not the case.The main reason is that Algorithm 1 makes use of the equational constraints theory in the lifting stage as well as the projection phase.
McCallum (1999) discussed how the theory of a reduced projection operator would improve the projection phase of CAD, by creating fewer projection polynomials.The only modification to the lifting phase of Collins' CAD algorithm described was the need to check the well-orientedness condition of Definition 8, (as is also the case when using the original McCallum operator for producing sign-invariant CADs).
In this section we note two subtleties in the lifting phase of Algorithm 1 which result in efficiencies that could be replicated for use with the original theory of equational constraints.In fact, the ProjectionCAD package (England, 2013b) discussed in Section 4.1 now has commands for building CADs invariant with respect to a single equational constraint which make use of these efficiencies.

A finer check for well-orientedness
Theorem 2.3 of (McCallum, 1999) justifies the use of P E (A), the original reduced projection operator.The proof uses Theorem 3 to conclude a CAD is sign-invariant for the equational constraint and Theorem 4 to conclude that the other constraints are signinvariant in the cells which are sections of f .The conditions of Theorems 3 mean that this result holds only when the equational constraint and the other projection polynomials found by recursively applying P ) have a finite number of nullification points.Theorem 4 requires that the resultants of the equational constraint with the other constraints have no nullification points which is guaranteed by the input satisfying Definition 8, the condition used in (McCallum, 1999).However, this also requires that all projection polynomials, including the non-equational constraints themselves, have no nullification points and hence is stronger than required.In Algorithm 1, step 22 only checks for nullification of the polynomials in E i (in this case meaning only the equational constraint).Hence this algorithm is checking the necessary conditions but not whether the non-equational constraints (in the main variable) are nullified.
Example 15.Assume the variable ordering x ≺ y ≺ z ≺ w and consider the polynomials and the formula f = 0∧g < 0. We could analyse this using a sign-invariant CAD with 557 cells but it is more efficient to make use of the equational constraint.Our implementation of Algorithm 1 produces a CAD with 165 cells while declaring the equational constraint in QEPCAD results in a CAD with 221 cells (the higher number due to issues discussed in subsection 5.2).Qepcad also returns an error message Error!Delineating polynomial should be added over cell(2,2)!indicating the output may not be correct.The error message was triggered by the nullification of g when x = y = 0 which does not invalidate the theory.It seems Qepcad is checking for nullification of all projection polynomials when equational constraints are declared leading to unnecessary errors.

Smaller lifting sets
Traditionally in CAD algorithms the projection phase identifies a set of projection polynomials, which are then used in the lifting phase to create the stacks.However when making use of equational constraints we can actually be more efficient by discarding some of the projection polynomials before lifting.
The non-equational constraints (in the main variable) are part of the set of projection polynomials, required in order to produce subsequent projection polynomials by taking their resultant with the equational constraint.However, these polynomials are not then (usually) required for the lifting since Theorem 4 can (usually) be used to conclude that they are sign-invariant in the cells produced by lifting the equational constraints.
Note that in Algorithm 1 the projection polynomials are formed from the input polynomials (in the main variable) and the set of polynomials P constructed in step 14 which are not in the main variable.The lower dimensional CAD D constructed in step 15 is guaranteed to be sign-invariant for P. In particular, P contains the resultants of the equational constraint with the other constraints and thus D is already decomposing the domain into cells such that the presence of an intersection of f and g is invariant in each cell.Hence for the final lift we need to build stacks with respect to f .
The following two examples (and Example 19 later) demonstrate these efficiencies.
Example 16.Consider from Section 1.3 the circle f 1 , hyperbola g 1 and sub-formula Building a sign-invariant CAD for these polynomials uses 83 cells with the induced CAD of R identifying 7 points.Declaring the equational constraint in QEPCAD results in a CAD with 69 cells while using our implementation of Algorithm 1 produces a CAD with 53 cells.Both implementations give the same induced CAD of R identifying 6 points but Qepcad uses more cells for the CAD of R 2 .In particular, ProjectionCAD has a cell where x < −2 and y is free while Qepcad uses three cells, splitting where g 1 changes sign.The splitting is not necessary for a CAD invariant with respect to an equational constraint since f 1 is non-zero for all x < −2.
Example 17.Now consider all four polynomials from Section 1.3 and the formula Φ from equation (2).In Section 2.4 we reported that a TTICAD could be built with 105 cells compared to a CAD with 249 cells built invariant with respect to the implicit equational constraint f 1 f 2 = 0 using Qepcad.The improved projection resulted in the induced CAD of R identifying 12 points rather than 16.We now observe that some of the cell savings was actually down to using smaller sets of lifting polynomials.We may simulate the projection with respect to the implicit equational constraint via Algorithm 1 by inputting a set consisting of the single formula Φ = f 1 f 2 = 0 ∧ Φ (note that logically Φ = Φ ).The implementation in ProjectionCAD would then produce a CAD with 145 cells.So we may conclude that improved lifting allowed for a saving of 104 cells and improved projection a further saving of 40 cells.
In this example 72% of the cell saving came from improved lifting and only 28% from improved projection but we should not conclude from this that the former is more important.The improved lifting is applicable for the final lift (from a CAD of R n−1 to one of R n ) while the improved projection applies to the first projection (from polynomials in n variables to those with n − 1).Hence the saving from improved projection get magnified throughout the rest of the algorithm and so as the number of variables in a problem increases we should expect to see its importance increase.
Example 18.We consider a simple 3d generalisation of the previous example.Let 4 < 0 and assume variable ordering x ≺ y ≺ z.Using Algorithm 1 on the two QFFs joined by disjunction gives a CAD with 109 cells while declaring the implicit equational constraint in Qepcad gives 739 cells.Using Algorithm 1 on the single formula conjuncted with the implicit equational constraint gave a CAD with 353 cells.So in this case the improved lifting saves 386 cells and the improved projection a further 244 cells.
Hence moving to going from 2 to 3 variables has increased the proportion of the saving from improved projection from 28% to 39%.Further, we note that the new projection theory allows for CADs to be produced for examples where no implicit equational constraint exists meaning the benefit of Algorithm 1 is greatly enhanced (see Section 7.3).

Formulating a Problem for TTICAD
Algorithm 1 will produce a TTICAD for a given list of QFFs.However, before using the algorithm various choices may be required which can have significant effects on the output of the algorithm.We examine some of these possibilities here, noting that much of this analysis was first discussed in (Bradford et al., 2013b).

Variable ordering
Note that Algorithm 1 is implicitly assuming that the variables used are subject to an ordering.As with all CAD algorithms, the variable ordering will have a large effect on the output, or even whether obtaining output is computationally feasible.Brown and Davenport (2007) proved there are problems where one variable ordering will lead to a CAD with a constant number of cells while another will give a number of cells doubly exponential in the number of variables.The ordering (or some parts of it) may be determined by the origin of the problem.For example, when using a CAD for quantifier elimination the quantified variables must be eliminated first.However, in many cases we may be free to specify the ordering.Dolzmann et al. (2004) considered the problem of choosing a variable ordering for producing a sign-invariant CAD.They identified a measure of CAD complexity that was correlated to the computation time, number of cells in the CAD and number of leaves in a partial CAD.They identified the sum of total degrees of all monomials of all projection polynomials, known as sotd and proposed the heuristic of picking the ordering with the lowest sotd.Although the best known heuristic, sotd does not always pick the ideal ordering as demonstrated by experiments in (Dolzmann et al., 2004;Bradford et al., 2013b) and Example 19.
In (Bradford et al., 2013b) we investigated the shortcoming of sotd, namely that it measures properties of the problem in the algebraic closure and thus misses some features specific to the real geometry.We suggested a new measure, the number of distinct real roots of the univariate projection factors, or ndrr which could compensate for this shortcoming.Unfortunately, ndrr has its own shortcomings, such as not admitting a greedy algorithm for picking variables one at a time.Hence we recommended using the measures in tandem for choosing variable orderings.
It was noted by Phisanbut (2011) that a class of problems particularly unsuitable for sotd is choosing between coupled variables (the real and imaginary parts of a complex variable).These are used when constructing a CAD to decompose the domain according to their branch cuts, one of the main applications of the TTICAD theory.We use examples from this class in this section.
Example 19.Consider f = √ z 2 + 1 where z ∈ C. The square root function has a branch cut along the negative real axis and so f has branch cuts when R = (z 2 + 1) = x 2 − y 2 + 1 < 0 and I = (z 2 + 1) = 2xy = 0, where x, y are coupled real variables such that z = x + iy.Suppose we use Algorithm 1 to build a TTICAD.For either variable ordering the discriminant of the equational constraint is a constant and its coefficients monomials of degree one.We have res y (R, I) = 4x 2 (x 2 + 1), res x (R, I) = 4(1 − y 2 )y 2 , which have the same sotd but different ndrr (as the latter has two real roots and the former none).A TTICAD using x ≺ y has 13 cells and one with y ≺ x has 21 cells.
The first two plots in Figure 6.1 are visualisations of the two TTICADs just described.Here the solid curve is the equational constraint I and the dashed curve the polynomial R. The dotted lines indicate the stacks above the isolated roots on the real line.Each circle indicates a cell with the number next to it the dimension.The final plot in Figure 6.1 is the imaginary part of f = √ z 2 + 1 which demonstrates that f has branch cuts on the imaginary axis above 1 and below −1.Remark 20.In Example 19 the TTICAD theory has allowed us to ignore the hyperbola except for when it intersects the y-axis: all that is needed for defining the branch cuts.
Although the theory of equational constraints would have allowed this, we require the improved lifting described in Section 5 to take advantage of it.In the next example the branch cuts require more than one QFF to describe them and so the theory of equational constraints could only be used with the product of all equational constraints from each QFF declared implicitly.In this case there are savings from the improved projection theory of TTICAD as well, as we described in Section 2.3.This is a generalisation of the following observation: given a formula φ with two equational constraints a CAD could be constructed using either the traditional theory of equational constraints or the TTICAD algorithm applied to two QFFs.On the surface it is not clear why the latter option would ever be chosen since it would certainly lead to more projection polynomials after the first projection.However, a specific equational constraint may have a comparatively large number of intersections with another constraint, in which case, while separating these into different QFFs would likely increase the number of projection polynomials it may still reduce the number of cells in the CAD (since the resultants taken would be less complicated leading to fewer projection factors at subsequent steps).
An example of a problem which could be tackled using the theory of equational constraints alone, but for which it is beneficial to split into two QFFs and tackle with TTICAD is the following.
Example 22. Assume x ≺ y and consider again Φ := f 1 = 0 ∧ g 1 > 0 ∧ f 2 = 0 ∧ g 2 < 0 but this time with polynomials below.These are plotted in Figure 10 where the solid curve is f 1 , the solid line g 1 , the dashed curve f 2 and the dashed line g 2 .
g 2 := −y − x 4 + 1 2 , First, if we use the theory of equational constraints (with either f 1 or f 2 designated) then a CAD is constructed which identifies all the intersections except for g 1 with g 2 This is visualised by the plot on the left while the plot on the right relates to a TTICAD with two QFFs.In this case only three 0-cells are identified, with the intersections of g 2 with f 1 and g 1 with f 2 ignored.The TTICAD has 31 cells while the CADs produced using equational constraints both have 39 cells.Both sotd and ndrr identify the smaller CAD.As suggested by the example we suggest using the measures sotd and ndrr applied to the set of projection polynomials as heuristics for picking an approach.
We may also consider whether to combine any QFFs if only a single truth-invariant formula is required.If the QFFs are related by conjunction then it would probably be beneficial.Formulae joined by disjunction could be combined only if they share an equational constraint, (so the new QFF has an overall one).Upon inspection of the projection operators, we see such a merger would not change the set of projection polynomials.
When considering the logical formulation the number of possibilities increases quickly.Hence we propose a method for TTICAD QFF formulation, making the choices one QFF at a time.Given a list { φi } of QFFs: (1) Take the disjunction of the QFFs and put that formula into disjunctive normal form, φi so that each φi is a conjunction of atomic formulae.
(2) Consider each φi in turn and let m i be the number of equational constraints.
• If m i = 0 then no designation is possible (and E i will be the full set A i ).
• If m i = 1 then the sole equational constraint is designated trivially.
• If m i > 1 then we consider all the possible partitions of the formula in φi into sub QFFs with at least one equational constraint each, and all the different designations of equational constraint within those sub-QFFs with more than one.Choose a partition and designation for this clause according to the heuristics based on sotd and ndrr applied to the projections polynomials from the clause.(3) Input the list of new QFFs, {φ i } to TTICAD.

Preconditioning input QFFs
Another option available before using Algorithm 1 is to precondition the input.Buchberger and Hong (1991) conducted experiments to see if Gröbner basis techniques could precondition problems effectively for CAD.They considered replacing any input polynomials which came from equations by a purely lexicographical Gröbner basis for them.In (Wilson et al., 2012b) this idea was considered in greater depth with a larger base of problems tested and the idea extended to include Gröbner reduction on the other polynomials.The preconditioning was shown to be highly beneficial in some cases but not others, but a simple metric was posited and shown to be a good indicator of when preconditioning was useful In (Bradford et al., 2013b) using Gröbner preconditioning for TTICAD was investigated by performing the Gröbner preconditioning on the individual QFFs.The problem must be suitably complicated for this preconditioning to work: each QFF must have multiple equational constraints amenable to the creation of a Gröbner Basis.
It was demonstrated that for such examples the preconditioning could produce significant reductions.However, again the benefit was not always universal with the measures sotd and ndrr applied to the projection polynomials again providing good heuristics.

Summary
In this section we have highlighted some of the choices a user may need to make before using Algorithm 1 (there may be others).The heuristics suggested are all implemented in the ProjectionCAD package discussed in Section 4. For the experimental results in Section 7 we use the required variable ordering for a problem if it has one and otherwise test all possible orderings.If there are questions of logical formulation or equational constraint designation we use the heuristics discussed here.No Gröbner precondition was used as the aim is to analyse the TTICAD theory itself.
It is important to note that our heuristics are just that, and as such can be misled by certain examples.Also, while we have considered these issues individually they of course intersect.For example, the TTICAD formulation with two QFFs was the best choice in Example 22 but if we had assumed the other variable ordering then a single QFF is superior.Taken together, all these choices of formulation can become combinatorially overwhelming and so methods to reduce this, such as the greedy algorithm in (Dolzmann et al., 2004) or the method at the end of Section 6.2 are important.

Description of experiments
Our timings were obtained on a Linux desktop (3.1GHzIntel processor, 8.0Gb total memory) with Maple 16 (command line interface), Mathematica 9 (graphical interface) and Qepcad-B 1.69.For each experiment we produce a CAD and give the time taken and number of cells (cell count).The first is an obvious metric while the second is crucial for applications performing operations on each cell.
For Qepcad the options +N500000000 and +L200000 were provided, the initialization included in the timings and explicit equational constraints declared when present with the product of those from the individual QFFs declared otherwise.In Mathematica the output is not a CAD but a formula constructed from one (Strzeboński, 2010), with the actual CAD not available to the user.Cell counts for the algorithms were provided by the author of the Mathematica code.
TTICADs are calculated using our ProjectionCAD implementation described in Section 4. The results in this section are not presented to claim that our implementation is state of the art, but to demonstrate the power of the TTICAD theory over the the conventional theory, and how it can allow even a simple implementation to compete.Hence the cell counts are of most interest.
The time is measured to the nearest tenth of a second, with a time out (T/O) set at 5000 seconds.When F occurs it indicates failure due to a theoretical reason such as not well-oriented (in either sense).The occurrence of Err indicates an error in an internal subroutine of Maple's RegularChains package, used by ProjectionCAD.This error is not theoretical but a bug, which should be fixed in the future and is beyond our control.
We started by considering examples originating from (Buchberger and Hong, 1991).However these problems (and most others in the literature) involve conjunctions of conditions, chosen as such to make them amenable to existing technologies.These problems can be tackled using TTICAD, but they do not demonstrate its full strength.Hence we introduce some new examples.The first set, those denoted with a †, are adapted from (Buchberger and Hong, 1991) by turning certain conjunctions into disjunctions.The second set were generated randomly as examples with two QFFs, only one of which has an equational constraint (using random polynomials in 3 variables of degree at most 2).
Two further examples came from the application of branch cut analysis for simplification.We included Example 21 along with the problem induced by considering the validity of the double angle formulae for arcsin.Finally we considered the worked examples from Section 1.3 and the generalisation to three dimensions presented in Example 18.Note that A and B following the problem name indicate different variable orderings.Full details for all examples can be found in the CAD repository (Wilson et al., 2012a) available freely online at http://opus.bath.ac.uk/29503.

Results
We present our results in Table 1.For each problem we give the name used in the repository, n the number of variables, d the maximum degree of polynomials involved and t the number of QFFs used for TTICAD.We then give the time taken and number of cells produced by each algorithm.
We first compare our TTICAD implementation with the sign-invariant CAD generated using ProjectionCAD with McCallum's projection operator.Since these use the same architecture the comparison makes clear the benefits of the TTICAD theory.The experiments confirm the fact that, since each cell of a TTICAD is a superset of cells from a sign-invariant CAD, the cell count for TTICAD will always be less than or equal to that of a sign-invariant CAD produced using the same implementation.Ellipse † A is not well-oriented in the sense of (McCallum, 1998), and so both methods return FAIL.Solotareff † A and B are well-oriented in this sense but not in the stronger sense of Definition 9 and hence TTICAD fails while the sign-invariant CADs can be produced.The only example with equal cell counts is Collision † A in which the non-equational constraints were so simple that the projection polynomials were unchanged.Examining the results for the worked examples and the 3d generalisation we start to see the true power of TTICAD.In 3D Example A we see a 759-fold reduction in time and a 50-fold reduction in cell count.
We next compare our implementation of TTICAD with the state of the art in CAD: Qepcad (Brown, 2003), Maple (Chen et al., 2009b) and Mathematica (Strzeboński, 2006(Strzeboński, , 2010)).Mathematica is the quickest, however TTICAD often produces fewer cells.We note that Mathematica's algorithm uses powerful heuristics and so actually used Gröbner bases on the first two problems, causing the cell counts to be so low.When all implementations succeed TTICAD usually produces far fewer cells than Qepcad or Maple, especially impressive given Qepcad is producing partial CADs for the quantified problems, while TTICAD is only working with the polynomials involved.For Collision † A the TTICAD theory offers no benefit allowing the better optimized alternatives to have a lower cell count.
Reasons for the TTICAD implementation struggling to compete on speed in general are that the Mathematica and Qepcad algorithms are largely implemented directly in C, have had more optimization, and in the case of Mathematica use validated numerics for lifting (Strzeboński, 2006).However, the strong performance in cell counts is very encouraging, both due its importance for applications where CAD is part of a wider algorithm (such as branch cut analysis) and for the potential if TTICAD theory were implemented elsewhere.

The increased benefit of TTICAD
We finish by demonstrating that the benefit of TTICAD over the existing theory should increase with the number of QFFs and that this benefit is much more pronounced if at least one of these does not have an equational constraint.
Example 23.We consider a family of examples (to which our worked examples belong).Assume x ≺ y and for j a non-negative integer define f j+1 := (x − 4j) 2 + (y − j) 2 − 1, Then Φ 2 is Φ from equation (2) and Ψ 2 is Ψ from equation (3).Table 2 shows the cell counts for various CADs produced for studying the truth of the formulae.Both Φ i and Ψ i may be studied by a sign-invariant CAD for the polynomials F i , shown in the column marked CADFull.The remaining CADs are specific to one formula.Each formula has had a TTICAD constructed using Algorithm 1 on the natural sub-formulae created by the disjunctions, while the Φ i have also had a CAD constructed using the theory of equational constraints alone.This was simulated by running Algorithm 1 on the single formula declaring the product of the f i s as an equational constraint (column marked ECCAD).All the proceeding CADs were constructed with ProjectionCAD.For each formula a CAD has also been created with Qepcad, with the product of f i declared as an equational constraint for Φ i .We see that the size of a sign-invariant CAD is growing much faster than the size of a TTICAD, regardless of whether or not all QFFs have an equational constraint.If they do (the case of the Φ i ) then we see that by declaring the implicit equational constraint the existing theory can also make big savings.However, this is dependent on making use of the improved lifting discussed in Section 5 as can be concluded by comparing the ECCAD figures with the Qepcad figures.In the case where at least one QFF does not have an equational constraint (the case of the Ψ i ) the existing theory of equational constraints cannot be used.So while the comparative benefit over sign-invariant CAD is slightly less, the benefit when comparing with the best available previous theory is much greater.

Conclusions
We have defined Truth Table Invariant CADs and by extending the theory of equational constraints have provided an algorithm to construct these efficiently, extending our previous work so that the algorithm may be applied to a general sequence of formulae.The algorithm has been implemented in Maple giving promising experimental results.TTICADs in general have much fewer cells than sign-invariant CADs using the same implementation and we showed that this allows even a simple implementation of TTI-CAD to compete with the state of the art CAD implementations.For many problems the TTICAD theory offers the smallest truth-invariant CAD for a parent formula, and there are also classes of problems for which TTICAD is exactly the desired structure.The benefits of TTICAD increase with the number of QFFs in a problem and is magnified if there is a QFF with no equational constraint (as the previous theory is not applicable here).We hope that these results inspire other implementations of TTICAD.

Future Work
There is scope for optimizing the algorithm and extending it to allow less restrictive input.Lemma 13 gives one extension that is included in our implementation while other possibilities include removing some of the caution implied by well-orientedness, analogous to (Brown, 2005).
Of course, the implementation of TTICAD used here could be optimised in many ways, but perhaps more desirable would be for TTICAD to be incorporated into existing state of the art CAD implementations.In particular, work is now ongoing on building a TTICAD with the RegularChains technology in Maple, already used to build signinvariant CADs as described in (Chen et al., 2009b).We see several possibilities for the theoretical development of TTICAD: • Can we apply the theory recursively instead of only at the top level?For example by widening the projection operator to allow enough information to conclude orderinvariance, as in (McCallum, 2001).• Can we define an algorithm to make use of more than one one equational constraint per QFF in order to gain reductions beyond the first projection?For example, can we generalise the theory of bi-equational constraints?• Can we make use of the ideas behind partial CAD to avoid unnecessary lifting once the truth value of a QFF on a cell is determined?• Can we implement the lifting algorithm in parallel?
• Can we modify the lifting algorithm to only return those cells required for the application (as indicated by preliminary investigations in (Wilson and England, 2013))?• Can anything be done when the input is not well oriented?

Fig. 1 .
Fig. 1.The polynomials from Section 1.3.The solid lines are f1 and g1 while the dashed lines are f2 and g2.

7
return I and S for D ; 8 else9 for i = 1 . . .t do Extract the set A i of polynomials in φ i ;Compute the set C i of contents of the elements of A i ;

Fig. 7 .
Fig. 7. Using ProjectionCAD in Maple to build a sign-invariant CAD for the unit circle.

Fig. 10 .
Fig. 10.Plots visualising the CADs described for the example in Section 6.

Table 2 .
Table detailing the number of cells in CADs constructed to analyse the truth of the formulae from Example 23.