Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the gens of a group, ring, or ideal always be a tuple? #34120

Open
DaveWitteMorris opened this issue Jul 6, 2022 · 8 comments
Open

Should the gens of a group, ring, or ideal always be a tuple? #34120

DaveWitteMorris opened this issue Jul 6, 2022 · 8 comments

Comments

@DaveWitteMorris
Copy link
Member

Looking at all occurrences of def gens in the sagemath source code reveals that the output of the gens method is a tuple in the vast majority of cases (including for the class ParentWithGens in src/sage/structure/parent_gens.pyx). In fact, the final line of the source code of the method is usually return tuple( <something> ). However, the search uncovered several exceptions that return a list:

  • FiniteGCAlgebra in src/sage/algebras/finite_gca.py
  • AbstractLinearCodeNoMetric in src/sage/coding/linear_code_no_metric.py
  • PermutationGroup_generic in src/sage/groups/perm_gps/permgroup.py -- the docstring says the method will return a tuple, and that seems to usually be the case, but SymmetricGroup(1).gens() is a list (and the same if 1 is replaced with some other number). This is clearly a bug, because the output type does not match the documentation.
  • SemimonomialTransformationGroup in src/sage/semimonomial_transformations/semimonomial_transformation_group.py -- the docstring says that the method will return a tuple, so this is another clear bug.
  • MagmaElement in src/sage/interfaces/magma.py
  • mwrank_EllipticCurve in src/sage/eclib/interface.py
  • FiniteSubgroup in src/sage/modular/abvar/finite_subgroup.py
  • ModularFormsSpace in src/sage/modular/modform/space.py
  • QuasiModularForms, QuasiCuspForms, ModularForms, CuspForms, and ZeroForm in src/sage/modular/modform_hecketriangle/space.py
  • SubSpaceForms in src/sage/modular/modform_hecketriangle/subspace.py
  • PollackStevensModularDomain in src/sage/modular/pollack_stevens/fund_domain.py
  • QuasiModularForms in src/sage/modular/quasimodform/ring.py
  • QuiverHomSpace in src/sage/quivers/homspace.py
  • QuiverRep_generic in src/sage/quivers/representation.py
  • UnsignedInfinityRing_class and InfinityRing_class in src/sage/rings/infinite.py
  • InfinityRing_class in src/sage/rings/padics/padic_generic.py
  • MPolynomialIdeal in src/sage/rings/polynomial/mult_polynomial_ideal.py -- the value is of type PolynomialSequence, which seems to be an immutable list. Single-variable polynomials return a tuple, and it would be good for the two to be consistent, even if we do not change the others in this list. This was pointed out in #34105 comment:4.
  • SymmetricReductionStrategy in src/sage/rings/polynomial/symmetric_reduction.pyx
  • RealIntervalField_class in src/sage/rings/real_mpfi.pyx
  • RealField_class in src/sage/rings/real_mpfr.pyx
  • EllipticCurve_number_field in src/sage/schemes/elliptic_curves/ell_number_field.py
  • EllipticCurve_rational_field in src/sage/schemes/elliptic_curves/ell_rational_field.py
  • SpecialCubicQuotientRing in src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py

Perhaps most (or all) of the above should be changed to a tuple.

An iterator or Family is returned in the following cases, but that makes sense because the set of generators may be infinite:

  • SteenrodAlgebra_generic in src/sage/algebras/steenrod/steenrod_algebra.py
  • HeckeAlgebra_base and HeckeAlgebra_anemic in src/sage/modular/hecke/algebra.py
  • OverconvergentModularFormsSpace in src/sage/modular/overconvergent/genus0.py
  • AlgebraicClosureFiniteField_generic in src/sage/rings/algebraic_closure_finite_field.py

This ticket arose from #34105 comment:4, which pointed out that multivariate polynomials behave differently than single-variable polynomials.

Related ticket: #33824 (make gens and orbits of PermutationGroup immutable)

CC: @yyyyx4

Component: algebra

Keywords: gens, tuple, list

Branch/Commit: public/ticket-34120 @ 52a359b

Issue created by migration from https://trac.sagemath.org/ticket/34120

@DaveWitteMorris DaveWitteMorris added this to the sage-9.7 milestone Jul 6, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member

mkoeppe commented Sep 3, 2022

comment:4

I think the infinite iterators in src/sage/modular/hecke/algebra.py should be replaced by an EnumeratedSetFromIterator

@mkoeppe
Copy link
Member

mkoeppe commented Sep 3, 2022

comment:5

Also all gens_dict methods should probably be replaced by gens returning a Family

@mkoeppe
Copy link
Member

mkoeppe commented Sep 3, 2022

comment:6

And +1 on changing all lists to tuples.

@fchapoton
Copy link
Contributor

comment:7

partly handled in #34500

@fchapoton
Copy link
Contributor

Branch: public/ticket-34120

@fchapoton
Copy link
Contributor

comment:8

here is some partial work on the case of rings/


New commits:

52a359bmake some "gens" method return tuples

@fchapoton
Copy link
Contributor

Commit: 52a359b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants