Inverse of permutation group elements

43 views
Skip to first unread message

Rob Beezer

unread,
Mar 4, 2011, 1:47:39 PM3/4/11
to sage-devel
Any thoughts on the following inconsistency? As near as I can tell,
the inverse() method is being supplied by some code meant for
combinatorics (words?). Should permutation elements be given their
own inverse method?

sage: S = SymmetricGroup(4)
sage: s = S("(1,2,3)")
sage: type(s)
<type
'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
sage: s^-1
(1,3,2)
sage: s.inverse()
(1,3,2)

sage: A = AlternatingGroup(4)
sage: a = A("(1,2,3)")
sage: type(a)
<type
'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
sage: a^-1
(1,3,2)
sage: a.inverse()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<snip>
AttributeError:
'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'
object has no attribute 'inverse'

Tom Boothby

unread,
Mar 4, 2011, 3:13:46 PM3/4/11
to sage-...@googlegroups.com
Yes, and I think that Permutations should support exponentiation, too:

sage: P = Permutation([1,2,3,4,5])
sage: P^2
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for ** or pow():
'Permutation_class' and 'int'

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

kcrisman

unread,
Mar 4, 2011, 3:20:34 PM3/4/11
to sage-devel


On Mar 4, 3:13 pm, Tom Boothby <tomas.boot...@gmail.com> wrote:
> Yes, and I think that Permutations should support exponentiation, too:
>
> sage: P = Permutation([1,2,3,4,5])
> sage: P^2
> Traceback (most recent call last):
> ...
> TypeError: unsupported operand type(s) for ** or pow():
> 'Permutation_class' and 'int'

>
> > sage: A = AlternatingGroup(4)
> > sage: a = A("(1,2,3)")
> > sage: type(a)
> > <type
> > 'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
> > sage: a^-1
> > (1,3,2)
> > sage: a.inverse()
> > ---------------------------------------------------------------------------
> > AttributeError                            Traceback (most recent call
> > last)
> > <snip>
> > AttributeError:
> > 'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'
> > object has no attribute 'inverse'
>

Rob, anything you do to make permutations and groups work better
together - also including the various group algebra classes - would be
fantastic for some of the stuff I do, where I have to find convoluted
ways to get them to work together that I really don't know if I
understand properly (but give the right answers).

- kcrisman

Dima Pasechnik

unread,
Mar 5, 2011, 1:33:57 AM3/5/11
to sage-devel, sage-comb...@googlegroups.com


On Mar 5, 4:13 am, Tom Boothby <tomas.boot...@gmail.com> wrote:
> Yes, and I think that Permutations should support exponentiation, too:
>
> sage: P = Permutation([1,2,3,4,5])
> sage: P^2
> Traceback (most recent call last):
> ...
> TypeError: unsupported operand type(s) for ** or pow():
> 'Permutation_class' and 'int'
>

I suppose Permutation_class does not delegate to GAP. Which might be
meaningful, given the
present inefficiency of doing this.

But why no exponentiation? This is weird. I cc to sage-combinat.

Dima

Dima Pasechnik

unread,
Mar 5, 2011, 1:36:33 AM3/5/11
to sage-devel


On Mar 5, 2:47 am, Rob Beezer <goo...@beezer.cotse.net> wrote:
> Any thoughts on the following inconsistency?  As near as I can tell,
> the  inverse()  method is being supplied by some code meant for
> combinatorics (words?).  Should permutation elements be given their
> own inverse method?
>
> sage: S = SymmetricGroup(4)
> sage: s = S("(1,2,3)")
> sage: type(s)
> <type
> 'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
> sage: s^-1
> (1,3,2)
> sage: s.inverse()
> (1,3,2)
>

it seems that there is some weird kind of inheritance happening -
elements of symmetric groups
get access to methods from Permutation_class, while elements of
"other" permutation groups do not.
Which is rather weird, indeed.

Volker Braun

unread,
Mar 5, 2011, 6:34:57 AM3/5/11
to sage-...@googlegroups.com
You need to construct PermutationGroupElements if you want to use group operations:

sage: P = PermutationGroupElement([(1,2,3,4,5)])
sage: P^2
(1,3,5,2,4)

The sage.combinat.Permutation stuff is presumably about the combinatorics of permutations. Though it would be nice if they could be merged :-)

Rob Beezer

unread,
Mar 5, 2011, 2:14:59 PM3/5/11
to sage-devel
On Mar 5, 3:34 am, Volker Braun <vbraun.n...@gmail.com> wrote:
> Though it would be nice if they could be merged :-)

+1, and I think that was KDC's suggestion above. For example:

sage: g = PermutationGroupElement([1,3,2])
sage: g.matrix()
[1 0 0]
[0 0 1]
[0 1 0]

sage: c = Permutation([1,3,2])
sage: c.to_matrix()
[1 0 0]
[0 0 1]
[0 1 0]

I'll likely experiment with adding an inverse() method for permutation
group elements.

Jason Grout

unread,
Mar 5, 2011, 2:25:11 PM3/5/11
to sage-...@googlegroups.com
On 3/5/11 1:14 PM, Rob Beezer wrote:
> On Mar 5, 3:34 am, Volker Braun<vbraun.n...@gmail.com> wrote:
>> Though it would be nice if they could be merged :-)
>
> +1, and I think that was KDC's suggestion above. For example:
>
> sage: g = PermutationGroupElement([1,3,2])
> sage: g.matrix()
> [1 0 0]
> [0 0 1]
> [0 1 0]
>
> sage: c = Permutation([1,3,2])
> sage: c.to_matrix()
> [1 0 0]
> [0 0 1]
> [0 1 0]

If you're bringing up that method, I feel obligated to point out
http://trac.sagemath.org/sage_trac/ticket/2215

Jason


Rob Beezer

unread,
Mar 10, 2011, 2:18:52 PM3/10/11
to sage-devel
.inverse() method for permutation group elements at

http://trac.sagemath.org/sage_trac/ticket/10911

Francois Maltey

unread,
Mar 11, 2011, 9:22:22 AM3/11/11
to sage-...@googlegroups.com, Francois Maltey
Hello,

I have some questions about semantics and typographics convention in :

1/ Permutation
2/ PermutationGroupElement
3/ permutations (with lower p)
4/ Permutations

Suppose I don't know Sage. How can I imagine the design of each function ?
What is the first (question or) answer I must get ?
I suppose it's to know if I create a new object ?

Permutations and PermutationGroupElement have almost the same name but
type and parent are different.

Is it two implementation of the same S(n) group ?
I'm a bit confusing because I feel I ignore Sage rules.

F.

Florent Hivert

unread,
Mar 15, 2011, 2:29:53 PM3/15/11
to sage-...@googlegroups.com
Hi Fran�ois,

> I have some questions about semantics and typographics convention in :
>
> 1/ Permutation
> 2/ PermutationGroupElement
> 3/ permutations (with lower p)
> 4/ Permutations
>
> Suppose I don't know Sage. How can I imagine the design of each function ?
> What is the first (question or) answer I must get ?
> I suppose it's to know if I create a new object ?
>
> Permutations and PermutationGroupElement have almost the same name
> but type and parent are different.

First of all in my opinion 3/ should be deprecated. The same effect could be
achieved using Permutations:

sage: Permutations([1,1,2,2,2]).list() == permutations([1,1,2,2,2])
True

The convention is that creating an object goes through a so-called
constructor of a class and should be capitalized. Moreover the code says:

def permutations(mset):
from sage.combinat.permutation import Permutations
ans = Permutations(mset)
return ans.list()

Maybe it is also to ensure a compatibility with M* but I think it is more
confusing that anything else.

1/ vs. 4/ is the standard usage is combinatorics: Permutations() is the set of
all permutations, Permutations([1,2,3,4]) is the *set* of the permutations of
[1,2,3,4] whereas Permutation([1,2,3,4]) is the permutation [1,2,3,4]. This is
a rather well followed usage in combinatorics: Partitions vs Partition /
DyckWords vs DyckWord, BinaryTrees vs BinaryTree... etc.

1/ vs 2/ a Permutation is a combinatorial data structure which is not
necessarily seen as an element of a group. It could be for example an ordering
of a set. On the contrary, PermutationGroupElement is an element of a
permutation Group.

I hope this helps

Cheers,

Florent

Reply all
Reply to author
Forward
0 new messages