Comparing generated subgroups

4 views
Skip to first unread message

jerome.p...@gmail.com

unread,
Apr 1, 2009, 10:48:13 AM4/1/09
to sage-support
I have a problem in comparing subgroups.
I'm building a list of all cyclic subgroups of a group, but I can't
seem to do a simple "in" look up to see if I've already generated a
particular subgroups.

So, I'm wondering what is the better way to compare two subgroups.

This is some test code to figure out what is going on.

G = SymmetricGroup(4)
H = G.subgroup([G((1,2,3))])
K = G.subgroup([G((2,3,1))])

print H
# Subgroup of SymmetricGroup(4) generated by [(1,2,3)]
print K
# Subgroup of SymmetricGroup(4) generated by [(1,2,3)]

# Yet the following returns false
print H == K
# And this one returns true
print H.list() == K.list()

# As well both the following are true
print H.is_subgroup(K)
print K.is_subgroup(H)

simon...@uni-jena.de

unread,
Apr 1, 2009, 2:25:18 PM4/1/09
to sage-support
Dear Jerome,

On 1 Apr., 10:48, "jerome.p.lefeb...@gmail.com"
<jerome.p.lefeb...@gmail.com> wrote:
> G = SymmetricGroup(4)
> H = G.subgroup([G((1,2,3))])
> K = G.subgroup([G((2,3,1))])

You can see how subgroups are compared: type 'K.__cmp__??' and you'll
see the source code. It is:

def __cmp__(self, other):
if self is other:
return 0
if not isinstance(other, PermutationGroup_generic):
return -1
c = cmp(self.ambient_group(), other.ambient_group())
if c: return c
if self.is_subgroup(other):
return -1
else:
return 1

'K==H' just tests whether 'K.__cmp__(H)' returns zero. As you can see
from the code, this is the case if and *only* if K is the same object
(in computer's memory) as H.

Unfortunately, the output of G.subgroup(...) is not cached. Hence,
even though G((1,2,3))==G((2,3,1)), the two subgroups are not
considered being equal.

I think this is a bug. Before returning -1 if self.is_subgroup(other),
it should be tested whether other.is_subgroup(self), in which case 0
should be returned. Do people agree?

Yours,
Simon

William Stein

unread,
Apr 1, 2009, 2:28:29 PM4/1/09
to sage-support
2009/4/1 simon.king <simon...@uni-jena.de>:

This is absolutely definitely, without any question, a huge bug. Open
a trac ticket!

William

simon...@uni-jena.de

unread,
Apr 2, 2009, 3:24:37 AM4/2/09
to sage-support
Hi William,

On Apr 1, 8:28 pm, William Stein <wst...@gmail.com> wrote:
> This is absolutely definitely, without any question, a huge bug. Open
> a trac ticket!

It is #5664.

And I found that things are much worse:

1.
sage: G2=G.subgroup([G((1,2,3,4)),G((1,2))])
sage: G==G2
True
sage: G2==G
Traceback (most recent call last):
...
AttributeError: 'SymmetricGroup' object has no attribute
'ambient_group'

Hence, == is not a symmetric relation, and __cmp__ raises an error
(which, afaik, must not be the case according to Python
specification).

2.
sage: G=SymmetricGroup(6)
sage: G1=G.subgroup([G((1,2,3,4,5)),G((1,2))])
sage: G2=G.subgroup([G((1,2,3,4)),G((1,2))])
sage: K=G2.subgroup([G1((1,2,3))])
sage: H=G1.subgroup([G2(())])
sage: H<K
False
sage: K<H
True

Hence, the trivial group in G1 is considered greater than a non-
trivial group in G2, because G1>G2.
Is this really what cmp should do for subgroups?

Yours,
Simon

simon...@uni-jena.de

unread,
Apr 2, 2009, 3:25:57 AM4/2/09
to sage-support
Hi,

On Apr 2, 9:24 am, simon.k...@uni-jena.de wrote:
> 1.
> sage: G2=G.subgroup([G((1,2,3,4)),G((1,2))])
...

I forgot one line: Here, G is still SymmetricGroup(4).

Cheers,
Simon

simon...@uni-jena.de

unread,
Apr 2, 2009, 9:14:54 AM4/2/09
to sage-support
Hi all,

I just found that PermutationGroup_generic.__cmp__ relies on the
comparison provided by gap, but *reverses* the output. Hence, we have

sage: G = PermutationGroup([[(1,2)]])
sage: H = PermutationGroup([[()]])
sage: G<H
True
sage: G._gap_()<H._gap_()
False

Is this what we want?

Yours,
Simon

David Joyner

unread,
Apr 2, 2009, 10:43:27 AM4/2/09
to sage-s...@googlegroups.com
Definitely not.


>
> Yours,
>     Simon
>
> >
>
Reply all
Reply to author
Forward
0 new messages