LIBRARY testcomplete;

"This procedure takes the compact presentation InputSequence for a 
 p-group, decodes it, and calculates a power-commutator presentation 
 for the group G; the output of pquotient is determined by the
 prlev supplied"

procedure TestComplete (InputSequence, prlev; G);

  procedure extGroup(G, n, p, padic; rhs);
     
    rhs = empty;
    for i = 1 to n do
      rhs[i] = conseq(G.1^0, n);
      for k = 1 to i-1 do	
	temp = rhs[i];
	temp[k] = G.1^0;
	rhs[i]=temp;
	for l = k to i-1 do
	  temp = rhs[l];
	  temp[k] = temp[k] * G.i^(padic mod p);
	  rhs[l] = temp;
	  padic = ( padic / p ) ;
	end; "l"
      end; "k"
    end; "i" 
  end; "extractGroup"

  procedure recreate(G, n, p, rhs; rels);

    rels = [];
    for i = 1 to n do
      temp = rhs[i];
      rels = rels JOIN [G.i^p * temp[i]^-1];
	for k = 1 to i-1 do
	  rels = rels JOIN [(G.i, G.k) * (temp[k]^-1)];
	end; "k"
    end; "i"
  end; "recreate"

  d = InputSequence[1];
  n = InputSequence[2];
  p = InputSequence[3];
  cc = InputSequence[4];
  longInt = InputSequence[5];

  "Check whether the group is cyclic -  the p-quotient function
   causes an error in the case of a cyclic group and thus is 
   not called. Instead we set up the group as shown"

  if (InputSequence[1] EQ 1) then 
     gp = free(a);
     gp.relations: a^(p^InputSequence[2]) = 1;
     if prlev gt 0 then print gp; end;
     return;
  end;

  G = fgrank(n);
  OurRelations = [];
  OurSequence = empty;
  len = 0;

  extGroup(G, n, p, longInt; rhs);
  recreate(G, n, p, rhs; OurRelations);

  G.relations: OurRelations;

  G = pquotient (G, p, cc; pr = prlev);
  gporder = order(G);

  if (gporder NE p^n) then
     print '--------------------------------- ERROR --------------------';
   else
     print 'ok';
   end;

END; "TestComplete"

FINISH;

"############################################################################ 
 ## AUTHOR:	C. Rhodes						      
 ## DATE:	Wed Jan 27 14:52:46 EST 1993  				      
 ## VERSION:	2.0	               					      
 ## PURPOSE:    This file contains the generic routine which allows CAYLEY    
 ##             to decode a compact group description created with 
 ##		MakeLibrary or To_cayley_format.			      
 ############################################################################" 
