[GAP Forum] Permutation Literals

Steve Linton sal at dcs.st-and.ac.uk
Wed Mar 9 09:28:48 GMT 2005


Dear GAP Forum,

Dan Rossul asked:

> When I try the command:
> 
> gap> g:=Group((1)(2)(3,4));
> Syntax error: ) expected
> 
> I suppose GAP should understand (1)(2)(3,4) = (3,4)
> 
> Of course if 
> 
> gap> gap> g:=Group((3,4));
> Group([ (3,4) ])
> 
> It is prefectly fine.....
> 
> I am not sure if GAP doesn't understand (1)(2)(3,4) = (3,4) or it is a
> real Syntax error: ) expected, if Syntax error where should I add the )?

The problem is that GAP cannot distinguish the use of parentheses to denote a
one-cycle from their use to enclose an expression, so, since you never really
need one-cycles, it usually assumes that parentheses without a comma inside 
enclose an expression. Thus the parser reads

Group((1)  

as the start of an expression denoting a group generated by the
integer 1 and expects, in fact, either a "," followed by the next generator, or
a ")" ending the call of Group. When it finds a "(" it is confused. You are,
in fact, not allowed to make a group of integers or rational numbers, for other
reasons, but the stage in the system which enforces that rule has not yet been
reached.

So, anyway, one-cycles are not supposed to be allowed in permutation
expressions. As has been pointed out, they are actually accepted, when they are
not the first cycle in the permutation, as in (3,4)(1). This is an accident,
and could even be regarded as a bug. By this point, the parser is certain that
it is reading a permutation and so cannot be "distracted" by other
possibilities.

(1)*(3,4) is equivalent to 1*(3,4) and is also accepted, since almost any
object can be multiplied by the integer 1, leaving it unchanged. (2)*(3,4)
fails, because it is equivalent to 2*(3,4), which is meaningless.

There is no way to make GAP read something like (1)(2)(3,4) as a permutation
of four cycles, short of reading it as a string and parsing it by hand, but it
is also hard to see in what situation you would need to do this. If you are
writing the expression by hand, you can simply omit the 1-cycles. If a
programme is generating the expression, you are probably better off with

PermList([1,2,4,3]).

We will amend the documentation to make this situation clearer.

	Steve

-- 
Steve Linton	School of Computer Science  &
      Centre for Interdisciplinary Research in Computational Algebra
	     University of St Andrews 	 Tel   +44 (1334) 463269
http://www.dcs.st-and.ac.uk/~sal	 Fax   +44 (1334) 463278   




More information about the Forum mailing list