A case study of the difficulty of quantifier elimination in constraint databases: the alibi query in moving object databases
In the constraint database model, spatial and spatio-temporal data are stored by boolean combinations of polynomial equalities and inequalities over the real numbers. The relational calculus augmented with polynomial constraints is the standard first…
Authors: Bart Kuijpers, Walied Othman, Rafael Grimson
A case study of the difficult y of quan tifier elimination in constrain t databases: the alibi query in mo ving ob ject databases . W alied Othman 1 Ba rt Kuijp ers 2 Rafael Grimson 3 Theoretical Computer Science Hasselt University & T ransnational University of Limburg, Belgium In t he constrain t database model, s patial and spatio-temporal data are stored b y b oolean combi- nations of p olynomial equalities and inequalities ov er the real num b ers. The relational calculus augmen ted with polynomial constrain ts is the standard first-or der query language for constraint databases. Although the expressive p o wer of this query language has been s tudied extensiv el y , the difficult y of the efficien t ev aluation of queries, usually inv olving some form of quantifie r elimi- nation, has receive d considerably less atten tion. The inefficiency of existing quan tifier-eli mination softw are and the int rinsic difficulty of quan tifier elimi nation hav e prov en to be a b ottle-nec k for for real-world implementation s of constrain t database systems. In this pap er, we fo cus on a particular query , called the alibi query , that was prop osed i n the con text of mo ving ob ject databases and that asks whether tw o moving ob jects whose p ositions are kno wn at certain moments in time, could hav e possi bly met, given certain sp eed constraints. Thi s query can b e seen as a constraint database query and its ev aluation relies on the elimi nation of a block of three existen tial quan tifiers. Implementa tions of general purp ose elim ination al gorithms, suc h as pr o vided b y QEPCAD, Redlog and Mathematica, ar e in the sp ecific case, for practical purposes, too slow in answering the alibi query and fail completely in the parametric case. The main cont ribution of this pap er is an analytical s olution to the parametric alibi query , which can be used to answer this query in the specific case in constan t time. W e also give an analytic solution to the alibi query at a fixed moment in time, which asks whether tw o moving ob jects that are known at discrete moments in time could hav e m et at a given moment in time, give n some sp eed constraints. The solutions we pr opose are based on geometric argumentation and they i llustrate the fact that some practical problems require creative solutions, where at l east in theory , existing s ystems could provide a solution. Categories and Sub ject Descriptors: H.2.3 [ Database Ma nagemen t ]: Langua ges— Query lan- guages ; H .2.8 [ Database Management ]: Database Appli cations— Sp atial datab ases and GIS ; F.4.0 [ Mathemati cal Logic and F ormal Languages ]: General General T erms: Theory , M athemat ical Logic, Query Languages, Spatial databases Additional Key W ords and Phrases: Constraint databases, moving ob j ects, beads, alibi query 1. INTRODUCTION AND SUMMARY The framework o f c onst r aint datab ases w as in tro duced in 1990 by K anellakis, Ku- per and Revesz [K anellakis et al. 199 5] as an extension o f the relationa l databas e mo del that allows the use of infinite, but fir st-order definable relatio ns ra ther than just finite rela tions. It provides a n elegant and p ow erful mo del for applications that 1 wa lied.othman@uhasselt.be 2 bart.kuijp ers@uhasselt.be 3 rafael.grimson@uhasselt.b e ACM Journal Name, V ol. V, No. N, 20YY, Pag es 1–0 ?? . 2 · deal with infinite sets of p oin ts in some real affine space R n , such as spatial a nd spatio-temp oral databas es [Paredaens et al. 1 994]. In the setting o f the constraint mo del, infinite relations in spatial or spatio-temp oral databases are finitely repre- sented as bo olea n co m bina tio ns of p olynomial equalities and inequalities, which are int erpreted ov er the real num b ers. V arious asp ects of the co nstraint databa se mo del ar e well-studied b y now. F or an o verview o f re search results w e refer to [Paredaens et al. 2000] and the text- bo ok [Revesz 2002]. The rela tional calculus augmen ted with p olynomial constra ints, or equiv alently , first-or der logic over the reals augmented with r elation predic a tes to address the database re lations R 1 , . . . , R m , FO (+ , × , <, 0 , 1 , R 1 , . . . , R m ) for short, is the standard first-or der query languag e for cons traint da tabases. The expressive power of first-o r der logic ov er the reals , as a constr ain t database query langua ge, has bee n studied extensively [Paredaens et al. 2 000]. It is well-known that first-or der constraint querie s can b e effectively ev a luated [T arski 1951 ; Paredaens et a l. 2000]. How ever, the difficulty of the efficient ev aluation of first-or der quer ies, usually in- volving some for m of quantifier elimination, ha s b een large ly neglected [Heintz and Kuijpe r s 20 04]. The existing constraint database sy stems or prototypes, such as Dedale and Disco [Pareda e ns et al. 200 0, Chapters 17 a nd 1 8] a r e base d o n g en- eral purp ose quantifier-elimination a lg orithms and ar e, in most cases, r estricted to work with linear da ta, i.e., they use firs t- order logic ov er the reals without mul- tiplication [P ar edaens et al. 2 000, P a rt IV]. Of the general pur p ose elimination algorithms [Basu et al. 1 9 96; Co llins 197 5; Grigo r’ev and V orob jo v 198 8 ; Heintz et al. 19 90; Reneg a r 19 92], so me are now av aila ble in s oft ware pack ag es such as QEPCAD [Ho ng 1990], Redlog [Stur m 2000] and Mathematica [W o lfram 2 007]. But the in trinsic inefficiency of q uan tifier elimination a nd the inefficiency o f its current implementations represent a b ottle-neck for rea l-w orld implementations of constraint database systems [Heintz and Kuijp ers 200 4]. In this pap er, we fo cus on a case study o f quantifier eliminatio n in c onstraint databases. Our example is the alibi query in moving ob ject databas es, which was int ro duced and studied in the area of geog raphic information systems (GIS) [Pfos er and Jensen 1999; E g enhofer 20 03; Hornsby a nd Eg enhofer 200 2; Miller 2 005]. This query can b e expresse d in the constraint da tabase for malism and, at least in the- ory co uld be answered, b oth in the sp ecific and the par ametric case, by exis ting implemen tations o f qua n tifier elimination over the r eals. The ev a luation of the al- ibi quer y a dds up to the elimination o f a blo ck o f three existential quantifiers. It turns out that pack ag es such a s Q EPCAD [Hong 1990], Redlog [Sturm 2000 ] and Mathematica [W olfra m 200 7], can only so lv e the alibi query in specific cases, with a r unning time tha t is not acceptable for moving ob ject database users. In the parametric cas e, these quantifier-elimination implementations fail mis erably . The main contribution of this pap er is a theo r etic a nd practical solution to the alibi query in the parametr ic case (and thus the sp ecific cases). The resear c h o n spatia l databas es, which s tarted in the 1 980s from work in geo- graphic infor mation systems, was extended in the seco nd ha lf of the 1990s to de a l with spatio- tempor a l data. In this field, one pa rticular line of r esearch, s tarted by W olfson, concentrates on m oving obje ct datab ases (MODs) [G¨ uting and Schneider 2005; W o lfson 2002 ], a field in which s ev eral data mo dels a nd query lang ua ges have AC M Journal Name , V ol. V, No. N, 20YY. · 3 bee n prop osed to deal with moving ob jects whose po sition is recor ded at discr ete moments in time. Some o f these mo dels ar e g eared towards handling uncer tain t y that may come from v arious sour ces (measurements of lo catio ns, int erp olation, ...) and several query fo r malisms have b een prop osed [Su et al. 2 001; Geerts 20 04; Kui- jper s and O thman 200 7]. F or a n ov erview o f mo dels a nd techniques fo r MODs, we refer to the b o ok by G ¨ uting and Schneider [G ¨ utin g and Schneider 20 05]. In this pap er, we fo cus on the tra jectories that are pr oduced b y moving ob jects and which ar e stor ed in a data base a s a co llection of tuples ( t i , x i , y i ), i = 0 , ..., N , i.e., as a finite s ample of time-stamp ed lo cations in the plane. These s amples may hav e b een obtained b y GPS- measurements or fro m other lo cation aw a re devic es. One pa rticular mo del for the manag emen t of the uncertaint y of the moving ob- ject’s p osition in b etw een s a mple p oints is pr o vided by the b e ad mo del. In this mo del, it is ass umed that b e sides the time-s tamped lo cations of the o b ject also some background knowledge, in particular a (e.g., physically o r law imp osed) s peed limitation v i at lo cation ( x i , y i ) is known. The b ead b e tw een tw o co ns ecutiv e sample po in ts is defined as the collection of time-space p o in ts where the moving o b jects ca n hav e passed, given the sp eed limitatio n (see Figure 1 for an illustratio n). The chain of b eads connecting consecutive tra jectory sample p oints is called a lifeline ne ck- lac e [E genhofer 2 003]. Wherea s b eads were alrea dy co nceptually known in the time geogr a ph y of H¨ age rstrand in the 1970s [H¨ age r strand 1 970], they were intro duced in the ar ea o f GIS by P foser [Pfos er a nd Jensen 19 9 9] a nd later studied by Eg enhofer and Hornsby [Egenhofer 2003 ; Hornsby and Eg enhofer 20 02], and Miller [Miller 2005], and in a query lang ua ge context by the prese nt authors [Kuijp ers and Oth- man 2 007]. In this setting, a q uery o f par ticular interest that has b een studied, mainly by Egenhofer and Hor nsb y [Egenho fer 2003 ; Hornsby and Egenhofer 2 002], is the alibi query . This b o olean quer y asks whether tw o moving ob jects, that ar e g iv en by samples of time-space p oints a nd s p eed limitations , can have ph ysically met. This question a dds up to deciding whether the necklaces of b eads o f these moving ob jects int ersect or not. This pro blem ca n b e cons idered solved in pr actice, when w e can efficiently decide whether tw o b eads int ersect. Although approximate solutions to this problem have b een prop osed [Egenhofer 2003], also a n exa ct solution is po ssible. W e s ho w that the alibi query can be formulated in the constr a in t databas e mo del by means of a first-order query . Ex- per imen ts with softw a re pa c k ages such as QE P CAD [Hong 1990 ], Redlog [Sturm 2000] and Mathematica [W olfr a m 200 7] on a v ariety of b eads show that deciding if tw o concr ete b eads intersect can b e computed on av e r age in 2 min utes (running Windows XP P ro, SP2 , with a Intel Pent ium M, 1.73 GHz, 1 GB RAM). This means that ev alua ting the alibi query on the lifeline necklaces of tw o moving o b jects that each consist of 100 b eads would take a round 10 0 × 100 × 2 minutes, which is almost t wo weeks, or , if we work with or de r ed time in ter v als a nd fir s t test o n overlapping time interv als, (100 + 100 ) × 2 minutes, which is a lmo st 7 hours. Clear ly , such a n amount of time is una cceptable. Another so lutio n within the rang e of constraint da tabases is to find a formula, in which the ap exes and limit sp eeds of t w o be ads appea r as pa rameters, that pa ra- metrically expr esses that tw o b eads intersect. W e call this pro blem the p ar ametric AC M Journ al Name, V ol. V, No. N, 20YY. 4 · alibi qu ery . A quantifier-free for m ula for this parametric version co uld, in theory , also b e o bta ined by eliminating one blo ck o f three existential quantifiers from a formula with 17 v ariables using existing quantifier-elimination pack ages. W e hav e attempted this appro a c h using Mathematica, Redlog a nd QEP CAD, but after sev- eral days of running, with the configuration describ ed a b ov e, w e have interrupted the computatio n, witho ut success ful outcome. Clear ly , the eliminating a blo ck of three existential quantifiers from a for m ula in 17 v ariables is b eyond the existing quantifier-elimination implement ations. In fa c t, it is well known that these imple- men tations fail on co mplicated, higher- dimensional problems. T he benefit o f having a quantifier-free first-o r der for m ula that expre s ses that tw o b eads in tersect is that the alibi query on tw o b eads can b e answered in constant time. The pro blem o f deciding whether tw o lifeline necklaces int ersect can then be done in time prop or- tional to the pro duct (or the sum, if w e first test on overlapping time interv als) o f the lengths of the tw o necklaces of b eads. The main contribution of this pap er is the des c ription of an analytic so lution to the alibi query . W e give a quantifier-free fo rm ula, that co n ta ins squar e ro ots, how ever, and tha t expres ses the (non-)emptiness of the intersection of tw o para- metrically given b eads. Although, in a str ict sense, this formula cannot b e s e en as quantifier-free first-order for m ula (due to the r o o ts), it still gives the abov e men tioned co mplexit y b enefits. Also, this formula with square ro ots can easily b e turned into a quantifier-free for mula o f similar length. At the basis of o ur solution is a geometric theorem that describ es three exclusive cas es in which b eads can in- tersect. These three cas e s ca n then b e tr a nsformed int o an analytic solution that can b e us e d to a nsw er the alibi query o n the lifeline necklaces of tw o moving o b jects in less than a min ute. T his provides a pr actical s olution to the alibi quer y . T o ba c k up our claim that the execution time of our metho d require s milliseco nds or less we implement ed this in Ma thema tica a nd compared it to us ing traditiona l quantifier eliminatio n to dec ide this quer y . W e have included this implementation in the App endix and used it to p erform numerous exp eriments which o nly confirm our claims. W e give ano ther e x ample o f a problem where co mmon s e nse pr ev ails ov er the existing implemen tatio ns of general qua n tifier elimination metho ds. This problem is the alibi query at a fix e d moment in time , which a sks whether t w o moving o b jects that are known at discrete moments in time c o uld hav e met a t a given moment in time. This problem can be translated in deciding whether four dis ks in the t wo-dimsnional pla ne hav e a non-empty int ersection. Again, this problem ca n be formulated in the co n text of the co n tr a in t mo del and adds up to the elimination of a blo ck of tw o exis ten tial quantifiers. Also for this problem we provide an exact solution in terms of a quantifier-free formula. This pap er is orga nized as follows. In Sectio n 2 , we descr ibe a mo del for tr a jecto ry (or moving ob ject) databases with uncertaint y using b eads. In Section 3 , we discuss the a libi query . The geometry o f b eads is discussed in Section 4. An analytic solution to this query is given in Section 5 and ex perimental results in Section 6 o f our implementation that can b e found in the App endix. The alibi quer y at a fixed moment in time is s olved in Section 7 . AC M Journal Name , V ol. V, No. N, 20YY. · 5 2. A MODEL F OR M OVING OBJECT DA T A WITH UNCERT AINT Y In this pa per , we consider moving o b jects in the tw o-dimensional ( x, y )-space R 2 and describ e their mov ement in the ( t, x, y )-space R × R 2 , where t is time (w e denote the s et o f the r e al num b ers by R ). In this section, we define tra jector ie s, tr a jecto ry samples, bea ds and tra jectory (sample) databases . Although it is mor e tra ditional to sp eak ab out moving ob ject databases, we use the ter m tra jectory data bases to emphasize that we manage the tra jectories pr oduce d by moving ob jects. 2.1 T rajectories and trajectory samples Moving ob jects, whic h we a ssume to b e p oin ts, pro duce a s p ecial kind of curves, which are parameterized by time and which we call tr aje ctories . Definition 1. A tr aje ctory T is the g raph of a mapping I ⊆ R → R 2 : t 7→ α ( t ) = ( α x ( t ) , α y ( t )) , i.e., T = { ( t, α x ( t ) , α y ( t )) ∈ R × R 2 | t ∈ I } , where I is the time domain o f T . In prac tice , tr a jecto ries ar e o nly k no wn at discr ete moments in time. This partial knowledge o f tra jectories is for malized in the following definition. If we wan t to stress that some t, x, y -v alues (or other v alues) ar e constants, we will use s ans serif characters. Definition 2. A tr aje ctory sample is a finite set of time-space p oints { ( t 0 , x 0 , y 0 ) , ( t 1 , x 1 , y 1 ) , ..., ( t N , x N , y N ) } , on which the or der on time, t 0 < t 1 < · · · < t N , induces a na tural o rder. F or pra ctical purp oses, we may assume that the ( t i , x i , y i )-tuples of a tra jectory sample contain rational v alues. A tra jector y T , which contains a tra jectory sa mple { ( t 0 , x 0 , y 0 ) , ( t 1 , x 1 , y 1 ) , ..., ( t N , x N , y N ) } , i.e., ( t i , α x ( t i ) , α y ( t i )) = ( t i , x i , y i ) for i = 0 , ..., N , is c a lled a ge osp a- tial lifeline for this tra jector y s ample [Eg enhofer 200 3]. A common example of a lifeline, is the r econstruction of a tra jector y fro m a tra jectory samples by linear int erp olation [G¨ uting and Schneider 2005 ]. 2.2 Mo deling uncertain t y with b eads Often, in practica l a pplica tions, mor e is known ab out tr a jecto ries than mer ely s ome sample p oints ( t i , x i , y i ). F o r instance, background knowledge like a physically or law imp osed sp eed limitation v i at lo cation ( x i , y i ) mig h t b e av ailable. Such a sp eed limit might even dep end on t i . The s peed limits that hold betw een tw o consecutive sample p oints ca n b e us e d to mo del the uncertaint y of a moving ob ject’s lo cation betw een sample p oin ts. More spec ifically , we know that at a time t , t i ≤ t ≤ t i +1 , the ob ject’s dis tance to ( x i , y i ) is at most v i ( t − t i ) and its dis ta nce to ( x i +1 , y i +1 ) is at most v i ( t i +1 − t ). The spa tial lo cation of the ob ject is therefore so mewhere in the intersection of the disc with center ( x i , y i ) and radius v i ( t − t i ) and the disc with c e nter ( x i +1 , y i +1 ) and ra dius v i ( t i +1 − t ). The geo metric lo cation of these p oints is referr ed to as AC M Journ al Name, V ol. V, No. N, 20YY. 6 · a b e ad [Pfoser and Jensen 1 999; E genhofer 2003] and defined, for general p oints p = ( t p , x p , y p ) and q = ( t q , x q , y q ) and sp eed limit v max as follows. 0 0 1 1 0 0 1 1 0 0 1 1 0 1 t y x Fig. 1. A b ead and a l i feline necklac e. Definition 3. The b e ad with orig in p = ( t p , x p , y p ), destination q = ( t q , x q , y q ), with t p ≤ t q , and maximal sp eed v max ≥ 0 is the set of a ll p oints ( t, x, y ) ∈ R × R 2 that satisfy the following constra in t formula 4 Ψ B ( t, x, y , t p , x p , y p , t q , x q , y q , v max ) := ( x − x p ) 2 + ( y − y p ) 2 ≤ ( t − t p ) 2 v 2 max ∧ ( x − x q ) 2 + ( y − y q ) 2 ≤ ( t q − t ) 2 v 2 max ∧ t p ≤ t ≤ t q . W e denote this set by B ( p, q , v max ) or B ( t p , x p , y p , t q , x q , y q , v max ). In the formula Ψ B ( t, x, y , t p , x p , y p , t q , x q , y q , v max ), we consider t p , x p , y p , t q , x q , y q , v max to b e para meters, whereas t, x, y ar e considered v aria bles defining the subset of R × R 2 . Figure 2 illustrates the notion o f b ead in time-space. Whereas a contin uous curve connecting the sample p o in ts of a tra jecto r y s ample was ca lle d a geo spatial lifeline, a chain of be a ds connecting succeeding tra jectory sample p oints is called a lifeline ne cklac e [Egenhofer 2003]. 2.3 T rajectory d atabases W e assume the existence of a n infinite se t Labe ls = { a , b , ..., a 1 , b 1 , ..., a 2 , b 2 , ... } of tr aje ctory lab els , that ser v e to identify individual tr a jectory sa mples. W e now define the notion of tra jectory da tabase. 4 Later on, this type of formula’s wi ll be refered to as FO (+ , × , <, 0 , 1)-formulas. AC M Journal Name , V ol. V, No. N, 20YY. · 7 Definition 4. A t r aje ctory (sample) datab ase is a finite s et o f tuples ( a i , t i,j , x i,j , y i,j , v i,j ), w ith i = 1 , ..., r and j = 0 , ..., N i , such that a i ∈ Lab els cannot app ear t wice in co m bina tio n with the same t - v a lue, such that { ( t i, 0 , x i, 0 , y i, 0 ) , ( t i, 1 , x i, 1 , y i, 1 ) , ..., ( t i,N i , x i,N i , y i,N i ) } is a tr a jectory sample for each i = 1 , ..., r and such that the v i,j ≥ 0 for each i = 1 , ..., r and j = 0 , ..., N i . 3. TRAJECTORY QUE RIES AND T HE ALIBI QUER Y In this section, we de fine the no tion of tra jectory databa se q uery , we s ho w how constraint databas e la nguages ca n b e used to quer y tra jectories a nd we define the alibi q ue r y and the pa rametric alibi query . 3.1 T rajectory q ueries A tr aje ctory datab ase query has b een defined as a pa rtial computable function from tra jectory data ba ses to tra jector y databases [Kuijp ers a nd Othman 20 07]. Often, we are also interested in queries that express a pro perty , i.e., in b o olean queries. More fo rmally , w e ca n say that a b o ole an tr aje ctory da tab ase query is a partial computable function from tra jectory databases to { T rue , False } . When we say tha t a function is computable, this is with resp ect to so me fixed enco ding of the tra jector y databases (e.g., rational nu mbers a re re presented a s pair s of natural num ber s in bit re pr esentation). 3.2 A co nstraint-based que ry lang uage Several la ng uages hav e b een pr opo sed to express quer ies on moving ob ject data and tra jectory databases (se e [G ¨ uting and Schneider 20 0 5] and references therein). One particular la nguage for querying tra jectory data, that was recently studied in deta il by the present authors, is provided by the forma lism of constra in t databases. This query langua ge is a first-order lo g ic w hich extends firs t-order logic over the real nu mbers with a predicate S to address the input tra jectory database . W e denote this logic by FO (+ , × , <, 0 , 1 , S ) and define it as follows. Definition 5. The langua ge FO (+ , × , <, 0 , 1 , S ) is a tw o-sorted lo gic with lab el variables a, b , c , ... (p o ssibly with subscr ipts) that refer to tra jectory lab els and r e al variables x, y , z , ..., v , ... (p ossibly with subscripts) that refer to r eal num b ers. The atomic formulas of F O (+ , × , <, 0 , 1 , S ) are — P ( x 1 , ..., x n ) > 0, wher e P is a po lynomial with integer co efficients in the rea l v ariables x 1 , ..., x n ; — a = b ; and — S ( a, t, x, y , v ) ( S is a 5-a ry predicate). The for m ula s of FO (+ , × , < , 0 , 1 , S ) a r e built from the atomic formulas using the logical co nnectiv es ∧ , ∨ , ¬ , ... and qua n tifica tion ov e r the t wo types of v ariables: ∃ x , ∀ x a nd ∃ a , ∀ a . The lab e l v ariables are assumed to range ov e r the lab els o ccurring in the input tra jectory da ta base and the real v ariables are assumed to range ov er R . The for mula S ( a, t, x, y , v ) expr e sses that a tuple ( a, t, x, y , v ) b elongs to the input tra jectory database. The interpretation of the other formulas is standard. AC M Journ al Name, V ol. V, No. N, 20YY. 8 · F or example, the FO ( + , × , <, 0 , 1 , S )-sentence ∃ a ∃ b ( ¬ ( a = b ) ∧ ∀ t ∀ x ∀ y ∀ v S ( a, t, x, y , v ) ↔ S ( b, t, x, y , v )) expresses the b o olean tra jectory quer y that says that there are tw o identical tra- jectories in the input database with different lab els. When we instantiate the free v aria bles in a FO (+ , × , <, 0 , 1 , S )-form ula ϕ ( a, b, ..., t, x, y , ... ) b y concrete v alues a , b , ..., t , x , y , ... w e write ϕ [ a , b , ..., t , x , y , ... ] for the formula we obtain. 3.3 The al ibi query The alibi query is the b oo lean query which asks whe ther tw o moving ob jects, say with la bels a and a ′ , tha t ar e av a ilable as samples in a tra jectory database, ca n hav e physically met. Since the p ossible p ositions of these moving o b jects a re, in betw een sa mple p oints, g iv en by b eads, the alibi query as ks to decide if the tw o lifeline necklaces of a and a ′ int ersect or not. More concretely , if the tra jectory a is given in the tra jectory database by the tuples ( a , t 0 , x 0 , y 0 , v 0 ) , ...., ( a , t N , x N , y N , v N ) and the tra jectory a ′ by the tuples ( a ′ , t ′ 0 , x ′ 0 , y ′ 0 , v ′ 0 ) , ...., ( a ′ , t ′ M , x ′ M , y ′ M , v ′ M ), then a has an a libi for no t meeting a ′ if for all i , 0 ≤ i ≤ N − 1 and all j , 0 ≤ j ≤ M − 1, B ( t i , x i , y i , t i +1 , x i +1 , y i +1 , v i ) ∩ B ( t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ) = ∅ . ( † ) W e r emark that the alibi query ca n be expr essed by a for m ula in the logic F O (+ , × , <, 0 , 1 , S ), which we know give. T o star t, we denote the subformula S ( a, t 1 , x 1 , y 1 , v 1 ) ∧ S ( a, t 2 , x 2 , y 2 , v 2 ) ∧ ∀ t 3 ∀ x 3 ∀ y 3 ∀ v 3 ( S ( a, t 3 , x 3 , y 3 , v 3 ) → ¬ ( t 1 < t 3 ∧ t 3 < t 2 )) , that expresse s that ( t 1 , x 1 , y 1 ) and ( t 2 , x 2 , y 2 ) are consecutive s ample p o in ts on the tra jectory a by σ ( a, t 1 , x 1 , y 1 , v 1 , t 2 , x 2 , y 2 , v 2 ). The alibi query on a and a ′ is then expresse d a s ϕ alibi [ a , a ′ ] = ¬∃ t 1 ∃ x 1 ∃ y 1 ∃ v 1 ∃ t 2 ∃ x 2 ∃ y 2 ∃ v 2 ∃ t ′ 1 ∃ x ′ 1 ∃ y ′ 1 ∃ v ′ 1 ∃ t ′ 2 ∃ x ′ 2 ∃ y ′ 2 ∃ v ′ 2 ( σ ( a , t 1 , x 1 , y 1 , v 1 , t 2 , x 2 , y 2 , v 2 ) ∧ σ ( a ′ , t ′ 1 , x ′ 1 , y ′ 1 , v ′ 1 , t ′ 2 , x ′ 2 , y ′ 2 , v ′ 2 ) ∧ ∃ t ∃ x ∃ y ( t 1 ≤ t ≤ t 2 ∧ t ′ 1 ≤ t ≤ t ′ 2 ∧ ( x − x 1 ) 2 + ( y − y 1 ) 2 ≤ ( t − t 1 ) 2 v 2 1 ∧ ( x − x 2 ) 2 + ( y − y 2 ) 2 ≤ ( t 2 − t ) 2 v 2 1 ∧ ( x − x ′ 1 ) 2 + ( y − y ′ 1 ) 2 ≤ ( t − t ′ 1 ) 2 v ′ 2 1 ∧ ( x − x ′ 2 ) 2 + ( y − y ′ 2 ) 2 ≤ ( t ′ 2 − t ) 2 v ′ 2 1 )) . It is well-known that F O (+ , × , <, 0 , 1 , S )-expressible queries can b e ev alua ted effectively on arbitrar y tra jectory database inputs [Paredaens et al. 200 0; K uijpers and Othman 2007]. Briefly explained, this ev a lua tion can be p erfor med by (1) replacing the o ccurrences of S ( a , t, x, y , v ) by a disjunction describing all the sa mple po in ts b elonging to the tra jector y sa mple a ; the sa me for a ′ ; and (2) eliminating all the q uan tifiers in the obtained for m ula . In concreto , using the notation fr o m ab ov e, each o ccur r ence of S ( a , t, x, y , v ) w ould be replaced in ϕ alibi [ a , a ′ ] by W N − 1 i =0 ( t = t i ∧ x = x i ∧ y = y i ∧ v = v i ) , a nd simila r for a ′ . This r e sults in a (ra ther complicated) first-order for m ula ov er the r eals ˜ ϕ alibi [ a , a ′ ] in which the pr e dicate S do es not o ccur any more. Since fir st-order logic ov er the reals admits the elimination of quantifiers (i.e., every formula can be eq uiv a len tly expressed by a quantifier-free formula), we AC M Journal Name , V ol. V, No. N, 20YY. · 9 can decide the truth v alue of ˜ ϕ alibi [ a , a ′ ] by eliminating all quantifiers from this expression. In this c ase, we have to eliminate o ne blo ck of existential quantifiers. W e can how e v er s implify the quantifier-elimination problem. It is eas y to s ee, lo oking at ( † ) a b ov e, that ¬ ˜ ϕ alibi [ a , a ′ ] is equiv alent to N − 1 _ i =0 M − 1 _ j =0 ψ alibi [ t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ] , where the r e stricted a libi-query for m ula ψ alibi ( t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ) abbreviates the formula ∃ t ∃ x ∃ y ( t i ≤ t ≤ t i +1 ∧ t ′ j ≤ t ≤ t ′ j +1 ∧ ( x − x i ) 2 + ( y − y i ) 2 ≤ ( t − t i ) 2 v 2 i ∧ ( x − x i +1 ) 2 + ( y − y i +1 ) 2 ≤ ( t i +1 − t ) 2 v 2 i ∧ ( x − x ′ j ) 2 + ( y − y ′ j ) 2 ≤ ( t − t ′ j ) 2 v ′ 2 j ∧ ( x − x ′ j +1 ) 2 + ( y − y ′ j +1 ) 2 ≤ ( t ′ j +1 − t ) 2 v ′ 2 j ) that expresses that tw o b eads in tersect. So, the ins tan tia ted for m ula ψ alibi [ t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ] expresses ( † ). T o eliminate the existential blo c k of quantifiers ( ∃ t ∃ x ∃ y ) from this expression, existing softw a re-pack a ges for qua n tifier elimination, such as QEP- CAD [Hong 19 90], Redlog [Sturm 2 000] and Mathematica [W o lfram 200 7] can b e used. W e exp erimented QEP C AD, Redlog a nd Ma thema tica to decide if several bea ds intersected. The latter tw o pr ograms hav e a s imilar p erformance and they outp e rform QEPCAD. T o give an idea of their p erformance, we give so me re- sults with Mathematica: the computation o f ψ alibi [0 , 0 , 0 , 1 , 2 , 2 , √ 8 , 0 , 3 , 3 , 1 , 2 , 2 , 2] to ok 6 seconds; that o f ψ alibi [0 , 0 , 0 , 1 , 2 , 2 , √ 8 , 0 , 3 , 4 , 1 , 2 , 2 , 2] to ok 20 9 s econds and the co mputatio n o f ψ alibi [0 , 0 , 0 , 1 , − 1 , − 1 , 1 , 0 , 1 , 1 , 2 , − 1 , 1 , 2 ] to ok 61 3 seconds. Roughly sp eaking, our ex p eriments show that, using Mathematica , this quantifier elimination can b e computed on av er age in ab out 2 minutes (running Windows XP Pr o, SP2, with a Intel Pentium M, 1.7 3GHz, 1 GB RAM). This means that ev aluating the a libi query on the lifeline necklaces of t wo moving ob jects that each consist of 100 bea ds would take around 100 × 100 × 2 minutes, which is almost tw o weeks, when applied na iv ely and at mos t (100 + 10 0) × 2 minutes or a quarter day , when first the in tersection of time-interv als is tested. Clea rly , in b oth cas es, s uc h an a moun t of time is una cceptable. There is a b etter solution, howev er, which we discuss next, that ca n decide if tw o bea ds intersect or no t in a co uple of milliseco nds. 3.4 The parametric al i bi query The uninstantiated formula ψ alibi ( t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ) can b e viewed as a parametric version o f the restricted alibi query , where the free v ariables are considered para meters. This for m ula co n ta ins three existential q uan- tifiers and the existing software-pack a ges for quantifier elimination could b e used to obtain a qua n tifier -free formula ˜ ψ alibi ( t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , AC M Journ al Name, V ol. V, No. N, 20YY. 10 · x ′ j +1 , y ′ j +1 , v ′ j ) that is equiv alent to ψ alibi . The formula ˜ ψ alibi could then b e used to straightforwardly answer the alibi query in time linear in its size, which is indep en- dent o f the size of the input a nd therefore constant. W e have tr ied to eliminate the existential blo ck o f quantifiers ∃ t ∃ x ∃ y from ψ alibi using Mathematica, Redlog a nd QEPCAD. After some minutes of running, Redlog invok es QEP CAD. After several days of running QEP CAD on the configur ation descr ibed ab ov e, w e have inter- rupted the computation witho ut result. Also Ma thematica ran into problems with- out g iving an answer. It is clea r that e limina ting a blo ck of three existential quan- tifiers from a for mula in 17 v ariables is b eyond the existing quantifier-elimination implemen tations. Also, the instantiation of several par ameters to adequately c ho- sen constant v alues do es no t help to pr o duce a solution. F or instance, witho ut loss of gener alit y we ca n lo cate ( t i , x i , y i ) in the or igin (0 , 0 , 0) and lo cate the other a pex of the first b e ad ab ov e the y -axis, i.e., we can take x i +1 = 0. F urthermor e, we can take v i = 1 and t i +1 = 1. But Mathema tica, Redlog and QE P CAD canno t also not cop e with this simplified situatio n. The main contribution of this pap er is a the descr iption of a quantifier-free for- m ula equiv ale nt to ψ alibi ( t i , x i , y i , t i +1 , x i +1 , y i +1 , v i , t ′ j , x ′ j , y ′ j , t ′ j +1 , x ′ j +1 , y ′ j +1 , v ′ j ). The solution we g iv e is no t a quantifier-free first-o rder formula in a strict sense, since it contains ro ot expres s ions, but it ca n b e easily turned into a qua n tifier -free first-order formula of similar length. It answers the alibi query o n the lifeline neck- laces o f t wo moving ob jects that each consist o f 100 b eads in less than a minute. This description of this quantifier-free formula is the sub ject of the next section. 4. PRELIMINARIE S ON TH E GEOME TRY OF BEADS Before, we can give an analytic s olution to the alibi query and prove its corr e ctness, we nee d to introduce some ter minology conc e r ning b eads. 4.1 Geometric co m p one n ts of b eads V arious geometr ic pr o per ties o f b eads hav e already b een desc r ibed [E genhofer 200 3; Kuijpe r s and Othman 2 0 07; Miller 2005]. Her e, we need so me mor e definitions and notations to describ e v arious c ompone nts of a bea d. These co mponents ar e illustrated in Figure 2. In this s e ction, let p = ( t p , x p , y p ) and q = ( t q , x q , y q ) be t wo time-space p oin ts, with t p ≤ t q and let v max be a p ositive rea l num b er. The b ead B ( p, q , v max ) is the intersection of tw o filled co nes, given by the equa- tions ( x − x p ) 2 + ( y − y p ) 2 ≤ ( t − t p ) 2 v 2 max ∧ t p ≤ t and ( x − x q ) 2 + ( y − y q ) 2 ≤ ( t q − t ) 2 v 2 max ∧ t ≤ t q resp ectively . T he bor der o f its b ottom c one is the set of all po in ts ( t, x, y ) that s atisfy Ψ C − ( t, x, y , t p , x p , y p , v max ) := ( x − x p ) 2 + ( y − y p ) 2 = ( t − t p ) 2 v 2 max ∧ t p ≤ t and is denoted by C − ( p, v max ) or C − ( t p , x p , y p , v max ); and the b or der of its upp er c one is the s et of all p oints ( t, x, y ) that satisfy Ψ C + ( t, x, y , t q , x q , y q , v max ) := ( x − x q ) 2 + ( y − y q ) 2 = ( t q − t ) 2 v 2 max ∧ t ≤ t q and is denoted by C + ( q , v max ) or C + ( t q , x q , y q , v max ). The set of the tw o a pexes of B ( p, q , v max ) is denotes τ B ( p, q , v max ), i.e ., τ B ( p, q , v max ) = { p, q } . AC M Journal Name , V ol. V, No. N, 20YY. · 11 W e call the top ological b order o f the b ead B ( p, q , v max ) its mantel and denote it by ∂ B ( p, q , v max ). It can b e easily verified that the mantel consis ts of the set of po in ts ( t, x, y ) that s atisfy Ψ ∂ ( t, x, y , t p , x p , y p , t q , x q , y q , v max ) := t p ≤ t ≤ t q ∧ 2 x ( x p − x q ) + x 2 q − x 2 p + 2 y ( y p − y q ) + y 2 q − y 2 p ≤ v 2 max 2 t ( t p − t q ) + t 2 q − t 2 p ∧ ( x − x p ) 2 + ( y − y p ) 2 = ( t − t p ) 2 v 2 max ∨ ( x − x q ) 2 + ( y − y q ) 2 = ( t q − t ) 2 v 2 max ∧ 2 x ( x p − x q ) + x 2 q − x 2 p + 2 y ( y p − y q ) + y 2 q − y 2 p ≥ v 2 max 2 t ( t p − t q ) + t 2 q − t 2 p . The first conjunction describ es the low er half o f the ma n tel and the sec o nd con- junction descr ibes the upp er ha lf of the mantel. The upp er and lower half o f the mantel are s eparated by a plane. The intersection of this plane with the be ad is an ellipse, and the b order of this ellipse is wha t we will refer to a s the rim of the b ead. W e deno te the rim of the b ead B ( p, q , v max ) by ρ B ( p, q , v max ) and remark that it is describ ed by the formula Ψ ρ ( t, x, y , t p , x p , y p , t q , x q , y q , v max ) := ( x − x p ) 2 + ( y − y p ) 2 = ( t − t p ) 2 v 2 max ∧ t p ≤ t ≤ t q ∧ 2 x ( x p − x q ) + x 2 q − x 2 p + 2 y ( y p − y q ) + y 2 q − y 2 p = v 2 max 2 t ( t p − t q ) + t 2 q − t 2 p . The plane in which the rim lies splits the b ead into an upp er-half b e ad and a b ottom-half b e ad . The b ottom-half b e ad is the s e t of a ll p oints ( t, x, y ) that satisfy Ψ B − ( t, x, y , t p , x p , y p , t q , x q , y q , v max ) := ( x − x p ) 2 + ( y − y p ) 2 ≤ ( t − t p ) 2 v 2 max ∧ t p ≤ t ≤ t q ∧ 2 x ( x p − x q ) + x 2 q − x 2 p + 2 y ( y p − y q ) + y 2 q − y 2 p ≤ v 2 max 2 t ( t p − t q ) + t 2 q − t 2 p and is denoted by B − ( t p , x p , y p , t q , x q , y q , v max ). The upp e r b ead is the s e t of all p oint s ( t, x, y ) that satisfy Ψ B + ( t, x, y , t p , x p , y p , t q , x q , y q , v max ) := ( x − x q ) 2 + ( y − y q ) 2 ≤ ( t q − t ) 2 v 2 max ∧ t p ≤ t ≤ t q ∧ 2 x ( x p − x q ) + x 2 q − x 2 p + 2 y ( y p − y q ) + y 2 q − y 2 p ≥ v 2 max 2 t ( t p − t q ) + t 2 q − t 2 p and is denoted by B + ( t p , x p , y p , t q , x q , y q , v max ). 4.2 The in tersection o f tw o cones Let C − ( t 1 , x 1 , y 1 , v 1 ) and C − ( t 2 , x 2 , y 2 , v 2 ) be tw o b ottom cones. A b ottom cone, e.g., C − ( t 1 , x 1 , y 1 , v 1 ), ca n b e seen a s a cir cle in 2-dimensio nal space ( x, y )-spa c e with center ( x 1 , y 1 ) and linea rly g rowing r adius ( t − t 1 ) v 1 as t 1 ≤ t . Let us a ssume that the a pex of neither of these cones is inside the other cone, i.e., ( x 1 − x 2 ) 2 + ( y 1 − y 2 ) 2 > ( t 1 − t 2 ) 2 v 2 1 ∨ t 1 < t 2 and ( x 1 − x 2 ) 2 + ( y 1 − y 2 ) 2 > ( t 1 − t 2 ) 2 v 2 2 ∨ t 2 < t 1 . This assumption implies that at t 1 and t 2 neither radius is larger than or equa l to the distance b etw een the tw o cone centers. So, at first the t wo circles are disjoint a nd after gr owing for s o me time they in tersect in one p oint. W e call the first (in time) time-space p oint where the t wo circles touch in a sing le po in t, and thus for which the sum of the tw o ra dii is equal to the distance b etw een the tw o centers the initial c ontact of the tw o cones C − ( t 1 , x 1 , y 1 , v 1 ) and C − ( t 2 , x 2 , AC M Journ al Name, V ol. V, No. N, 20YY. 12 · ( t q , x q , y q ) t y x ρ B C + C − τ B ( t p , x p , y p ) B + B − Fig. 2. A dissection of the bead B ( t p , x p , y p , t q , x q , y q , v max ). y 2 , v 2 ). It is the unique p oint ( t, x, y ) that satisfies the formula Ψ I C − ( t, x, y , t 1 , x 1 , y 1 , v 1 , t 2 , x 2 , y 2 , v 2 ) := t 1 ≤ t ∧ t 2 ≤ t ∧ ( x − x 1 ) 2 + ( y − y 1 ) 2 = ( t − t 1 ) 2 v 2 1 ∧ ( x − x 2 ) 2 + ( y − y 2 ) 2 = ( t − t 2 ) 2 v 2 2 ∧ (( t − t 1 ) v 1 + ( t − t 2 ) v 2 ) 2 = ( x 1 − x 2 ) 2 + ( y 1 − y 2 ) 2 . The initial cont act o f tw o co nes C + ( t 1 , x 1 , y 1 , v 1 ) and C + ( t 2 , x 2 , y 2 , v 2 ) is g iv en by the formula Ψ I C + ( t, x, y , t 1 , x 1 , y 1 , v 1 , t 2 , x 2 , y 2 , v 2 ) that we obtain from Ψ I C − by replacing in t 1 ≤ t ∧ t 2 ≤ t by t ≤ t 1 ∧ t ≤ t 2 . W e denote the singleton sets containing the initial contacts by IC ( C − ( t 1 , x 1 , y 1 , v 1 ) , C − ( t 2 , x 2 , y 2 , v 2 )) a nd IC ( C + ( t 1 , x 1 , y 1 , v 1 ) , C + ( t 2 , x 2 , y 2 , v 2 )). 00 11 initial contact ( t 2 , x 2 , y 2 ) ( t 1 , x 1 , y 1 ) ( t, x, y ) v 2 ( t − t 2 ) v 1 ( t − t 1 ) ( x 1 , y 1 ) ( x 2 , y 2 ) Fig. 3. In tersecting cones and their initial cont act (3-dimensional view on the left and 2- dimensional view on the r igh t). AC M Journal Name , V ol. V, No. N, 20YY. · 13 F rom the la st equation in of the system in Ψ I C − a nd Ψ I C + , w e ea s ily o btain t = √ ( x 1 − x 2 ) 2 +( y 1 − y 2 ) 2 + t 1 v 1 + t 2 v 2 v 1 + v 2 . T o compute the o ther tw o co ordinates ( x, y ) of the initial contact, we observe that for in the plane of this time v alue t , it is on the line seg men t b ounded by ( x 1 , y 1 ) and ( x 2 , y 2 ) and that its distance from ( x 1 , y 1 ) is v 1 ( t − t 1 ) a nd its distance from ( x 1 , y 1 ) is v 2 ( t − t 2 ). W e can conclude that the initial contact has ( t, x, y )-co ordinates given by the following system of equations t = √ ( x 1 − x 2 ) 2 +( y 1 − y 2 ) 2 + t 1 v 1 + t 2 v 2 v 1 + v 2 x = x 1 + v 1 ( t − t 1 ) x 2 − x 1 √ ( x 2 − x 1 ) 2 +( y 2 − y 1 ) 2 y = y 1 + v 1 ( t − t 1 ) y 2 − y 1 √ ( x 2 − x 1 ) 2 +( y 2 − y 1 ) 2 . This mea ns that we can give more ex plicit descriptio ns to re pla ce Ψ I C − and Ψ I C + . 5. AN ANAL YTIC SOLUTION TO T HE ALIBI QUER Y In this section, w e first descr ibe our s olution to the alibi query o n a g eometric level. Next, we pr ov e its corr ectness and transform it into an analytic solutio n and finally we show how to construct a qua n tifier -free first-order for m ula out of the a nalytic solution. 5.1 Preliminary geometric consideratio n s Fig. 4. One b ead is con tained in the other. The solution we pr esen t is based on the observ a tion that the t wo ma in ca s es of int ersection (that do no t exclude each other ) ar e: (1 ) an ap ex of one b ead is in the other; and (2) the mantels of the b eads intersect. The inclusio n of o ne b ead in the other, illustrated in Figure 4, is an ex ample of the fir st ca se. It is clear that if no ap ex is contained in another bea d a nd we still assume that the b eads intersect, than their mantels must intersect. W e show this more forma lly in L e mma 1. In this s econd case, the idea is to find a sp ecial po in t (a witness po in t) that is eas ily computable a nd necessa rily in the intersection. AC M Journ al Name, V ol. V, No. N, 20YY. 14 · 0 0 1 1 00 00 11 11 0 1 0 0 1 1 Fig. 5. Clean cut b et w een cones. Let us conside r tw o be a ds with b ottom co ne s C − ( t 1 , x 1 , y 1 , v 1 ) and C − ( t 2 , x 2 , y 2 , v 2 ) and let us a ssume that no ne of the a peces is inside the other cone. O ne sp ecial po in t is the p oint of initial c o n tact IC ( C − ( t 1 , x 1 , y 1 , v 1 ) , C − ( t 2 , x 2 , y 2 , v 2 )). How ever, this p oint ca n not b e guara n tee d to be in the intersection if the mantels of the tw o bea ds intersect, as we will show in the following ex ample. Co nsider tw o b eads with bo ttom cones C − (0 , 0 , 0 , 1) and C − (0 , 2 , 0 , 1). The intersection is a hyperb ola in the pla ne x = 1 with equation t 2 − y 2 = 1. The initial c o n tact of the tw o bo ttom cones is the p oint (1 , 0 , 1). T o show that this p oint of initial contact do es no t need to b e in the intersection o f the t wo b eads, the idea is to cut this p oint o ut of the int ersection as follows. Supp ose o ne b ead has ap exes, (0 , 0 , 0 ) a nd ( a, b, c ) and sp eed 1. The pla ne in which its rim lies is g iv en by − 2 a x + a 2 − 2 by + b 2 + 2 ct − c 2 = 0. This plane cuts the plane α given by the equality x = 1 in a line given by the equation − 2 by + 2 ct − 2 a + a 2 − c 2 = 0. Clearly , we ca n choose ( a, b, c ) such that the line c on tains the p oints √ 5 2 , 1 , 1 2 and √ 2 , 1 , 1 . Everything b elow this line will b e pa rt o f the first b ead and the se c o nd co ne, but the initial c o n tact is situated ab ov e the line, effectively cutting it out o f the intersection. All this is illustr a ted in Figure 6. W e notice how the plane in which the rim lies a nd the rim itself is the evil do- er. If neither rim intersects the mantel of the o ther b ead, then the in tersection of mantels is the same as an intersection of cones. In which case the initial co n ta ct will not b e cut out a nd can b e used to deter mine if there is in tersection in this manner. Using contrap osition on the statement in the previous par agraph we get: if there is an in tersectio n and no initial contact is in the in ters e c tion then a rim m us t int ersect the other b ead’s mantel. T o v er ify in terse ction with the a pexes and initial contacts is straightforw ard. V erifying if a r im intersects a ma n tel r esults in solving a quartic po lynomial e quation in one v a riable and verifying the solution in a single inequality in which no v aria ble AC M Journal Name , V ol. V, No. N, 20YY. · 15 initial contact α ↔ x = 1 α − 2 by + 2 ct − 2 a + a 2 − c 2 = 0 Fig. 6. The ini tial contact cut out. app ears with a deg ree higher than one. 5.2 Outline o f the solu tion Suppo se, for the remainder of this sec tio n, we wish to verify if the b eads B 1 = B ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) a nd B 2 = B ( t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) intersect. Mor eov er, we assume the b eads ar e non-empty , i.e., ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ≤ ( t 2 − t 1 ) 2 v 2 1 and ( x 4 − x 3 ) 2 + ( y 4 − y 3 ) 2 ≤ ( t 4 − t 3 ) 2 v 2 2 . W e firs t o bserve that a n intersection b etw een beads can b e c la ssified into three, m utually exclusive, cases. The three cases then ar e : (I) an a pex of one b ead is contained in the other, i.e., τ B 1 ∩ B 2 6 = ∅ or B 1 ∩ τ B 2 6 = ∅ ; (I I) not (I) , but the r im of one b ead intersects the mantel of the other, i.e., ρ B 1 ∩ ∂ B 2 6 = ∅ or ρ B 2 ∩ ∂ B 1 6 = ∅ ; AC M Journ al Name, V ol. V, No. N, 20YY. 16 · (I I I) not (I) a nd not (I I) and the initial c on tact o f the upp er or low er cones is in the int ersection o f the b eads, i.e., IC ( C − 1 , C − 2 ) ⊂ B 1 ∩ B 2 or IC ( C + 1 , C + 2 ) ⊂ B 1 ∩ B 2 . If none of these three cases o ccur then the b eads do not intersect, as we show in the correctnes s pro of b elow. First, we give the following geo metr ic lemma. L emma 1. If B 1 ∩ B 2 6 = ∅ , τ B 1 ∩ B 2 = ∅ and τ B 2 ∩ B 1 = ∅ , then ∂ B 1 ∩ ∂ B 2 6 = ∅ . Proof. F rom the assumptions, we k no w there is a p oint p 1 in B 2 , e.g ., an ap ex of B 2 , that is no t in B 1 . Also , there is a p oint p 2 that is in B 2 and in B 1 . The line segment bo unded b y p 1 and p 2 lies in B 2 , sinc e B 2 is c on vex. The line segment cuts the ma n tel of B 1 since p 2 is inside B 1 and p 1 is not. Let p be this p oin t where the segment bo unded by p 1 and p 2 int ersects ∂ B 1 . This p oint lies either on the upper -half b ead B + 1 or on the b ottom-half b ead B − 1 . L et r b e the ap ex o f this half bea d. Since p is inside B 2 and r is not, the line seg ment b o unded by p and r must cut ∂ B 2 in a p oint q . This p oint lies of co urse on ∂ B 2 and o n ∂ B 1 since the line segment b o unded by p and r is a part of ∂ B 1 . Hence their mantels must have a non-empty intersection if the b eads have a non-empty intersection and neither b ead contains the ap exes of the o ther. Now, w e show that if B 1 and B 2 int ersect and neither ( I ), no r ( I I ) o ccur, then ( I I I ) o ccurs . The or em 1. If B 1 ∩ B 2 6 = ∅ , τ B 1 ∩ B 2 = ∅ , B 1 ∩ τ B 2 = ∅ , ρ B 1 ∩ ∂ B 2 = ∅ and ρ B 2 ∩ ∂ B 1 = ∅ , then IC ( C − 1 , C − 2 ) ⊂ B 1 ∩ B 2 or IC ( C + 1 , C + 2 ) ⊂ B 1 ∩ B 2 . Proof. Let us as sume that the hypo theses of the statement of the theo rem is true. It is sufficient to prove that either C − 1 ∩ C − 2 ⊂ B − 1 ∩ B − 2 or C + 1 ∩ C + 2 ⊂ B + 1 ∩ B + 2 . W e will split the pr oo f in two ca s es. F ro m the fourth a nd fifth hypotheses it follows that either (1) ρ B 1 ⊂ B 2 or ρ B 2 ⊂ B 1 ; or (2) ρ B 1 ∩ B 2 = ∅ and ρ B 2 ∩ B 1 = ∅ . Case (1) : W e assume ρ B 2 ⊂ B 1 (the case ρ B 1 ⊂ B 2 is co mpletely a nalogous). W e prov e C − 1 ∩ C − 2 ⊂ B − 1 ∩ B − 2 (the case for upp er cones is co mpletely ana logous). The following arg ument is illustrated in Figure 7. Since ρ B 2 ⊂ B 1 , we know that ρ B 2 is inside C − 1 , and ( t 3 , x 3 , y 3 ) is outside. W e can show that v 2 < v 1 . Consider the plane s panned by the t wo a xis of symmetry of b oth C − 1 and C − 2 . Both C − 1 and C − 2 int ersect this pla ne in tw o ha lf line s each. Moreover, we know that C − 1 int ersects the ax is of symmetry of C − 2 . Let t 0 be the mo men t at which this happ ens. Ob vio us ly t 0 > t 1 , but we know a lso know t 0 > t 3 since ( t 3 , x 3 , y 3 ) is outside C − 1 . W e hav e that v 1 ( t 0 − t 1 ) = p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 . Since ρ B 2 is inside C − 1 and ( t 3 , x 3 , y 3 ) is o utside, this means b oth ha lf lines fro m C − 2 int ersect the ha lf lines from C − 1 . Let t ′ 0 and t ′′ 0 be the moments in time at which this happ ens and let t ′ 0 > t ′′ 0 . W e have ag ain that t ′ 0 > t 1 and t ′ 0 > t 3 . Then v 1 ( t ′ 0 − t 1 ) = p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + v 2 ( t ′ 0 − t 3 ) if and only if v 1 ( t ′ 0 − t 0 ) = v 2 ( t ′ 0 − t 3 ). Since t 0 > t 3 , we get v 2 < v 1 . T his is depicted in Fig ure 7. It follows that every straight half line star ting in ( t 3 , x 3 , y 3 ) on C − 2 int ersects C − 1 betw een ( t 3 , x 3 , y 3 ) and ρ B 2 , since ρ B 2 is inside C − 1 , and ( t 3 , x 3 , y 3 ) is outside. W e also know that this line do es not intersect C − 1 beyond ρ B 2 since the co ne C − 2 is ent irely inside C − 1 beyond the rim ρ B 2 . T he r efore, C − 1 ∩ C − 2 ⊂ B − 2 . AC M Journal Name , V ol. V, No. N, 20YY. · 17 t ′′ 0 C − 1 C − 2 t 0 t ′ 0 t 1 t 3 t Fig. 7. Illustration to the pro of. Clearly , B − 2 int ersects B − 1 since it c a n not intersect B + 1 . W e know C − 1 ∩ ∂ B − 2 is a closed contin uous c ur v e that lies entirely in C − 1 . This curve is also contained in B − 1 . Indeed, if we assume this is not the cas e, then it intersects the plane in which ρ B 1 lies, and he nce it intersects ρ B 1 itself, contradicting the as sumption ρ B 1 ∩ ∂ B 2 = ∅ . Case (2) : Now assume ρ B 1 ∩ B 2 = ∅ and ρ B 2 ∩ B 1 = ∅ . Clearly , v 1 can not b e equal to v 2 , otherwise the depicted intersection can not o ccur. So s uppose witho ut loss of generality that v 2 < v 1 . Now either B − 2 int ersects b oth B − 1 and B + 1 or B + 2 int ersects bo th B − 1 and B + 1 . These cas es are mutually exclusive b ecause of the following. If B + 2 int ersects B + 1 then ρ B 2 is inside C + 1 , likewise if B − 2 int ersects B − 1 then ρ B 2 is inside C − 1 . Hence ρ B 2 ⊂ B 1 which co ntradicts our hypothesis . If B + 2 int ersects B − 1 then ρ B 2 m ust b e o utside C − 1 and thus B − 2 m ust b e a s well, hence B − 2 int ersects neither B − 1 nor B + 1 . L ik ewise, if B − 2 int ersects B + 1 then B + 2 can no t intersect B 1 . T o prov e that if B − 2 int ersects B − 1 then it also intersects B + 1 and if B − 2 int ersects B + 1 then it also intersects B − 1 we pr oc eed as follows (the case for B + 2 is a nalogous). Suppo se B − 2 int ersects B − 1 , then B − 2 ∩ B − 1 ⊂ B 1 , but ρ B 2 is outside B 1 , that means B − 2 m ust intersect B + 1 since it can not intersect B − 1 anymore. This is the “what go es in m ust come out” -principle. Likewise, supp ose B − 2 int ersects B + 1 , then B − 2 ∩ B + 1 ⊂ B 1 , but ( t 3 , x 3 , y 3 ) is outside B 1 , that mea ns B − 2 m ust int ersect B − 1 since it can not int ersect B − 1 anymore. So supp ose now that B − 2 int ersects b oth B − 1 and B + 1 (the ca se for B + 2 is com- pletely analog ous). If B − 2 int ersects B − 1 that means ρ B 2 is co mpletely inside C − 1 and therefore that C − 1 ∩ C − 2 ⊂ B − 2 . W e pro ceed like in the firs t ca se, we k no w that C − 1 ∩ B − 2 is a closed contin uous curve. This curve lies ent irely in C − 1 . If this curve is not entirely in B − 1 that means it intersects the plane in which ρ B 1 lies, and hence intersects ρ B 1 itself. But this is contradictory to the a ssumption that ρ B 1 ∩ ∂ B 2 = ∅ . In Theorem 1, we proved that if there is an intersection and neither rim cuts the AC M Journ al Name, V ol. V, No. N, 20YY. 18 · Fig. 8. Case (I I) is not redundan t: B (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9) and B (0 , 3 , 0 , 2 , 3 , 2 , 1 . 9) seen from the top and the side. other b ead’s mantel and neither ap ex of a bea d is co ntained in the other then there m ust b e an initial co n ta ct in the intersection. Visua lizing how b eads intersect mig ht tempt one to think there is always an initial contact in the intersection. There exist counterexamples in whic h there is an int ersection and no initial contact is in that int ersection. That mea ns case (I I) is not redundant. This situation is depicted in Figure 8. The b eads ar e B (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9) a nd B (0 , 3 , 0 , 2 , 3 , 2 , 1 . 9 ). It is clear that the initial contact of the bo ttom co nes lies in the plane spanned by the axis of symmetry of those b ottom cones, in this ca se this is the plane y = 0. The in tersection of Figure 8 can be se e n in Fig ure 9, where the t wo b eads clea r ly hav e no in tersection and th us no initial contact in the intersection. In the case of the upp er cones the initial c o n tact must lie in the pla ne y = 3 . The intersection of Figur e 8 can b e seen in Figure 1 0, where the tw o b eads c learly hav e no in tersection and there is again no initial contact in the intersection. AC M Journal Name , V ol. V, No. N, 20YY. · 19 Fig. 9. Inte rsection of Figure 8 with the plane y = 0. Fig. 10. In tersection of Figure 8 with the plane y = 3. This concludes the outline. 5.3 A formula for Cas e (I) In Case (I) , we verify whether τ B 1 ∩ B 2 6 = ∅ or B 1 ∩ τ B 2 6 = ∅ . T o chec k if that is the case we merely need to verify if one of the ap exes satisfies the set of equa tio ns of the other b ead. In this way we o btain Φ I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := (Ψ B ( t 3 , x 3 , y 3 , t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) ∨ Ψ B ( t 4 , x 4 , y 4 , t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) ∨ Ψ B ( t 1 , x 1 , y 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) ∨ Ψ B ( t 2 , x 2 , y 2 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 )) . F or the following sections we ass ume that the ap ex s ets o f the b eads are not singletons, i.e., t 1 < t 2 and t 3 < t 4 . 5.4 A formula for Cas e (I I) Now, let us as sume that Φ I failed in the previous sectio n. Note that we can alwa ys apply a speed-pre serving [Kuijp ers a nd Othman 2007] tr ansformation to R × R 2 to obta in ea sier co ordinates . W e ca n alwa ys find a transfor mation such that ( t ′ 1 , x ′ 1 , y ′ 1 ) = (0 , 0 , 0) a nd that the line- s egment co nnecting ( t ′ 1 , x ′ 1 , y ′ 1 ) and ( t ′ 2 , x ′ 2 , y ′ 2 ) is p erp endicular to the y -a x is, i.e., y ′ 2 = 0. This tr ansformation is a comp osition of a transla tion in R × R 2 , a spa tial r otation in R 2 and a scaling in R × R 2 [Kuijpe r s and Othman 20 07]. Let the co ordinates w itho ut a prime b e the original se t, and let co or dinates with a prime be the ima ge of the same co ordinates AC M Journ al Name, V ol. V, No. N, 20YY. 20 · without a pr ime under this tr a nsformation. Note that we do not need to transfor m back b ecause the query is inv a riant under such tra nsformations [Kuijp ers and O th- man 200 7]. The following formula returns the transformed co or dina tes ( t ′ , x ′ , y ′ ) of ( t, x, y ) g iv en the p oints ( t 1 , x 1 , y 1 ) and ( t 2 , x 2 , y 2 ): ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t, x, y , t ′ , x ′ , y ′ ) := ( y 2 6 = y 1 ∧ t ′ = ( t − t 1 ) p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ∧ x ′ = ( x − x 1 )( x 2 − x 1 ) +( y − y 1 )( y 2 − y 1 ) ∧ y ′ = ( x − x 1 )( y 1 − y 2 ) + ( y − y 1 )( x 2 − x 1 )) ∨ ( y 2 = y 1 ∧ t ′ = ( t − t 1 ) ∧ x ′ = ( x − x 1 ) ∧ y ′ = ( y − y 1 )) . The tra nslation is ov er the vector ( − t 1 , − x 1 , − y 1 ), the rotation ov er minus the angle that ( t 2 − t 1 , x 2 − x 1 , y 2 − y 1 ) makes with the x -axis, a nd a scaling by a fa c to r p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 . Notice that the r otation a nd sc a ling only need to o c c ur if y 2 is no t alr eady in place, i.e., if y 2 6 = y 1 . The formula ψ cr d ( t ′ 1 , x ′ 1 , y ′ 1 , t 1 , x 1 , y 1 , t ′ 2 , x ′ 2 , y ′ 2 , t 2 , x 2 , y 2 , t ′ 3 , x ′ 3 , y ′ 3 , t 3 , x 3 , y 3 , t ′ 4 , x ′ 4 , y ′ 4 , t 4 , x 4 , y 4 ) is shor t for ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t 1 , x 1 , y 1 , t ′ 1 , x ′ 1 , y ′ 1 ) ∧ ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t 2 , x 2 , y 2 , t ′ 2 , x ′ 2 , y ′ 2 ) ∧ ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t 3 , x 3 , y 3 , t ′ 3 , x ′ 3 , y ′ 3 ) ∧ ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t 4 , x 4 , y 4 , t ′ 4 , x ′ 4 , y ′ 4 ). This transfor mation yields some simple equations for the rim ρ B 1 : ρ B 1 ↔ x 2 + y 2 = t 2 v 2 1 2 x ( − x ′ 2 ) + x ′ 2 2 = v 2 1 (2 t ( − t ′ 2 ) + t ′ 2 2 ) 0 ≤ t ≤ t ′ 2 . Not only that, but with these equations we c a n deduce a s imple parametriza tion in the x -co ordinate for the r im, ρ B 1 ↔ t = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 v 2 1 t ′ 2 y = ± r v 2 1 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 v 2 1 t ′ 2 2 − x 2 0 ≤ t ≤ t ′ 2 . W e remark that this implies t ′ 2 6 = 0 and v 1 6 = 0. If t ′ 2 = 0, then B 1 is a p oint, hence degenerate. If v 1 = 0 , then B 1 is a line segment, and aga in degenerate. Next we will inject these parameteriza tions in the co nstraints for ∂ B + 2 and ∂ B − 2 separately . The constraints for ∂ B − 2 are ( x − x ′ 3 ) 2 + ( y − y ′ 3 ) 2 = ( t − t ′ 3 ) 2 v 2 2 2 x ( x ′ 3 − x ′ 4 ) + x ′ 2 4 − x ′ 2 3 + 2 y ( y ′ 3 − y ′ 4 ) + y ′ 2 4 − y ′ 2 3 ≤ v 2 2 2 t ( t ′ 3 − t ′ 4 ) + t ′ 2 4 − t ′ 2 3 t ′ 3 ≤ t ≤ t ′ 4 . W e will explain how to pro ceed to compute the intersection w ith ∂ B − 2 and simply reuse for m ula s fo r intersection with ∂ B + 2 . First, we insert our expressions fo r x and y in the first equation. This is equiv alent to computing in tersections of ρ B 1 with C − 2 and g iv es ( x − x ′ 3 ) 2 + ± s v 2 1 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 v 2 1 t ′ 2 2 − x 2 − y ′ 3 2 AC M Journal Name , V ol. V, No. N, 20YY. · 21 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 v 2 1 t ′ 2 − t ′ 3 2 v 2 2 , or equiv alently ± 2 y ′ 3 q v 2 1 (2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ) 2 − (2 v 2 1 t ′ 2 ) 2 x 2 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 2 v 2 1 t ′ 2 t ′ 3 2 v 2 2 − 2 v 2 1 t ′ 2 2 ( x − x ′ 3 ) 2 − 2 v 2 1 t ′ 2 2 y ′ 2 3 − v 2 1 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 − 2 v 2 1 t ′ 2 2 x 2 or equiv alently ± v 1 2 y ′ 3 q x 2 4 ( x ′ 2 2 − v 2 1 t ′ 2 2 ) + x 4 x ′ 2 2 ( v 2 1 t ′ 2 2 − x ′ 2 2 ) + ( v 2 1 t ′ 2 2 − x ′ 2 2 ) 2 = x 2 4 x ′ 2 2 v 2 2 − v 2 1 + x 4 − x ′ 2 2 v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 + 2 v 4 1 t ′ 2 2 x ′ 3 + v 2 1 x ′ 2 v 2 1 t ′ 2 2 − x ′ 2 2 + v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 2 − 4 v 4 1 t ′ 2 2 x ′ 2 3 + y ′ 2 3 − v 4 1 − x ′ 2 2 + v 2 1 t ′ 2 2 . By s quaring left and right hand in this last ex pr ession, we rid ourselves of the square ro ot a nd obtain the following p olyno mial equation o f degree four . Squaring may cr eate new solutions, so to ensure we o nly get useful solutions, we hav e to add the condition that the square ro ot e x ists. This is the ca se if and only if φ √ ( x, t ′ 2 , x ′ 2 , v 1 ) := x 2 4 x ′ 2 2 − v 2 1 t ′ 2 2 + x 4 x ′ 2 2 v 2 1 t ′ 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − x ′ 2 2 2 ≥ 0 is sa tisfied. W e no tice that if B 1 is de g enerate, i.e., x ′ 2 2 = v 2 1 t ′ 2 2 , then the square ro ot v anishes and the p olynomial in φ 4 is the square of a p olynomial of de g ree tw o , yielding to at mo st tw o ro ots and intersection p oints as we exp ect. The case were v 1 = 0 is captured b y the formula in the next sec tion, that is why we leav e that ca s e out here a nd demand that v 1 6 = 0. So the following s till works if one or b oth b eads is degenerate: φ 4 ( x, t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) := ∃ a ∃ b ∃ c ∃ d ∃ e ax 4 + b x 3 + c x 2 + dx + e = 0 ∧ a = 4 x ′ 2 2 v 2 2 − v 2 1 2 ∧ b = − 32 x ′ 4 2 v 2 2 v 2 2 − v 2 1 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 +2 v 4 1 t ′ 2 2 x ′ 3 + v 2 1 x ′ 2 v 2 1 t ′ 2 2 − x ′ 2 2 ∧ c = 8 x ′ 2 2 − v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 x ′ 2 3 + y ′ 2 3 + + v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 2 − v 4 1 − x ′ 2 2 + v 2 1 t ′ 2 2 + (2 v 1 y ′ 3 ) 2 x ′ 2 2 − v 2 1 t ′ 2 2 + 4 − x ′ 2 2 v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 + 2 v 4 1 t ′ 2 2 x ′ 3 + v 2 1 x ′ 2 v 2 1 t ′ 2 2 − x ′ 2 2 2 ∧ d = 8 − x ′ 2 2 v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 + 2 v 4 1 t ′ 2 2 x ′ 3 + v 2 1 x ′ 2 v 2 1 t ′ 2 2 − x ′ 2 2 v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 2 − 4 v 4 1 t ′ 2 2 x ′ 2 3 + y ′ 2 3 − v 4 1 − x ′ 2 2 + v 2 1 t ′ 2 2 + ( 2 v 1 y ′ 3 ) 2 4 x ′ 2 2 v 2 1 t ′ 2 2 − x ′ 2 2 ∧ e = (2 v 1 y ′ 3 ) 2 v 2 1 t ′ 2 2 − x ′ 2 2 2 + v 2 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 4 v 4 1 t ′ 2 2 t ′ 3 2 − 4 v 4 1 t ′ 2 2 x ′ 2 3 + y ′ 2 3 − v 4 1 − x ′ 2 2 + v 2 1 t ′ 2 2 2 . AC M Journ al Name, V ol. V, No. N, 20YY. 22 · The quantifiers we in tro duced here are o nly in plac e for esthetical considera tio ns and ca n b e eliminated by direc t substitution. W e note that if v 1 = v 2 , w e get p olynomials of degree merely t wo. This can b e solved in an exa ct manner using nes ted square ro ots (or Maple if you will). This gives us at mos t fo ur v alues for x . Let φ r oots ( x a , x b , x c , x d , t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) be a formula that r eturns all four rea l ro ots, if they exist, that s atisfy b oth φ 4 ( x, t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) and φ √ ( x, t ′ 2 , x ′ 2 , v 1 ). W e substitute these v alues in the parameter equations of ρ B 1 . By substituting these in the last equation ab ov e, we can deter- mine the sign of the squa re ro ot we need to ta k e for y . A p oint ( t, x, y ) satisfies the following formula is a p oint on ρ B 1 , but instead of using the square ro ot for y , we use an express io n fr om ab ov e to get the cor r ect sign for the squa re ro ot if y ′ 3 6 = 0. If y ′ 3 = 0 we have to use the s quare ro ot ex pression and then it do es not ma tter which sign the square ro ot has; we nee d both: ψ ρ ( t, x, y , t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) := y ′ 3 6 = 0 ∧ t 2 v 2 1 t ′ 2 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ∧ 2 y ′ 3 2 v 2 1 t ′ 2 y = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 2 v 2 1 t ′ 2 t ′ 3 2 v 2 2 − 2 v 2 1 t ′ 2 2 ( x − x ′ 3 ) 2 − 2 v 2 1 t ′ 2 2 y ′ 2 3 − v 2 1 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 − 2 v 2 1 t ′ 2 2 x 2 ∧ 0 ≤ t ≤ t ′ 2 ∨ y ′ 3 = 0 ∧ t 2 v 2 1 t ′ 2 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ∧ 0 ≤ t ≤ t ′ 2 ∧ 2 v 2 1 t ′ 2 2 y 2 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 − 2 v 2 1 t ′ 2 2 x 2 . The four r oo ts give us four spatio- tempora l p oints on ρ B 1 ∩ C − 2 . In order for these p oint s ( t, x, y ) to be in ρ B 1 ∩ ∂ B − 2 , they need to satisfy ψ − ( t, x, y , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) := 2 x ( x ′ 3 − x ′ 4 ) + x ′ 2 4 − x ′ 2 3 + 2 y ( y ′ 3 − y ′ 4 ) + y ′ 2 4 − y ′ 2 3 ≤ v 2 2 2 t ( t ′ 3 − t ′ 4 ) + t ′ 2 4 − t ′ 2 3 . This formula returns True if ( t, x, y ) lies in the sa me half space as the b ottom-half bea d. C − 2 ρ B 1 B − 2 Fig. 11. The ri m i n tersects the cone and solutions are verified i n a half -space. The fo r m ula ψ + returns True if ( t, x, y ) lies in the sa me half space as the upper -half be a d, i.e., ψ + ( t, x, y , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) := ψ − ( t, x, y , t ′ 4 , x ′ 4 , y ′ 4 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ). By co m bining ψ ρ ( t, x, y , t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) a nd ψ − ( t, x, y , ˆ t, ˆ x, ˆ y , ˜ t, ˜ x, ˜ y , v ) we get a formula that decides the emptyness of the intersection ρ B 1 ∩ ∂ B − 2 in terms o f a par ameter x : ψ ρ ∩ ∂ ± ( x, t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 , ˆ t, ˆ x, ˆ y , ˜ t, ˜ x, ˜ y , v ) := AC M Journal Name , V ol. V, No. N, 20YY. · 23 ∃ y y ′ 3 = 0 ∧ y 2 2 v 2 1 t ′ 2 2 = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 v 2 1 − 2 v 2 1 t ′ 2 2 x 2 ∨ y ′ 3 6 = 0 ∧ 2 y ′ 3 2 v 2 1 t ′ 2 y = 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 − 2 v 2 1 t ′ 2 t ′ 3 2 v 2 2 − 2 v 2 1 t ′ 2 2 ( x − x ′ 3 ) 2 − 2 v 2 1 t ′ 2 2 y ′ 2 3 − v 2 1 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 2 − 2 v 2 1 t ′ 2 2 x 2 ∧ 2 x ( ˆ x − ˜ x ) + ˜ x 2 − ˆ x 2 + 2 y ( ˆ y − ˜ y ) + ˜ y 2 − ˆ y 2 2 v 2 1 t ′ 2 ≤ v 2 2 2 v 2 1 t ′ 2 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ( ˆ t − ˜ t ) + 2 v 2 1 t ′ 2 ˜ t 2 − ˆ t 2 ∧ 0 ≤ t ′ 2 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ≤ 2 v 2 1 t ′ 3 2 ∧ ˆ t 2 v 2 1 t ′ 2 2 ≤ t ′ 2 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ≤ ˜ t 2 v 2 1 t ′ 2 2 ∨ ˜ t 2 v 2 1 t ′ 2 2 ≤ t ′ 2 2 xx ′ 2 − x ′ 2 2 + v 2 1 t ′ 2 2 ≤ ˆ t 2 v 2 1 t ′ 2 2 . W e are ready now to cons tr uct the formula that de c ides if ρ B 1 and B − 2 hav e a non-empty int ersection: ϕ ρ 1 ∩ ∂ − 2 ( t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) := ∃ x ∃ x a ∃ x b ∃ x c ∃ x d ( φ r oots ( x a , x b , x c , x d , t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 ) ∧ ( x = x a ∨ x = x b ∨ x = x c ∨ x = x d ) ∧ ψ ρ ∩ ∂ ± ( x, t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , v 2 , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v ′ 2 ) . The formula that decides if ρ B 1 int ersects ∂ B + 2 lo oks striking ly similar : ϕ ρ 1 ∩ ∂ + 2 ( t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) := ∃ x ∃ x a ∃ x b ∃ x c ∃ x d ( φ r oots ( x a , x b , x c , x d , t ′ 2 , x ′ 2 , v 1 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) ∧ ( x = x a ∨ x = x b ∨ x = x c ∨ x = x d ) ∧ ψ ρ ∩ ∂ ± ( x, t ′ 2 , x ′ 2 , v 1 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 , t ′ 4 , x ′ 4 , y ′ 4 , t ′ 3 , x ′ 3 , y ′ 3 , v ′ 2 ) . The quantifiers in tro duced here can also b e eliminated in a straightforward man- ner. Notice that φ r oots acts as a function rather than a formula that inputs ( t ′ 2 , x ′ 2 , v 1 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) to constr uct a p olynomial of degree four and r eturns the four ro ots ( x a , x b , x c , x d ), if they exist, of tha t po ly nomial. The ex is ten tia l quan- tifier for the v ar ia ble x is used to c y cle through tho s e ro ots to see if any of them do es the trick. Finally we a re re a dy to present the formula for Case (I I) : Φ I I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := ( v 1 6 = 0 ∧ v 2 6 = 0) ∧ ¬ Φ I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) ∧ ∃ t ′ 1 ∃ x ′ 1 ∃ y ′ 1 ∃ t ′ 2 ∃ x ′ 2 ∃ y ′ 2 ∃ t ′ 3 ∃ x ′ 3 ∃ y ′ 3 ∃ t ′ 4 ∃ x ′ 4 ∃ y ′ 4 ( ψ cr d ( t ′ 1 , x ′ 1 , y ′ 1 , t 1 , x 1 , y 1 , t ′ 2 , x ′ 2 , y ′ 2 , t 2 , x 2 , y 2 , t ′ 3 , x ′ 3 , y ′ 3 , t 3 , x 3 , y 3 , t ′ 4 , x ′ 4 , y ′ 4 , t 4 , x 4 , y 4 ) ∧ ϕ ρ 1 ∩ ∂ − 2 ( t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v ′ 2 ) ∨ ϕ ρ 1 ∩ ∂ + 2 ( t ′ 2 , x ′ 2 , v 1 , t ′ 3 , x ′ 3 , y ′ 3 , t ′ 4 , x ′ 4 , y ′ 4 , v 2 ) ∨ ψ cr d ( t ′ 3 , x ′ 3 , y ′ 3 , t 3 , x 3 , y 3 , t ′ 4 , x ′ 4 , y ′ 4 , t 4 , x 4 , y 4 , t ′ 1 , x ′ 1 , y ′ 1 , t 1 , x 1 , y 1 , t ′ 2 , x ′ 2 , y ′ 2 , t 2 , x 2 , y 2 ) ∧ ϕ ρ 1 ∩ ∂ − 2 ( t ′ 3 , x ′ 3 , v 2 , t ′ 1 , x ′ 1 , y ′ 1 , t ′ 2 , x ′ 2 , y ′ 2 , v ′ 1 ) ∨ ϕ ρ 1 ∩ ∂ + 2 ( t ′ 3 , x ′ 3 , v 2 , t ′ 1 , x ′ 1 , y ′ 1 , t ′ 2 , x ′ 2 , y ′ 2 , v ′ 1 ) . The rea der may no tice that a lot of quantifiers hav e b een introduced in the for - m ula ab ov e. These quantifiers ar e merely there to intro duce easier co ordinates a nd can b e str aightf orwardly computed (and eliminated) by the formula ψ cr d and hence AC M Journ al Name, V ol. V, No. N, 20YY. 24 · the formula ϕ A ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , t, x, y , t ′ , x ′ , y ′ ). The latter ac tually acts like a function, para meterized by ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 ), that inputs ( t, x, y ) and o utputs ( t ′ , x ′ , y ′ ). 5.5 A formula for Cas e (I II) Here, we as sume that bo th ϕ I and ϕ I I fail. So, there is no ap ex contained in the other be a d a nd neither r im cuts the mantel of the other b ead. As we proved in Theorem 1, the intersection be t ween tw o half b eads will re duce to the intersection b et ween tw o co nes and that means there is an initial contact that is pa rt of the intersection. T o verify if this is the case we compute the tw o initial contacts and verify if they are effectively par t of the int ersection. Using the expres sion for the initial con tact IC ( C − 1 , C − 2 ), we computed in Sec- tion 4.2 w e can construct a form ula that decides if it is part o f B − 1 ∩ B − 2 . W e will recycle the fo r m ula s ψ − from the pre v ious section to construct an expr ession without the need for extra v ar iables. The following formula that returns True if IC ( C − 1 , C − 2 ) = ( t 0 , x 0 , y 0 ) satisfies ψ − ( t 0 , x 0 , y 0 , t ′ , x ′ , y ′ , ˆ t, ˆ x, ˆ y , v ): φ − ( t 1 , x 1 , y 1 , v 1 , t 3 , x 3 , y 3 , v 2 , t ′ , x ′ , y ′ , ˆ t, ˆ x, ˆ y , v ) := 2( x ′ − ˆ x ) ( x 1 v 2 + x 3 v 1 ) p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + v 1 (( t 3 − t 1 ) v 2 ) ( x 3 − x 1 ) + 2 ( y ′ − ˆ y ) ( y 1 v 2 + y 3 v 1 ) p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + v 1 (( t 3 − t 1 ) v 2 ) ( y 3 − y 1 ) + p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 ( v 1 + v 2 ) ˆ x 2 − x ′ 2 + ˆ y 2 − y ′ 2 ≤ v 2 ˆ t 2 − t ′ 2 ( v 1 + v 2 ) + 2 p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + t 1 v 1 + t 3 v 2 t ′ − ˆ t p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 . The following fo r m ula expr esses that the time co ordinate t 0 of IC ( C − 1 , C − 2 ) satisfies the constraints t ′ ≤ t ≤ t ′′ and ˆ t ≤ t ≤ ˇ t : ψ t t 1 , x 1 , y 1 , v 1 , t 3 , x 3 , y 3 , v 2 , t ′ , t ′′ , ˆ t, ˇ t := t ′ ( v 1 + v 2 ) ≤ p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + t 1 v 1 + t 3 v 2 ≤ t ′′ ( v 1 + v 2 ) ∧ ˆ t ( v 1 + v 2 ) ≤ p ( x 1 − x 3 ) 2 + ( y 1 − y 3 ) 2 + t 1 v 1 + t 3 v 2 ≤ ˇ t ( v 1 + v 2 ) . Now, IC ( C − 1 , C − 2 ) ⊂ B − 1 ∩ B − 2 if and only if ψ IC − ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) where ψ IC − ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := ψ t ( t 1 , x 1 , y 1 , v 1 , t 3 , x 3 , y 3 , v 2 , t 1 , t 2 , t 3 , t 4 ) ∧ φ − ( t 1 , x 1 , y 1 , v 1 , t 3 , x 3 , y 3 , v 2 , t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) ∧ φ − ( t 1 , x 1 , y 1 , v 1 , t 3 , x 3 , y 3 , v 2 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) a nd IC ( C + 1 , C + 2 ) ⊂ B + 1 ∩ B + 2 if and only if ψ IC + ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := ψ t ( t 2 , x 2 , y 2 , v 1 , t 4 , x 4 , y 4 , v 2 , t 1 , t 2 , t 3 , t 4 ) ∧ φ − ( t 2 , x 2 , y 2 , v 1 , t 4 , x 4 , y 4 , v 2 , t 2 , x 2 , y 2 , t 1 , x 1 , y 1 , v 1 ) ∧ φ − ( t 2 , x 2 , y 2 , v 1 , t 4 , x 4 , y 4 , v 2 , t 4 , x 4 , y 4 , t 3 , x 3 , y 3 , v 2 ). The formula that expresses the criterium for Cas e (I I I) then lo oks as follows: Φ I II ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := ( v 1 + v 2 6 = 0) ∧ ¬ Φ I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) ∧ ( ψ IC − ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) ∨ ψ IC + ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 )) . AC M Journal Name , V ol. V, No. N, 20YY. · 25 5.6 The formula for the parametric alibi query The final f ormula that decides if t wo b eads, B 1 = B ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) and B 2 = B ( t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ), do no t intersect lo ok s as follows ψ alibi ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) := ¬ (( t 1 < t 2 ∧ t 3 < t 4 ) ∧ (Φ I II ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) ∨ Φ I I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 )) ∨ Φ I ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 , t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 )) . 6. EXPERIMENT S In this section, we co mpare our solutionto the alibi query (using the formula given in Section 5 .6) with the metho d of eliminating qua n tifier s of Mathematica. In the following table it is clear that traditiona l quantifier e limina tion p erfor ms badly o n the exa mple b eads. Its r unning times highly deviates from their av er age and rang e in the min utes. Whereas the metho d des cribed in this pap er p erforms in running times that cons is ten tly only needs milliseconds or less. This shows our metho d is efficien t and o ur claim, that it runs in milliseco nds or les s , holds. F or this first set of b eads we chose to verify intersection of tw o oblique b eads (1-2) and the intersection of one oblique and o ne straight be a d (3-4 ). The b eads that ac tua lly int ersected had a remark able low running time with the QE-metho d. The b eads The running times B 1 B 2 QE Our Metho d 1 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (0 , 3 , 0 , 2 , 3 , 2 , 2) 0 . 656 Seconds 0 . 016 Seconds 2 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (0 , 4 , 0 , 2 , 4 , 2 , 2) 324 . 453 Seconds 0 . 063 Seconds 3 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (0 , 3 , 0 , 2 , 3 , 0 , 2) 0 . 438 Seconds 0 . 015 Seconds 4 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (0 , 4 , 0 , 2 , 4 , 0 , 2) 475 . 719 Seconds 0 . 031 Seconds The type of b eads in this seco nd s et are a s in the first. How ever, these b eads all have overlapping time interv als unlike the first s e t, wher e the time int erv als coincided. The b eads The running times B 1 B 2 QE Our Metho d 1 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (1 , 3 , 0 , 3 , 3 , 2 , 2) 63 . 375 Seco nds 0 . 078 Seconds 2 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (1 , 4 , 0 , 3 , 4 , 2 , 2) 59 . 485 Seco nds 0 . 078 Seconds 3 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (1 , 3 , 0 , 3 , 3 , 0 , 2) 29 . 734 Seco nds 0 . 031 Seconds 4 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (1 , 4 , 0 , 3 , 4 , 0 , 2) 27 . 281 Seco nds 0 . 032 Seconds The type of b eads in this third set a re as in the first. But this time the time int erv als are completely disjoint. Note that the running times for the QE- method are more co nsistent in this s et a nd the previous one. The b eads The running times B 1 B 2 QE Our Metho d 1 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (3 , 3 , 0 , 4 , 3 , 2 , 2) 63 . 641 Seco nds 0 . 046 Seconds 2 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (3 , 4 , 0 , 4 , 4 , 2 , 2) 61 . 781 Seco nds 0 . 016 Seconds 3 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (3 , 3 , 0 , 4 , 3 , 0 , 2) 52 . 735 Seco nds 0 . 031 Seconds 4 (0 , 0 , 0 , 2 , 0 , 2 , 1 . 9 ) (3 , 4 , 0 , 4 , 4 , 0 , 2) 56 . 875 Seco nds 0 . 046 Seconds AC M Journ al Name, V ol. V, No. N, 20YY. 26 · 7. THE ALIBI QUERY A T A FIXED MOMENT IN TIM E 7.1 Introdu ction In this section, we present another example where common se ns e prev ails over the general q uan tifier-elimination metho ds. The problem is the following. As in the previous setting, we hav e lists of time stamp ed-lo cations o f tw o moving o b jects and upper b ounds on the ob ject’s sp eed b etw een time s tamps. W e wish to know if tw o ob jects could have met a t a g iv en moment in time. F or the remainder of this sec tion, we re use the assumptions from the previous section. W e wish to verify if the b eads B 1 = B ( t 1 , x 1 , y 1 , t 2 , x 2 , y 2 , v 1 ) a nd B 2 = B ( t 3 , x 3 , y 3 , t 4 , x 4 , y 4 , v 2 ) intersect at a moment in time t 0 . Moreov e r, we assume the b eads are non-empty , i.e., ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ≤ ( t 2 − t 1 ) 2 v 2 1 and ( x 4 − x 3 ) 2 + ( y 4 − y 3 ) 2 ≤ ( t 4 − t 3 ) 2 v 2 2 and that t 1 ≤ t 0 ≤ t 2 and t 3 ≤ t 0 ≤ t 4 are satisfied. This means we nee d to eliminate the q ua n tifier s in ∃ x ∃ y ( x − x 1 ) 2 + ( y − y 1 ) 2 ≤ v 2 1 ( t 0 − t 1 ) 2 ∧ ( x − x 2 ) 2 + ( y − y 2 ) 2 ≤ v 2 1 ( t 0 − t 2 ) 2 ∧ ( x − x 3 ) 2 + ( y − y 3 ) 2 ≤ v 2 2 ( t 0 − t 3 ) 2 ∧ ( x − x 4 ) 2 + ( y − y 4 ) 2 ≤ v 2 2 ( t 0 − t 4 ) 2 . Eliminating quantifi ers gives us a formula that decide whether or not four discs hav e a no n-empt y intersection. F or ease of no tation we will use the following ab- breviations: ( x, y ) ∈ D i if and only if ( x − x i ) 2 + ( y − y i ) ≤ r 2 i and ( x, y ) ∈ C i if and o nly if ( x − x i ) 2 + ( y − y i ) = r 2 i . 7.2 Main the o rem Using Helly’s theorem we can simplify the problem even more. Helly’s theorem states that if you have a set S of m co n vex sets in n dimensional space a nd if any subset of S o f n + 1 convex sets has a non- empt y intersection, then a ll m co n vex se ts hav e a non- empt y intersection. F or the plane, this means we only need to find a quantifier free- formu la that dec ides if thre e discs hav e a non-empty intersection. F or the rema inder o f this section assume that we wan t to verify whether D 1 ∩ D 2 ∩ D 3 is no n-empt y . The or em 2. Three discs , D 1 , D 2 and D 3 , hav e a non- empt y intersection if a nd only if o ne of the following cases o ccur : (1) there is a disc whose center is in the other tw o discs; or (2) the previo us case do es not o ccur and there exists a pa ir of disc s for which one of b oth intersection p oints of their b order ing circles lies in the remaining disc. Proof. The if -direc tio n is trivia l. The only if -direction is less trivial. W e will use the following abbreviatio ns, D = D 1 ∩ D 2 ∩ D 3 and C = ∂ D . Assume D is non-empty a nd that neither (1 ) nor (2) holds. The intersection D is conv ex as it is the intersection of co n vex s e ts. W e distinguish betw een the case where D is a p oint or and the case where D is not a p oint. —Suppo s e D is a single p oint p . This po in t p can no t lie in the interior of the thr ee discs, beca use D would not be a p oint then. Nor can p lie in the interior of t wo disc s . If that would b e the case then there exists a neighborho o d of p that is pa rt o f the intersection of those tw o discs, AC M Journal Name , V ol. V, No. N, 20YY. · 27 say D 1 and D 2 . Mor eov er p would b e part o f C 3 and this neighborho o d would int ersect the interior of D 3 . T his means D is no t a p oint. So p must lie on the b orde r of tw o discs, say D 1 and D 2 , and p must also b e pa rt of D 3 bec ause D = { p } . This contradicts o ur a s sumption that (2) do es not ho ld. —Assume D is not a p oint. All p oints on C belo ng to at lea st one C i . I f there is a po in t that do es not b e lo ng to a n y C i , then it is in the int erior of all D i and there exists a neighbor ho o d of tha t p oint that is in the int erior of all D i and hence in D . That c o n tradicts to the fact that this p oint is in C . F urthermore, not all p oint s of C b e long to a single C i . If that was the case then D i would b e par t of (and equal to) D and its center w ould b e inside the other t wo discs which contradicts the assumption that (1) do es not hold. So, C is made up of parts of the C i , of which some may coincide but not all of them. When traveling along C you will encounter a po in t p that connects part of a C i and part of a C j , where i 6 = j , that do not co incide, otherwise (1) must o ccur again which is a co n tr a diction. How ever, this p a lso yields to a contradiction since it belo ngs to tw o different C i , say C 1 and C 2 , and is part of C hence D and D 3 . This contradicts the assumption that (2) do es not o ccur . 7.3 T ranslating the theorem in a formula W e can simplify the equations even fur ther us ing c o o r dinate transformations. By applying a translation, rota tion and scaling we may assume that ( x 1 , y 1 ) = (0 , 0), x 2 ≥ 0, r 1 = 1 and y 2 = 0. Using these s implifica tions and tr anslating Theorem 2, we g et the fo llo wing formula. Ψ 1 ( x 2 , r 2 , x 3 , y 3 , r 3 ) := ( − x 2 ) 2 ≤ r 2 2 ∧ ( − x 3 ) 2 + ( − y 3 ) 2 ≤ r 2 3 ∨ ∃ x ∃ y x 2 + y 2 = 1 ∧ ( x − x 2 ) 2 + y 2 = r 2 2 ∧ ( x − x 3 ) 2 + ( y − y 3 ) 2 ≤ r 2 3 . This is a for m ula that de c ides if either the center of the first disc is part of the t wo other discs, see the first line, or if either there exists a p oint in the in ter section o f the fir st tw o circles that is part of the third disc. All that remains now is making the expressio n ∃ x ∃ y x 2 + y 2 = 1 ∧ ( x − x 2 ) 2 + y 2 = r 2 2 ∧ ( x − x 3 ) 2 + ( y − y 3 ) 2 ≤ r 2 3 quantifier free. T o do this we assume that C 1 and C 2 do not coincide but hav e a non-empty int ersection. This is equiv alent to x 2 6 = 0 ∧ x 2 ≤ r 2 + 1. Next, we need to compute the po in t(s) wher e C 1 and C 2 int ersect. x 2 + y 2 = 1 ( x − x 2 ) 2 + y 2 = r 2 2 or x = x 2 2 +1 − r 2 2 2 x 2 y = ± r 1 − x 2 2 +1 − r 2 2 2 x 2 2 or x = x 2 2 +1 − r 2 2 2 x 2 y = ± r 1 − x 2 2 +1 − r 2 2 2 x 2 1 + x 2 2 +1 − r 2 2 2 x 2 AC M Journ al Name, V ol. V, No. N, 20YY. 28 · or x = x 2 2 +1 − r 2 2 2 x 2 y = ± 1 2 x 2 r r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 . If y = 0, then verifying if that single p oint of intersection is part of D 3 is easy , one only needs to verify if x 2 2 + 1 − r 2 2 2 x 2 − x 2 2 + y 2 3 ≤ r 2 3 or equiv alently 1 − r 2 2 − x 2 2 2 + 4 x 2 2 y 2 3 ≤ 4 x 2 2 r 2 3 . If y 6 = 0, then verifying if o ne b oth p oint s of in tersection is pa rt of D 3 is less triv ia l, since this in volves square r o o ts x 2 2 + 1 − r 2 2 2 x 2 − x 3 2 + ± 1 2 x 2 r r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 − y 3 ! 2 ≤ r 2 3 x 2 2 + 1 − r 2 2 − 2 x 2 x 3 2 + ± r r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 − 2 x 2 y 3 ! 2 ≤ 4 x 2 2 r 2 3 or x 2 2 + 1 − r 2 2 − 2 x 2 x 3 2 + r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 +(2 x 2 y 3 ) 2 ± 4 x 2 y 3 r r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 ≤ 4 x 2 2 r 2 3 or x 2 2 + 1 − r 2 2 − 2 x 2 x 3 2 + r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 +(2 x 2 y 3 ) 2 − 4 x 2 2 r 2 3 ≤ ± 4 x 2 y 3 r r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 . This is almost a FO (+ , × , < , 0 , 1)-formula except for the square r oo t. How ever, the squa re ro ot can b e eliminated as we will show next. The pr evious expressio n is of the fo r m L ≤ ± a √ W . The presence of the ± simplifies this a lot, this means either sign of the square r o o t will do, a nd also that we may assume the right hand- side is po sitive. Of co urse the squar e ro ot must exist as well, this means W ≥ 0. This expressio n can then b e simplified to W ≥ 0 ∧ L ≤ 0 ∨ L 2 ≤ a 2 W and g iv es us the expr e ssion Φ 2 ( x 2 , r 2 , x 3 , y 3 , r 3 ) := r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 ≥ 0 ∧ x 2 2 + 1 − r 2 2 − 2 x 2 x 3 2 + r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 + (2 x 2 y 3 ) 2 − 4 x 2 2 r 2 3 ≤ 0 ∨ x 2 2 + 1 − r 2 2 − 2 x 2 x 3 2 + r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 +(2 x 2 y 3 ) 2 − 4 x 2 2 r 2 3 2 ≤ ( 4 x 2 y 3 ) 2 r 2 2 − ( x 2 − 1 ) 2 (1 + x 2 ) 2 − r 2 2 . AC M Journal Name , V ol. V, No. N, 20YY. · 29 7.4 The sa fety for mula Now, all that remains to b e constructed is a for m ula that r eturns the conv enient co ordinates and a for m ula that guara n tees that C 1 and C 2 actually int ersect for safety , i.e., to exclude the ca se of empt y in tersection. The latter is constructed as follows. The formula ϕ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) r eturns True if and o nly if the tw o circles, with centers ( x 1 , y 1 ) and ( x 2 , y 2 ) and r a dii r 1 and r 2 resp ectively , hav e a distance b etw een their ce n ter s that is not la rger that the sum of their r a dii and not equal to zero to ensure they do not coincide. W e hav e ϕ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) := 0 < ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ≤ ( r 1 + r 2 ) 2 . The formula φ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) returns True if and only if the second circle is not fully enclo sed by the firs t, i.e., the sum of the distance b et ween the c en ter s plus the second radius is bigger than the first radius and vice versa. W e can write φ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) := ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ≥ ( r 1 − r 2 ) 2 . These tw o s afet y co nditio ns give us our safety formula Φ safety ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) := ϕ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) ∧ φ ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) . 7.5 The ch a nge of co ordinates The tra nsformation consists of a tra nslation, rota tio n and scaling. The tra nslation to mov e the first circle’s center to the origin. The r otation to a lign the second center with the x -axis . Finally the sca ling to ensure that the first cir cle’s r adius is equal to one. First, the transla tion T ( x, y ) := ( x − x 1 , y − y 1 ) . The rotation is R ( x, y ) := 1 p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 x 2 − x 1 y 2 − y 1 y 1 − y 2 x 2 − x 1 x y and finally , the scaling is S ( x, y ) := 1 r 1 ( x, y ) . The trans fo rmation is then a comp o- sition o f thos e three tra nsformations A ( x, y ) = ( S ◦ R ◦ T )( x, y ) := ( x 2 − x 1 )( x − x 1 ) + ( y 2 − y 1 )( y − y 1 ) r 1 p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 , ( y 1 − y 2 )( x − x 1 ) + ( x 2 − x 1 )( y − y 1 ) r 1 p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ! . The following formula takes three circles with centers ( x i , y i ) and radii r i resp ec- tively , a nd transfor ms them in three new cir cles where the first c ir cle has center (0 , 0) a nd radius 1, the seco nd cir cle has center ( x ′ 2 , 0) a nd radius r ′ 2 and the thir d circle has center ( x ′ 3 , y ′ 3 ) and r adius r ′ 3 . Φ transformatio n ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 3 , y 3 , r 3 , x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) := x ′ 2 = p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 r 1 ∧ r ′ 2 = r 2 r 1 ∧ r ′ 3 = r 3 r 1 ∧ x ′ 3 = ( x 2 − x 1 )( x 3 − x 1 ) + ( y 2 − y 1 )( y 3 − y 1 ) r 1 p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ∧ y ′ 3 = ( y 1 − y 2 )( x 3 − x 1 ) + ( x 2 − x 1 )( y 3 − y 1 ) r 1 p ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 . AC M Journ al Name, V ol. V, No. N, 20YY. 30 · Note that this is no t a F O (+ , × , <, 0 , 1 )-formula anymore due to the square ro ots and fractions. This ” form ula” is mea n t to ac t like a function, which s ubstitutes co or - dinates. The substituted co ordinates have fra ctions and s q uare ro ots but these can easily b e disp osed of when having the entire inequality on a c o mmon denomina tor, isolating the squar e ro ot a nd squar ing the inequality , as we showed in Section 7.3. 7.6 The formula for the ali bi query at a fixed mo ment in time First, we constr uct a formula that chec ks for any o f tw o cir c les out of three if any of the conditions in Theorem 2 a re s a tisfied. Ψ 2/3 ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 3 , y 3 , r 3 ) := ∃ x ′ 2 ∃ r ′ 2 ∃ x ′ 3 ∃ y ′ 3 ∃ r ′ 3 ( Φ transformatio n ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 3 , y 3 , r 3 , x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∧ Ψ 1 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∨ Φ safety ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 ) ∧ Φ 2 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∨ Φ transformatio n ( x 1 , y 1 , r 1 , x 3 , y 3 , r 3 , x 2 , y 2 , r 2 , x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∧ Ψ 1 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∨ Φ safety ( x 1 , y 1 , r 1 , x 3 , y 3 , r 3 ) ∧ Φ 2 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∨ Φ transformatio n ( x 2 , y 2 , r 2 , x 3 , y 3 , r 3 , x 1 , y 1 , r 1 , x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∧ Ψ 1 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) ∨ Φ safety ( x 2 , y 2 , r 2 , x 3 , y 3 , r 3 ) ∧ Φ 2 ( x ′ 2 , r ′ 2 , x ′ 3 , y ′ 3 , r ′ 3 ) This formula is all we nee d to incorp orate Helly’s theo rem in o ur final formula. F our discs hav e a non-empty intersection if a nd o nly if the fo llowing fo rm ula is satisfied Ψ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 3 , y 3 , r 3 , x 4 , y 4 , r 4 ) := Ψ 2/3 ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 3 , y 3 , r 3 ) ∧ Ψ 2/3 ( x 1 , y 1 , r 1 , x 2 , y 2 , r 2 , x 4 , y 4 , r 4 ) ∧ Ψ 2/3 ( x 1 , y 1 , r 1 , x 3 , y 3 , r 3 , x 4 , y 4 , r 4 ) ∧ Ψ 2/3 ( x 2 , y 2 , r 2 , x 3 , y 3 , r 3 , x 4 , y 4 , r 4 ) . This is almost a qua n tifier free-for m ula except for the fractions a nd square r oo ts. How ever, as we showed b efore these ca n easily b e disp osed of. W e o mitted these tedious c on versions for the sake o f clarity . 8. CONCLUSION In this pap er, we pro p osed a metho d that decides if tw o b eads hav e a non-empty int ersection or not. Exis ting qua n tifier -elimination metho ds could achiev e this a l- ready thro ugh means of quantifi er elimination though no t in a reasonable amo unt of time. Deciding intersection of concr ete b eads to ok of the orde r of minutes, while the para metric case could b e mea sured at lea st in days if a solution would ever be obtained. The parametric solution we la id o ut in this pap er only takes a few milliseconds or less. The so lution we present is a first-orde r formula containing square r o o t-expressions. These can easily be disp osed of using re peated squa rings and adding extra condi- tions, thus obtaining a true quantifier free-e x pression for the alibi query . W e also give a solution to the alibi query at a fixed moment in time. The so lutio ns we pro pos e a re based on geometric argumentation and they illus- trate the fact tha t some pra ctical pro blems r equire cr eative so lutions, where a t lea st AC M Journal Name , V ol. V, No. N, 20YY. · 31 in theory , existing systems could pr ovide a solution. Acknowledgements This resear c h has b een partially funded by the Europ ean Union under the FP 6- IST-FET pr o gramme, Pro ject n. FP6-14 915, GeoPKDD: Geographic Priv acy- Aw are Knowledge Discovery and Delivery , and by the Resea r c h F oundatio n Flan- ders (FW O -Vlaanderen), Research Pro ject G.03 44.05. REFERENCES Basu, S. , R., P. , and Ro y, M.-F. 1996. On the combinato rial and algebraic complexity of quan tifier elimi nation. Journal of the ACM 43 , 1002–1045. Collins, G. 1975. Quan tifier elimination for r eal closed fields b y cylindrical algebraic decomp osi- tion. In Automata The ory and F ormal La nguages . Lecture Notes i n Computer Science, vol. 33. Springer-V erlag, 134–183. Egenhofer, M. 2003. Approximation of geopatial lifeli nes. In Sp adaGIS, Workshop on Sp atial Data and Ge o gr aphic Information Systsems . Uni v ers i t y of Geno v a. Electr. proceedings, 4p. Geer ts, F. 2004. Moving ob jects and their equations of motion. In Constr aint Datab ases, Pr o c e ed - ings of the 1st International Symp osium on Applic ations of Constr aint Datab ases, (CDB’04) . Lecture Notes in Computer Science, vol. 3074. Springer, 41–52. Grigor ’ev, D. and V orobjo v, N. N. j. 1988. Solving systems of p ol ynomial i nequalities in subexp onen tial time. Journal of Symb olic Computation 5 , 37–64. G ¨ uting, R. and Schneider, M. 2005. Moving Ob je ct Datab ases . M organ K aufmann. H ¨ agerstrand, T. 1970. What ab out people i n regional science? Pap ers of the R e g ional Science Asso ciation 24 , 7–21. Heintz, J . and Kuijpers, B. 2004. Constrain t databases, data structures and efficien t query ev aluation. In Constr aint Datab ases, Pr o c e e dings of t he 1st International Sy mp osium “Appli- c ations of Constr aint Datab ases” (CDB’04) . Lecture Notes i n Computer Science, vol. 3074. Springer-V erlag, 1–24. Heintz, J. , Roy, M.-F. , a nd Solern ´ o, P. 1990. Sur la complexit´ e du princip e de T arski- Seiden b erg. Bul letin de la So ci´ et´ e Math ´ ematiq ue de F r anc e 118 , 101–126. Hong, H. 1990. QEPCAD — quan tifier elimination by partial cylindrical al gebraic decomp osition. h ttp://www.cs.usna.edu/˜qe pcad/B/QEPCAD.html. Hornsby, K. and Egenh ofer, M. 2002. Mo deling moving ob jects ov er mu ltiple granularities. Anna ls of Mathematics and Artificial Intel ligenc e 36, 1–2, 177–194. Kanellakis, P. , Kuper, G . , and Revesz, P. 1995. Constraint query languages. Journal of Computer and Sy stem Sci enc e 51, 1, 26–52. A prelimi nar y r eport app eared i n the Pr o c e e dings 9th ACM Symp osium on Princ i ples of D atab ase Systems (PODS’90) . Kuijpers, B. a n d Othman , W. 2007. T ra j ecto ry databases: Data mo dels, uncertaint y and com- plete query languages. In Pr o c e e dings of the 11th Inte rnati onal Confer enc e on Datab ase The ory (ICDT’07) . Lecture Notes i n Computer Science, v ol. 4353. Springer-V erlag, 224–238. Miller, H. 2005. A m easuremen t theory for time geograph y . Geo gr aphic al Analysis 37, 1, 17–. P aredaens, J. , Kuper, G. , and Libkin, L. 2000. Constr aint datab ases . Springer-V erlag. P aredaens, J. , V an den Bussche, J. , and V an Gucht, D. 1994. T ow ards a theory of spatial database queries. In Pr o c e e dings o f the 13th ACM Symp osium on Princi ples of Datab ase Systems (PODS’94) . ACM Press, New Y ork, 279–288. Pfoser, D. an d Jen sen, C. S. 1999. Capturing the uncertaint y of moving-ob ject representations. In A dvanc e s in Sp atial Datab ases (SSD’99) . Lecture Notes in Computer Science, vol. 1651. 111– 132. Renegar, J. 1992. On the computational complexit y and geometry of the firs t- or der theory of the reals I, I I, I I I. Jornal of Symb olic Computation 13 , 255–352. Revesz, P. 2002. Intro duction t o Constr aint Datab ases . Springer-V erlag. Sturm, T. 2000. Redlog. http://www.algebra.fim.uni-passau.de/˜redlog/. AC M Journ al Name, V ol. V, No. N, 20YY. 32 · Su, J. , Xu, H. , and Ibarra, O. 2001. Moving ob jects: Logical r elationships and queries. In A dvanc es in Sp atial and T emp or al Datab ases (SSTD’01) . Lecture Notes in Computer Science, v ol. 2121. Springer, 3–19. T arski, A. 1951. A D e cision Metho d for Elementary Algebr a and Ge ometry . Universit y of California Press. W olfram . 2007. M athemat ica 6. htt p://www.wolfram.com. W olfson, O. 2002. Mo ving ob j ects information managemen t: The database challenge. I n Pr o- c e e dings of the 5th Intl. Workshop NGITS . Spri nger, 75–89. Appe ndix: T he Ma thema tica implementation The function alibi , using the metho d descr ibed in this pap er, retur ns True if the bea d with a p exes ( t 1 , x 1 , y 1) and ( t 2 , x 2 , y 2 ) and sp eed v 1 intersects the b ead with ap exes ( t 3 , x 3 , y 3) and ( t 4 , x 4 , y 4 ) and sp eed v 2 and False otherwise. The function alibiQE do es the same except it uses the built-in quantifier elimination metho d of Ma thema tica . Note that Case (I I) in our implementation corr espo nds to Case (I I I) in the description and vice versa. The reason for doing so is that Case (I I I) , in the description, is computationally a lot easier tha n Cas e (I I) . Mor e o ver, once any o f the thr ee ca ses retur ns Tr ue , our implementation exits a nd retur ns that result and th us omitting further computation. AC M Journal Name , V ol. V, No. N, 20YY. · 33 Needs @ "Miscellaneous`RealOnly` " D ; isBeadNonEmpty @ t1_ , x1_ , y1_ , t2_ , x2_ , y2_ , v_ D : = t1 £ t2 ß H x2 - x1 L ^ 2 + H y2 - y1 L ^ 2 £ v ^ 2 * H t2 - t1 L ^ 2 inbead @ t_, x_ , y_ , t1_ , x1_ , y1_ , t2_ , x2_ , y2_ , v_ D : = H x - x1 L ^ 2 + H y - y1 L ^ 2 £ v ^ 2 * H t - t1 L ^ 2 ß H x - x2 L ^ 2 + H y - y2 L ^ 2 £ v ^ 2 * H t - t2 L ^ 2 ß H t1 £ t £ t2 L Case1 @ t1_, x1_ , y1_ , t2_ , x2_ , y2_ , v1_ , t3_ , x3_ , y3_ , t4_ , x4_ , y4_ , v2_ D : = inbead @ t3, x3, y3, t1, x1, y1, t2, x2, y2, v1 D Þ inbead @ t4, x4, y4, t1, x1, y1, t2, x2, y2, v1 D Þ inbead @ t1, x1, y1, t3, x3, y3, t4, x4, y4, v2 D Þ inbead @ t2, x2, y2, t3, x3, y3, t4, x4, y4, v2 D CheckICCondition @ t1_ , x1_ , y1_ , v1_ , t3_ , x3_ , y3_ , v2_ , lc_ D : = Ø HH x3 - x1 L ^ 2 + H y3 - y1 L ^ 2 £ v1 ^ 2 * H t3 - t1 L ^ 2 ß If @ lc, t3 ³ t1, t3 £ t1 DL ß Ø HH x3 - x1 L ^ 2 + H y3 - y1 L ^ 2 £ v2 ^ 2 * H t3 - t1 L ^ 2 ß If @ lc, t3 £ t1, t3 ³ t1 DL ß Ø H v1 == 0 ß v2 == 0 L CheckHalfSpace @ t_ , x_ , y_ , t1_ , x1_ , y1_ , t2_ , x2_ , y2_ , v1_ , lc_ D : = If @ lc, H t1 £ t £ t2 L ß 2 * x * H x1 - x2 L + x2 ^ 2 - x1 ^ 2 + 2 * y * H y1 - y2 L + y2 ^ 2 - y1 ^ 2 £ v1 ^ 2 * H 2 * t * H t1 - t2 L + t2 ^ 2 - t1 ^ 2 L , H t1 £ t £ t2 L ß 2 * x * H x1 - x2 L + x2 ^ 2 - x1 ^ 2 + 2 * y * H y1 - y2 L + y2 ^ 2 - y1 ^ 2 ³ v1 ^ 2 * H 2 * t * H t1 - t2 L + t2 ^ 2 - t1 ^ 2 LD Case2 @ t1_, x1_ , y1_ , t2_ , x2_ , y2_ , v1_ , t3_ , x3_ , y3_ , t4_ , x4_ , y4_ , v2_ D : = Module @8 lcs < , If @ CheckICCondition @ t1, x1, y1, v1, t3, x3, y3, v2, True D , Module @8 t0, x0, y0 < , t0 = H t1 * v1 + t3 * v2 + Sqrt @H x1 - x3 L ^ 2 + H y1 - y3 L ^ 2 DL H v1 + v2 L ; x0 = x1 + v1 * H t0 - t1 L * H x3 - x1 L Sqrt @H x1 - x3 L ^ 2 + H y1 - y3 L ^ 2 D ; y0 = y1 + v1 * H t0 - t1 L * H y3 - y1 L Sqrt @H x1 - x3 L ^ 2 + H y1 - y3 L ^ 2 D ; lcs = CheckHalfSpace @ t0, x0, y0, t1, x1, y1, t2, x2, y2, v1, True D ß CheckHalfSpace @ t0, x0, y0, t3, x3, y3, t4, x4, y4, v2, True DD , lcs = False D ; If @ lcs, lcs = True, If @ CheckICCondition @ t2, x2, y2, v1, t4, x4, y4, v2, False D , Module @8 t0, x0, y0 < , t0 = H t2 * v1 + t4 * v2 + Sqrt @H x2 - x4 L ^ 2 + H y2 - y4 L ^ 2 DL H v1 + v2 L ; x0 = x2 + v1 * H t0 - t2 L * H x4 - x2 L Sqrt @H x2 - x4 L ^ 2 + H y2 - y4 L ^ 2 D ; y0 = y2 + v1 * H t0 - t2 L * H y4 - y2 L Sqrt @H x2 - x4 L ^ 2 + H y2 - y4 L ^ 2 D ; lcs = CheckHalfSpace @ t0, x0, y0, t1, x1, y1, t2, x2, y2, v1, False D ß CheckHalfSpace @ t0, x0, y0, t3, x3, y3, t4, x4, y4, v2, False DD , lcs = False DD ; lcs D CoordinateChange @ t1_ , x1_ , y1_ , t2_ , x2_ , y2_ , tp1_ , xp1_ , yp1_ , tp2_ , xp2_ , yp2_ , tp3_ , xp3_ , yp3_ , tp4_ , xp4_ , yp4_ D : = Module @8 at1, a11, a12, a21, a22, b1, b2, b3 < , b1 = t1; b2 = x1; b3 = y1; at1 = Sqrt @H x2 - x1 L ^ 2 + H y2 - y1 L ^ 2 D ; a11 = x2 - x1; a12 = y2 - y1; a21 = y1 - y2; a22 = x2 - x1; If @ y1 y2, f @ t_ , x_ , y_ D : = Module @8 tt, tx, ty < , tt = t; tx = x; ty = y; 8 tt - b1, tx - b2, ty - b3
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment