Bug with subgroup method?

57 views
Skip to first unread message

Altario

unread,
Jun 23, 2021, 2:36:39 PMJun 23
to sage-devel
SageMath version 9.0, Release Date: 2020-01-01
Using Python 3.8.5.
Ubuntu 20.04 LTS
64bit

Hi,

I want to create the multiplicative group (Z/7Z)*={1,2,3,4,5,6}

I did these steps:


sage: n=7                                                                                            

sage: Zn=Zmod(n)                                                                                     

sage: G=Zn.unit_group() 

sage: list(G)

[1, f, f^2, f^3, f^4, f^5]                                                                   

sage: G.inject_variables()                                                                           
Defining f

Then I want to create the subgroups H generated by f^2=2 mod 7 which is {1,2,4}.

I did the following steps:

sage: H = G.subgroup([f^2])                                                                          

sage: list(H)                                                                                        

[1, f, f^2]

sage: Zn(f)                                                                                          

3

"There seems to be a bug in the subgroup method: H should consist of [1, f^2, f^4]."
 cf:

Is there a solution for this ? Or I miss something?


David Roe

unread,
Jun 23, 2021, 3:24:40 PMJun 23
to sage-devel
I agree that this is a bug.  There are several issues, and I don't know if there's an easy fix.

1. The elements of the enumeration are produced by passing in exponent vectors in terms of the generators of H:
sage: H([1])
f
sage: H([1])^3
1
It's unfortunate that we choose the same letter to represent the generator of H as we do for the generator of G; this is just the default variable name for multiplicative groups.

2. The generators of H are elements of G, not of H, but they print in a reasonable way:
sage: H.0
f^2
sage: (H.0).parent()
Multiplicative Abelian group isomorphic to C6
sage: H.0.parent() is G                                                                                                                
True
I think that they should be elements of H, but that will mean they print incorrectly unless we update the element class.

3. There is no coercion from H to G:
sage: G.has_coerce_map_from(H)                                                                                                          
False
There should be.

I'm not going to be able to work on this soon, but am happy to help advise anyone who wants to.
David

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/a5c47bce-605c-4c6f-93b5-8db638c30c2an%40googlegroups.com.

Travis Scrimshaw

unread,
Jun 23, 2021, 8:31:22 PMJun 23
to sage-devel
+1 for having the ambient group having a coercion from a subgroup. One other bug is that

sage: H.gen(0).parent() is G
True

sage: H([2])
f^2
sage: _.parent()
Multiplicative Abelian subgroup isomorphic to C3 generated by {f^2}

Best,
Travis

Samuel Lelievre

unread,
Jun 24, 2021, 4:21:42 AMJun 24
to sage-devel
Also discussed at Ask Sage:

- Ask Sage question 57703
  Multiplicative group of Zmod(n)
  https://ask.sagemath.org/question/57703

Mickaël Hamdad

unread,
Jun 24, 2021, 3:53:38 PMJun 24
to sage-...@googlegroups.com
And Is there a way to list H directly with numerical values ?

Le jeu. 24 juin 2021 à 21:48, Mickaël Hamdad <hamdad....@gmail.com> a écrit :
Thank you very much!!!!
Just what H.0 mean ?

--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/D3zdWqswrFo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/0989e81f-6497-4f09-8a51-5311c838773an%40googlegroups.com.

Mickaël Hamdad

unread,
Jun 24, 2021, 3:53:38 PMJun 24
to sage-...@googlegroups.com
Thank you very much!!!!
Just what H.0 mean ?

Le jeu. 24 juin 2021 à 10:21, Samuel Lelievre <samuel....@gmail.com> a écrit :
--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/D3zdWqswrFo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/0989e81f-6497-4f09-8a51-5311c838773an%40googlegroups.com.

David Roe

unread,
Jun 24, 2021, 4:00:38 PMJun 24
to sage-devel
H.0 is Sage notation for the 1st generator of H.

sage: preparse("H.0")                                                                                                                  
'H.gen(0)'

As for getting the value, it depends on what kind of element you have.  

sage: H.0._exponents                                                                                                                    
(2,)
sage: H.0.value()                                                                                                                      
2
sage: H([1])._exponents                                                                                                                
(1,)
sage: H([1]).value()
Traceback (most recent call last):
...
AttributeError... 

Also remember that the exponent vectors depend on the context: H.0 is an element of G (inappropriately in my opinion) and is thus expressed in terms of a generator of G, while H([1]) is in terms of a generator H.
David



You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAHJeuofvY5btZv%2BT3gWeb4C8hU7aTiNUHrsD%2BdhTDcbKpnn2Xw%40mail.gmail.com.

Mickaël Hamdad

unread,
Jun 26, 2021, 12:36:26 PMJun 26
to sage-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages