10.07.2015 Views

A linear-time algorithm to compute geodesics in ... - Project Euclid

A linear-time algorithm to compute geodesics in ... - Project Euclid

A linear-time algorithm to compute geodesics in ... - Project Euclid

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Ill<strong>in</strong>ois Journal of MathematicsVolume 54, Number 1, Spr<strong>in</strong>g 2010, Pages 109–128S 0019-2082A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICSIN SOLVABLE BAUMSLAG–SOLITAR GROUPSMURRAY ELDERAbstract. We present an <strong>algorithm</strong> <strong>to</strong> convert a word of length n<strong>in</strong> the standard genera<strong>to</strong>rs of the solvable Baumslag–Solitar groupBS(1,p) <strong>in</strong><strong>to</strong> a geodesic word, which runs <strong>in</strong> <strong>l<strong>in</strong>ear</strong> <strong>time</strong> andO(n log n) space on a random access mach<strong>in</strong>e.1. IntroductionRecently, Miasnikov, Roman’kov, Ushakov and Vershik [7] provedthatforfree metabelian groups with standard generat<strong>in</strong>g sets, the follow<strong>in</strong>g problemis NP-complete:• given a word <strong>in</strong> the genera<strong>to</strong>rs and an <strong>in</strong>teger k, decide whether the geodesiclength of the word is less than k.They call this the bounded geodesic length problem for a group G with f<strong>in</strong>itegenerat<strong>in</strong>g set G. It follows that given a word, comput<strong>in</strong>g its geodesic length,and f<strong>in</strong>d<strong>in</strong>g an explicit geodesic representative for it, are NP-hard problems.These problems are referred <strong>to</strong> as the geodesic length problem and the geodesicproblem, respectively.In this article, we consider the same problems for a different class ofmetabelian groups, the well known Baumslag–Solitar groups, with presentations〈a, t|tat −1 = a p 〉for any <strong>in</strong>teger p ≥ 2. We give a determ<strong>in</strong>istic <strong>algorithm</strong> which takes as <strong>in</strong>puta word <strong>in</strong> the genera<strong>to</strong>rs a ±1 ,t ±1 of length n, and outputs a geodesic wordrepresent<strong>in</strong>g the same group element, <strong>in</strong> <strong>time</strong> O(n). Consequently, the threeproblems are solvable <strong>in</strong> <strong>l<strong>in</strong>ear</strong> <strong>time</strong>. 1Received March 6, 2009; received <strong>in</strong> f<strong>in</strong>al form Oc<strong>to</strong>ber 28, 2010.2000 Mathematics Subject Classification. Primary 20F65. Secondary 68Q25.1 It is clear that solv<strong>in</strong>g the geodesic problem implies the other two. In [3] the author andRechnitzer show they are all <strong>in</strong> fact equivalent.109c○2011 University of Ill<strong>in</strong>ois


110 M. ELDERIn an unpublished prepr<strong>in</strong>t [6], Miller gives a procedure <strong>to</strong> convert a word<strong>in</strong> the above group <strong>to</strong> a geodesic of the form t −k zt −m where z belongs <strong>to</strong> aregular language over the alphabet {a, a −1 ,t}. Miller’s <strong>algorithm</strong> would takeexponential <strong>time</strong> <strong>in</strong> the worst case. The <strong>algorithm</strong> presented here followsMiller’s procedure with some modifications (us<strong>in</strong>g po<strong>in</strong>ters <strong>in</strong> part one and acareful track<strong>in</strong>g procedure <strong>in</strong> part two) <strong>to</strong> ensure <strong>l<strong>in</strong>ear</strong> <strong>time</strong> and O(n log n)space. Also, our <strong>algorithm</strong> does not output normal forms — the geodesicoutput depends on the <strong>in</strong>put word. A geodesic normal form is easily obta<strong>in</strong>ablehowever, if one first runs a (polynomial <strong>time</strong>) <strong>algorithm</strong> <strong>to</strong> convert <strong>in</strong>putwords <strong>in</strong><strong>to</strong> a normal form (see, for example, [2]).We use as our computational model a random access mach<strong>in</strong>e, which allowsus <strong>to</strong> access (read, write and delete) any specified location <strong>in</strong> an array <strong>in</strong>constant <strong>time</strong>.Recent work of Diekert and Laun [1] extends the result of this paper <strong>to</strong>groups of the form 〈a, t|ta p t −1 = a q 〉 when p divides q. Their <strong>algorithm</strong> runs<strong>in</strong> quadratic <strong>time</strong>, but <strong>in</strong> the case p = 1 the <strong>time</strong> reduces <strong>to</strong> <strong>l<strong>in</strong>ear</strong>, althoughtheir <strong>algorithm</strong> is qualitatively different.2. Prelim<strong>in</strong>ariesFix G p <strong>to</strong> be the Baumslag–Solitar group 〈a, t|t −1 at = a p 〉 for some p ≥ 2.We will call a s<strong>in</strong>gle rela<strong>to</strong>r a brick, with sides labeled by t edges, as <strong>in</strong> Figure 1.The Cayley graph can be obta<strong>in</strong>ed by glu<strong>in</strong>g <strong>to</strong>gether these bricks. We call asheet a subset of the Cayley graph made by lay<strong>in</strong>g rows of bricks a<strong>to</strong>p eachother <strong>to</strong> make a plane, also shown <strong>in</strong> Figure 1. The complete Cayley graphis obta<strong>in</strong>ed by glu<strong>in</strong>g these sheets <strong>to</strong>gether so that every vertex has degreeFigure 1. Parts of the Cayley graph of G 3 .


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 111four. From side-on, the Cayley graph looks like a rooted p-ary tree. Somenice pictures can be found <strong>in</strong> [4], pp. 155–160.We fix an orientation for the Cayley graph by mak<strong>in</strong>g t edges go up vertically,and a edges runn<strong>in</strong>g horizontally from left <strong>to</strong> right. Given this convention,we can speak of the <strong>to</strong>p or bot<strong>to</strong>m of a brick. We def<strong>in</strong>e the level of avertex <strong>in</strong> the Cayley graph <strong>to</strong> be the t-exponent sum of a word start<strong>in</strong>g fromthe identity vertex <strong>to</strong> it. So the identity is at level 0, and t l is at level l. Notethat this is well def<strong>in</strong>ed s<strong>in</strong>ce if u = G v then Brit<strong>to</strong>n’s lemma implies u and vhave the same t-exponent sum.A word <strong>in</strong> the genera<strong>to</strong>rs a ±1 ,t ±1 is said <strong>to</strong> be of the form P if it conta<strong>in</strong>sno t −1 letters and at least one t letter, and of the form N if it conta<strong>in</strong>s not’s and at least one t −1 . Then a word is of the form PNP say, if it is theconcatenation of three words of the form P,N,P <strong>in</strong> that order. The t-exponentsum of a word is the number of t letters m<strong>in</strong>us the number of t −1 letters. Wewrite = G when two words represent the same element <strong>in</strong> the group and =when they are identical as str<strong>in</strong>gs, and l(w) is the number of letters <strong>in</strong> thestr<strong>in</strong>g w.The follow<strong>in</strong>g simple lemma and corollaries come from [6] and[5].Lemma 1 (Commutation). If u, v have t-exponent sum zero then uv = G vu.Corollary 2(Geodesics). A geodesic cannot conta<strong>in</strong> a subword of theform NPNP or PNPN.Corollary 3 (Push<strong>in</strong>g as). If w is of type NP and has t-exponent zero,then w = G u = t −k u P where u P is of type P and t-exponent k, and l(u) ≤l(w). If w is of type PN and t-exponent zero then w = G v = v P t −k where v Pis of type P and t-exponent k, and l(v) ≤ l(w).The two corollaries are simply a matter of commut<strong>in</strong>g subwords of t-exponent zero past each other. We will show how this can be done <strong>in</strong> <strong>l<strong>in</strong>ear</strong><strong>time</strong> and O(n log n) space <strong>in</strong> the <strong>algorithm</strong>. The trick is <strong>to</strong> use po<strong>in</strong>ters, whichwe will expla<strong>in</strong> <strong>in</strong> Section 4 below.3. t-exponent sum of the <strong>in</strong>put wordThe <strong>algorithm</strong> we describe <strong>in</strong> this paper applies only <strong>to</strong> <strong>in</strong>put words withnonnegative t-exponent sum. To convert words of negative t-exponent sum<strong>to</strong> a geodesic, we modify the procedure given here as follows. Take as <strong>in</strong>putthe <strong>in</strong>verse of the <strong>in</strong>put word, which has positive t-exponent sum. Run the<strong>algorithm</strong> as described on this word, then at the end, write the <strong>in</strong>verse of theoutput word as the f<strong>in</strong>al output.Rewrit<strong>in</strong>g the <strong>in</strong>put and output words as their <strong>in</strong>verses clearly can be done<strong>in</strong> <strong>l<strong>in</strong>ear</strong> <strong>time</strong> and space.


112 M. ELDER4. Algorithm part oneThe first stage of the <strong>algorithm</strong> is <strong>to</strong> rearrange the <strong>in</strong>put word and freelyreduce, <strong>to</strong> convert it <strong>to</strong> a standard form. We assume the <strong>in</strong>put word haslength n and has nonnegative t-exponent sum.Proposition 4. Any word w ∈ G p of length n with nonnegative t-exponentsum can be converted <strong>to</strong> a word u = G w of the formsuch that• l(u) ≤ n,• k,q,m ≥ 0,• q ≥ k + m,• |ε 0 | > 0 if k>0,• |ε q | > 0 if m>0,• |ε i |


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 113• In row 5, write a blank symbol <strong>in</strong> the first address, then write the numbers 0through n <strong>in</strong> the rema<strong>in</strong><strong>in</strong>g addresses. This row <strong>in</strong>dicates the previous columnaddress that was read (so are “backwards po<strong>in</strong>ters”). As the <strong>algorithm</strong>progresses, the entries <strong>in</strong> this row may change.Here is List A <strong>in</strong> its <strong>in</strong>itial state, with <strong>in</strong>put word at 2 a ···at −1 .List A ↓column 0 1 2 3 4 ··· n − 1 n n+1word S a t t a ··· a t −1 Ft-exp<strong>to</strong> 1 2 3 4 5 ··· n n+1from 0 1 2 3 ··· n − 2 n − 1 nAs the <strong>algorithm</strong> progresses, we will “reorder” the word written <strong>in</strong> row 2us<strong>in</strong>g the po<strong>in</strong>ters <strong>in</strong> rows 4 and 5 (and leav<strong>in</strong>g the letters <strong>in</strong> row 2 fixed,possibly eras<strong>in</strong>g some). To read the word, start at the S symbol. Move <strong>to</strong> thecolumn address <strong>in</strong>dicated <strong>in</strong> row 4. At the beg<strong>in</strong>n<strong>in</strong>g this will be column 1.From the current column, read the entry <strong>in</strong> row 4 <strong>to</strong> move the the next column.Cont<strong>in</strong>ue until you reach the F symbol. At any stage, <strong>to</strong> step back <strong>to</strong> theprevious address, go <strong>to</strong> the column address <strong>in</strong>dicated by row 5. Throughoutthe <strong>algorithm</strong>, the po<strong>in</strong>ters will never po<strong>in</strong>t <strong>to</strong> or from a column which has ablank symbol <strong>in</strong> row 2. The po<strong>in</strong>ters allow us <strong>to</strong> rearrange and delete lettersfrom the word <strong>in</strong> row 2 efficiently (<strong>in</strong> constant <strong>time</strong>), without hav<strong>in</strong>g <strong>to</strong> moveany letters on the table.For convenience, we <strong>in</strong>dicate the current address be<strong>in</strong>g read by a cursor.We assume that mov<strong>in</strong>g the cursor from one position <strong>in</strong> the list <strong>to</strong> anothertakes constant <strong>time</strong> on a random access mach<strong>in</strong>e.Here are two subrout<strong>in</strong>es that we will use many <strong>time</strong>s. Each one takesconstant <strong>time</strong> <strong>to</strong> call.Subrout<strong>in</strong>e 1: Free reduction. This subrout<strong>in</strong>e elim<strong>in</strong>ates freely cancel<strong>in</strong>gpairs xx −1 <strong>in</strong> row 2 of List A, <strong>in</strong> constant <strong>time</strong>. Assume that the cursor ispo<strong>in</strong>t<strong>in</strong>g <strong>to</strong> column k, and that the entry <strong>in</strong> the address (2, k) is not blank.Read the entries <strong>in</strong> rows 2, 4 and 5 of column k. Say the letter <strong>in</strong> row 2is x, and the <strong>in</strong>tegers <strong>in</strong> rows 4 and 5 are i, j.If position j row 2 is x −1 , then we can cancel this pair of genera<strong>to</strong>rs fromthe word as follows:• Read the <strong>in</strong>teger <strong>in</strong> row 5 position j, and go <strong>to</strong> the address <strong>in</strong>dicated (sayit is r). In row 4 of this address, write i. In row 5 position i, writer.• Erase entries <strong>in</strong> columns j and k.• Go <strong>to</strong> position i.


114 M. ELDERIn this way, we have deleted x −1 x from the word, and adjusted the po<strong>in</strong>tersso that they skip these positions.List A↓column ··· r ··· j ··· k ··· i ···word x −1 xt-exp<strong>to</strong>ifrom r jList A↓column ··· r ··· j ··· k ··· i ···word × ×t-exp × ×<strong>to</strong> i × ×from × × rElse, if position i row 2 is x −1 , we perform a similar operation <strong>to</strong> erasexx −1 from the word, adjust<strong>in</strong>g po<strong>in</strong>ters appropriately.Assum<strong>in</strong>g that we can access positions us<strong>in</strong>g the po<strong>in</strong>ters <strong>in</strong> constant <strong>time</strong>(that is, we have a random access mach<strong>in</strong>e), then this procedure takes constant<strong>time</strong> <strong>to</strong> run.Subrout<strong>in</strong>e 2: Consecutive as. This subrout<strong>in</strong>e elim<strong>in</strong>ates the occurrenceof subwords a ±3p (where p ≥ 2 is fixed) <strong>in</strong> constant <strong>time</strong>. Bound<strong>in</strong>g the numberof consecutive a and a −1 letters will be important for the <strong>time</strong> complexityof the <strong>algorithm</strong> later on.Aga<strong>in</strong>, assume the cursor is po<strong>in</strong>t<strong>in</strong>g <strong>to</strong> column k and the entry at address(2,k) is not blank.• If the letter at this address is a, set a counter acount = 1. Move backone square (us<strong>in</strong>g po<strong>in</strong>ter <strong>in</strong> row 5) <strong>to</strong> column j. If address (2,j)isa,<strong>in</strong>crement acount. Repeat until acount = 3p or the next letter is not a.Note maximum number of steps is 3p (constant).If acount = 3p and you are at column i, writeta 3 t −1 over the first 5 as,and blank symbols <strong>in</strong> the rema<strong>in</strong><strong>in</strong>g 3p − 5 addresses up <strong>to</strong> position k.Adjust the po<strong>in</strong>ters so that the po<strong>in</strong>ter at the added t −1 po<strong>in</strong>ts <strong>to</strong> the value<strong>in</strong>dicated at (4,k), and write the appropriate value <strong>in</strong> row 5 of that position.• If the letter at this position is a −1 , do the same with a −1 <strong>in</strong>stead of a.This procedure takes constant <strong>time</strong>, and if it is successful (that is, replacesa ±3p by t −1 a ±3 t) it strictly reduces the length of the word.We are now read<strong>in</strong>g <strong>to</strong> describe part one of the <strong>algorithm</strong>, prov<strong>in</strong>g Proposition4.


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 115Step 1. Write the <strong>in</strong>put word <strong>in</strong> freely reduced form on List A as follows.Read the first letter and write it <strong>in</strong> address (1, 2) of List A. For each subsequentletter if it freely cancels with the previous letter <strong>in</strong> row 2, erase the previousletter and cont<strong>in</strong>ue. At the same <strong>time</strong>, record the successive t-exponent sumof the word by <strong>in</strong>crement<strong>in</strong>g and decrement<strong>in</strong>g a counter each <strong>time</strong> a t ±1 isread.So the word <strong>in</strong> row 2 of the tape is freely reduced and has nonnegativet-exponent (by assumption). Fill <strong>in</strong> rows 1, 4 and 5 of List A with the columnnumbers and po<strong>in</strong>ters set <strong>to</strong> the <strong>in</strong>itial state.Step 2. In this step, we elim<strong>in</strong>ate all occurrences of a ±3p <strong>in</strong> the word.Set k =3p − 1. Assume the entire word <strong>in</strong> row 2 is freely reduced, andconta<strong>in</strong>s no more than 3p − 1 consecutive as ora −1 s up <strong>to</strong> column k.• Move cursor <strong>to</strong> column k. Follow<strong>in</strong>g the po<strong>in</strong>ter <strong>in</strong> row 4, move <strong>to</strong> the nextcolumn after k. If the letter <strong>in</strong> row 2 is a ±1 , then perform Subrout<strong>in</strong>e 2.• If the subrout<strong>in</strong>e f<strong>in</strong>ds a ±3p , then with the cursor at the each end of the<strong>in</strong>serted word (of length 5), perform Subrout<strong>in</strong>e 1. Repeat until Subrout<strong>in</strong>e1 f<strong>in</strong>ds no more cancel<strong>in</strong>g pairs and so the entire word <strong>in</strong> row 2 is freelyreduced. Set k = the column <strong>to</strong> the right of the previous k and repeat.At the end of this procedure, the entire word is freely reduced and has noa ±3p subwords. The number of <strong>time</strong>s Subrout<strong>in</strong>e 2 is performed is at mostthe number of <strong>time</strong>s we iterate the above steps, which is at most n − 3p,and the <strong>to</strong>tal number of <strong>time</strong>s we perform Subrout<strong>in</strong>e 1 is O(n) s<strong>in</strong>ce each<strong>time</strong> it is successful the word reduces length, so it is successful at most n<strong>time</strong>s and unsuccessful at most twice (for each end) after each application ofSubrout<strong>in</strong>e 2.So we now have a freely reduced word with less than 3p a ±1 letters <strong>in</strong>succession, <strong>in</strong> row 2 of List A. The po<strong>in</strong>ters <strong>in</strong> row 4 still po<strong>in</strong>t <strong>to</strong> columns <strong>to</strong>the right, s<strong>in</strong>ce we have not commuted any subwords yet.Step 3. Construct a second list we call List B of 2n + 1 4-tuples, which weview as a 4 × (2n + 1) table. In the first row write the <strong>in</strong>tegers from −n <strong>to</strong> n.Start<strong>in</strong>g at column 0 of List A, set a counter texp = 0. Read<strong>in</strong>g the word<strong>in</strong> row 2 from left <strong>to</strong> right, if <strong>in</strong> column k you read a t ±1 letter, add ±1 <strong>to</strong>texp, and write the value of texp at address (3,k) of List A. In List B, ifaddress (2, texp) isblank,writek. If it conta<strong>in</strong>s a value, write k <strong>in</strong> address(3, texp) if it is blank, otherwise <strong>in</strong> address (4, texp).In other words, each <strong>time</strong> you read a t ±1 , write the current t-exponent sumunderneath it, and <strong>in</strong> List B keep a record of how many <strong>time</strong>s this t-exponenthas appeared (which we call the number of “strikes” for that exponent) andat which positions <strong>in</strong> List A it appeared.


116 M. ELDERHere we show List A for the <strong>in</strong>put word at 2 atat −1 at −1 at −1 ata ···,andthecorrespond<strong>in</strong>g List B, as an example.List A↓column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ···word S a t t a t a t −1 a t −1 a t −1 a t at-exp 1 2 3 2 1 0 1<strong>to</strong> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15from 0 1 2 3 4 5 6 7 8 9 10 11 12 13List Bt-exp ··· −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 ···strike 1 11 2 3 5strike 2 9 7strike 3 13When an entry occurs <strong>in</strong> the last row of List B at some position labeledtexp, mean<strong>in</strong>g the same exponent has occurred 3 <strong>time</strong>s , then we have a prefixof the form either NPNP or PNPN, so we apply Corollary 2 as follows.Suppose the entries <strong>in</strong> this column are p a ,p b ,p 3 ,withp 3 the most recentlyadded. These correspond <strong>to</strong> the positions <strong>in</strong> List A where the value texp haveappeared.To beg<strong>in</strong> with, the word written <strong>in</strong> row 2 of List A appears <strong>in</strong> the correc<strong>to</strong>rder (from left <strong>to</strong> right), the po<strong>in</strong>ters have only been used <strong>to</strong> possibly skipblank addresses. So at the start of this step we know that p a comes before p b .However, as the <strong>algorithm</strong> progresses, we will not know which of p a and p bcomes first <strong>in</strong> the word. That is, as we <strong>in</strong>troduce po<strong>in</strong>ters <strong>to</strong> List A <strong>to</strong> movesubwords around, a letter <strong>in</strong> column p could sit before a letter <strong>in</strong> column qwith q


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 117Now one of columns q a ,q b must conta<strong>in</strong> a t ±1 <strong>in</strong> row 2, with sign opposite<strong>to</strong> that of p 3 .• If q a is same sign as p 3 ,thenordermustbep a − q a − p b − q b − p 3 .• If q b is same sign as p 3 ,thenordermustbep b − q b − p a − q a − p 3 .• Both q a ,q b have opposite sign <strong>to</strong> p 3 . In this case, we look at the letters <strong>in</strong>row 2 of columns p a ,p b . If the letter at address (2,p a ) has opposite sign<strong>to</strong> that <strong>in</strong>(2,p 3 ), then it must come first, s<strong>in</strong>ce one of p a ,p b must match upwith q a ,q b .If both p a ,p b have same letter as p 3 <strong>in</strong> row 2, then we are <strong>in</strong> a situationlike tat −1 atat −1 at. But s<strong>in</strong>ce there is a t ±1 letter preced<strong>in</strong>g both p a and p b ,then the t-exponent before p a ,p b ,p 3 are read is the same, and is recordedthree <strong>time</strong>s. This case cannot arise s<strong>in</strong>ce we apply this procedure the first<strong>time</strong> we see the same number more than twice.Us<strong>in</strong>g this subrout<strong>in</strong>e, we can determ<strong>in</strong>e the correct order of the columnsp a ,p b and q a ,q b ,<strong>in</strong>O(n) <strong>time</strong>. Rename the first position p 1 and second p 2 ,and q 1 ,q 2 as appropriate. So we have p 1 − q 1 − p 2 − q 2 − p 3 .The subword between positions q 1 and p 2 has t-exponent 0, as does thesubword from q 2 <strong>to</strong> p 3 . By commut<strong>in</strong>g one of these subwords (us<strong>in</strong>g Lemma 1),we can place a t next <strong>to</strong> a t −1 somewhere and get a free cancellation. Theprecise <strong>in</strong>struction will depend on the letters at each of these addresses, andwe will consider each situation case-by-case.Case 1.List Acolumn ··· p 1 ··· q 1 ··· p 2 ··· q 2 ··· p 3 ···word t t −1 t t −1 tt-exp k 1 k 2<strong>to</strong> i 1 i 2 i 3from j 1 j 2 j 3Between p 1 and q 1 we have only a letters (or noth<strong>in</strong>g). So we will commutethe subword q 1 − p 2 back <strong>to</strong>wards p 1 as follows:• j 1 row 4, replace p 1 by i 2• i 2 row 5, replace q 1 by j 1• p 2 row 4, replace i 3 by i 1• i 1 row 5, replace p 1 by p 2• j 2 row 4, replace q 1 by i 3• i 3 row 5, replace p 2 by j 2• delete columns p 1 ,q 1• delete p 1 and q 1 from List B columns k 1 and k 2 , respectively.


118 M. ELDERThis has the effect of mov<strong>in</strong>g the subword back through the word, but withoutchang<strong>in</strong>g more that a constant number of entries <strong>in</strong> the lists (with randomaccess).The next case applies <strong>to</strong> our runn<strong>in</strong>g example shown above.Case 2.List Acolumn ··· p 1 ··· q 1 ··· p 2 ··· q 2 ··· p 3 ···word t t t −1 t −1 tt-exp k 1 k 2<strong>to</strong> i 1 i 2 i 3from j 1 j 2 j 3This <strong>time</strong> we will commute the subword q 2 − p 3 back past the subword oft-exponent zero and next <strong>to</strong> p 1 as follows:• j 1 row 4, replace p 1 by i 2• i 2 row 5, replace p 1 by j 1• p 3 row 4, replace i 3 by i 1• i 1 row 5, replace p 1 by p 3• j 2 row 4, replace q 2 by i 3• i 3 row 5, replace p 3 by j 2• delete columns q 1 ,p 2• delete p 1 and q 2 from List B columns k 1 and k 2 , respectively.Below we show the two lists after commut<strong>in</strong>g and delet<strong>in</strong>g tt −1 for ourrunn<strong>in</strong>g example after this step. We read the new word off List A follow<strong>in</strong>gthe po<strong>in</strong>ters as a at tatat −1 at −1 a at −1 ···.List A↓column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ···word S a × t a t a t −1 a t −1 a × a t at-exp × 2 3 2 1 × 1<strong>to</strong> 1 12 × 4 5 6 7 8 9 10 14 × 13 3 15from 0 × 13 3 4 5 6 7 8 9 × 1 12 10List Bt-exp ··· −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 ···strike 1 9 3 5strike 2 13 7strike 3


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 119The rema<strong>in</strong><strong>in</strong>g cases are similar and we leave it <strong>to</strong> the reader <strong>to</strong> imag<strong>in</strong>ethe <strong>in</strong>structions for each one. Corollary 2 guarantees that some commutationwill reduce length <strong>in</strong> each case.With the cursor at position p 3 or if blank, the non-blank letter <strong>to</strong> its right,perform Subrout<strong>in</strong>e 1 until unsuccessful, then Subrout<strong>in</strong>e 2 until unsuccessful,and alternately until both are unsuccessful. S<strong>in</strong>ce each successful applicationof a subrout<strong>in</strong>e reduces word length, the <strong>to</strong>tal number of successes of each is nthroughout the whole <strong>algorithm</strong>. Once both are unsuccessful the entire wordis aga<strong>in</strong> freely reduced and avoids a ±3p , and the cursor is at the next non-blankposition <strong>to</strong> the right of p 3 . We then resume Step 3 from this position.So after perform<strong>in</strong>g this procedure, List A conta<strong>in</strong>s a possibly shorter word<strong>in</strong> row 2, which is read start<strong>in</strong>g at column 0 and follow<strong>in</strong>g po<strong>in</strong>ters, and List Bconta<strong>in</strong>s the correct data of t-exponents and addresses (although addressesdon’t stay <strong>in</strong> order). S<strong>in</strong>ce we removed one of the 3 “strikes,” we start atp 3 + 1 and cont<strong>in</strong>ue fill<strong>in</strong>g out row 3 of List A, add<strong>in</strong>g appropriate entries<strong>to</strong> List B, until we aga<strong>in</strong> get 3 strikes. Note that we do not backtrack, sothe <strong>to</strong>tal number of right steps taken <strong>in</strong> Step 3 (assum<strong>in</strong>g the random accessmodel of computation allows us <strong>to</strong> read and write at any specified position<strong>in</strong> the table) is O(n). The number of <strong>time</strong>s we need <strong>to</strong> apply the subrout<strong>in</strong>es(successfully and unsuccessfully) is also O(n) regardless of how many <strong>time</strong>sStep 3 is called, so so all <strong>to</strong>gether this step takes O(n) <strong>time</strong>.At the end of this step, s<strong>in</strong>ce the word has nonnegative t-exponent sum,and all “3 strikes” have been elim<strong>in</strong>ated, the word must be of the form E, P ,PN, NP, NPN,orPNP.Step 4. If the word at this stage is of the form PNP,itst-exponent summust be zero, so it has a prefix of the form PN and suffix NP, both of zerot-exponent sum. Say p 1 ,p 2 are the two positions that the t-exponent is zero.We commute the prefix and suffix by rewrit<strong>in</strong>g po<strong>in</strong>ters. If the word on List Ais not written <strong>in</strong> order from left <strong>to</strong> right, we can create a new List A <strong>in</strong> whichthe word is <strong>in</strong> correct order, by read<strong>in</strong>g the current list follow<strong>in</strong>g the po<strong>in</strong>ters.So after this, we can assume the configuration of List A is as follows:List Acolumn 0 ··· p 1 ··· p 2 ··· n +1word S t −1 t Ft-exp 0 0<strong>to</strong> i 1 i 2 i 3from j 1 j 2 j 3Then do the follow<strong>in</strong>g:• 0 row 4 replace i 1 by p 2• p 2 row 5 replace j 2 by 0


120 M. ELDER• j 3 row 4 replace n +1 by p 1• p 1 row 5 replace 0 by j 3• j 1 row 4 replace p 2 by n +1• n + 1 row 5 replace j 3 by j 1 .The word is now the form NPN.Step 5. At this po<strong>in</strong>t the word <strong>in</strong> List A row 2 is of the form E, P , PN, NPor NPN. We can ascerta<strong>in</strong> which of these it is <strong>in</strong> constant <strong>time</strong> simply bycheck<strong>in</strong>g the first and last t ±1 letter <strong>in</strong> the word, which lie at most 3p stepsfrom the ends of the tape (positions S and F ), follow<strong>in</strong>g po<strong>in</strong>ters.• No t ±1 letters: E• First t last t: P• First t last t −1 : PN• First t −1 last t: NP• First t −1 last t −1 : NPN.In the case E, thewordisa i with |i| < 3p, so by check<strong>in</strong>g a f<strong>in</strong>ite list wecan f<strong>in</strong>d a geodesic for it and be done. So for the rest of the <strong>algorithm</strong> assumeu is of the form P,PN,NP,NPN.In the last two cases, NP and NPN it is possible the word conta<strong>in</strong>s asubword of the form t −1 a xp t for an <strong>in</strong>teger x, which will be <strong>in</strong> {±1, ±2}. Ifso, we want <strong>to</strong> replace it by a x , which will always reduce length. This iseasily done <strong>in</strong> constant <strong>time</strong>, assum<strong>in</strong>g the cursor is po<strong>in</strong>t<strong>in</strong>g <strong>to</strong> the columnconta<strong>in</strong><strong>in</strong>g the first t letter <strong>in</strong> the word. From this column scan back at most 3pletters <strong>to</strong> a t −1 letter and count the number of a ±1 letters <strong>in</strong> between. Then ifyou f<strong>in</strong>d t −1 a xp t rewrite with a x and then move forward <strong>to</strong> the next t letter.Repeat this at most O(n) <strong>time</strong>s (the maximum number of t letters <strong>in</strong> theword) until no such subword appears. Note that <strong>to</strong> locate the first t letter <strong>in</strong>the word <strong>to</strong> start this takes O(n) <strong>time</strong> <strong>to</strong> scan the word, but you only need<strong>to</strong> do this once.We now have a word <strong>in</strong> one of the forms P,PN,NP,NPN which conta<strong>in</strong>sno t −1 a xp t subword.Step 6. In this step, we apply Corollary 3 <strong>to</strong> push all of the a ±1 letters <strong>in</strong>the word <strong>in</strong><strong>to</strong> a s<strong>in</strong>gle sheet of the Cayley graph. The output of this step (theword <strong>in</strong> row 2 of List A) will be a word of the form t −k u P t −l where u P is aword of type P with t-exponent ≥ k + l, andk,l ≥ 0 and the word still doesnot conta<strong>in</strong> a subword of the form t −1 a xp t.Case P . The word is of the form u P so done.Case PN. Say texp is the f<strong>in</strong>al t-exponent of the word, which occurs atpositions p 1 and q 1 . If q 1 is not the end of the word (that is, there are a ±1letters at the end of the word), then we want <strong>to</strong> push the a letters there backthrough the word <strong>to</strong> t-exponent 0, which starts after p 1 . The configuration of


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 121the tape is as follows (where we assume j 3 ≠ q 1 s<strong>in</strong>ce there are a ±1 letters atthe end of the word):List Acolumn ··· p 1 ··· p 2 ··· n +1word t t −1 Ft-exp texp texp<strong>to</strong> i 1 i 2from j 1 j 2 j 3Then do the follow<strong>in</strong>g:• q 1 row 4, replace i 2 with n +1• n + 1 row 5, replace j 3 with q 1• p 1 row 4, replace i 1 with i 2• i 2 row 5, replace q 1 with p 1• j 3 row 4, replace n +1 with i 1• i 1 row 5, replace p 1 with j 3 .So we have commuted the word a ±m at the end, through the subword oft-exponent 0. Check for cancellation of a ±1 a ∓1 , if this occurs then cancel.Repeat up <strong>to</strong> 3p − 1 (constant) <strong>time</strong>s.Next, let p 2 ,q 2 be the columns at which (texp + 1) occurs. Repeat theprocedure at this level. Aga<strong>in</strong> freely cancel.Iterate this until all a ±1 letters are pushed <strong>in</strong><strong>to</strong> the middle of the word, sothe result<strong>in</strong>g word is of the form u P t −k where u P is a word of type P witht-exponent at least k. Note that at the <strong>to</strong>p level there is only one a i subword,which will not be canceled, so there is no free cancellation of t letters <strong>in</strong> thisstep. At every other level there can be at most 6p − 2 consecutive a ±1 letters.Case NP. Same as previous case, this <strong>time</strong> push<strong>in</strong>g as <strong>to</strong> the right.Case NPN. Break the word <strong>in</strong><strong>to</strong> NP and PN subwords, with the NPsubword end<strong>in</strong>g with t, and each of zero t-exponent sum, and perform theabove steps <strong>to</strong> push a letters <strong>to</strong> the right and left, respectively, then ensurethere is no t −1 a ip t subword. In the NP prefix the maximum number ofconsecutive a ±1 letters is 6p − 2 at every level except the <strong>to</strong>p level, s<strong>in</strong>ce wecut the word immediately after a t, so at this level we have at most 3p − 1consecutive a ±1 s,and<strong>in</strong>thePN suffix we can have at most 6p − 2ateverylevel, so all <strong>to</strong>gether there could be at most 9p − 3 consecutive a ±1 s.So after this step, the positive part of the word, u P , stays with<strong>in</strong> a s<strong>in</strong>glesheet of the Cayley graph. We writeu P = a ε0 ta ε1 ···a εm−1 ta εm ,where each |ε i | < 9p and with ε 0 not a multiple of p when the word is of theform NP or NPN.


122 M. ELDERStep 7. In this step, we remove all occurrences of a ±p t <strong>in</strong> the word. Scan <strong>to</strong>the first t <strong>in</strong> row 2. If the preced<strong>in</strong>g p letters are a ±1 , then replace a ±p t byta ±1 .Stayatthist letter and repeat until there is no a ±p t, then move <strong>to</strong> thenext t letter. S<strong>in</strong>ce each replacement reduces length the <strong>time</strong> for this step is<strong>l<strong>in</strong>ear</strong>. At the end, you have elim<strong>in</strong>ated all a ±p t subwords so the word is ofthe form u = t −k u P t −l = t −k a ε0 t ···ta εm t −l with |ε i |


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 123Proof. Let v be some geodesic for u. Apply<strong>in</strong>g Proposition 4 we can put v<strong>in</strong><strong>to</strong> the form t −d a ψ0 t ···ta ψr t −l for some <strong>in</strong>tegers d, r, l, andψ 0 ≠0 if d>0,|ψ i | 0.If d>0, then apply<strong>in</strong>g Brit<strong>to</strong>n’s lemma <strong>to</strong>u −1 v = a −εq t −1 ···t −1 a −ε0 t −d a ψ0 t ···ta ψr t −lwe must have a p<strong>in</strong>ch t −1 a −ψ0 t, which is not possible s<strong>in</strong>ce 0 < |ψ 0 | 0.This proves the first assertion. Now <strong>to</strong> <strong>compute</strong> it. Observe that <strong>in</strong> theCayley graph for G p , the paths u, v travel up a s<strong>in</strong>gle sheet, from level 0 <strong>to</strong>level q. The suffix of v may cont<strong>in</strong>ue <strong>to</strong> travel up, and return <strong>to</strong> level q viat −s ,sov lies <strong>in</strong> precisely the sheet determ<strong>in</strong>ed by u.We locate v by track<strong>in</strong>g the path u, and all possible geodesic paths, levelby level <strong>in</strong> this sheet, as follows.Label the identity vertex by S (for start). If ε 0 ≠ 0, draw a horizontall<strong>in</strong>e of |ε 0 | a edges, <strong>to</strong> the left if ε i < 0 and right if positive. Then draw avertical t edge up from this l<strong>in</strong>e, and complete the picture by draw<strong>in</strong>g <strong>in</strong> thebrick conta<strong>in</strong><strong>in</strong>g a ε0 t on its boundary. Label the corner correspond<strong>in</strong>g <strong>to</strong> theendpo<strong>in</strong>t of a ε0 t by U, and on each corner <strong>compute</strong> the distance d 1 ,d 2 back<strong>to</strong> S (which will be |ε 0 | +1 and p −|ε 0 | +1). If |d 1 − d 2 |≤1, then keep bothlabels, and s<strong>to</strong>re two words g 1 ,g 2 which are <strong>geodesics</strong> <strong>to</strong> these po<strong>in</strong>ts. If theirdifference is greater than 1, then discard the larger label and only keep theshort one, plus a geodesic word g 1 <strong>to</strong> it. See Figure 2. Ifε 0 = 0, then simplydraw the t edge and no bricks, and s<strong>to</strong>re g 1 = t.Now assume you have drawn this picture up <strong>to</strong> level i


124 M. ELDERFigure 3. Thenexttwolevels.brick with boundary a εi t also conta<strong>in</strong>s the po<strong>in</strong>t(s) d 1 , (d 2 ), and so <strong>to</strong> <strong>compute</strong>the distance <strong>to</strong> the corners of the new brick, one simply <strong>compute</strong>s from thesepo<strong>in</strong>ts, s<strong>in</strong>ce they are the closest po<strong>in</strong>ts on the level i <strong>in</strong> this sheet. Label thecorners of the new brick <strong>in</strong> level i +1 by U, d 1 , (d 2 ) as before. Update g 1 , (g 2 )by append<strong>in</strong>g suffix(es) a j t. Once we <strong>compute</strong> the data for some level, we candiscard the data for previous level.In this way, one can draw the path u <strong>in</strong> its sheet up <strong>to</strong> level q, and keeptrack of the distances from S <strong>to</strong> each level of the sheet, us<strong>in</strong>g constant <strong>time</strong>and O(n log n) space (writ<strong>in</strong>g the labels <strong>in</strong> b<strong>in</strong>ary) for each level. Figure 3shows the next two iterations of this.At level q, drawa εq from U <strong>to</strong> the endpo<strong>in</strong>t of u, whichwemarkwithE.Note this distance is at most 3p − 1.Now, a geodesic <strong>to</strong> E from S must travel the shortest distance up fromlevel 0 <strong>to</strong> this level, so without loss of generality v starts with one of g 1 or g 2 ,say g x (x =1, 2) end<strong>in</strong>g at the po<strong>in</strong>t labeled d x , then ends with a suffix from d x<strong>to</strong> E of the form a m ,oroftypePN, which by Corollary 3 we may assumehas the form ta ρ1 t ···ta ρs t −s with s>0.S<strong>in</strong>ce d(E,U) < 3p and d(U, d x ) ≤ 1, then this suffix is equal <strong>to</strong> a word <strong>in</strong> a jor length at most 3p, which is a fixed constant, so f<strong>in</strong>d<strong>in</strong>g a geodesic suffixfor v is simply a matter of check<strong>in</strong>g a f<strong>in</strong>ite number of possible suffixes, whichcan be done <strong>in</strong> constant <strong>time</strong>, so we are done. See Figure 4.□Figure 4. The <strong>to</strong>p level.


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 125Proposition 6(u of type NP). Let u = t −k a ε0 t ···ta εq be the output ofpart one, where q ≥ k, |ε i |


126 M. ELDERFigure 5. Level q, with3p − 1 = 11 edges on either side ofd 1,q ,d 2,q added.then ends with some word equal <strong>to</strong> a m for some power m. Sov = g x,q v ∗ wherev ∗ is of the form a m or PN. Note that |m| < 3p otherwise v is not geodesic.To <strong>compute</strong> v ∗ , we do the follow<strong>in</strong>g.Draw the l<strong>in</strong>e at level q with 3p−1 edges <strong>to</strong> the right and left of the po<strong>in</strong>t(s)d 1 ,d 2 . See Figure 5. Read a εq along the l<strong>in</strong>e from the po<strong>in</strong>t U, draw vertical tedge up, and cover the l<strong>in</strong>e with bricks as before. Label the po<strong>in</strong>ts on thenext level up as U, d 1,q+1 , (d 2,q+1 ). Do not discard the previous level as wedid before. This <strong>time</strong> we will s<strong>to</strong>re all levels from q <strong>to</strong> q + r.Aga<strong>in</strong> extend the l<strong>in</strong>e at level q +1 out by 3p − 1 edges on either side ofthese po<strong>in</strong>ts, read a δq+1 , and repeat.Note that we are s<strong>to</strong>r<strong>in</strong>g all these levels. Each level has a row of at most 7bricks, so the amount of space required <strong>to</strong> s<strong>to</strong>re these levels with three labelson each level is O(n log n) s<strong>in</strong>ce the labels take O(log n) space and the numberof levels is r ≤ n. Note also that we do not s<strong>to</strong>re each <strong>in</strong>dividual g i,j —wes<strong>to</strong>re g 1,q+r ,g 2,q+r only.At level q + r, fromthepo<strong>in</strong>tmarkedU, read a δq+r and mark the endpo<strong>in</strong>tby E r . As before, if v extends above this level, then it can go only a boundednumber of levels more, so draw these layers of bricks <strong>in</strong>, aligned with thepo<strong>in</strong>t E r . Soageodesic<strong>to</strong>E r will be one of a f<strong>in</strong>ite number of paths, asbefore. Choose a shortest path <strong>to</strong> E r ,appendt −r <strong>to</strong> it, and s<strong>to</strong>re it as v r .Note that l(v r ) ≤ n so we need O(n) space <strong>to</strong> s<strong>to</strong>re the word.Now the geodesic for u could be v r , or could be a path of the form v s =g x,q a ηq t ···ta ηq+s t −s with s


A LINEAR-TIME ALGORITHM TO COMPUTE GEODESICS 127labeled U at level q <strong>to</strong> the endpo<strong>in</strong>t of the l<strong>in</strong>e t −r <strong>in</strong> the Cayley graph andtravels more that 3p − 1 a ±1 edges along some level, then it is not geodesic.This means that if a path for u leaves the s<strong>to</strong>red diagram, it is not geodesic.Therefore, <strong>to</strong> locate our geodesic output, we simply must check all paths v sthat lie <strong>in</strong>side the s<strong>to</strong>red diagram.Label the po<strong>in</strong>ts along the l<strong>in</strong>e t −r from E r that stay with<strong>in</strong> the diagramby E r−1 ,...,E 0 where E i is at level q + i.At level q + r − 1, <strong>compute</strong> the length of the shortest path that travels viag x,q+r−1 <strong>to</strong> d x,q+r−1 , the across <strong>to</strong> E r−1 via a ±1 edges, then ends by t −r+1 ,where x =1, 2. Call this path v r−1 . Compare the lengths of v r ,v r−1 and s<strong>to</strong>rethe shortest one. Note that the path(s) g x,q+r−1 are not s<strong>to</strong>red, but are easilyobta<strong>in</strong>ed by delet<strong>in</strong>g their suffixes.Repeat for each level below, s<strong>to</strong>r<strong>in</strong>g the shortest path, and the word g x,ifor all levels where E i is conta<strong>in</strong>ed <strong>in</strong> the s<strong>to</strong>red diagram.When this process term<strong>in</strong>ates, we have located a geodesic for the <strong>in</strong>putword.□Proposition 8 (u of type NPN). Let u = t −k a ε0 t ···ta εq ta δq+1 t ···ta δq+r t −r be the output of part one, where q ≥ k, r ≥ 1, |ε i |


128 M. ELDER[4] D. B. A. Epste<strong>in</strong>, J. W. Cannon, D. F. Holt, S. V. F. Levy, M. S. Paterson andW. P. Thurs<strong>to</strong>n, Word process<strong>in</strong>g <strong>in</strong> groups, Jones and Bartlett Publishers, Bos<strong>to</strong>n,MA, 1992. MR 1161694[5] J.R.J.Groves,M<strong>in</strong>imal length normal forms for some soluble groups, J. Pure Appl.Algebra 114 (1996), 51–58. MR 1425318[6] C. F. Miller III, Normal forms for some soluble Baumslag–Solitar groups, unpublishedmanuscript, 1997.[7] A. Myasnikov, V. Roman’kov, A. Ushakov and A. Vershik, The word and geodesicproblems <strong>in</strong> free solvable groups, Trans. Amer. Math. Soc. 362 (2010), 4655–4682.MR 2645045Murray Elder, University of Newcastle, Department of Mathematics,Callaghan NSW 2308, AustraliaE-mail address: murrayelder@gmail.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!