Opened 21 months ago

Closed 20 months ago

## #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: |

### 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

Authors: | → Frédéric Chapoton |
---|---|

Branch: | → u/chapoton/31212 |

Commit: | → b4a7173f8c86897d5b2bba1992647e42890e0ac7 |

Status: | new → needs_review |

### comment:2 Changed 21 months ago by

Reviewers: | → Franco Saliola |
---|---|

Status: | needs_review → positive_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

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

Branch: | u/chapoton/31212 → b4a7173f8c86897d5b2bba1992647e42890e0ac7 |
---|---|

Resolution: | → fixed |

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

New commits:

`trac 31212 fix submonoid`