Termination of Linear Programs with Nonlinear Constraints
Tiwari proved that termination of linear programs (loops with linear loop conditions and updates) over the reals is decidable through Jordan forms and eigenvectors computation. Braverman proved that it is also decidable over the integers. In this pap…
Authors: Bican Xia, Zhihai Zhang
T ermination of Linear Programs with Nonlinear Constrain ts ⋆ Bican Xia, Zhihai Zhang School o f Mathematical Sciences, P eking U niversi ty xb c@math.pku .edu .cn, infzzh@gmail.co m Abstract. In [16] Tiw ari prov ed that termination of linear programs (loops with linear loop cond itions and up dates) o ver the reals is decid- able through Jordan forms and eigenve ctors computation. In [4] Brav er- man pro ved that it is also decidable ov er the integers. In this pap er, w e consider the t ermination of lo ops with p olynomial lo op conditions and linear up dates ov er the reals and integers. First, w e prov e th at the termination of such loops o ver the integers is u ndecidable. S econd, with an assumption, we pro vide an algorithm to decide the termination of a class of suc h programs o ver the reals. Our metho d is similar to that of Tiw ari in spirit but uses different tec hniqu es. Finally , we conjecture th at the termination of linear programs with p olynomial lo op conditions ov er the reals is undecidable in general by redu cin g the p roblem t o another decision prob lem related to num b er theory and ergodic theory , whic h w e guess undecidable. 1 In tr o duction T ermination analysis is an imp o rtant aspect of pro gram v erification. Guaranteed termination of program loops is necessary for man y applica tions, especially those for which unexp ected b ehavior can be ca tastrophic. F or a generic lo op while ( conditions ) { u pdates } , it is well known that the termina tion problem is undecida ble in g eneral, even for a simple class o f p olynomial pro grams [3]. In [2] Blo ndel et al. pro ved that, even when all the co nditions a nd updates are given as piecewise linear functions, the termination of the lo op remains undecidable. In [16] Tiwari prov ed that ter mination of the following pro grams is decidable ov er R (the real n umber s) P 0 : while ( B X > b ) { X := AX } , where A and B ar e resp ectively n × n a nd m × n matric es, B X > b represents a conjunction of linear inequalities ov er the state v ariables X and X := AX ⋆ This w ork is supp orted in part by NKBRPC-2004CB31800 3, NS F C-6057300 7, NSFC-907 18041 and NKBRPC-2005CB32 1902. represents a (deterministic) linear up date of e a ch v ar ia ble. Subsequen tly in [4] Brav er man prov ed that the ter mination of P 0 is dec idable ov er Z (the integers). In this paper , w e consider the pr oblem of termination of the following lo op: P 1 : while ( P ( X ) > 0) { X := AX } , where X = [ x 1 . . . x N ] T is the vector o f state v ar iables o f the pr o gram, P ( X ) = [ P 1 ( X ) P 2 ( X ) . . . P m ( X )] T are p olynomial co nstraints, each P i ( X ) (1 ≤ i ≤ m ) is a p olynomial in Q [ X ] and A is an N × N matrix ov er Q (the r ational num b ers). That is to say , we replace the linea r co nstraints in P 0 with p oly no mial cons traints and k eep linear updates unc hange d. There ar e some well known tec hniques for deciding termina tion o f some s p e- cial kinds of progra ms. Ra nking functions are most often used for this purp ose. A ra nking function for a lo op maps the v alues of the lo o p v aria bles to a well- founded domain; further, the v alues of the map decr ease on each iteratio n. A linear ranking function is a ranking function that is a linear combination of the loo p v aria bles and constants. Recently , the synthesis of ranking functions draws incr e asing a tten tio n, and some heuristics concerning how to automati- cally generate linear ra nk ing functions for linear programs hav e b een prop os ed in [8,9,12]. In [12] P o delski et al. provided a n efficien t and complete sy nthe- sis metho d based on linear progra mming to co nstruct linea r r anking functions. In [5] Chen et al. prop ose d a metho d to genera te non-linear ranking functions based on semi-algebraic system s olving. How ever, existence of ranking function is only a sufficient condition on the termination of a progra m. It is not difficult to construct prog rams that ter minate, but do not ha ve ra nking functions. T o s olve the pr oblem of termina tion of P 1 , we do not use the technique o f ranking functions. Our method is similar to that of Tiwari in spirit. O ur main contributions in this pap er a re as follows. First, we prov e that the termination o f P 1 ov er Z is undecidable. Then it is easy to prove that, if “ > ” is replaced with “ ≥ ” in P 1 , terminatio n of the resulted P 1 ov er Z is undecidable either. Seco nd, with an assumption, we provide an algorithm to decide the termination of P 1 ov er R . Finally , we conjecture tha t the termination of P 1 ov er R is undecidable in genera l by constructing a lo op and reducing the pr oblem to another decision problem related to n umber theory and ergo dic theory , whic h w e guess undecidable. The rest of the pap er is organized as follows. Section 2 pro ves the undecid- ability of P 1 and its v ariation over Z . Section 3 introduces our main algorithm. The main steps of the algorithm are o utlined first and some details of the steps are in tro duced separately in sev er al subsectio ns. With an ass umption, w e prove the correctnes s of our algor ithm at the end of Section 3. After presenting our conjecture that the termination of P 1 is generally undecidable in Section 4, we conclude the pap er in Section 5. 2 Undecidabilit y of P 1 o ver Z Definition 1. A lo op with N variables is c al le d terminating over a ring R if for al l the inputs X ∈ R N , it is terminating; otherwise it is c al le d nonterminating . The undecidabilit y of P 1 is obtained by a reduction to Hilb ert’s 10 th problem. Consider the following lo o p: P 2 : while ( x m +1 − f ( x 1 , . . . , x m ) 2 > 0) { X := AX } where X = x 1 . . . x m +1 T , A = diag(1 , ..., 1 , 1 / 2) is a diagona l ma trix and f ( x 1 , . . . , x m ) is a polyno mial with in teg er co efficients. Lemma 1. F or any input ( x 1 , . . . , x m +1 ) ∈ Z m +1 , P 2 terminates if and only if f ( x 1 , . . . , x m ) do es not have inte ger r o ots. Pr o of. ( ⇒ ) If f ( x 1 , . . . , x m ) has an in teg er ro ot, say ( y 1 , . . . , y m ) , ob viously P 1 do es not terminate with the input Y = ( y 1 , . . . , y m , 1) . ( ⇐ ) If f ( x 1 , . . . , x m ) has no integer roo ts, for an y given X ∈ Z m +1 , − f ( x 1 , . . . , x m ) 2 is a fixed negative n umber . Because ( x 1 , ..., x m ) will nev er b e changed and (1 / 2) n → 0 as n → + ∞ , the loo p will terminates after sufficien tly large n iterations. Theorem 1. T ermination of P 1 over Z is u nde cidable. Pr o of. Be c a use the existence of an int eger ro o t of a n a rbitrary Diophantine equation is undecidable, the termination of P 1 ov er Z is undecidable according to Lemma 1. If “ > ” is substituted with “ ≥ ” in P 1 , the loo p be comes P ′ 1 : while ( P ( X ) ≥ 0) { X := AX } . Analogously , we denote by P ′ 2 the lo o p o btained by substituting “ ≥ ” for “ > ” in P 2 . It is easy to see that Lemma 1 still holds for P ′ 2 . Then we get the following theorem. Theorem 2. T ermination of P ′ 1 over Z is u nde cidable. 3 Relativ ely Complete Algorithm for T ermination of P 1 o ver R T o decide whether P 1 terminates on a given input X ∈ R N , it is natura l to consider a gener a l expression of A n X , for instance, a unified for mu la expr essing A n X for any n . If o ne has suc h unified formula of A n X , o ne can express the v alues of P ( X ) after n iterations. Then, for each e le men t of P ( X ) (each constraint) , i.e. , P i ( X ), one ma y try to determine whether P i ( X ) > 0 as n → + ∞ b y guessing the dominant term o f P i ( X ) and deciding the sign of the term. That is the main idea of our algo r ithm w hich will b e describ ed formally in Subsection 3.2. A t several main steps of our algorithm, a few techniques and results in n umber theor y and erg o dic theo ry are needed. F o r the sake of clarity , the details are introduced subsequently in the next subsections. The first subsection is devoted to expr essing A n X in a unified formula. 3.1 General Expression for A n X by Generating F unction In this subsectio n the general expressio n of A n X will be deduced with generating function, not Jorda n for m. Lemma 2. [1 3] L et α 1 , . . . , α d b e a se quenc e of c omplex nu mb ers, d ≥ 1 and α d 6 = 0 . The fol lowing c onditions on a function f : N → C ar e e qu ivalent to e ach other: i. P n ≥ 0 f ( n ) x n = P ( x ) Q ( x ) , wher e Q ( x ) = 1+ α 1 x + . . . + α d x d and P ( x ) is a p olynomial in x of de gr e e less than d. ii. F or al l n ≥ 0 , f ( n + d ) + α 1 f ( n + d − 1) + α 2 f ( n + d − 2) + . . . + α d f ( n ) = 0 . iii F or al l n ≥ 0 , f ( n ) = k P i =1 P i ( n ) γ n i , and Q ( x ) = 1 + α 1 x + α 2 x 2 + . . . + α d x d = k Q i =1 (1 − γ i x ) d i , wher e t he γ i ’s ar e distinct, and P i ( n ) is a p olynomial in n of de gr e e less than d i . Corollary 1. A is a d × d squar e matrix with its entries in Q . Supp ose that the char acteristic p olynomial of A is D ( x ) = x d + α 1 x d − 1 + . . . + α d − s x s , wher e α d − s 6 = 0 and s ≥ 0 . Define f ( n ) = A n + s X and let f j ( n ) b e the j - th c omp onent of f ( n ) . Then for e ach j , f j ( n ) c an b e expr esse d as f j ( n ) = k X i =1 p j i ( n ) ξ n i , (1) wher e ξ i ’s ar e al l the distinct nonzer o c omplex eigenvalues of A and p j i ( n ) is a p olynomial in n of de gr e e less t han t he multiplicity of ξ i . Pr o of. Fir s t, A d + α 1 A d − 1 + · · · + α d − s A s = 0 b ecause D ( x ) is the characteristic po lynomial of A . So, for any n ≥ 0 , f ( n + d − s ) + α 1 f ( n + d − ( s + 1)) + · · · + α d − s f ( n ) = A n + d X + α 1 A n + d − 1 X + · · · + α d − s A n + s X = ( A d + α 1 A d − 1 + · · · + α d − s A s ) A n X = 0 . Thu s, for each j , f j ( n + d − s ) + α 1 f j ( n + d − ( s + 1)) + · · · + α d − s f j ( n ) = 0 . By Lemma 2, f j ( n ) = k P i =1 p j i ( n ) ξ n i and Q ( x ) = 1 + α 1 x + · · · + α d − s x d − s = k Q i =1 (1 − ξ i x ) d i where p j i ( n ) is a po lynomial in n o f degree less than d i . It’s easy to s ee that x = 0 is not a solution of Q ( x ) and P k i =1 d i = d − s . Because D ( x ) = x d Q ( 1 x ) = x d − s + α 1 x d − s − 1 + . . . + α d − s = x d k Y i =1 (1 − ξ i x ) d i = x s k Y i =1 ( x − ξ i ) d i , ξ i ’s are all the distinct nonz e r o complex eigenv alues of A and d i is the multiplicit y of ξ i . That completes the pro of. R emark 1. According to Cor ollary 1, we may compute the general expressio n of A n X as follows. First, compute all the complex eig env alues of A and their m ultiplicities. Second, supp ose each f j ( n ) of f ( n ) is in the for m of eq.(1) where the co efficients of p j i are to b e computed. Third, compute f (1) , . . . , f ( d ) , and obtain a set of linear equations by comparing the coefficie nts of the resulted f j ( i ) (1 ≤ i ≤ d ) to those of eq.(1). Finally , b y so lving those linear equations, w e can obtain f j ( n ) and f ( n ) . Example 1. Let’s consider the following loop: while ( x 5 + x 2 1 + x 1 x 2 − x 2 3 − 2 x 3 x 4 − x 2 4 > 0) { X := AX ; } , where A = 2 6 6 6 6 4 1 − 2 5 0 0 0 2 1 5 0 0 0 0 0 0 2 0 0 0 − 1 2 − 1 0 0 0 0 0 − 1 2 3 7 7 7 7 5 . W e sha ll show how to compute the general ex pr ession of A n X by tak ing use of Corollar y 1. The characteristic po lynomial of A is D ( λ ) = λ 5 + 3 10 λ 4 + 7 10 λ 3 + 1 5 λ 2 + 9 10 λ + 1 2 = ( λ + 1 2 )( λ 2 − 6 5 λ + 1)( λ 2 + λ + 1) . The eigenv alues of A are ξ 1 = 3 + 4 i 5 , ξ 2 = 3 − 4 i 5 , ξ 3 = − 1 2 + √ 3 2 i , ξ 4 = − 1 2 − √ 3 2 i , ξ 5 = − 1 2 . Set f ( n ) = A n X = ˆ f 1 ( n ) f 2 ( n ) f 3 ( n ) f 4 ( n ) f 5 ( n ) ˜ T . F or an y n > 0 , we have f ( n + 5) + 3 10 f ( n + 4) + 7 10 f ( n + 3) + 1 5 f ( n + 2) + 9 10 f ( n + 1) + 1 2 f ( n ) = 0 . Because the multiplicities of ξ 1 , ξ 2 , ξ 3 , ξ 4 and ξ 5 are all 1, by Coro llary 1, we may assume for 1 ≤ j ≤ 5 f j ( n ) = ( 5 X i =1 a j i x i ) ξ n 1 + ( 5 X i =1 b j i x i ) ξ n 2 + ( 5 X i =1 c j i x i ) ξ n 3 + ( 5 X i =1 d j i x i ) ξ n 4 + ( 5 X i =1 e j i x i ) ξ n 5 . Let f ( 1) , f (2) , f (3) , f (4) and f (5) eq ua l to AX, A 2 X, A 3 X, A 4 X a nd A 5 X r esp ec- tively , and by solving some linear equations (see Remark 1) we can obtain f 1 ( n ) = „ 2 − i 4 x 1 + i 4 x 2 « ξ n 1 + „ 2 + i 4 x 1 − i 4 x 2 « ξ n 2 , f 2 ( n ) = „ − 5 i 4 x 1 + 2 + i 4 x 2 « ξ n 1 + „ 5 i 4 x 1 + 2 − i 4 x 2 « ξ n 2 , f 3 ( n ) = „ ( 1 2 − √ 3 i 6 ) x 3 − 2 √ 3 i 3 x 4 « ξ n 3 + „ ( 1 2 + √ 3 i 6 ) x 3 + 2 √ 3 i 3 x 4 « ξ n 4 , f 4 ( n ) = „ √ 3 i 6 x 3 + ( 1 2 + √ 3 i 6 ) x 4 « ξ n 3 + „ − √ 3 i 6 x 3 + ( 1 2 − √ 3 i 6 ) x 4 « ξ n 4 , f 5 ( n ) = x 5 ξ n 5 . 3.2 Main Algorithm According to subsection 3.1, the general expression of A n + m X is a p olynomial in x 1 , . . . , x N , n and ξ 1 , . . . , ξ q , the nonzero complex ro ots of D ( x ). If we substitute A n + m X for X in P ( X ) and deno te the resulted P j ( X )(1 ≤ j ≤ m ) ∈ P ( X ) b y P j ( X, n ), then P j ( X, n ) can b e written as P j ( X, n ) = p j 0 ( X, n ) + p j 1 ( X, n ) η n 1 + . . . + p j M ( X, n ) η n M , (2) where η k (1 ≤ k ≤ M ) is the pro duct of some ξ j ’s. T o determine whether P 1 terminates, we hav e to determine for each j whether P j ( X, n ) > 0 holds for all n . T o this end, it is sufficient to know whether the dominant term ( le ading term ) of eq.(2) is p ositive or not a s n → + ∞ . I n the following, we shall give a more deta ile d description of eq .(2 ) so that we can obtain the expression of the leading term of eq.(2). Let η k = r k e α k 2 π i , where i = √ − 1 and r k is the mo dulus of η k . Without loss of gene r ality , w e assume r 1 < r 2 < · · · < r M . F o r conv e nience, set η 0 = r 0 = 1. Rewrite P j ( X, n ) as P j ( X, n ) = p j 0 ( X, n ) r n 0 + p j 1 ( X, n ) e nα 1 2 π i r n 1 + · · · + p j M ( X, n ) e nα M 2 π i r n M . Suppo se T j is the common p erio d of all the e α q 2 π i (1 ≤ q ≤ M ) where α q is a rational n um be r . Definition 2. F or e ach j (1 ≤ j ≤ m P l =1 T l ) , if j = s − 1 P l =1 T l + i and 1 ≤ i ≤ T s , then define G j ( X, n ) , P s ( X, T s n + i − 1) . Notation 1 F or e ach j ( 1 ≤ j ≤ m P l =1 T l ) , exp and G j ( X, n ) , c ol le ct the r esult with r esp e ct to (w.r.t.) n l r n k , and let C j kl ( X, n ) denote the c o efficient of the term n l r n k . Then G j ( X, n ) can b e wr itten as C j 10 ( X, n ) r n 1 + C j 11 ( X, n ) nr n 1 + · · · + C j 1 d 1 ( X, n ) n d 1 r n 1 + · · · (3) + C j M 0 ( X, n ) r n M + C j M 1 ( X, n ) nr n M + · · · + C j M d M ( X, n ) n d M r n M , where d l (1 ≤ l ≤ M ) is the greatest degree of n in G j ( X, n ) w.r.t. r l . It can be deduced that if r i < r j , the order o f n l 1 r n i is less than the or der of n l 2 r n j for any l 1 and l 2 when n go es to infinit y . Similar ly , if l 1 < l 2 , the order of n l 1 r n i is less than the order of n l 2 r n i . So, it is natural to in tro duce an or dering on the terms n l r n j as follows. Definition 3. We define n l 1 r n i ≺ n l 2 r n j if r i < r j or r i = r j and l 1 < l 2 . A term C j kl n l r n j in e q. (3) is said to b e the leading term and C j kl the leading co efficient if n l r n j o c curring in C j kl is the lar gest one under that or dering ≺ . Suppo se G j ( X, n ) = P s ( X, T s n + t ) for some s a nd t . F or those e α q 2 π i ’s wher e α q ’s are rationa l n umber s, e ( T s n + t ) α q 2 π i = e tα q 2 π i bec ause T s is the commo n p e- rio d. Because there ma y b e so me e ( T s n + t ) α q 2 π i ’s with irrational α q ’s, each C j kl ( X, n ) can be div ided int o three parts, C j kl ( X, n ) = C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, n ) , where C j kl 0 ( X ) do es not contain an y e ( T s n + t ) α q 2 π i , C j kl 1 ( X ) co nt ains e ( T s n + t ) α q 2 π i with ratio nal α q and C j kl 2 ( X, n ) contains those e ( T s n + t ) α q 2 π i with irra tional α q 1 . F urther, C j kl 2 ( X, n ) can b e wr itten as C j kl 2 ( X, n ) = C j kl 2 ( X, sin( ( nT s + t ) α k 1 2 π ) , cos(( nT s + t ) α k 1 2 π ) , . . . , sin(( nT s + t ) α ks k 2 π ) , cos(( nT s + t ) α ks k 2 π )) , where { α k 1 2 π , . . . , α ks k 2 π } is a maximum r ational ly indep endent g roup 2 . Example 2. W e contin ue to use the lo op in Exa mple 1 to illustra te the ab ov e concepts and notations. Because | ξ 1 | = | ξ 2 | = 1 , let ξ 1 = e α 1 2 π i and ξ 2 = e − α 1 2 π i , where α 1 2 π is the argument of ξ 1 . It’s not difficult to chec k that α 1 is an irr a tional num b er. 3 F or the sake of clarity , in the following we firstly reduce the expr e s sions of f 1 ( n ) , f 2 ( n ) , f 3 ( n ) , f 4 ( n ) and f 5 ( n ) , a nd then substitute them in the lo op g uard. Let α 2 = 1 3 , then ξ 3 = e α 2 2 π i , ξ 4 = e − α 2 2 π i , and f 1 ( n ) , f 2 ( n ) , f 3 ( n ) , f 4 ( n ) and f 5 ( n ) can be r ewritten as f 1 ( n ) = x 1 cos( nα 1 2 π ) + x 1 − x 2 2 sin( nα 1 2 π ) , f 2 ( n ) = x 2 cos( nα 1 2 π ) + 5 x 1 − x 2 2 sin( nα 1 2 π ) , f 3 ( n ) = x 3 cos( nα 2 2 π ) + √ 3 x 3 + 4 √ 3 x 4 3 sin( nα 2 2 π ) , f 4 ( n ) = x 4 cos( nα 2 2 π ) − √ 3 x 3 + √ 3 x 4 3 sin( nα 2 2 π ) , f 5 ( n ) = x 5 ( − 1 2 ) n . Substituting f 1 ( n ) , f 2 ( n ) , f 3 ( n ) , f 4 ( n ) and f 5 ( n ) for x 1 , x 2 , x 3 , x 4 and x 5 resp ec- tively in the lo op guar d, w e get that the res ulted lo op guard is L 1 r n 1 + ( L 21 + L 22 + L 23 ) r n 2 , where r 1 = 1 2 , r 2 = 1 , and L 1 = ( − 1) n x 5 , L 21 = − x 2 3 + 2 x 3 x 4 + 4 x 2 4 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 , L 22 = 2 x 2 4 − 2 x 3 x 4 − x 2 3 2 cos( n 2 α 2 2 π ) − ( √ 3 x 3 x 4 + √ 3 x 2 4 ) sin( n 2 α 2 2 π ) , L 23 = − x 2 1 + x 2 2 − 6 x 1 x 2 4 cos( n 2 α 1 2 π ) + 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 sin( n 2 α 1 2 π ) . 1 Later it will b e proved th at C j kl 0 ( X ) , C j kl 1 ( X ) and C j kl 2 ( X, n ) are reals for any n . 2 “Rationally independ ent” will be d escrib ed later. 3 A general alg orithm for chec king whether an argumen t is a rational multiple of π will b e stated in detail in sub section 3.4. Since α 2 = 1 3 , the perio d of ξ 2 3 = e 2 α 2 2 π = cos(2 α 2 2 π ) + sin(2 α 2 2 π ) i is 3. Then we compute G 1 ( X, n ) = ( ( − 1) 3 n x 5 ) r 3 n 1 + C 120 r 3 n 2 , G 2 ( X, n ) = ( ( − 1) 3 n +1 x 5 ) r 3 n +1 1 + C 220 r 3 n +1 2 , G 3 ( X, n ) = ( ( − 1) 3 n +2 x 5 ) r 3 n +2 1 + C 320 r 3 n +2 2 . T ake G 1 ( X, n ) as an ex a mple. C 120 = C 1200 + C 1201 + C 1202 , C 1200 = − x 2 3 + 2 x 3 x 4 + 4 x 2 4 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 , C 1201 = 2 x 2 4 − 2 x 3 x 4 − x 2 3 2 , C 1202 = − x 2 1 + x 2 2 − 6 x 1 x 2 4 cos(3 n 2 α 1 2 π ) + 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 sin(3 n 2 α 1 2 π ) . Notation 2 We denote by C j kl ( X, n ) ≻ 0 (and c al l C j kl ( X, n ) “p ositive”) if min { C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 ) } > 0 subje ct t o { y 2 11 + y 2 12 = 1 , · · · , y 2 s k 1 + y 2 s k 2 = 1 } . R emark 2. It is not difficult to see C j kl ( X, n ) ≻ 0 iff ∀ ( y 11 , y 12 , . . . , y s k 1 , y s k 2 ) ( ( y 2 11 + y 2 12 = 1) ∧ · · · ∧ ( y 2 s k 1 + y 2 s k 2 = 1) → C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 ) > 0) bec ause { ( y 11 , y 12 , . . . , y s k 1 , y s k 2 ) : y 2 i 1 + y 2 i 2 = 1 , i = 1 , ..., s k } is a bounded closed set. If ≻ and > ar e repla ced with and ≥ resp ectively in the notatio n, w e get the notation of C j kl ( X, n ) 0 (“no nnegative”). Roughly sp ea k ing, fo r a ny G j ( X, n ) , if its leading co efficient C j kl ( X, n ) ≻ 0 , there ex is ts an integer N 1 such that for a ll n > N 1 , G j ( X, n ) > 0 . If all the leading co efficients of all the G j ( X, n ) ’s are “p o sitive”, there exists N ′ such that for all n > N ′ , a ll the G j ( X, n ) ’s ar e p ositive. Ther efore, P 1 is non terminating with input X ′ := A N ′ X . On the o ther hand, if P 1 is nonterminating, do es there exist an input X s uch that the leading co efficients of a ll the G j ( X, n ) ’s a re “ p o sitive”? W e do not know the answer yet . How ever, w ith an assumption describ ed b elow, the answer is yes. Assump tion for the mai n algorithm : F or any X ∈ R n and any C j kl ( X, n ) , C j kl 2 ( X, n ) being not identically zero implies min( C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 )) 6 = 0 sub ject to y 2 i 1 + y 2 i 2 = 1 ( i = 1 , . . . , s k ) . It is not difficult to se e that the as sumption is e q uiv a lent to the following formula: [ ∀ X ∀ Y ( C j kl 2 ( X, n ) ≡ 0 ∨ V 1 ≤ i ≤ s k y 2 i 1 + y 2 i 2 = 1 → C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, Y ) > 0) i W [ ∀ X ∃ Y ( C j kl 2 ( X, n ) ≡ 0 ∨ V 1 ≤ i ≤ s k y 2 i 1 + y 2 i 2 = 1 → C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, Y ) < 0) i . Because C j kl 2 ( X, n ) can b e written as P i ∈ I f i 1 ( X ) sin( nα i 2 π ) + f i 2 ( X ) cos( nα i 2 π ) , where I is an index set, C j kl 2 ( X, n ) ≡ 0 is equiv a lent to V i ∈ I f i 1 ( X ) = f i 2 ( X ) = 0 . Thu s, the assumption can b e chec ked with r eal q ua nt ifier elimination tec hniques. Example 3. F or those C ij k ’s in E xample 2, let’s chec k whether they satisfy the assumption. F or clar ity , w e present a clear pro of here rather than make use of any to o l for real quantifier elimination. T ake G 1 ( X, n ) for exa mple. It’s clear that C 1202 ( X, n ) ≡ 0 if and only if x 1 = x 2 = 0 . It is not difficult to compute D = inf n ≥ 1 C 1202 ( X, n ) = − s „ − x 2 1 − x 2 2 + 6 x 1 x 2 4 « 2 + „ 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 « 2 . If x 1 = x 2 = 0 does not ho ld, 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 + D < 0 b ecause ( 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 ) 2 − D 2 = − 1 16 (5 x 2 1 + x 2 2 − 2 x 1 x 2 ) 2 < 0 . Let M = min y 2 11 + y 2 12 =1 ( C 1200 ( X ) + C 1201 ( X ) + C 1202 ( X, y 11 , y 12 )) , then M = − ( x 3 + x 4 ) 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 + D < 0 if x 1 = x 2 = 0 do es not hold. Consequently , G 1 ( X, n ) satisfies the assumption. Similarly it can b e prov ed G 2 ( X, n ) and G 3 ( X, n ) satisfy the assumption to o . Thu s the lo op in Example 1 satisfies the assumption. W e s hall sho w in nex t section how ha rd it is to deal with the case tha t the assumption do es not hold. Now, w e are re a dy to describ e our main algo rithm. F or the sake of br evity , the algorithm is describ ed as a nondeterministic alg orithm. The basic idea is to g ue s s a leading ter m for ea ch G j ( X, n ) fir s t. Then, setting its co efficient be “p o s itive” a nd the co efficients of the terms with higher or der b e “nonnegative”, we can g et a semi-algebraic system (SAS). If o ne of our guess is satisfiable, i.e. , one of the SASs ha s so lutions, P 1 is nonterminating. Otherwise, it is terminating. Algorithm Terminati on Step 0 Co mpute the general expressio n of A n + m X . Step 1 Substitute A n + m X for X in P ( X ) , and compute a ll G j ( X, n ) (finite ma ny , say , j = 1 , ..., L ). Step 2 Gues s a leading term for each G j ( X, n ) , sa y C j k j l j n l j r n k j . Step 3 Co nstruct a semi-algebra ic sy stem S as follows. S j = C j k j l j ≻ 0 ∧ V ( k>k j ) ∨ ( k = k j ∧ l>l j ) C j kl ( X, n ) 0 , S = V L j =1 S j . Step 4 If one of these systems is satisfia ble, return ”nonterminating”. Otherwise return ”terminating”. R emark 3. If t he assumpt ion for the main algor ithm do es not hold, then Termin ation is incomplete. That is, if it returns “nonterminating”, the lo o p is nonterminating. O therwise, it tells nothing. Example 4. F or the lo op in Example 1, we ha ve computed the G i ( X, n ) ’s in Example 2 and verified that it s atisfies the as sumption o f the main algo rithm in E xample 3. W e shall finish its ter mination decision in this example, following the steps in Termin ation . By Steps 2 and 3 of Termin ation , we sho uld guess leading terms and con- struct SASs according ly . T o be concrete, let’s take as an example one certain guess and suppo se w e hav e the following se mi-algebra ic system 8 < : C 120 ( X, n ) ≻ 0 , C 220 ( X, n ) ≻ 0 , C 320 ( X, n ) ≻ 0 . According to No ta tion 2 a nd Remark 2, the ab ov e inequa lities are equiv alent to ( ∀ y 11 , y 12 ) y 2 11 + y 2 12 = 1 → 8 > < > : − ( x 3 + x 4 ) 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 − x 2 1 + x 2 2 − 6 x 1 x 2 4 y 11 + 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 y 12 > 0 , − ( x 4 − x 3 2 ) 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 − x 2 1 + x 2 2 − 6 x 1 x 2 4 y 11 + 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 y 12 > 0 , − ( x 4 + x 3 2 ) 2 + 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 − x 2 1 + x 2 2 − 6 x 1 x 2 4 y 11 + 7 x 2 1 − x 2 2 − 2 x 1 x 2 4 y 12 > 0 . In E xample 3, we hav e shown that 5 x 2 1 + x 2 2 − 2 x 1 x 2 4 + D ≤ 0 . Th us, the ab ov e pred- icate for mula do es not hold. In fac t, none of the fo rmulas obta ined in Step 3 holds. Th us, the lo op in Example 1 is terminating. R emark 4. It is w ell known that real qua ntifier elimination is de c ida ble from T arski’s work [15]. Ther efore, the semi-a lgebraic sy stems in Step 3 can be s olved. F or the to ols for solving semi-alg ebraic systems, please be referred to [6,7,10,18]. R emark 5. There are some techniques to decrea se the a mount of computation of the algorithm Terminati on . F or example, we can use Lemma 3 when guessing leading terms for each G j ( X, n ) . Lemma 3. [4 ] L et ξ 1 , ξ 2 , . . . , ξ m ∈ C b e a c ol le ction of distinct c omplex num b ers such that | ξ i | = 1 and ξ i 6 = 1 for al l i . L et α 1 , α 2 , . . . , α m b e any c omplex numb ers and z n = α 1 ξ n 1 + . . . + α m ξ n m . Then one of the fol lowing is true: 1. the r e al p art Re ( z n ) = 0 for al l n ; or 2. ther e is c < 0 such t hat Re ( z n ) < c for infinitely many n ’s. According to Lemma 3, if C j kl 0 = 0 and C j kl ( X, n ) is not identically zero w.r.t. n , then C j kl ( X, n ) can no t b e alw ays nonneg a tive. According to the former discussion { G j − 1 P k =1 T k +1 ( X, n ) , . . . , G j − 1 P k =1 T k + T j ( X, n ) } are obtained fro m P j ( X, n ) . Then the lea ding term with the greatest order among all the leading terms of the above set should not b e o f the form C j k j l j n l j r n k j where C j k j l j 0 = 0. Thus, this should b e a voided when guessing leading ter ms for each G j . In the follo wing s ubsections, we shall ex plain the details of the main steps of Termin ation and prove its correctness . 3.3 Compute the Minim al P olynomials of α + β , α − β , α · β and α β A t Step 1 of the main alg o rithm, we ma y compute η k (1 ≤ k ≤ M ) which are the pro ducts of so me ξ j ’s after substituting the general expre s sion of A n + m X for X in P ( X ) . In order to describ e η k , we need the minimal polynomia ls of η k . In this subsection a method is present ed to solv e a more general problem. In [14] Strzeb onski gav e an a lgorithm to compute { α + β , α − β , α · β , α β } nu merically where α and β are given algebr aic num b er s. Here we wan t to present another more in tuitive metho d based on symbolic computation. In the following let α ⋄ β denote one of { α + β , α − β , α · β , α β } . Without loss of generality let’s assume that the minimal p olynomial o f α is f 1 ( x ) whos e degree is d 1 and the minimal po lynomial of β is f 2 ( x ) who se degree is d 2 . W e can b ound α and β in W 1 and W 2 , respectively , where W 1 , W 2 are “b oxes”, by isolating the complex zer os of f 1 ( x ) and f 2 ( x ). Since the degree of α is d 1 and the degree of β is d 2 , the degr ee of α ⋄ β is at most d 1 · d 2 . Then there must ex ist x 1 , . . . x d 1 · d 2 +1 in Z such that x 1 + x 2 α ⋄ β + . . . + x d 1 · d 2 +1 ( α ⋄ β ) d 1 · d 2 = 0 . Thu s we c a n design a n algor ithm to enumerate a ll the ( x 1 , . . . , x d 1 · d 2 +1 ) ∈ Z d 1 · d 2 +1 and chec k whether it is a solution. Since there e x ists one solution this algorithm must terminate a nd output a solution. Assume that its output is a 0 , a 1 , . . . , a d 1 · d 2 and f ( x ) = a 0 + a 1 x + . . . + a d 1 · d 2 x d 1 · d 2 . Because f ( α ⋄ β ) = 0 , the minimal p olyno mia l of α ⋄ β is an irreducible factor of f ( x ). F actor f ( x ) in Q . Without loss o f generality , we assume f ( x ) = g 1 ( x ) m 1 · g 2 ( x ) m 2 . . . g d ( x ) m d . W e can chec k whether g j ( x )(1 ≤ j ≤ d ) is the minimal p olynomial of α ⋄ β b y solving the following semi- algebraic system (SAS): { g j ( x ⋄ y ) = 0 , f 1 ( x ) = 0 , f 2 ( y ) = 0 , x ∈ W 1 , y ∈ W 2 } . If it is s a tisfiable, g j ( x ) is the minimal polyno mial of α ⋄ β ; otherwise it is not. Thu s the minimal po lynomial of α ⋄ β can b e obtained. 3.4 Chec k Whe ther the Argument of α Is a Rational Mul ti ple of π A t Step 1 of the main algo r ithm, T s is necessar y for de fining G j ( X, n ) . Th us for a given η k we have to chec k whether its argument is a rational mu ltiple o f π and if it is, we need to know the p e r io d o f η k | η k | . This subsectio n a ims at this problem. Suppo se the minimal polynomia l of α is p ( x ) whose degree is d . Without loss of genera lit y s uppo se α = r e β 2 π i . W e can b ound α in W by isolating all the complex ro o ts of p ( x ). Since the degree of α is d , the degr ee of α must b e d . Then the degree o f α · α = r 2 is a t most d 2 . Thus the degree of r is at mo st 2 d 2 . The degr ee of α − 1 is at most 2 d 2 bec ause the degree of α − 1 is the same as the degree of α . Since the degree of α is d the degree of α · r − 1 = e iβ 2 π is at most 2 d 3 . If β is a rational num b er , α must b e a unit ro o t and its minimal polynomial m ust b e a cyclo tomic po lynomial. As a result if β is a rational nu mber the mini- mal p o ly nomial of α m ust be a c y clotomic polyno mia l whose degree is less tha n or equal to 2 n 3 . All the cyclotomic p olynomia ls can b e computed explicitly a c- cording to the theor y of cyclotomic field. Th us let C P j ( x ) denote the cyclo to mic po lynomial who se deg ree is j . Then, β is a rational n um be r if and only if the following is sa tis fia ble ∃ r (( r 6 = 0) ^ ( 2 d 3 _ j =1 C P j ( x/r ) = 0) ^ ( p ( x ) = 0) ^ ( x ∈ W )) . Because C P j ( x/r ) = 0 ⇐ ⇒ r j C P j ( x/r ) = 0, the ab ov e q uantifier formula is decidable. If it’s satisfiable the minimal p olynomial of α can b e computed by chec king whether ∃ r (( r 6 = 0) ^ ( C P j ( x/r ) = 0) ^ ( p ( x ) = 0) ^ ( x ∈ W )) is satisfiable one b y one. 3.5 Chec k Ratio nal Indep endence Given a set of algebr aic num b ers, α 1 = e β 1 2 π i , . . . , α d = e β d 2 π i , wher e β 1 , . . . , β d are irrationa l n umber s. In this subsection we present a metho d to c heck whether β 1 , . . . , β d are r ational ly indep endent . Definition 4. Irr ational numb ers β 1 , . . . , β d ar e rationally indep endent if ther e do es not exist r ational numb ers a 1 , . . . , a d such that d P j =1 a j β j ∈ Q . Obviously , β 1 , . . . , β d are rationally indep endent if and only if 1 , β 1 , . . . , β d are linea rly indepe ndent in Q . It ca n b e deduced that β 1 , . . . , β d are r ationally independent if and only if ∀ ( b 1 , . . . , b d ) ∈ Z d , d P j =1 b j β j / ∈ Z . Lemma 4. [1 ] L et λ 1 , . . . , λ m with m ≥ 2 b e line arly dep endent lo garithms of algebr aic numb ers. Define α j = e λ j (1 ≤ j ≤ m ) . F or 1 ≤ j ≤ m , let log A j ≥ 1 b e an upp er b ound for max { h ( α j ) , | λ j | D } wher e D is the de gr e e of the numb er field K = Q ( α 1 , . . . , α m ) over Q and h ( α ) denotes t he absolute lo garithmic heig ht of α . Then ther e exist r ational inte gers n 1 , . . . , n m , not al l of which ar e zer o, such that n 1 λ 1 + . . . + n m λ m = 0 and | n k | < (11( m − 1) D 3 ) m − 1 (log A 1 ) ... (log A m ) log A k for 1 ≤ k ≤ m . R emark 6. Baker is the fir s t one to use his tr a nscendence ar g ument s to establish such an estima te. Ho wever, the description here follows Lemma 7.19 in [17]. Sequence { β 1 , . . . , β d , 1 } ar e linearly indep endent in Q iff { β 1 2 π i , . . . , β d 2 π i , 2 π i } are linearly independent in Q . If n 1 β 1 2 π i + . . . + n d β d 2 π i + n d +1 2 π i = 0 , then e n 1 β 1 2 π i · · · e n d β d 2 π i = 1 . That is α n 1 1 · · · α n d d = 1 . According to Lemma 4 w e can decide whether { β 1 , . . . , β d } are rationally independent by enumerating n k from ⌊− (11 dD 3 ) d (log A 1 ) · · · (log A d +1 ) log A k ⌋ , . . . , ⌈ (11( d ) D 3 ) d (log A 1 ) · · · (log A d +1 ) log A k ⌉ for k = 1 , . . . , d and chec king whether α n 1 1 · · · α n d d = 1 . F or an y g iven ( n 1 , . . . , n d ) , whether α n 1 1 · · · α n d d = 1 ca n b e determined b y c hecking whether the fo llowing SAS has solutions. { x n 1 1 · · · x n d d = 1 , q j ( x j ) = 0 , x j ∈ W j , j = 1 , ..., d } , where q j is the minima l poly nomial of α j and W j contains only one complex ro ot of q j for j = 1 , . . . , d . 3.6 Compute the Infim um of C j kl 2 T o prov e the correctness of our main algor ithm, we need some further results. First, let’s introduce a lemma in ergo dic theory . Let S be the unit circumfer- ence. Usually any p oint on S , sa y ( a, b ) , is denoted as a co mplex n umber a + b i . Define π : R m → S m as ( x 1 , . . . , x m ) → ( e x 1 2 π i , . . . , e x m 2 π i ) . Define m-torus T m = { ( e x 1 2 π i , . . . , e x m 2 π i ) | x j ∈ R } and L π ( α ) : T m → T m as ( e y 1 2 π i , . . . , e y m 2 π i ) → ( e ( y 1 + α 1 )2 π i , . . . , e ( y m + α m )2 π i ) . Lemma 5. [1 1] If α ∈ R m , the t r anslation L π ( α ) ( X ) is er go dic iff for al l K ∈ Z m , ( K, α ) / ∈ Z wher e ( K, α ) stands for the inner pr o duct of K and α . According to Lemma 5 w e know tha t if α 1 is a n irra tional num b er, the clo- sure of { e nα 1 2 π i } n ≥ 1 is the unit cir c umference. Also, if α 1 , . . . , α m are rationally independent, L π ( α ) ( X ) is erg o dic. Th us the clos ure of { L n π ( α ) (0) } n ≥ 1 is T m . Lemma 6. If α k 1 , . . . , α ks k ar e ra t ional ly indep endent and C j kl 2 is of the form C j kl 2 ( X, sin( nα k 1 2 π ) , cos( nα k 1 2 π ) , . . . , sin( nα ks k 2 π ) , cos( nα ks k 2 π )) for a fixe d X , t hen inf n ≥ 1 { C j kl 2 ( X, sin( nα k 1 2 π ) , cos( nα k 1 2 π ) , . . . , sin( nα ks k 2 π ) , cos( nα ks k 2 π )) } is e qual t o min { C j kl 2 ( X, x 1 , y 1 , . . . , x s k , y s k ) } subje ct to { x 2 i + y 2 i = 1 , 1 ≤ i ≤ s k } . Pr o of. Acco rding to Lemma 5 for an y ( x 1 , y 1 , . . . , x s k , y s k ) there exists a subse- quence, say { n i } i ≥ 1 , such that lim i → + ∞ (sin( n i α k 1 2 π ) , cos( n i α k 1 2 π ) , . . . , sin( n i α ks k 2 π ) , cos( n i α ks k 2 π )) = ( x 1 , y 1 , . . . , x s k , y s k ) . Theorem 3. L et γ i = ( nT j ′ + j ′′ ) α ki 2 π ( 1 ≤ i ≤ s k ) and supp ose that C j kl 2 = C j kl 2 ( X, sin ( γ 1 ) , cos( γ 1 ) , . . . , sin( γ s k ) , cos( γ s k )) . Then inf n ≥ 1 { C j kl 2 ( X, sin ( γ 1 ) , cos( γ 1 ) , . . . , sin( γ s k ) , cos( γ s k )) } is e qual t o min { C j kl 2 ( X, x 1 , y 1 , . . . , x s k , y s k ) } subje ct to { x 2 i + y 2 i = 1 , 1 ≤ i ≤ s k } . Pr o of. Acco rding to Lemma 5 a nd Lemma 6, it’s sufficien t to prov e that T s k is the clo sure of { ( e γ 1 i , . . . , e γ s k i ) } n ≥ 1 . Beca use { α 1 , . . . , α s k } ar e rationally indepen- dent , { T j ′ α 1 , . . . , T j ′ α s k } are rationa lly independent, to o. Thus, T s k is the closure of { ( e nT j ′ α k 1 2 π i , . . . , e nT j ′ α ks k 2 π i ) } n ≥ 1 . The result of rota ting ( e nT j ′ α k 1 2 π i , . . . , e nT j ′ α ks k 2 π i ) by ( j ′′ α k 1 2 π , . . . , j ′′ α ks k 2 π ) is ( e γ 1 i , . . . , e γ s k i ) . Conseque ntly , T s k is the closure of { ( e γ 1 i , . . . , e γ s k i ) } n ≥ 1 . That completes the pro of. 3.7 Correctness F or each j , P j ( X, n ) can b e wr itten as D j 10 ( X, n ) r n 1 + D j 11 ( X, n ) nr n 1 + . . . + D j 1 d 1 ( X, n ) n d 1 r n 1 + · · · D j H 0 ( X, n ) r n H + D j H 1 ( X, n ) nr n H + . . . + D j H d H ( X, n ) n d H r n H . The D j kl ’s in the ab ov e are real b ecause P j ( X, n ) ∈ R and those n l r n k ’s are of different o rders. Just lik e C j kl , D j kl can be div ided int o three parts, D j kl = D j kl 0 ( X ) + D j kl 1 ( X, n ) + D j kl 2 ( X, n ) . Because D j kl 0 ( X ) contains no e ( nT j ′ + j ′′ ) α q 2 π i ’s, the e ( nT j ′ + j ′′ ) α q 2 π i ’s c o ntained in D j kl 1 ( X, n ) a re p erio dic and the e ( nT j ′ + j ′′ ) α q 2 π i ’s contained in D j kl 2 ( X, n ) are not, D j kl 0 , D j kl 1 and D j kl 2 are all rea l. Since C j kl ( X, n ) results from D j kl ( X, n ) , we get the following lemma . Lemma 7. F or al l n ∈ N and e ach C j kl ( X, n ) = C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, n ) , C j kl 0 ( X ) ∈ R , C j kl 1 ( X, n ) ∈ R and C j kl 2 ( X, n ) ∈ R . Lemma 8. Consider C j kl ( X, n ) = C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, n ) . 1. inf n ≥ 1 { C j kl ( X, n )) } > 0 if and only if min { C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 ) } > 0 subje ct t o { y 2 t 1 + y 2 t 2 = 1 , 1 ≤ t ≤ s k } . 2. If I = C j kl 0 ( X ) + C j kl 1 ( X ) + D < 0 , then ther e is c < 0 s uch that C j kl ( X, n ) < c for infinitely many n ’s, wher e D = min { C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 ) } subje ct t o { y 2 t 1 + y 2 t 2 = 1 , 1 ≤ t ≤ s k } . Pr o of. 1. It has b een prov ed that inf n ≥ 1 C j kl 2 ( X, n ) = min { C j kl 2 ( X, y 11 , y 11 , . . . , y s k 1 , y s k 2 ) } sub ject to { y 2 t 1 + y 2 t 2 = 1 , 1 ≤ t ≤ s k } . Consequently inf n ≥ 1 { C j kl ( X, n )) } = min { C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, y 11 , y 12 , . . . , y s k 1 , y s k 2 ) } . sub ject to { y 2 t 1 + y 2 t 2 = 1 , 1 ≤ t ≤ s k } . 2. Let Y = ( y 11 , y 12 , . . . , y s k 1 , y s k 2 ) and Y ′ = ( y ′ 11 , y ′ 12 , . . . , y ′ s k 1 , y ′ s k 2 ) . D can b e at- tained b ecause { y 2 t 1 + y 2 t 2 = 1 , 1 ≤ t ≤ s k } is a b ounded clo sed s et and C j kl 2 ( X, Y ) is a co nt inu ous function of Y . Assume that D = C j kl 2 ( X, Y ′ ) . Since I < 0 there exists a neighbor ho o d o f Y ′ , say U , such that ∀ Y ∈ U ⇒ C j kl 0 ( X ) + C j kl 1 ( X ) + C j kl 2 ( X, Y ) < I / 2 . Let c = I / 2 and γ i = ( nT j ′ + j ′′ ) α ki 2 π . Because of the density o f { ( e γ 1 i , . . . , e γ s k i ) } n ≥ 1 , there are infinitely many n ’s such that (cos γ 1 , sin γ 1 , . . . , cos γ s k , sin γ s k ) lies in U . Thus there a re infinitely many n ’s such that C j kl ( X, n ) < c . If the main algor ithm, Termin ation , finds one solution, X 0 , the leading co ef- ficient o f G j ( X 0 ) , say C j kl ( X 0 , n ) , satisfies C j kl ( X, n ) ≻ 0 . Accor ding to the defini- tion of ≻ there exist c j > 0 ( j = 1 , . . . , L ) such tha t C j kl ( x, n ) > c j for all n . Thus P 1 is nonterminating. This means tha t if the a lgorithm outputs “ no nt erminat- ing”, then P 1 is nonterminating indeed. On the other hand, if the main algo rithm o utputs “ terminating”, then for any { C j k j l j ( X, n ) , j = 1 , . . . , L } there is a subset V ⊆ { 1 , . . . , L } such that ^ j ∈ V C j k j l j ( X, n ) ≻ 0 is not satisfiable sub ject to V j / ∈ V C j k j l j ≻ 0 ∧ V ( k>k j ) ∨ ( k = k j ∧ l>l j ) C j kl ( X, n ) 0 According to th e assump tion for the mai n algorithm , we get that with the ab ov e constraints ∀ j ∈ V , inf n ≥ 1 C j k j l j ( X, n ) ≤ 0 . Thu s by Lemma 8 , ∀ j ∈ V , C j k j l j ( X, n ) is identically zero or there are infinitely many n ’s and so me c < 0 such tha t C j k j l j ( X, n ) < c . Tha t means P 1 is terminating. Therefore, we g et the follo wing theorem. Theorem 4. U nder the assumption of t he main algo rithm, Termi natio n r e- turns “terminating” if and only if P 1 is t erminating. 4 Conjecture In this section, we s hall discuss the general case of P 1 wherein our assumption for the main algor ithm may not hold. Suppo se p ( X ) = p ( x 11 , x 12 , . . . , x m 1 , x m 2 ) ∈ Q [ X ] , and one of the loop condi- tions is p ( X ) 2 > 0 . F ro m the discussio n in Section 3 , we kno w that if we substi- tute A n + m X for X in the co nditions, ther e must b e a p olyno mial q such that the condition bec o mes q ( X , sin( nα 1 2 π ) , cos( nα 1 2 π ) , . . . , sin( nα m 2 π ) , cos( nα m 2 π )) 2 > 0 . Because p is arbitra r y , q c a n b e arbitrar y . F urther, α 1 , ..., α m can be made ratio- nally indep endent because A can b e arbitrary . It’s not har d to see that we can construct a progra m Q such that it is terminating if and only if S q,α , { n : q (sin( nα 1 2 π ) , cos( nα 1 2 π ) , . . . , sin( nα m 2 π ) , cos( nα m 2 π )) = 0 } contains infinitely ma n y elemen ts. F or an y p ( X ) ∈ Q [ X ] the dec is ion pr oblem “whether { X : p ( X ) = 0 } T Z 2 m = ∅ ” is undecidable. Z 2 m is a “regular” set while E = { (sin( nα 1 2 π ) , cos( nα 1 2 π ) , . . . , sin( nα m 2 π ) , cos( nα m 2 π )) } n ≥ 1 is a chaotic set when { α 1 , . . . , α m } a r e rationa lly independent acco rding to the er- go dic theory . Intuitiv ely , deciding whether S p,α = { X : p ( X ) = 0 } T E = ∅ is more difficult than deciding whether { X : p ( X ) = 0 } T Z 2 m = ∅ . So, we intuit ively guess the decision pr oblem “whether S p,α is empty” is undecida ble. F ollowing the same idea, we guess the decision problem “whether S p,α contains infinitely many elemen ts” is m uch mo re difficult and thus undecidable. Thus, we ma ke the following co njecture: Conjec ture. The decis ion problem “whether the lo op P 1 is terminating ov er R ” is undecidable. 5 Conclusion In this pap er we hav e proved tha t termination of P 1 ov er Z is undecidable. Then w e give a relatively complete algor ithm, with an assumption, to determine whether P 1 is terminating o ver R . If the assumption holds, P 1 is terminating iff o ur a lgorithm outputs “terminating”. If the assumption do es not hold, P 1 is nonterminating if the algor ithm outputs “ nonterminating”. W e demo nstrate the main steps of our a lgorithm b y a n example. Finally we show how har d it is to determine the termination of P 1 by reducing its ter mination to the problem of “ whether S p,α has infinite many elements”. W e conjecture the la tter problem is undecidable. Thus, if our conjecture holds, the termination of P 1 ov er R is undecidable. Ac knowledgem en t The authors would like to thank P rof. Lu Y ang for prop os ing the problem to us a nd encoura g ing us to work o n it. W e thank Pro f. Mic hel W aldschmidt for his introduction to Baker’s work. W e a re also gr ateful to Prof. Bob Caviness, Prof. Ho o n Hong a nd Pr of. Daniel Richardson for their insightful suggestio ns . Finally w e w o uld like to thank Prof. Chao chen Z ho u, Pro f. Naijun Zhan and all the other members in our group for the discussion at our weekly se minar. References 1. A. Baker : Linear F orms in the Logarithms of A lgebraic Nu mbers I, I I, I I I , IV. Mathematika 13: 204–2 16, 1966; ibid., 14: 102–107 , 220–2 28, 1967; ibid., 15: 204– 216, 1968. 2. V.D. Blondel, O. Bournez, P . Koiran, C.H. Papadimitriou and J.N. Tsitsiklis: De- ciding stability and mortality of p iecewise affine dynamical sy stems. The or etic al Computer Scienc e , 255(1–2): 687 –696, 2001. 3. A.R. Bradley , Z. Manna and H.B. Sipma: T ermination of P olynomial Programs. In Pr o c. V erific ation, Mo del-Che cking, and A bstr act-Interpr etation (VMC A I ) Jan uary 2005, LNCS 3385 , pp.113–129 , 2005. 4. M. Bra verman: T ermination of Integer Linear Programs. CA V 2006, LNCS 4114 , pp.372–385, 2006. 5. Y. Chen, B. Xia, L. Y ang, N. Zhan and C. Zhou: Disco vering Non-linear ranking functions by Solving Semi-algebrai c Systems. LNCS 4711 , pp.34–49, 2007. 6. G. E. Coll ins: Q uantifier elimination for real closed fi elds by cylind rical algebraic decomp osition. In: Automata The ory and F ormal L anguages (Brakhage, H., ed.), LNCS 33 , 134 –165. Springer, Berlin Heidelberg, 1975. 7. G. E. Collins and H. Hong: Partial cy lindrical algebraic decomp osition for quanti- fier elimination, Journal of Symb oli c Computation , 12 : 299–328, 1991. 8. M. colon and H.B. Sipma: Synthesis of linear ranking functions. In T ACAS01 , LNCS 2031 , pp.67–81, 2001. 9. D. Dams, R. Gerth, and O . Grumb erg: A heuristic for the automatic generation of rankin g functions. In Workshop on A dvanc es in V erific ation (W A V e00) , p p .1–8, 2000. 10. A . Dolzman and T. Sturm: REDLOG: Computer algebra meets compu ter logic. ACM SIGSAM Bul letin , 31 (2): 2–9, 1997. 11. R . Mane: Er go dic The ory and Di ffer entiable Dynamics . Springer-V erlag, NewY ork , 1987. 12. A . P o delski and A. Rybalchenko : A complete metho d for the syn th esis of linea r ranking functions. In VMCAI , LNCS 2937 , p p .465–48 6, 2004. 13. R . Stanley: Enumer ative Combi natorics , vol. 1. Cam b rid ge Un iver sit y Press, 1997. 14. A .W. Strzeb onski: Compu t ing in t he Field of Complex Algebraic Num b ers. J. Symb olic Computation 24: 647–656 , 1997. 15. A . T arski: A De cision Metho d for Elementary A l gebr a and Ge ometry (2nd edn.). Universit y of Calif orn ia Press, Berk eley , 1951. 16. A . Tiw ari: T ermination of Linear Programs. In R. A lur and D.A. Peled(Eds.): CA V 2004, LNCS 3114 , pp.70–82, 2004. 17. M. W aldschimidt: Diophantine Appr oximation on Line ar Algebr aic Gr oups . Springer-V erlag, Berlin, 2000. 18. B. Xia: DIS COVERER: A to ol for solving semi-algebraic systems, Softwar e Demo at ISSA C 2007 , W aterloo, July 30, 2007. Also: ACM SIGSAM Bul letin , 41(3) ,102– 103, 2007.
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment