#5664: Bugs in PermutationGroup_subgroup.__cmp__
-----------------------+----------------------------------------------------
 Reporter:  SimonKing  |       Owner:  SimonKing          
     Type:  defect     |      Status:  new                
 Priority:  critical   |   Milestone:  sage-3.4.1         
Component:  algebra    |    Keywords:  comparison subgroup
-----------------------+----------------------------------------------------
Description changed by SimonKing:

Old description:

> At http://groups.google.com/group/sage-
> support/browse_thread/thread/533747d48a1f29eb?hl=en
> it was reported that comparision of subgroups of permutation groups does
> not work as expected:
>
> {{{
> sage: G = SymmetricGroup(4)
> sage: H = G.subgroup([G((1,2,3))])
> sage: K = G.subgroup([G((2,3,1))])
> sage: G((1,2,3))==G((2,3,1))
> True
> sage: K==H
> False
> }}}
>
> Even worse, comparison may raise an error -- afaik, the Python
> specification says that `__cmp__` is not supposed to raise errors:
> {{{
> 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'
> }}}
>
> So, `==` is not a symmetric relation.
>
> Of course, G==G2 invokes G.__cmp__(G2), which tests whether G and G2 are
> the same as PermutationGroup_generic.
> In contrast, G2==G tests whether G2 and G are the same as
> PermutationGroup_subgroup.
>
> So, what do people want?
>  1. A symmetric relation? Then K.__cmp__() should invoke
> PermutationGroup_generic.__cmp__().
>  2. Or should K.__cmp__(H) test whether K and H are subgroups of the same
> PermutationGroup, and then continue with testing whether K and H are
> subgroup of each other?
>
> Note that the with 1., == would test whether K and H are isomorphic
> abstract groups, which is the job of K.is_isomorphic(H).
>
> Therefore, I am in favour of 2.
>
> But then:
>  * What should be returned if neither H is a subgroup of K nor K is a
> subgroup of H?
>  * What should be returned if H is subgroup of G1 and K is subgroup of
> G2, with H contained in K contained in G2 contained in G1? Currently,
> K.__cmp__(H) would  -1 in this case (hence, H<K although K is contained
> in H!). Example:
>  {{{
> 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
> }}}
>
> So, the trivial group in G1 is considered greater than a non-trivial
> group in G2, because G1>G2.
>
> So, before working on a patch, I'd like to get people's opinion on what
> is a good specification of 'comparison of subgroups'.

New description:

 At http://groups.google.com/group/sage-
 support/browse_thread/thread/533747d48a1f29eb?hl=en
 it was reported that comparision of subgroups of permutation groups does
 not work as expected:

 {{{
 sage: G = SymmetricGroup(4)
 sage: H = G.subgroup([G((1,2,3))])
 sage: K = G.subgroup([G((2,3,1))])
 sage: G((1,2,3))==G((2,3,1))
 True
 sage: K==H
 False
 }}}

 Even worse, comparison may raise an error -- afaik, the Python
 specification says that `__cmp__` is not supposed to raise errors:
 {{{
 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'
 }}}

 So, `==` is not a symmetric relation.

 Of course, G==G2 invokes `G.__cmp__(G2)`, which tests whether G and G2 are
 the same as PermutationGroup_generic.
 In contrast, G2==G tests whether G2 and G are the same as
 PermutationGroup_subgroup.

 So, what do people want?
  1. A symmetric relation? Then `K.__cmp__()` should invoke
 `PermutationGroup_generic.__cmp__()`.
  2. Or should `K.__cmp__(H)` test whether K and H are subgroups of the
 same PermutationGroup, and then continue with testing whether K and H are
 subgroup of each other?

 Note that with 1., == would test whether K and H are isomorphic abstract
 groups, which is the job of K.is_isomorphic(H).

 Therefore, I am in favour of 2.

 But then:
  * What should be returned if neither H is a subgroup of K nor K is a
 subgroup of H?
  * What should be returned if H is subgroup of G1 and K is subgroup of G2,
 with H contained in K contained in G2 contained in G1? Currently,
 `K.__cmp__(H)` would  -1 in this case (hence, K<H although H is contained
 in K!). Example:
  {{{
 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
 }}}

 So, the trivial group in G1 is considered greater than a non-trivial group
 in G2, because G1>G2.

 So, before working on a patch, I'd like to get people's opinion on what is
 a good specification of 'comparison of subgroups'.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5664#comment:2>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to