SymmetricGroup's "in" and ".contains", and reason for working a certain way

34 views
Skip to first unread message

Gaurav Dhingra

unread,
Dec 10, 2015, 8:03:55 AM12/10/15
to sympy
Hi everyone

>>> from sympy.combinatorics.named_groups import SymmetricGroup
>>> s_4 = SymmetricGroup(4)           # symmetricGroup of order 4

>>> p = Permutation(1, 2, 3)
>>> p in s_4
False

>>> s_4.contains(p)
True

Regarding my second question:
I am aware that contrary to GAP, which makes Groups like a little differently
>>> s_4 = SymmetricGroup(4)
>>> s_4.is_group
False

while in GAP
gap> s_4:= SymmetricGroup(4)
gap> IsGroup(s_4)
True

Is there any reason for why things work this way? Is thought to have some benefit contrary to how GAP defines it?

Gaurav Dhingra (gxyd)

Aaron Meurer

unread,
Dec 10, 2015, 12:59:24 PM12/10/15
to sy...@googlegroups.com
On Thu, Dec 10, 2015 at 7:03 AM, Gaurav Dhingra <axyd...@gmail.com> wrote:
> Hi everyone
>
>>>> from sympy.combinatorics.named_groups import SymmetricGroup
>>>> s_4 = SymmetricGroup(4) # symmetricGroup of order 4
>
>>>> p = Permutation(1, 2, 3)
>>>> p in s_4
> False
>
>>>> s_4.contains(p)
> True

I'm guessing this is a bug. It's probably related to the weirdness of
the group API (see below).

>
> Regarding my second question:
> I am aware that contrary to GAP, which makes Groups like a little
> differently
>>>> s_4 = SymmetricGroup(4)
>>>> s_4.is_group
> False
>
> while in GAP
> gap> s_4:= SymmetricGroup(4)
> gap> IsGroup(s_4)
> True
>
> Is there any reason for why things work this way? Is thought to have some
> benefit contrary to how GAP defines it?

This API seems really weird to me. It seems there is a distinction
between a group that is completely generated and a group that is just
generators. I don't think it's a good design, since the name of the
object is PermutationGroup, I would expect it to always represent a
group. At the very least, it shouldn't use the term "is_group" to
determine if the object's elements have been completely generated or
not.

Aaron Meurer

>
> Gaurav Dhingra (gxyd)
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/a20749c7-33e4-4558-b220-ead863509367%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages