#31212 closed defect (fixed)

fix submonoid method when the generating set include the identity

Reported by: Franco Saliola Owned by:
Priority: major Milestone: sage-9.3
Component: algebra Keywords: submonoid, monoid, semigroups
Cc: Mike Zabrocki, Anne Schilling Merged in:
Authors: Frédéric Chapoton Reviewers: Franco Saliola
Report Upstream: N/A Work issues:
Branch: b4a7173 (Commits, GitHub, GitLab) Commit: b4a7173f8c86897d5b2bba1992647e42890e0ac7
Dependencies: Stopgaps:

Status badges

Description

Fix the submonoid method so that we don't get two copies of the identity element when the generating set already includes the identity element.

sage: R = IntegerModRing(15)
sage: R.submonoid([R.one()]).list()         # this should be [1]
[1, 1]

sage: S = SymmetricGroup(4)
sage: S.submonoid([S.one()]).list()         # this should be [()]
[(), ()]

sage: S = SymmetricGroup(4)
sage: S.submonoid(list(S)).cardinality()    # this should be 24
25

Change History (4)

comment:1 Changed 21 months ago by Frédéric Chapoton

Authors: Frédéric Chapoton
Branch: u/chapoton/31212
Commit: b4a7173f8c86897d5b2bba1992647e42890e0ac7
Status: newneeds_review

New commits:

b4a7173trac 31212 fix submonoid

comment:2 Changed 21 months ago by Franco Saliola

Reviewers: Franco Saliola
Status: needs_reviewpositive_review

Salut Frédéric! Thanks so much for this quick fix and the other improvements to the surrounding code.

comment:3 Changed 21 months ago by Samuel Lelièvre

Does this also fix duplicate generators?

sage: S = SymmetricGroup(4)
sage: M = S.submonoid([S[3], S[3]])
sage: M
A subgroup of (Symmetric group of order 4! as a permutation group)
with 2 generators
sage: M.list()
[(), (1,2)(3,4), (1,2)(3,4)]

Using OrderedDict, or just dict once we drop Python 3.6 support, could help. See:

comment:4 Changed 20 months ago by Volker Braun

Branch: u/chapoton/31212b4a7173f8c86897d5b2bba1992647e42890e0ac7
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.