How to bypass breaking of loop in GAP I was trying to find whether there exists a finite  group with the following presentation:
$$<a, b,c, d|\,a^2, b^2,c^2, d^2, (a\,c)^{4\,i}, (a\,d)^{3\,j}, (b\,c)^{3\,k}, (b\,c)^{3\,l}, (a\,c\,d)^{3\,m}, (b\,c\,d)^{4\,n},(a\,b\,c)^{3\,o},(a\,b\,d)^{4\,p},(a\,b\,c\,d)^{3\,q}>,$$
 where $$1\le i,j,\ldots,q \le 3$$ are integers.
I wrote a code. (I'll give it at the end). While running, it gives the error messages as follows:

Error Message
I  Coset table calculation failed -- trying with bigger table limit
I  Coset table calculation failed -- trying with bigger table limit
I  Coset table calculation failed -- trying with bigger table limit
I  Coset table calculation failed -- trying with bigger table limit
Error, exceeded the permitted memory (`-o' command line option) in
prev[2 * limit] := 2 * limit - 1; called from 
TCENUM.CosetTableFromGensAndRels( fgens, grels, fsgens ) called from
CosetTableFromGensAndRels( fgens, grels, List( trial, UnderlyingElement ) 
) called from Attempt( gens ) called from
FinIndexCyclicSubgroupGenerator( G, infinity ) called from
(  )  called from read-eval loop at line 7 of >second.g you can 'return;'

If we now give the command "brk> return;" then GAP terminates after giving a message

gap: cannot extend the workspace any more!

I was looking for a solution for this problem. I don't want termination of the program. Otherwise I have to do $3^9=19683$ runnings vy hand and its a dam boring job. 

Code
for i in [1 .. 3] do
for j in [1 .. 3] do
for k in [1 .. 3] do
for l in [1 .. 3] do
for m in [1 .. 3] do
for n in [1 .. 3] do
for o in [1 .. 3] do
for p in [1 .. 3] do
for q in [1 .. 3] do
F2 := FreeGroup( "a", "b","c", "d" );
A5 := F2 / [ F2.1^2, F2.2^2,F2.3^2, F2.4^2, (F2.1*F2.3)^(4*i), (F2.1*F2.4)^(3*j), (F2.2*F2.3)^(3*k), (F2.2*F2.3)^(3*l), (F2.1*F2.3*F2.4)^(3*m), (F2.2*F2.3*F2.4)^(4*n),(F2.1*F2.2*F2.3)^(3*o),(F2.1*F2.2*F2.4)^(4*p),(F2.1*F2.2*F2.3*F2.4)^(3*q) ];
AppendTo( "second.txt",[i,j,k,l,m,n,o,p,q,],Size(A5),"\n" );
od; od; od; od; od; od; od; od; od;

 A: You can use the silent option to achieve that. Unfortunately, using it in this example
is a bit tricky (we cannot directly pass it to the Size command, which triggers the
coset enumeration, because Size cannot deal with failure of the enumeration).
But this should work. Of course it will only find examples which are small enough
for the naive coset enumeration to work, so you may easily miss finite examples.
To do this properly, I am afraid you will have to learn more of the theoretical
background, and also perhaps look at tools like ACE, the advanced coset enumerator.
But even then it is a slow business.
One other thing you could do is to set the max option to a larger numerical value than
the default value CosetTableDefaultMaxLimit; you then need more time and more,
though.
F := FreeGroup( "a", "b", "c", "d" );
for i in [1 .. 3] do for j in [1 .. 3] do
 for k in [1 .. 3] do for l in [1 .. 3] do
  for m in [1 .. 3] do for n in [1 .. 3] do
   for o in [1 .. 3] do for p in [1 .. 3] do
    for q in [1 .. 3] do
      Print("Running computation for ",[i,j,k,l,m,n,o,p,q,],"\n");
      rels := [ F.1^2, F.2^2,F.3^2, F.4^2,
                (F.1*F.3)^(4*i), (F.1*F.4)^(3*j), (F.2*F.3)^(3*k),
                (F.2*F.3)^(3*l), (F.1*F.3*F.4)^(3*m), (F.2*F.3*F.4)^(4*n),
                (F.1*F.2*F.3)^(3*o), (F.1*F.2*F.4)^(4*p),
                (F.1*F.2*F.3*F.4)^(3*q) ];
      G := F / rels;

      G := FactorGroupFpGroupByRels(F, rels : silent);
      ct := TryCosetTableInWholeGroup(TrivialSubgroup(G) : silent);
      if ct <> fail then
        size := Length(ct[1]);
        #AppendTo( "second.txt",[i,j,k,l,m,n,o,p,q,],size,"\n" );
        Print( "  found G for ",[i,j,k,l,m,n,o,p,q,]," of size ", size,"\n" );
      fi;
    od;
   od; od;
  od; od;
 od; od;
od; od;

