<<

Journal of Computer and System Sciences  1398 journal of computer and system sciences 53, 19 (1996) article no. 0045

An O(n) Algorithm for Abelian p- and an O(n log n) Algorithm for Isomorphism

Narayan Vikas*

Department of Computer Science and Engineering, Indian Institute of Technology (IIT), Delhi, Hauz Khas, New Delhi - 110016, India

Received October 6, 1988; revised July 20, 1993 and October 9, 1995

and the of G is |G|. We will use ab to denote a V b. For The isomorphism problem for groups is to determine whether two a # G, the order of a, denoted as o(a), is the smallest finite groups are isomorphic. The groups are assumed to be represented ie1 such that ai=e (ai means a is multiplied by itself i by their multiplication tables. Tarjan has shown that this problem can be times). Further, if G is finite then o(a)||G| (to read as o(a) done in time O(nlog n + O(1)) for groups of cardinality n. Savage has claimed an algorithm for showing that if the groups are Abelian, is a factor of |G|). A G is said to be an Abelian m isomorphism can be determined in time O(n2). We improve this bound p-group if G is Abelian and |G|=p , where p is a prime and give an O(n log n) algorithm for Abelian group isomorphism. number and me0 an integer. Thus, every element in an Further, we show that if the groups are Abelian p-groups then Abelian p-group has order p power. If G is a finite Abelian isomorphism can be determined in time O(n). We also show that the group and p ||G|, where p is a prime number, then there is elementary divisor sequence for an Abelian group can be determined in time O(n log n) and for an Abelian p-group it can be determined in time an element a # G such that o(a)=p. If a group G has an ele- k i O(n). ] 1996 Academic Press, Inc. ment of order p then G has an element of order p , for all i

Two groups G1 and G2 are said to be isomorphic, written Before we give our algorithms, we state some relevant as G1rG2 , if there is a f: G1 Ä G2 which is one-to- definitions and results of group theory. Readers may refer to one and onto such that for all a, b # G1 , f(ab)=f(a) f(b). [3, 5, 6] for a study on group theory. Notice that the product ab is computed in G1 and the A nonempty set G is said to form a group if there is in G product f(a) f(b) is computed in G2 . G1 r3 G2 will denote such that a binary operation *, called the product, defined that G1 and G2 are not isomorphic. The direct product of two groups G and G is the group (i) a, b # G implies that a V b # G (closed); 1 2 G1 _G2=[(a, b)|a#G1,b#G2] whose multiplication is (ii) a, b, c # G implies that a V (b V c)=(a V b) V c defined by (a1 , b1) V (a2 , b2)=(a1a2, b1b2). The product (associative law); a1 a2 is computed in G1 and the product b1 b2 is computed in (iii) there exists an element e # G such that a V e= G2 . The identity of G1 _G2 is (e1 , e2), where e1 and e2 e V a=a for all a # G (the existence of an identity element are the identities of G1 and G2 respectively. Note that in G); |G1 _G2 |is|G1| times |G2 | and o(a, b)=lcm(o(a), o(b)), \a # G , \b # G , where o(a) is the order of the element a in (iv) for every a # G there exists an element a&1 # G 1 2 G , o(b) is the order of b in G , and lcm is the least common such that a V a&1=a&1 V a=e (the existence of inverses 1 2 multiple operator. in G). Let a be an element of a group G such that o(a)=k. The A group G is said to be Abelian (or commutative), after set (a)=[a, a2, a3, ..., ak&1, ak=e] is a group ( the name of the famous mathematician Abel, if for every of G) called the generated by a. One can easily i a, b # G, a V b=b V a. G is said to be a finite group if it has prove that o(a )=lcm(i, o(a))Âi, \i=1, 2, ..., k. Note that finite number of elements. |G| denotes the cardinality of G two finite cyclic groups (a) and (b) are isomorphic iff o(a)=o(b). It is easy to see that for two finite groups to be isomorphic it is a necessary condition that the orders of the * Current address: School of Computing Science, Simon Fraser Univer- groups be the same. In case of finite cyclic groups it is also sity, Burnaby, British Columbia, Canada V5A 1S6. a sufficient condition for isomorphism. Let C(k) represent

1 0022-0000Â96 18.00 Copyright  1996 by Academic Press, Inc. All rights of reproduction in any form reserved.

File: 571J 139801 . By:BV . Date:29:08:96 . Time:11:47 LOP8M. V8.0. Page 01:01 Codes: 6426 Signs: 4489 . Length: 60 pic 11 pts, 257 mm 2 NARAYAN VIKAS a cyclic group of order k. Any Abelian p-group is Abelian groups, it is sufficient to find just the orders of the isomorphic to a direct product of cyclic groups of p power prime power order elements in the groups and we give an orders. Further, for any Abelian p-group G of order O(n log n) algorithm in Section 3 for finding orders of all the pm, me1, G can be represented as prime power order elements in an Abelian group and an O(n) algorithm in Section 2 for finding orders of all the GrC( pr1)_C( pr2)_}}}_C(prk), (I) element in an Abelian p-group. However, if we were inter- k where i=1 ri=m, ri eri+1>0, 1Ei1, G* can be algorithms with documentations. represented as 2. ABELIAN p-GROUP ISOMORPHISM G*rG( pa1)_G( pa2)_ } } } _G( pas), (II) 1 2 s Let us consider the representation of an Abelian p-group m where 10 an integer \i=1, 2, ..., s such that n= is an ordering on ri 's (ri 's are in nonincreasing order). We a1 a2 as ai ai p1 p2 }}}ps ,G(pi ) is an Abelian pi -group of order p i would like to obtain a formula for the number of elements ai t r1 r2 rk and the elements of G( pi ) are all the elements of G* whose of order p in C( p )_C( p )_ } } } _C( p ). Since there is ai orders are pi power, \i=1, 2, ..., s. Note that each G( pi ) exactly one element of order 1, we will assume t>0. In order can be further expanded to a direct product of cyclic groups to obtain this result we first find the number of elements of t ri of pi power orders as explained above in (I). Thus, G* order p in C( p ), \i=1, 2, ..., k. Note that if ri0, in (x) will be plication table will always be denoted by M and assumed to ( p&1)+(p&1)2+p(p&1)2+p2(p&1)2 be hardwared. 3 2 t&2 2 t t&1 We will assume that groups are finite and of order >1. +p (p&1) +}}}+p (p&1) =p &p . Two groups of order 1 each (i.e., identity element is the only We now calculate the number of elements of order pt, t>0, element in the two groups) are isomorphic and the EDS of in C( pr1)_ } } } _C( prk). Let j be the value satisfying the a group of order 1 is empty. The symbol e will be used to following two conditions: denote the identity element for the group under considera- (i) tEr , \i=1, 2, ..., j. tion. In any group, there is exactly one element of order 1, i namely the identity element. (ii) t>ri , \i=j+1, j+2, ..., k. Tarjan has shown [7] that isomorphism of two finite Thus there are k& j cyclic groups in the representation of G t groups of cardinality n can be determined in time which do not have any elements of order p .If(x1,x2, ..., xk) log n+O(1) r1 rk O(n ). Savage [9] has claimed an algorithm for is an element of C( p )_}}}_C(p ) then o(x1 , x2 , ..., showing that if the groups are Abelian, isomorphism can be xk)=lcm(o(x1), o(x2), ..., o(xk))=max(o(x1), o(x2), ..., 2 determined in time O(n ). In [9], isomorphism testing of o(xk)), since o(xi)isappower, \i=1, 2, ..., k. Thus if t Abelian groups is based on determining their entire EDS o(x1 , x2 , ..., xk)=p , it must be the case that o(xh)= t rh t (beacause two finite Abelian groups are isomorphic iff they p , xh # C(p ), for some value of h,1EhEk, and o(xi)Ep , ri have the same EDS). The EDS of an Abelian group is xi # C( p ), \i=1, 2, ..., k. Since a group having an element claimed in [9] to be found using quotient groups, etc. and of order ps has an element of order pi for all i

File: 571J 139802 . By:BV . Date:29:08:96 . Time:11:47 LOP8M. V8.0. Page 01:01 Codes: 6941 Signs: 5431 . Length: 56 pic 0 pts, 236 mm ABELIAN GROUP ISOMORPHISM 3 the number of elements of order pt, t>0, in C(pri)as representation of p. Let B denote the bit string corre- calculated above, is pt& pt&1 and the number of elements of sponding to the binary representaion of p.Ifx{e, we need order Ept in C( pri)ispt. Thus, the total number of elements to calculate x p. To calculate x p we can utilize the binary to of order pt, t>0, in C(pr1)_ } } } _C( prk)is decimal conversion procedure as follows. We assume that x2i corresponds to the ith least significant bit of B, (pt&pt&1) V (pt)j&1 V prj+1 V prj+2 V }}}Vprk \i=0, 1, ..., |B|, where |B| is the length of the string B. We then calculate x2i, \i=1, 2, ..., |B| (the expression t&1 t t&1 t j&2 rj+1 rj+2 rk +p V (p &p ) V (p ) V p V p V }}}Vp corresponding to i=0 is already known). The calculation of 2i 2i&1 +pt&1 pt&1 (pt&pt&1) x can be done using x , which corresponds to the bit pre- V V i i i&1 i&1 vious to the bit corresponding to x2 ,asx2=x2 V x2 . t j&3 r r r V (p ) V p j+1 V p j+2 V }}}Vp k Thus, we jump to x2i without having to go through certain +}}}+(pt&1) j&1(pt&pt&1) V prj+1 V prj+2 V }}}Vprk powers of x. Finally the product of these elements formed in this way, with the exception that the elements correspond- =p(m+tV j&(r1+r2+}}}+rj))(1&1Âp j). (III) ing to bits which are zeros do not take part in the product, gives us x p. In case x p was not e, we need to calculate x p2. r r r m (We have replaced p j+1 V p j+2 V }}} Vp k by p  We follow the same process as above by replacing x with x p. r r r ( p 1p 2 }}}p j) in the above calculation.) The value of x raised to other p powers follows similarly and pk Let r1 , r2 , ..., rk and r$1, r$2, ..., r$h be two sequences such we continue until we get x =e for some k. Since |B|is that pr1, pr2, ..., prk and pr1$, pr$2, ..., prh$ for two Abelian p-groups pj pj+1 O(log2 p), having calculated x , x can be calculated in G and G$ respectively (see (I) in Section 1). From the above m time O(log2 p). Since o(x) is at most p , o(x) can be formula (III) and conditions (i) and (ii), it is clear that the calculated in time O(m log2 p)=O(log n). Thus, the orders t r r number of elements of order p in C( p 1)_ } } } _C( p k)is of all the elements in G can be found in time O(n log n). t r$ equal to the number of elements of order p in C( p 1) A detailed form of Algorithm 2 is given in the Appendix. r$h _}}}_C(p ), \t>0, iff the sequences r1 , r2 , ..., rk and r$1, r$2, ..., r$h are identical (i.e., iff the EDS's of G and G$ are Outline of Algorithm 3. We now present an O(n) identical, i.e., iff G and G$ are isomorphic). Thus, given two algorithm for finding orders of all the elements in G.To Abelian p-groups G1 and G2 , it is sufficient to find the num- determine o(x), x # G, we keep incrementing the power of x t t ber of elements of order p , \t>0 (of course, p need not by 1 until an element, say xk, is encountered whose order exceed the cardinality of the group under consideration; has already been found (initially o(e) is assumed to be hence there is an upper bound on t)inG1and G2 to deter- already found). We then calculate the orders of all the k&1 2 k&1 mine if G1rG2 . elements x, x , ..., x (we store these elements in this We now give some algorithms for finding orders of all the order in an array, say CURRENT, at the time they are m elements in an Abelian p-group G with |G|=n=p . Note formed) in O(k) time with the aid of the fact that o( yi)= that, given n, it is not difficult to test if n is a prime power lcm(i, o( y))Âi, \y # G. We use the properties of prime num- and find p and m. We do not include here an algorithm to bers and the fact that order of every element in G is a prime do this but one can verify that the complexity of such an p power to compute this lcm efficiently as discussed below. algorithm will not affect the complexity of our algorithms. We first find o(x) from o(xk). To do this we decompose k b e e Outline of Algorithm 1. An inefficient way to find as k=temp V p , temp and b are integers, b 0, temp 1, orders of all the elements in G would be that for each x # G, and temp has no factors of p (i.e., p |% temp). This decomposi- keep incrementing the power of x by 1 until the identity ele- tion can be done in O(log k) time in the worst case. Also, e i i ment is achieved, requiring time O(n2) in totality (because o(x) k since o(x ) is not already found and hence x {e (because o(e) is marked as already found), \i=1, 2, ..., k&1. o(x) is at most n). The value of x raised to a new power, say k b i, i.e., the value of xi, is obtained by multiplying the already Thus o(x )=lcm(k, o(x))Âk=lcm(temp V p , o(x))Âk=temp e e b calculated value of xi&1 with x using the multiplication table. V o(x)Âk (because o(x)isappower and o(x) k p , and A detailed form of Algorithm 1 is given in the Appendix. since p |% temp, o(x) and temp are coprime). Hence, o(x)=o(xk) V kÂtemp. Outline of Algorithm 2. The fact that the order of Now we calculate o(xi), \i=2, 3, ..., k&1. If p |% i (this can every element in G is a p power, we need to raise x to p be checked in constant time by testing if i mod p{0) then powers only to find o(x), \x # G. In order to do this o(xi)=lcm(i, o(x))Âi=i V o(x)Âi (because o(x)isappower efficiently, we first represent p into its binary equivalent. and p |% i)=o(x). If p|i then i is of the form u V pc, ce1, i This conversion can be done in time O(log2 p). Although it ue1, c and u are integers, and p |% u. Thus, o(x )= may not be posible to skip raising x to some powers which lcm(i, o(x))Âi=lcm(u V pc, o(x))Â(u V pc)=u V o(x))Â(u V pc) are not p power, it may still be possible to skip raising x to (because o(x)isappower and o(x)>iepc, and since certain powers which are not p powers by using the binary p |% u, o(x) and u are coprime)=o(x)Âpc. But this way

File: 571J 139803 . By:BV . Date:29:08:96 . Time:11:47 LOP8M. V8.0. Page 01:01 Codes: 7226 Signs: 5574 . Length: 56 pic 0 pts, 236 mm 4 NARAYAN VIKAS requires that i be decomposed as i=u V pc which will take Outline of Algorithm 3.1 for Isomorphism Testing.

O(log i) time in the worst case, implying that the entire To test isomorphism of two Abelian p-groups G1 and G2 algorithm to find orders of all the elements in G will take in with cardinality n= pm, we first find the orders of the the worst case a total of O(nlog n) time. We, however, do elements in the two groups which takes O(n) time as dis- better by adopting a different technique as discussed below. cussed in Algorithm 3. Then, as explained in Section 2, we k t We still calculate o(x) from o(x ) as discussed above. just need to see if the number of elements of order p in G1 i t Considering the elements x , \i=2, ..., k&1, again, we note is equal to the number of elements of order p in G2 , \t>0. that i has one of the following forms: While finding the orders of the elements, we keep a record of the number of elements of order pt as N(t) (see Algorithm (a) i=u, for some integer ue2 and p |% u. 3 in the Appendix). Of course, t need not exceed m but we c (b) i=p , for some integer ce1. may improve this upper bound on t as follows. While c (c) i=u V p , for some integer ue2, p |% u, and some finding the orders of the elements in group Gi , we keep a integer ce1. record of the largest integer maxpi such that there is an element of order pmaxpi in G (see Algorithm 3 in the Note that any integer of the form (c) can be obtained by i Appendix), \i=1, 2. To test isomorphism, we first check if multiplying an integer of form (a) and an integer of form (b). maxp =maxp .IfG rG then definitely maxp =maxp ; If i is of form (a) then we have already shown that we can 1 2 1 2 1 2 otherwise they are not isomorphic. Assuming maxp = find o(xi) in constant time as o(xi)=o(x) as discussed 1 maxp2 , we just have to test if the number of elements of above. t t c order p in G is equal to the number of elements of order p If i is of form (b), say i= pc, then o(x p )=lcm( pc, o(x))Âpc 1 in G , \t=1, 2, ..., maxp (=maxp ). If this is the case then =o(x)Âpc (because o(x)isappower and o(x)>pc), \ce1, c 2 1 2 G is isomorphic to G ; otherwise they are not. Since maxp is an integer, and pc

File: 571J 139804 . By:BV . Date:29:08:96 . Time:11:47 LOP8M. V8.0. Page 01:01 Codes: 6797 Signs: 5613 . Length: 56 pic 0 pts, 236 mm ABELIAN GROUP ISOMORPHISM 5

affect the complexity of our algorithm. Each pi is then results) to the theory of partitions. Some of these results can represented by its binary equivalent. We raise each element x be found in [1, 4]. 2 ai of G* to powers pi , pi , ..., pi in this order, \i=1,2,...,s,to To determine the EDS of an Abelian p-group G of order m see if o(x) is a prime power and, consequently, to find o(x)if n= p , m1, we have to find the right values for k and ri , it is a prime power (note that if o(x)isapipower then o(x) \i=1, 2, ..., k, such that (I) (in Section 1) is satisfied. Our ai is at most pi and we do not need to raise x to powers of pi algorithm for finding the EDS for G is as follows. ai powers higher than pi , \i=1, 2, ..., s. Further, as soon as Algorithm 4. 1. For each x # G, find o(x). Keep a o(x) is found, we stop raising x to anymore powers. Only in record of the largest integer r1 such that there is an element the worst case we may have to raise x to all the powers of order pr1 in G. Keep a record of the number of elements a 2 i t r pi , p , ..., p , \i=1, 2, ..., s.). The process of raising x to 1 i i of order p , \t=1, 2, ..., r1 (by definition of our EDS, p is 2 ai powers pi , pi , ..., pi takes, in total, O(ai log2 pi) time (using the first member of the EDS for G). the binary representation of pi; see the analysis of Algorithm 2. Get a partition of m=r1+r2+r3+}}}+rk, k1, 2). Thus, to see if o(x) is a prime power and, consequently, different from all partitions of m found so far such that r e to find o(x) if it is a prime power takes, in the worst case, 1 r2 er3 e }}}erk>0 (partitioning m such that a largest time O(a1 log2 p1+a2 log2 p2+}}}+as log2 ps)=O(log n). part in the partition is fixed to be r1 , where r1 is found in Hence, to detect all the prime power order elements and, con- step 1). sequently, to find the orders of all the prime power order 3. For t := 1 to r do elements in G* takes time O(n log n). 1 begin Some modifications in Algorithm 2 in the Appendix may (a) find the appropriate value of j such that be done as follows. Since we know that in G*, the number of (i) tEr , \i=1, 2, ..., j, and elements of order p power is pai , before raising x to a p i i i i (ii) t>r , \i= j+1, ..., k (meeting condi- power, we check if all the elements of order p power have i i tions (i) and (ii) of Section 2). been found or not by having a counter for each pai ; counter i (b) from the formula (III) derived in Section 2 (i) may be used to give the number of elements of order p i find the number of elements of order pt. power that have been so far found, \i=1, 2, ..., s. A(i, V) may (c) if the number of elements of order pt be used to represent the binary equivalent of p , and P(i) may i calculated in step 1 is not equal to the number be used to represent p , \i=1, 2, ..., s. Information necessary i of elements of order pt calculated in step 3(b) for isomorphism testing can be similarly recorded as in Algo- then goto 2 (from our discussion in Section 2, rithm 3 in the Appendix; now MAXP(i) can be used to give pr1, pr2, ..., prk is not the EDS for G). the largest integer t such that there is an element of order pti i i end; in G*, and N(i, t) can be used to give the number of elements r1 r2 rk t 4. p , p , ..., p is the EDS for G (if all the r1 cases were of order p in G*, \t=1, 2, ..., ti , \i=1, 2, ..., s. Isomorphism i satisfied in step 3(c) then from our discussion in Section 2, of two Abelian groups G1* and G*2 with |G*|=|1 G*|=2 n= r1 r2 rk a1 a2 as p , p , ..., p must be the EDS for G). p1 p2 }}}ps can then be detected in an additional time of O(a1+a2+}}}+as) which is at most O(log n) (one can Let us analyze the above algorithm. Step 1 can be done in easily design this using Algorithm 3.1). Thus, the entire pro- time O(n) using Algorithm 3. An algorithm for partitioning cess of testing isomorphism is dominated by the time taken in integers such that the parts in the partition are in nonin- finding the orders of the prime power order elements which creasing order can be easily designed which will run in linear can be done in O(n log n) time. time in the number of partitions. In the worst case, in step

2, we will have to find all the partitions of m such that r1 4. FINDING THE EDS OF ABELIAN GROUPS (found in step 1) is a largest part in the partition (clearly r m) and no part in the partition exceeds r . Using the a. EDS of Abelian p-groups 1 1 result in [2] for f (m), step 2 will take time O(nÂlogp n)in Let us assume that all the Abelian p-groups of order totality. The length of a partition found in step 2 is at most m n= p , which are isomorphic to each other are put together m=O(logp n). Since r1 er2 e }}}erk, step 3(a) can be in one class. The number of such different isomorphism done in time O(logp n) for all the r1 cases of t together, i.e., classes is the number of different EDS's that one can think the values of j for different values of t can all be found in time m of obtaining through the number p , i.e., the number of O(logp n). Steps 3(b) and 3(c) take constant time and, m ways one can factorize p which is basically the number of hence, take time O(r1)=O(logp n) for all the r1 cases of t. different partitions f(m) of the integer m. It can be shown Thus, step 3 takes time O(logp n) when invoked once. Step 3 m [2] that f(m)isO(e Âm)=O(nÂlogp n). An exact formula is invoked a maximum of O(nÂlogp n) times. Hence, step 3 for f(m) can be found in [1, 8]. We, indeed, at this point takes a maximum of O(logp n V nÂlogp n)=O(n) time in thank one of the greatest mathematicians Ramanujan totality and the time complexity of the entire algorithm is who contributed excellent results (apart from many other O(n).

File: 571J 139805 . By:BV . Date:29:08:96 . Time:11:47 LOP8M. V8.0. Page 01:01 Codes: 6752 Signs: 5575 . Length: 56 pic 0 pts, 236 mm 6 NARAYAN VIKAS b. EDS of Abelian Groups 3. EDSOFG* is the EDS for G*.

a1 a2 as Let G* be an Abelian group with |G*|=n=p1 p2 }}}ps , Step 1 takes time O(n log n) using the algorithm 10 an described in Section 3. For each i in step 2, the execution of ai integer, \i=1, 2, ..., s. The algorithm for finding EDS of G* steps 2 and 3 in Algorithm 4 takes time O( pi ). Thus, step a1 a2 as is as follows. 2 runs in time O( p1 + p2 +}}}+ps ). Hence, the entire algorithm runs in time O(n log n). Algorithm 5. 1. For each x # G*, if x is a prime power order element, find o(x). Keep a record of the largest ti 5. RESEARCH PROBLEMS integer ti such that there is an element of order pi in G*, \i=1, 2, ..., s. Keep a record of the number of elements To date an O(n) algorithm for finding orders of all the t \ \ of order pi in G*, t=1, 2, ..., ti , i=1, 2, ..., s. Initialize elements in an Abelian group of order n is not known. EDSOFG* to be an empty sequence. Further, it is not known if there exists an O(n) algorithm for 2. For i := 1 to s do Abelian group isomorphism. begin Isomorphism of two groups of order n can be determined log n+O(1) p := p i ; in time O(n ) [7] due to Tarjan. We have shown

m := a i ; that isomorphism of two Abelian groups of order n can

r 1 := t i ; be determined in time O(n log n) and isomorphism of two Do steps 2 and 3 of Algorithm 4; Abelian p-groups of order n can be determined in time O(n). EDSOFG*:=EDSOFG* & pr1, pr2, ..., prk These may help design more efficient algorithms for deter- (& is a concatenation operator as described in mining isomorphism for other special groups. Section 1) end;

APPENDIX

Algorithm 1. for each x # G do begin power := x; ord(x):=1; while power { e do begin (M is the multiplication table) power := M( power, x); ord(x):=ord(x)+1 end end Algorithm 2. (First finding the binary representation for p) q := p; j := 0; while q>0 do begin j := j +1; A( j):=qmod 2; q := q div 2 (div performs an integer division) end; j := j +1; A( j) :=&1; (end of bit sequence marker) (Now A contains the binary representation of p in the reverse order; the least significant bit of p is stored in A(1) and

the most significant bit of p is stored in A( j&1). Since the binary sequence for p is of length O(log2 p), A contains O(log2 p) elements.) (Utilizing the binary representation of p, we calculate the orders of elements of G as follows)

File: 571J 139806 . By:BV . Date:29:08:96 . Time:11:48 LOP8M. V8.0. Page 01:01 Codes: 3313 Signs: 2288 . Length: 56 pic 0 pts, 236 mm ABELIAN GROUP ISOMORPHISM 7

L1: for each x # G do begin power := x; k := 1; L2: while power { e do begin k := k V p; (after the ith iteration of the while loop labelled L2, the value of k at this point will be pi ) temp := power; m :=2; (start from the second bit in A; since p is prime, the least significant bit of p which is stored in A(1) must be 1) L3: while A(m){&1do begin temp := M( temp, temp); if A(m){0then power := M( power, temp); m := m +1; end (L3) (At this point power=xk has been calculated) end; (L2) ord(x):=k end (L1)

(Since the length of the bit sequence representing p is O(log2 p), the while loop labelled L3 iterates O(log2 p) times. Since the order of an element x in G is at most pm, the while loop labelled L2 iterates at most m times. The for loop labelled

L1 iterates n times. Thus, the algorithm runs in time O(nm log2 p)=O(n log n).)

Algorithm 3.

N :=0; (N is an array where N(t) records the number of elements of order pt in G, used later for isomorphism testing) for each x # G do processed(x):=0;(processed(x)=0 indicates that o(x) is not yet found, whereas processed(x)=1 indicates that o(x) has been found) ord(e):=1; processed(e):=1; N(0) :=1; MAXP :=0; (records the maximum integer t such that there is an element of order pt in G, used later for isomorphism testing)

L1: for each x # G do begin power := x; i := 0; L2: while processed( power){1do begin i := i +1; CURRENT(i):=power;(CURRENT(i) stores the element xi; the orders of the elements currently being (stored in CURRENT have not yet been found) power := M( power, x); end; (L2) k := i +1; (the order of xk has already been calculated) if i>0 then call COMPUTE; (compute orders of x, x2, ..., xk&1 which are stored in CURRENT and mark them processed) end; (L1)

File: 571J 139807 . By:BV . Date:29:08:96 . Time:11:48 LOP8M. V8.0. Page 01:01 Codes: 2600 Signs: 1705 . Length: 56 pic 0 pts, 236 mm 8 NARAYAN VIKAS

Procedure COMPUTE (Compute the orders of x, x2, ..., xk&1; power is xk, o(power) has already been calculated. First calculate o(x) from o(xk) and then calculate the orders of x2, x3, ..., xk&1.) L1: begin (First find o(x) from o(xk)=o(power). To do this first find the largest factor temp of k such that p |% temp.) r := k; t := r; L2: while (r=t) and (r{1)do begin temp := r; r := rÂp; t :=trunc(r)(t=wrx) end; (L2) ord(x):=ord( power) V kÂtemp; (k is of the form temp V pb, where temp is as calculated above in the while loop labelled L2, tempe1, p |% temp, and be0, temp and b integers; o(x)ek since xi { e, \i=1, 2, ..., k&1. Hence, o(xk)=lcm(k, o(x))Âk= lcm(temp V pb, o(x))Âk=temp V o(x)Âk (because o(x)isappower and o(x)eke pb, and since p |% temp, o(x) and temp are coprime)) processed(x):=1;

t:=logp ord(x); N(t):=N(t)+1; if t>MAXP then MAXP := t;(o(x)eo(xi), \i=1, 2, ..., o(x). So orders of xi, \i=2, ..., k&1, do not affect MAXP) (Having calculated o(x) above, we now calculate o(x pc), \ce1, c an integer, such that pcpc and o(x)isappower)=o(x)Âi) processed(CURRENT(i)) :=1;

t :=logp ord(CURRENT(i)); N(t):=N(t)+1; c := c +1; i := p c end; (L3) (We have now found o(x) and o(xi ), for all i such that i is a p power, 1

t :=logp ord(CURRENT(u)); N(t):=N(t)+1; c (Having found a u which has no factors of p, we find o(xu V p ), \ce1, c an integer, such that u V pc

File: 571J 139808 . By:BV . Date:29:08:96 . Time:11:48 LOP8M. V8.0. Page 01:01 Codes: 3182 Signs: 2023 . Length: 56 pic 0 pts, 236 mm ABELIAN GROUP ISOMORPHISM 9

t :=logp ord(CURRENT(i)); N(t):=N(t)+1; c := c +1; j := p c; i := u V j end (L5) end (end of if u mod p{0 then begin ...) end (L4) end (L1) (The while loop labelled L2 in the Procedure COMPUTE runs in time O(log k) but orders of k&1 elements are found in COMPUTE in time O(k). It is readily seen that the entire algorithm runs in time O(n).) Algorithm 3.1. (Suppose that N1, MAXP1 and N2, MAXP2 have been calculated for two Abelian p-groups G1 and G2, respectively, from the above Algorithm 3, where the meaning of N1, N2 is similar to N as in Algorithm 3 and the meaning of MAXP1, MAXP2 is similar to MAXP. Assume that |G1 |=|G2|=n=pm. The following steps test for isomorphism of G1 and G2 in time O(log n).) L1: begin if MAXP1 { MAXP2 then z :=false else L2: begin t := 1; z :=true; L3: while (z and (tEMAXP1)) do begin if N1(t){N2(t)then z :=false; t := t +1 end (L3) end (L2) if z then print ``G1rG2'' else print ``G1r3 G2'' end (L1)

(The while loop labelled L3 iterates at most m=logp n times.)

REFERENCES 5. I. N. Herstein, ``Topics in Algebra,'' Blaisdell, New York, 1964. 6. S. MacLane and G. Birkhoff, ``Algebra,'' Macmillan Co., New York, 1967. 1. G. E. Andrews, ``The Theory of Partitions,'' Encyclopedia of Mathe- 7. G. L. Miller, On the nlog n isomorphism technique, in ``Proceedings matics and Its Applications, Vol. 2, AddisonWesley, Reading, MA, Tenth Annual ACM Symposium on Theory of Computing (STOC), 1976. San Diego, CA, May 1978.'' 2. T. M. Apostol, ``Introduction to Analytic Number Theory,'' Springer- 8. H. Rademacher, On the partition function p(n), Proc. London Math. Verlag, New YorkÂBerlin, 1976. Soc. 43 (1937), 241254. 3. M. Hall Jr., ``Theory of Groups,'' Macmillan Co., New York, 1959. 9. C. Savage, ``An O(n2) Algorithm for Abelian Group Isomorphism,'' 4 G. H. Hardy and E. M. Wright, ``An Introduction to the Theory of Num- Technical Report, TR 80-01, North Carolina State University, January bers,'' 4th ed., Clarendon Press, Oxford, 1960. 1980.

File: 571J 139809 . By:BV . Date:29:08:96 . Time:11:44 LOP8M. V8.0. Page 01:01 Codes: 3022 Signs: 2015 . Length: 56 pic 0 pts, 236 mm