# Revision history [back]

### Overloading the binary operation of symmetric groups to reverse the order

I believe the Sage implementation of symmetric groups uses GAP which composes permutations in the opposite order to what I am used to. E.g. if (1,2) denotes the permutations switching 1 and 2, and (2,3) switches 2 and 3, then I would say (1,2) * (2,3) = (1,2,3), because I would first evaluate (2,3) and then (1,2) (the order in which one evaluates functions). Sage on the other hand produces (1,2) * (2,3) = (1,3,2).

About a year ago, a friend helped me overload the definition of the binary operation to have the composition of permutations evaluated in the order I am used to. The code that worked was

class NewSymmetricGroupElement(sage.groups.perm_gps.permgroup_element.SymmetricGroupElement):
def _mul_(self, other):
"""Calling the original class method with order inverted"""
return sage.groups.perm_gps.permgroup_element.SymmetricGroupElement._mul_(other, self)

class NewSymmetricGroup(SymmetricGroup):
def _element_class(self):
return NewSymmetricGroupElement


I recently updated to Sage 8.4 and the code no longer works. Here is what happens, after executing the code above, I run:

NS3=NewSymmetricGroup(3); NS3
> Symmetric group of order 3! as a permutation group
a=NS3((1,2)); b=NS3((2,3));

a*b = (1,3,2) # I would expect (1,2,3)


Can anyone spot what I am doing wrong?

 2 retagged tmonteil 27023 ●30 ●196 ●508 http://wiki.sagemath.o...

### Overloading the binary operation of symmetric groups to reverse the order

I believe the Sage implementation of symmetric groups uses GAP which composes permutations in the opposite order to what I am used to. E.g. if (1,2) denotes the permutations switching 1 and 2, and (2,3) switches 2 and 3, then I would say (1,2) * (2,3) = (1,2,3), because I would first evaluate (2,3) and then (1,2) (the order in which one evaluates functions). Sage on the other hand produces (1,2) * (2,3) = (1,3,2).

About a year ago, a friend helped me overload the definition of the binary operation to have the composition of permutations evaluated in the order I am used to. The code that worked was

class NewSymmetricGroupElement(sage.groups.perm_gps.permgroup_element.SymmetricGroupElement):
def _mul_(self, other):
"""Calling the original class method with order inverted"""
return sage.groups.perm_gps.permgroup_element.SymmetricGroupElement._mul_(other, self)

class NewSymmetricGroup(SymmetricGroup):
def _element_class(self):
return NewSymmetricGroupElement


I recently updated to Sage 8.4 and the code no longer works. Here is what happens, after executing the code above, I run:

NS3=NewSymmetricGroup(3); NS3
> Symmetric group of order 3! as a permutation group
a=NS3((1,2)); b=NS3((2,3));

a*b = (1,3,2) # I would expect (1,2,3)


Can anyone spot what I am doing wrong?