Opened 21 months ago

Last modified 11 days ago

## #31217 new defect

# make subsemigroup work for MatrixSpace

Reported by: | Franco Saliola | Owned by: | |
---|---|---|---|

Priority: | major | Milestone: | sage-9.8 |

Component: | algebra | Keywords: | semigroups, matrices |

Cc: | Frédéric Chapoton, Mike Zabrocki, schilling | Merged in: | |

Authors: | Reviewers: | ||

Report Upstream: | N/A | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description

`subsemigroup`

does not work for matrices; and even when the command does not fail, the answer could be wrong.

Let's try the subsemigroup generated by `A`

, where

sage: M = MatrixSpace(ZZ, 2) sage: A = matrix([[0, 1], [0, 0]]) sage: A * A [0 0] [0 0]

Note that `A * A == 0`

so the subsemigroup consists of `A`

and `0`

.

(1) First obvious attempt fails (this is how I expected it to work):

sage: M.subsemigroup([A]) ... TypeError: <class 'sage.sets.family.TrivialFamily_with_category'> is not hashable and does not implement _cache_key()

This error message is not helpful: after digging around a while, I figured out that the input gets converted to a `Family`

, so after trying to specify a `Family`

instead, I realized that the real problem is that `A`

is not immutable.

(2) Second attempt fails:

sage: M.subsemigroup([M(A)]) ... TypeError: <class 'sage.sets.family.TrivialFamily_with_category'> is not hashable and does not implement _cache_key()

I thought this work work because I explicitly converted `A`

to an element of `M`

. It turns out that `M(A)`

is not immutable, which seems like another issue that should be corrected.

sage: M(A).is_immutable() False

(3) Third attempt: first create `A`

as an immutable matrix.

sage: M = MatrixSpace(ZZ, 2) sage: A = matrix([[0, 1], [0, 0]], immutable=True) sage: S = M.subsemigroup([A]); S A subsemigroup of (Full MatrixSpace of 2 by 2 dense matrices over Integer Ring) with 1 generators

Here, the command does not fail, but the result is wrong:

sage: S.list() # fails first time, but not the second time... ... TypeError: mutable matrices are unhashable sage: S.list() [[0 1] [0 0]] sage: [A, A*A] # this is what the answer should be [ [0 1] [0 0] [0 0], [0 0] ]

### Change History (5)

### comment:1 Changed 20 months ago by

Milestone: | sage-9.3 → sage-9.4 |
---|

### comment:2 Changed 15 months ago by

Milestone: | sage-9.4 → sage-9.5 |
---|

### comment:3 Changed 10 months ago by

Milestone: | sage-9.5 → sage-9.6 |
---|

### comment:4 Changed 6 months ago by

Milestone: | sage-9.6 → sage-9.7 |
---|

### comment:5 Changed 11 days ago by

Milestone: | sage-9.7 → sage-9.8 |
---|

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

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.