Termination of Integer Linear Programs

Relevanta dokument
Exam EI2452/EI3364 Reliability analysis of power systems

Isometries of the plane

1. Compute the following matrix: (2 p) 2. Compute the determinant of the following matrix: (2 p)

12.6 Heat equation, Wave equation

Tentamen i Matematik 2: M0030M.

Algoritmer och Komplexitet ht 08. Övning 6. NP-problem

Module 6: Integrals and applications

Module 1: Functions, Limits, Continuity

1. Varje bevissteg ska motiveras formellt (informella bevis ger 0 poang)

ADSP ADSP ADSP ADSP. Advanced Digital Signal Processing (18-792) Spring Fall Semester, Department of Electrical and Computer Engineering

8 < x 1 + x 2 x 3 = 1, x 1 +2x 2 + x 4 = 0, x 1 +2x 3 + x 4 = 2. x 1 2x 12 1A är inverterbar, och bestäm i så fall dess invers.

denna del en poäng. 1. (Dugga 1.1) och v = (a) Beräkna u (2u 2u v) om u = . (1p) och som är parallell

Pre-Test 1: M0030M - Linear Algebra.

Solutions to exam in SF1811 Optimization, June 3, 2014

NP-fullständighetsbevis

This exam consists of four problems. The maximum sum of points is 20. The marks 3, 4 and 5 require a minimum

Tentamen MMG610 Diskret Matematik, GU

Boiler with heatpump / Värmepumpsberedare

and u = och x + y z 2w = 3 (a) Finn alla lösningar till ekvationssystemet

Writing with context. Att skriva med sammanhang

Support Manual HoistLocatel Electronic Locks

BOENDEFORMENS BETYDELSE FÖR ASYLSÖKANDES INTEGRATION Lina Sandström

Grafisk teknik IMCDP IMCDP IMCDP. IMCDP(filter) Sasan Gooran (HT 2006) Assumptions:

1. a Vad menas med medianen för en kontinuerligt fördelad stokastisk variabel?

Preschool Kindergarten

F ξ (x) = f(y, x)dydx = 1. We say that a random variable ξ has a distribution F (x), if. F (x) =

IE1206 Embedded Electronics

Schenker Privpak AB Telefon VAT Nr. SE Schenker ABs ansvarsbestämmelser, identiska med Box 905 Faxnr Säte: Borås

Viktig information för transmittrar med option /A1 Gold-Plated Diaphragm

Styrteknik: Binära tal, talsystem och koder D3:1

Beijer Electronics AB 2000, MA00336A,

Adding active and blended learning to an introductory mechanics course

(D1.1) 1. (3p) Bestäm ekvationer i ett xyz-koordinatsystem för planet som innehåller punkterna

Webbregistrering pa kurs och termin

Make a speech. How to make the perfect speech. söndag 6 oktober 13

Grafisk teknik IMCDP. Sasan Gooran (HT 2006) Assumptions:


Information technology Open Document Format for Office Applications (OpenDocument) v1.0 (ISO/IEC 26300:2006, IDT) SWEDISH STANDARDS INSTITUTE

Självkörande bilar. Alvin Karlsson TE14A 9/3-2015

Webbreg öppen: 26/ /

Grafisk teknik. Sasan Gooran (HT 2006)

Workplan Food. Spring term 2016 Year 7. Name:

LUNDS TEKNISKA HÖGSKOLA Institutionen för Elektro- och Informationsteknik

Kvalitetsarbete I Landstinget i Kalmar län. 24 oktober 2007 Eva Arvidsson

2.1 Installation of driver using Internet Installation of driver from disk... 3

En bild säger mer än tusen ord?

Discovering!!!!! Swedish ÅÄÖ. EPISODE 6 Norrlänningar and numbers Misi.se

Uttagning för D21E och H21E

Chapter 2: Random Variables

Problem som kan uppkomma vid registrering av ansökan

Calculate check digits according to the modulus-11 method

2 Uppgifter. Uppgifter. Svaren börjar på sidan 35. Uppgift 1. Steg 1. Problem 1 : 2. Problem 1 : 3

1. Find for each real value of a, the dimension of and a basis for the subspace

Rastercell. Digital Rastrering. AM & FM Raster. Rastercell. AM & FM Raster. Sasan Gooran (VT 2007) Rastrering. Rastercell. Konventionellt, AM

Kurskod: TAMS11 Provkod: TENB 28 August 2014, 08:00-12:00. English Version

Kurskod: TAMS28 MATEMATISK STATISTIK Provkod: TEN1 05 June 2017, 14:00-18:00. English Version

Hur fattar samhället beslut när forskarna är oeniga?

Rep MEK föreläsning 2

Provlektion Just Stuff B Textbook Just Stuff B Workbook

Consumer attitudes regarding durability and labelling

Förtroende ANNA BRATTSTRÖM

Ett hållbart boende A sustainable living. Mikael Hassel. Handledare/ Supervisor. Examiner. Katarina Lundeberg/Fredric Benesch

samhälle Susanna Öhman

Resultat av den utökade första planeringsövningen inför RRC september 2005

CUSTOMER READERSHIP HARRODS MAGAZINE CUSTOMER OVERVIEW. 63% of Harrods Magazine readers are mostly interested in reading about beauty

Module 4 Applications of differentiation

Service och bemötande. Torbjörn Johansson, GAF Pär Magnusson, Öjestrand GC

CHANGE WITH THE BRAIN IN MIND. Frukostseminarium 11 oktober 2018

Kurskod: TAMS11 Provkod: TENB 07 April 2015, 14:00-18:00. English Version

English. Things to remember

Exempel på uppgifter från 2010, 2011 och 2012 års ämnesprov i matematik för årskurs 3. Engelsk version

Tentamen i Matematik 2: M0030M.

Semigroups of Sets Without the Baire Property In Finite Dimensional Euclidean Spaces Vénuste NYAGAHAKWA

Theory 1. Summer Term 2010

Custom-made software solutions for increased transport quality and creation of cargo specific lashing protocols.

Om oss DET PERFEKTA KOMPLEMENTET THE PERFECT COMPLETION 04 EN BINZ ÄR PRECIS SÅ BRA SOM DU FÖRVÄNTAR DIG A BINZ IS JUST AS GOOD AS YOU THINK 05

Methods to increase work-related activities within the curricula. S Nyberg and Pr U Edlund KTH SoTL 2017

Förskola i Bromma- Examensarbete. Henrik Westling. Supervisor. Examiner

Här kan du checka in. Check in here with a good conscience

INSTALLATION INSTRUCTIONS

Tentamen i Matematik 3: M0031M.

IE1206 Embedded Electronics

Samverkan på departementsnivå om Agenda 2030 och minskade hälsoklyftor

MO8004 VT What advice would you like to give to future course participants?

Wittgenstein for dummies Eller hur vi gör det obegripliga begripligt. Västerås 15 februari 2017

Högskolan i Skövde (SK, JS) Svensk version Tentamen i matematik

6 th Grade English October 6-10, 2014

Tentamen i kurserna Beräkningsmodeller (TDA181/INN110) och Grundläggande Datalogi (TDA180)

LARS. Ett e-bokningssystem för skoldatorer.

Evaluation Ny Nordisk Mat II Appendix 1. Questionnaire evaluation Ny Nordisk Mat II

Mönster. Ulf Cederling Växjö University Slide 1

Grammar exercises in workbook (grammatikövningar i workbook): WB p 121 ex 1-3 WB p 122 ex 1 WB p 123 ex 2

Hjälpmedel: Inga, inte ens miniräknare Göteborgs Universitet Datum: 2018 kl Telefonvakt: Jonatan Kallus Telefon: ankn 5325

In Bloom CAL # 8, sista varv och ihopsättning / last rows and assemble

VHDL Basics. Component model Code model Entity Architecture Identifiers and objects Operations for relations. Bengt Oelmann -- copyright

SVENSK STANDARD SS :2010

onsdag den 21 november 2012 PRONOMEN

Övning 5 ETS052 Datorkommuniktion Routing och Networking

Transkript:

Termnaton of Integer Lnear Programs Mark Braverman Department of Computer Scence Unversty of Toronto Abstract. We show that termnaton of a smple class of lnear loops over the ntegers s decdable. Namely we show that termnaton of determnstc lnear loops s decdable over the ntegers n the homogeneous case, and over the ratonals n the general case. Ths s done by analyzng the powers of a matrx symbolcally usng ts egenvalues. Our results generalze the work of Twar [Tw04], where smlar results were derved for termnaton over the reals. We also gan some nsghts nto termnaton of non-homogeneous nteger programs, that are very common n practce. 1 Introducton Termnaton analyss s one of the buldng blocks of automated verfcaton. For a generc loop whle (condtons) { commands } t s well known that the termnaton problem s undecdable n all but the most smple cases. Even when all the condtons and updates are gven as pecewse lnear functons, the problem of decdng termnaton of the loop remans undecdable snce such programs can naturally smulate counter machnes [Tw04], and the problem of whether a counter machne termnates on all nputs s undecdable [BBK + 01]. In vew of the undecdablty mentoned above, the efforts on practcal termnaton analyss of loops have been concentrated on partal decson procedures. One approach s syntheszng a rankng functon. Synthess of rankng functons has been studed n [CSS03, BMP05a, BMP05b]. In some cases, one can even fnd a complete method for synthess of lnear rankng functons [PR04]. Even a complete synthess method, however, can only establsh exstence of a certan way of provng termnaton, and not actually decde the termnaton problem tself. It s not hard to construct an example of a program that termnates but has no lnear rankng functon. The termnaton problem appears to be much harder, and one can expect t to be decdable only n the smplest cases. In [Tw04] termnaton has been shown to be decdable for loops of the form whle (Bx > b) { x Ax + c } where Bx > b represents a conjuncton of lnear nequaltes over the state varables x, andx Ax + c represents a (determnstc) lnear update of each Partally supported by an NSERC postgraduate scholarshp. T. Ball and R.B. Jones (Eds.): CAV 2006, LNCS 4144, pp. 372 385, 2006. c Sprnger-Verlag Berln Hedelberg 2006

Termnaton of Integer Lnear Programs 373 varable. The varables are nterpreted over the reals IR, and there are no constrants on the ntal condtons. Roughly speakng, [Tw04] shows that only the subspace correspondng to egenvectors of A wth postve real egenvalues s relevant to the termnaton problem. In the homogeneous case whle (Bx > 0) { x Ax } t s mmedate to see that f there s an egenvector v of A such that Av = λv, λ>0andbv > 0, then the loop s non-termnatng on v. The decson procedure depends on the fact that the nequalty Bx > 0 s strct. More mportantly, t depends on the fact that the varables are nterpreted over the reals. As the followng example llustrates, a program may be termnatng over the ntegers, but not over the reals. Example 1. Consder the homogeneous loop { ( ) x whle (4x + y>0) y ( ) } 2 4 x 4 0)( y The matrx has two egenvectors, ( 1 17, 4) and ( 1+ 17, 4) correspondng to egenvalues 1 17 and 1+ 17, respectvely. The egenvector ( 1+ 17, 4) satsfes the loop condton, and corresponds to a postve egenvalue. Hence the loop does not termnate over IR. However, the lne ( 1+ 17, 4)α does not contan any ratonal ponts, and the loop outsde ths lne s always domnated by the egenvalue 1 17 < 0 that s bgger n absolute value than the other egenvalue. At the lmt, the orbt of (x, y) wll alternate between the drectons ( 1 17, 4) and (1 + 17, 4). Hence the loop termnates on all ntegers. The example hghlghts the dfference between the nteger and the real case. In general, t s not unusual to have dfferences between hardness of decdablty of problems over the reals IR and problems over the ntegers ZZ. One notorous example s quantfer elmnaton. Gven a quantfed formula Q 1 x 1 Q 2 x 2...Q n x n f(x 1,...,x n ), there s an algorthm to decde ts valdty over IR [Tar51], but not over ZZ. In fact, by undecdablty of Dophantne equatons [Mat93], the formula above s undecdable even n the case when Q = for all. It has been conjectured n [Tw04] that the termnaton of programs as above s stll decdable when nterpreted over the ntegers. In ths paper we prove the followng: Theorem 1. Let A, B s,b w be ratonal matrces and b s,b w,cbe ratonal vectors. Then the termnaton problem of the loop whle (B s x>b s ) (B w x b w ) { x Ax + c } s decdable when the varables range over the reals IR or the ratonals Q. Its decdable over the ntegers ZZ n the homogeneous case when b s,b w,c=0. Theorem 1 settles the termnaton problem over the ratonals for a lnear loop wth a determnstc update and no ntal condtons n the most general form.

374 M. Braverman Usng Lemma 4 on lnear combnatons of sums of powers of complex unts, we are able to deal wth non-strct nequaltes. Over the ntegers termnaton n the non-homogeneous case remans an ntrgung open problem. We wll return to t n Secton 6. In practce, the programs are usually specfed over nteger varables, and t s encouragng to know that the termnaton of homogeneous loops as above s stll decdable n ths settng. Most of the paper s dedcated to provng Theorem 1. 2 Proof Outlne of Theorem 1 The man part of the proof s n decdng termnaton over Q for homogeneous programs (.e. programs for whch b s,b w,c= 0). Unlke the termnaton analyss over IR [Tw04], we cannot gnore the vectors correspondng to negatve and complex egenvalues. As llustrated n the followng example, t s possble that there are no ratonal ponts on the non-termnatng subspace S + correspondng to the postve egenvalues of A, but there s a ratonal vector outsde S + very close to t, and on whch the loop s stll non-termnatng. Example 2. Consder the loop whle (4x 5y >0) { ( ) x y ( )} 2 4 x 4 0)( y The matrx has two egenvectors, (1 + 17, 4) and (1 17, 4) correspondng to egenvalues 1+ 17 and 1 17, respectvely. The only egenvector n S + s v 1 = (1 + 17, 4), whch satsfes the loop condton, but contans no ratonal ponts. However, the orbt of a ratonal perturbaton q 1 of v 1 converges to the drecton of v 1 at the lmt. Hence t s possble to choose q 1 that s a nontermnatng ratonal ntal condton, and the loop s non-termnatng over Q despte the fact that there are no ratonal ponts n S +.Thepontq 1 =(9, 7) s an example of a specfc such value. Note that 9 7 1+ 17 4 < 0.005, whch means that q 1 s a good ratonal approxmaton of v 1. We wll see that the set N of real ponts for whch the program s non-termnatng s a convex cone. Hence t has a dmenson and a unque mnmal lnear space S mn contanng t. The rough outlne of the procedure for fndng a ratonal pont n N (.e. n Q n N) sasfollows: Termnaton (loop P ) compute S mn Q mn S mn Q n f Q mn = return termnatng f dm(q mn )=dm(s mn ) return non-termnatng else reduce the loop to a loop P on the subspace Q mn run Termnaton(P )

Termnaton of Integer Lnear Programs 375 At each teraton, S mn s the current feasble real subspace, and Q mn ts ratonal subspace. We contnuously update both untl ther dmensons match or untl Q mn becomes empty. If the dmensons match, we know that Q mn s dense n N, and we can return non-termnatng. IfQ mn becomes empty, we can return termnatng. At each teraton we reduce the dmenson of the loop by at least 1, hence the algorthm termnates. The crucal step n the computaton s the ablty to compute S mn at each step of the teraton. Runnng the procedure on Example 1 above, we would obtan that S mn s the one-dmensonal space span{( 1 + 17, 4)}, andq mn = {0}, thusoutputtng termnatng. On the other hand, for Example 2 above we would obtan S mn =IR 2,andQ mn = Q 2,thusdm(Q mn )=dm(s mn ), and we output non-termnatng. 3 Prelmnares 3.1 Lnear Algebra We wll see that symbolcally powerng the matrx A s an essental step n decdng termnaton of the loop. If A s smlar to some matrx D va A = P 1 DP then A n =(P 1 DP) n =(P 1 DP)(P 1 DP)...(P 1 DP) =P 1 D n P. Hence powerng the matrx A s as hard as powerng the matrx D. Wewould lke to make D as smple as possble. It s well known from lnear algebra [HK71] that any A can be transformed nto Jordan canoncal form: Lemma 2 (Jordan canoncal form). For any matrx A C n n there s a matrx P,andamatrxD of the form D = Dag(J 1,J 2,...,J N ) wth each block J havng the form λ 10... 0 0 λ 1... 0 J =....... 0 0 0.,.. 1 0 0 0... λ where λ s an egenvalue of A and A = P 1 DP. Moreover, f A s an algebrac matrx, then D and P are also algebrac matrces and ther entres can be computed from the entres of A. Next, we explctly wrte the n-th power of the matrx D. The formula can be proved by nducton on n. Lemma 3. For a matrx D = Dag(J 1,...,J N ) n Jordan canoncal form, ts n-th power s gven by D n = Dag(J n 1,Jn 2,...,Jn N ),where

376 M. Braverman ( ) ( ) n λ n nλn 1 λ n 2 n 2... λ n (N 1) N 1 ( ) 0 λ n J n nλ n 1 n... λ n (N 2) = N 2.........,. 0 0.. λ n nλ n 1 0 0... 0 λ n ( ) n where N s the dmenson of the block J,and =0f n<k. k 3.2 A Lemma About Complex Unts Let ζ 1 be a complex number on the unt crcle, that s, ζ =1.Itseasyto see that the orbt ζ,ζ 2,ζ 3,... wll vst the negatve half of the complex plane nfntely often. We need a generalzaton of ths fact to a lnear combnaton of such ζ s. Lemma 4. Let ζ 1,ζ 2,...,ζ m C be a collecton of dstnct complex numbers such that ζ =1and ζ 1for all. Letα 1,α 2,...,α m be any complex numbers. Denote z n = α 1 ζ1 n + α 2 ζ2 n +...+ α m ζm. n Then one of the followng s true: 1. the real part Re(z n )=0for all n; or 2. there s a c<0 such that Re(z n ) <cfor nfntely many n s. We wll be nterested n the case when z n IR are all reals. In ths case we have Re(z n )=z n for all n, and the lemma apples drectly to z n. Proof. Due to space constrants, we wll only present a proof dea here. Frst of all, we can wrte y n =2Re(z n )=z n + z n = α 1 ζ n 1 +...+ α mζ n m +ᾱ 1 ζ n 1 +...+ᾱ m ζ n m IR. After collectng together terms where ζ = ζ j, we see that the clam for y n s equvalent to the clam for the z n, but now y n IR for all n. Hence t suffces to prove the lemma under the assumpton z n IR. We actually show that f z n s not syntactcally 0, then the second possblty above holds. The two key clams of the proof are that N 1. The cumulatve sum of the z n s bounded from above: z n C 1,where C 1 > 0 s some explct constant. 2. The sum of absolute values z n s bounded from below: each N for some explct constant C 2 > 0. n=0 N+m n=n+1 z n >C 2 for

Termnaton of Integer Lnear Programs 377 Both clams are not too hard to prove, and together they yeld the statement of the lemma: Choose an nteger K such that K C 2 > 4C 1. Then for any N we have by the frst clam N+Km n=n+1 z n = N+Km n=0 z n N z n < 2C 1. n=0 On the other hand, by the second clam we have N+Km n=n+1 z n = These together mply that K 1 N+m+m =0 n=n+m+1 N+Km n=n+1, z n<0 z n >K C 2 > 4C 1. z n < C 1. Hence there s an n {N +1,...,N + Km} such that z n < C 1 /(Km). Set c = C 1 /(Km). We have just seen that there s a z n satsfyng z n <c among any Km consecutve elements. Ths completes the proof of Lemma 4. Remark: It s also possble to gve a less constructve proof of Lemma 4 usng ergodc theory. 4 Termnaton over Q and IR n the Homogeneous Case In ths secton we assume that the loop s homogeneous, that s c, b s,b w =0.Let N be the set of nontermnatng ponts of the program over IR n. We are nterested n determnng whether N and N Q n are empty. Forapontz IR n we consder the evoluton of the loop wth ntal varables vector z. Wedenotethevalueofthevarablesafter teratons by z() =A z. In partcular z(0) = z. z N f and only f z() satsfes the loop condtons B s z() > 0andB w z() 0 for all 0. Frst, we note that N s a convex cone. Lemma 5. Assumng N, N must be a convex cone. That s, for every x, y N and λ>0, λx N, and the lne segment connectng x to y belongs to N. Proof. Snce the loop s homogeneous, the executon on x wll run for exactly as long as the executon on λx. In partcular f the loop does not termnate on x, twllnottermnateonλx. Suppose that ntally z s on the lne segment connectng x wth y. Thenz(0) = z = αx +(1 α)y for some α [0, 1]. On the n-th teraton we have z(n) =αx(n)+(1 α)y(n), s stll on the lne segment connectng x(n) wth y(n), and

378 M. Braverman B s z(n) =αb s x(n)+(1 α)b s y(n) > 0, B w z(n) =αb w x(n)+(1 α)b w y(n) 0, because the loop does not termnate on both x and y. N s a convex body n IR n and as such, has a dmenson d N,whchstherank of the smallest subspace contanng N. Determnng the mnmum lnear space S mn = span{n} contanng N s central to the constructon. 4.1 Fndng the Mnmum Space S mn N Intuton: N s a convex cone. If we consder N as a subset on S mn,weseethat t has an nteror nt(n), and for any pont x n the nteror small perturbatons x + εv of x reman n N f and only f v S mn.thev s for whch x + εv s n N span S mn. We frst fnd such an x, wecallz max, and then generate all the small perturbatons that leave z max n N n order to get a lnear bass for S mn. We are nterested n the behavor of the loop wth ntal condton z(0). In partcular, we would lke to know whether z() =A z(0) always satsfes the loop condtons. Snce we know the Jordan canoncal form of A, we can explctly wrte the whle condton after steps as { Bs A z(0) > 0 B w A z(0) 0 { Bs P 1 D Pz(0) > 0 B w P 1 D Pz(0) 0 where D = PAP 1 = Dag(J 1,...,J N ) s the Jordan canoncal form of A. Our next goal s to use (1) to wrte the condtons on z() n an explct form. Let 0 <λ 1 <λ 2 <... < λ r be the absolute values of the egenvalues of A sorted n the ncreasng order. We only consder the nonzero egenvalues here. Let {ζ j } be complex numbers on the unt crcle, ζ j =1,andζ j 1suchthat the egenvalues of A are a subset of {λ 1,λ 1 ζ 11,λ 1 ζ 12,...,λ 1 ζ 1m1,λ 2,λ 2 ζ 21,λ 2 ζ 22,...,λ 2 ζ 2m2,..., λ r,λ r ζ r1,λ r ζ r2,...,λ r ζ rmr }. The ζ j are the arguments of the correspondng egenvalues. By Lemma 3, symbolcally, D s a lnear combnaton of {λ 1,λ 1ζ11,λ 1ζ12,...,λ 1ζ1m 1,λ 1 1,λ 1 1 ζ11 1,λ 1 1 ζ12 1,...,λ 1ζ 1 ( n 1 1 ( n 1 1 ) λ (n1 1) 1, ( n 1 1 ) λ (n1 1) 1 ζ (n1 1) 11,..., ) λ (n1 1) 1 ζ (n1 1) 1m 1,λ 2,λ 2 ζ 21,λ 2 ζ 22,...,λ 2 ζ 2m 2,... ( λ r,λ rζr1,λ rζr2,...,λ rζrm r,..., n r 1 ( ) λ (nr 1) r ζ (nr 1) r1,..., n r 1 ( ) n r 1 ) λ (nr 1) r, 1m 1,..., λr (nr 1) ζrm (nr 1) r } (1)

Termnaton of Integer Lnear Programs 379 Thus we can rewrte (1) as a set of condtons on the ntal z(0) of the form Cond k (z(0),)=λ 1 (C k11 + ζ 11 N k111 + ζ 12 N k112 +...+ ζ 1m 1 N k11m1 )z(0)+ λ 1 1 (C k12 + ζ11 1 N k121 + ζ12 1 N k122 +...+ ζ1m 1 1 N k12m1 )z(0) +...+ ( ) λ (n1 1) n 1 1 1 (C k1n1 + ζ (n1 1) 11 N k1n11 + ζ (n1 1) 12 N k1n12 +...+ ζ (n1 1) 1m 1 N k1n1m 1 )z(0) +...+ λ r (C kr1 + ζr1 N kr11 + ζr2 N kr12 +...+ ζrm 1 N kr1mr )z(0)+ λ 1 r ( n r 1 (C kr2 + ζr1 1 N kr21 + ζr2 1 N kr22 +...+ ζrm 1 r N kr2mr )z(0) +...+ ) λr (nr 1) (C krnr + ζ (nr 1) r1 N krnr1 + ζ (nr 1) r2 N krnr2 +...+ ζrm (nr 1) r N krnrm r )z(0) 0, where {>, }. The coeffcents C kjl and N kjlt are all algebrac vectors and can be computed explctly. Moreover, n our case all the condtons and A are over the reals, hence every coeffcent m j t=1 N kjltζ jt wll add up to a real number. Apontz(0) s n N f and only f the condtons Cond k (z(0),) are satsfed for all k and for all =0, 1, 2... Usng the Jordan canoncal form of A, wecanspltthespaceir n nto the subspace S + correspondng to the postve egenvalues of A, and the subspace S o correspondng to the other egenvalues. Each v IR n decomposes unquely nto asumv = v + + v o such that v + S + and v o S o.ifwewrtecond k (z(0) +,) we get all N kjlt s equal to zero, snce there are no vectors n S + correspondng to the complex egenvalues. Smlarly, n Cond k (z(0) o,)wegetallc kjl s equal to zero. Observe that the magntude of the terms C kjl + ζ j1n kjl1 + ζ j2n kjl2 +...ζ jm j N kjlmj remans bounded by a constant ndependent of throughout the teraton. Hence the magntude of( the components ) of Cond k (z(0)) as tends to s prmarly dctated by the λ (l 1) l 1 j terms of the products. These terms have a clear domnance order as. For hgher j the terms grow geometrcally faster, because λ j 1 λ j 2 for j 1 <j 2. For the same j, terms wth hgher l grow ( ) ( ) polynomally faster, because for l l 1 1 l 2 1 1 <l 2. Ths yelds a natural lexcographc order on the pars of ndexes jl: Ind = {0 11 12... 1n 1 21... 2n 2... r1... rn r }. The term 0 s the smallest term, t s ntroduced for completeness n the case of non-strct nequaltes. It does not correspond to any actual ndex. Our frst step s very smlar to [Tw04]: we solve the problem over the postve egenspace S +.

380 M. Braverman Lemma 6. For every vector z S + the program wth ntal condtons A q z s non-termnatng for some nteger q 0 f and only f there s a functon ndex z : k ndex z (k) Ind whch maps the condton Cond k (z) to the hghest rankng nonzero C k,ndexz (k). All hgher rankng coeffcents must be zero. In other words, for each k, { Ck,nd z =0, f nd ndex z (k) C k,nd z>0, f nd = ndex z (k) In the case that the k-th nequalty s strct we must have ndex z (k) 0. Proof. Frst of all note that snce z s n S +, only the C k,nd (and no N k,nd,t s) appear n the expressons for Cond k (z,). It s obvous that for A q z to be non-termnatng for some q the condtons Cond k (z,) must be satsfed as. In partcular, the hghest rankng coeffcent, whch domnates the behavor as goes to nfnty must be postve (or all of them may be 0 n the case of a non-strct nequalty). Note that ndex z s a well-defned functon for each such z. Conversely, f the ndex z (k) functon as n the statement of the lemma exsts, then the domnatng term n each Cond k (z,) has a postve coeffcent. Hence the condtons Cond k (z,) are satsfed for suffcently large. In partcular, there s a q such that they are satsfed for q, makng the program non-termnatng on A q z. We denote the set of z s for whch A q z N for some q by N e eventually nontermnatng. Those are the ponts whch mght be termnatng, but become non-termnatng after fntely many applcatons of A. Lemma 6 gves a characterzaton of N e, and assocates a unque functon ndex z wth each z N e.we clam that there s a maxmum such functon. Lemma 7. There s a z max N S + wth an ndex functon ndex zmax = ndex max such that for any z N S +, for all k, ndex z (k) ndex max (k). Proof. FrstwenotethatN e s convex. If z 1,z 2 N e, then there s a q such that A q z 1,A q z 2 N. N s convex, hence the lne segment I connectng A q z 1 to A q z 2 s n N. The lne segment connectng z 1 to z 2 s mapped to I by A q, hence t s n N e. Denote z =(z 1 + z 2 )/2. Then t s easy to see that ndex z =max(ndex z1,ndex z2 ). Thus, there can be only one maxmal ndex functon, whch s the maxmum ndex functon for some z max N e S +. We can take suffcently many teratons of z max to obtan z max N S +.

Termnaton of Integer Lnear Programs 381 Note that t s easy to compute z max and ndex max by consderng the constrant satsfacton problem correspondng to each ndex functon and choosng the maxmum feasble functon and a correspondng z max. In fact, a generc element y of N S + satsfes ndex y = ndex max. As mentoned n the begnnng of the secton, the man dea n fndng the mnmal space S mn contanng N s that t s spanned by small perturbatons of z max. The clam s that a small perturbaton of z max s n N as long as we do not ntroduce any terms that are more domnant than the currently domnant ones. Lemma 8. For a vector v IR n there s an ε 0such that z max + εv N f and only f for all k { Ck,nd v =0, for nd ndex max (k) N k,nd,t v =0, for nd ndex max (k), for all t Proof. The f drecton. Cond k (z max,) s domnated by the C k,ndexmax(k)z term for all. It wll reman postve f we add εv to t for some small ε. Bythe condton t wll reman domnatng, snce no non-zero hgher order terms are ntroduced by addng εv. The only f drecton. We frst show by contradcton that the frst condton must hold. Suppose that there s a v and ε such that y = z max + εv N, but C k,nd v 0forsomek and nd ndex max (k). Decompose y = y + + y o,so that y + S + and y o S o.thenc k,nd y = C k,nd y +. There are two cases: Case 1: For each k, the hghest-rankng non-zero C k,nd y + s postve. In ths case y + N e by Lemma 6. By the defnton of ndex max we get C k,nd y = C k,nd y + =0forallnd ndex max. Hence C k,nd v =(C k,nd y)/ε = 0, contradcton. Case 2: There s a k such that the hghest-rankng non-zero C k,nd y = C k,nd y + s negatve. In ths case the domnatng term of Cond k (y, ) hasthecoeffcent C k,nd y + ζ k1 N k,nd,1y + ζ k2 N k,nd,2y +...+ ζ km k N k,nd,mk y. By Lemma 4 the expresson wll be negatve below C k,nd y nfntely often, hence Cond k (y, ) wll be volated nfntely often, contradcton. Now suppose that for some k and nd ndex max (k) the second condton s volated. We already know that C k,nd y = 0, and the domnatng term of Cond k (y, ) hasthecoeffcent C() =ζ k1 N k,nd,1y + ζ k2 N k,nd,2y +...+ ζ km k N k,nd,mk y, whch s not dentcally 0. By Lemma 4 we know that there s a c<0such that C() <cnfntely often. Snce ths s a domnatng term, t wll cause Cond k (y, ) to be volated nfntely often, contradcton.

382 M. Braverman Solvng the constrant system from Lemma 8 gves us a lnear bass for S mn.the computaton s done entrely symbolcally over algebrac numbers. Note that we do not need to know ε from Lemma 8, but merely that such an ε exsts. Ths solves the termnaton problem over IR. Our goal now s to tackle the problem over Q. If S mn =, we can return termnates, otherwse we need to fnd the ratonal subspace of S mn. 4.2 Lookng for Ratonal Ponts n S mn If the parameters of the loop are gven by ratonals, then the spannng vectors of S mn can be produced as explct algebrac numbers. Denote by L S the base vectors for S mn presented as algebrac numbers n some fnte degree extenson Q(α) ofq. By vewng Q(α) as a fnte-dmensonal vector space over Qwecan fnd the maxmum space Q mn of ratonal vectors spanned by L S.Forfurther detals about computatons wth algebrac numbers see [Bhu93, Loos83, Yap00]. We llustrate fndng the ratonal subspace wth the followng smple example. Example 3. Consder the smple example when Q(α) =Q( 2) and L S = {v 1 = (1, 0, 2),v 2 =( 2, 1, 0)}. We are lookng for coeffcents β,γ Q( 2) for whch βv 1 + γv 2 Q 3. By wrtng β = β 1 + β 2 2, γ = γ1 + γ 2 2 wth β 1,β 2,γ 1,γ 2 Q we obtan the condtons β +( 2)γ Q β 2 γ 1 =0 γ Q ( γ 2 =0 2)β Q β 1 =0 Hence we must have γ = β/ 2 Q, and the ratonal subspace of span(l S )s one dmensonal, spanned by 2v 1 + v 2 =(0, 1, 2). There are three possble cases. The frst one s that dm(q mn )=dm(s mn ). Ths means that the ratonal ponts are dense n the nontermnatng set N, and hence there are nontermnatng ratonal ponts, and we can return nontermnatng. If dm(q mn ) = 0, then the only potental nontermnatng ratonal pont s 0. It s trval to check whether 0 s non-termnatng n the homogeneous case: we just need to check whether t satsfes the loop condtons. If t does we return non-termnatng, otherwse return termnatng. The more dffcult and nterestng case s when 0 < d = dm(q mn ) < dm(s mn ). In ths case there are some ratonal ponts n S mn, but we can no longer guarantee that any of them are n N, snce they all le n a proper subspace of S mn. The only thng we know s that all potental ratonal non-termnatng ponts le n Q mn.denotebyr mn the space of real vectors spanned by Q mn. Obvously dm(r mn )=dm(q mn ). We prove the followng. Lemma 9. R mn s nvarant under A, that s Av R mn for any v R mn. Proof. Frst of all, the non-termnatng set N s nvarant under A, snce f the loop s nontermnatng on x, t s also nontermnatng on Ax. N contans a lnear bass for S mn, hence S mn s nvarant under A.

Termnaton of Integer Lnear Programs 383 Let q be any ratonal vector n Q mn. Aq s ratonal, and Aq S mn by the nvarance of S mn. Hence by the defnton of Q mn (as contanng all the ratonal vectors n S mn ), Aq Q mn. The ratonal vectors of R mn span t, hence R mn s nvarant under A. R mn s a subspace nvarant under A, and t has a ratonal bass L R ={r 1,...,r d }. We can translate the acton of A on R mn wth respect to L R,toobtanad d ratonal matrx A such that A : α 1 r 1 +...+ α d r d β 1 r 1 +...+ β d r d, where (β 1,...,β d ) T = A (α 1,...,α d ) T. The condtons B s x>0andb w x 0 can also be readly translated nto ratonal condtons over the d-dmensonal coeffcent vector (α 1,...,α d ), where x = α 1 r 1 +...+ α d r d R mn.thuswe obtan a new loop, over d-dmensonal vectors whle (B sx>0) (B wx 0) { x A x } and we need decde termnaton of the new loop over Q. Note that we have reduced the dmenson of the problem from n to d<n, and thus we wll be able to decde termnaton over Q n the homogeneous case n at most n teratons. 5 The Integer and the Non-homogeneous Cases In the case the program s nterpreted over the reals or the ratonals, the transton from general termnaton to the homogeneous case s done exactly as n [Tw04] by addng an extra auxlary varable z. The program whle (B s x>b s ) (B w x b w ) { x Ax + c } always termnates f and only f the program whle (B s x>b s z) (B w x b w z) (z >0) { x Ax + cz, z z } termnates.thsstruebothoverq and IR. If the frst program does not termnate, then the second does not termnate wth the same ntal condton and z = 1. In the opposte drecton, we can scale a nontermnatng startng pont of the second program so that z = 1, and thus make t a nontermnatng startng pont for the frst one. Note that n the homogeneous case we can scale any nontermnatng soluton, and hence termnaton over Q s always equvalent to termnaton over ZZ. Ths s not true n the non-homogeneous case: termnaton over Q mples termnaton over ZZ, but not vce versa. Thus t can only be used as a partal termnaton test. The termnaton problem over ZZ as well as termnaton of loops wth ntal condtons appears to be much harder and wll be dscussed n next secton. 6 Further Drectons and Open Problems We have seen that termnaton of determnstc loops wth no ntal condtons s decdable over QandoverZZ n the homogeneous case. On the other hand,

384 M. Braverman by allowng the lnear loop to be general enough one can easly make the termnaton problem undecdable. For example, havng k dfferent update functons dependng on dfferent condtons whle one of the k condtonssmetfor1 k f B x>d { x A x + c } s enough to make the termnaton problem undecdable, snce ths class of loops s suffcently rch to allow encodng of counter machnes [Tw04]. Ths gves rse to natural open questons about termnaton of programs more general than the ones consdered n ths paper, but for whch termnaton s stll decdable. One such class are the programs dscussed n [PR04]. They are smlar to the ones descrbed here, but have a nondetermnstc nequalty as an update: whle (B s x>b s ) (B w x b w ) { x Ax + c } In [PR04] a complete lnear rankng functon generatng algorthm s presented, but t stll leaves the more general termnaton problem open over ether IR, Q or ZZ. Another natural generalzaton s ntroducng ntal condtons and the related problem of termnaton over ZZ. It appears that to decde termnaton over ZZ t s necessary to be able to tell, gven a pont x 0, whether the program termnates on x 0 or not. Solvng the termnaton problem on a gven nput would requre a much sharper verson of Lemma 4. In Lemma 4, we have shown that the expresson z n = m =1 α ζ n always eventually falls below zero by at least some fxed amount c. It s even possble to compute the nfmum of the expresson usng ergodc theory. However, ths stll falls short of solvng the termnaton problem. Consder the followng algebrac expresson. Here ζ =1,ζ 1: z() =Re(ζ +1 2 ). We would lke to know whether z() ever falls below 0. Ths depends on how close the orbt of ζ gets to 1. To answer ths queston some analyss of the contnued fracton expanson of log ζ seems to be needed. We summarze the problems: 1. Gven a determnstc lnear loop P and an nput x 0,doesP termnate on x 0? 2. Gven a determnstc lnear loop P does t termnate on all nteger nputs? 3. How much nondetermnsm can be ntroduced n a lnear loop wth no ntal condtons before termnaton becomes undecdable? 7 Concluson We have demonstrated a frst termnaton decson procedure that works over the ntegers for smple homogeneous loop programs. Most programs n practce are specfed over the ntegers, yet algorthms usually only work wth the larger doman of real numbers because decson procedures are generally easer there.

Termnaton of Integer Lnear Programs 385 We have ganed new nsghts nto termnaton of more general determnstc lnear loops. We beleve that technques presented n the paper can be generalzed usng more refned analyss to obtan at least a good partal termnaton test over the ntegers for loops wth ntal constrants. Acknowledgments. I would lke to thank Marsha Chechk and Are Gurfnkel for encouragng me to work on the problem. I am also grateful to Are Gurfnkel for hs many useful comment on prelmnary versons of the paper. I would lke to thank Ila Bnder for our useful dscussons on applyng the ergodc theorem. Fnally, I would lke to thank the anonymous referees for the many useful suggestons for mprovements of the paper. References [BPR03] S. Basu, R. Pollack, M.F. Roy, Algorthms n Real Algebrac Geometry, Sprnger, 2003. [Bhu93] M. Bhubaneswar, Algorthmc Algebra, Sprnger-Verlag, 1993. [BBK + 01] V.D. Blondel, O. Bournez, P. Koran, C.H. Papadmtrou, J.N. Tstskls, Decdng stablty and mortalty of pecewse affne dynamcal system. Theoretcal Computer Scence, 255 (1-2), pp. 687696, 2001. [BMP05a] A.R. Bradley, Z. Manna, H.B. Smpa, Lnear rankng wth reachablty, n CAV 2005, pp. 491-504, 2005. [BMP05b] A.R. Bradley, Z. Manna, H.B. Smpa, Termnaton analyss of nteger lnear loops, n CONCUR 2005, pp. 488-502, 2005. [CSS03] M.A. Colón, S. Sankaranarayanan, H.B. Smpa, Lnear nvarant generaton usng non-lnear constrant solvng, n CAV 2003, LNCS 2725, pp. 420-432, 2003. [HK71] K. Hoffman and R. Kunze, Lnear Algebra, Prentce-Hall, 2nd ed., 1971. [Loos83] R. Loos, Computng n Algebrac Extensons, n B. Buchberger, G.E. Collns et al. eds., Computer Algebra: Symbolc and Algebrac Computaton, 2nd ed., Sprnger-Verlag, pp. 173-188, 1983. [Mat93] Y. Matyasevch, Hlbert s Tenth Problem, The MIT Press, Cambrdge, London, 1993. [PR04] A. Podelsk, A. Rybalchenko, A complete method for synthess of lnear rankng functons, n B. Steffen and G. Lev (Eds.): VMCAI 2004, LNCS 2937, pp. 239-251, 2004. [Tar51] A. Tarsk, A Decson Method for Elementary Algebra and Geometry, 2nd ed. Berkeley, CA: Unversty of Calforna Press, 1951. [Tw04] A. Twar, Termnaton of lnear programs, n R. Alur and D.A. Peled (Eds.): CAV 2004, LNCS 3114, pp. 70-82, 2004. [Yap00] C.K. Yap, Fundamental Problems of Algorthmc Algebra, Oxford Unversty Press, 2000.