-
Notifications
You must be signed in to change notification settings - Fork 160
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
Tweak Rees matrix semigroups code #3664
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the specific comments in the code, I would like to emphasize that after the change, Matrix
for Rees matrix semigroups will return an immutable result, whereas the result has been mutable up to now (due to a declaration of Matrix
as a mutable attribute, which is read before the declaration in reesmat.gd
).
I think the new behaviour is better, but the change may cause problems.
DeclareSynonymAttr("MatrixOfReesMatrixSemigroup", Matrix); | ||
DeclareSynonymAttr("MatrixOfReesZeroMatrixSemigroup", Matrix); | ||
DeclareAttribute("MatrixOfReesMatrixSemigroup", IsReesMatrixSubsemigroup); | ||
DeclareAttribute("MatrixOfReesZeroMatrixSemigroup", IsReesZeroMatrixSubsemigroup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to now, there was just one attribute Matrix
with two synonyms MatrixOfReesMatrixSemigroup
, MatrixOfReesZeroMatrixSemigroup
.
Do we really need/want two independent attributes MatrixOfReesMatrixSemigroup
, MatrixOfReesZeroMatrixSemigroup
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be an alternative way of doing this, so that there were not two independent attributes? We could have one attribute called something like MatrixOfReesOrReesZeroMatrixSemigroup
with the other names being synonyms for it, but that feels a bit weird to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there was just one attribute with different names MatrixOfReesMatrixSemigroup
, MatrixOfReesZeroMatrixSemigroup
up to now, the situation seems to be that either no object lies in both IsReesMatrixSubsemigroup
and IsReesZeroMatrixSubsemigroup
or the attribute values for objects in both filters are equal.
In the former case, introducing two independent attributes is on the one hand safer (one gets an error if one calls the wrong attribute), but on the other hand Matrix
methods for the two cases make the distinction disappear, and from this point of view just one filter is wasted.
In the latter case, introducing two independent attributes may cause that the same value has to be computed twice, if one asks for the values of both attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former case is the true one: IsReesMatrixSemigroupElement
and IsReesZeroMatrixSemigroupElement
(from which IsReesMatrixSubsemigroup
and IsReesZeroMatrixSubsemigroup
are derived) are different categories, and so a GAP object cannot lie in both.
Is it a problem to 'waste' filters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked @wilfwilson beforehand to make sure that the filters are mutually exclusive, and hence split this into two attributes. The alternative would IMHO not be to introduce MatrixOfReesOrReesZeroMatrixSemigroup
, but rather I'd just turn one DeclareAttribute
back into DeclareSynonymAttr
.
But I really think it's best the way I now did it. Yes, we loose one filter bit. I don't see an issue with that, we have plenty bits left ;-).
Thanks for pointing out the mutability difference. I would be surprised if the immutable result causes anything to break, but we'll see. |
Good point, I actually forgot about that! I'll update this PR to also remove that "mutable attribute Matrix". |
Thanks for these changes and comments all, I will double check that everything still works in Semigroups today or tomorrow, then I’ll happy “approve”. |
77b4aa7
to
3ebe958
Compare
@james-d-mitchell thank you! In any case, we won't merge this before a new Semigroups release with the changes has been made, and picked up into the packages distribution. |
@james-d-mitchell made a new release (thanks!), hopefully it will be picked up soon by the package distribution system. |
Excellent. So once @alex-konovalov resp. the package distribution picked up Semigroups 3.1.5, we could merge this, I guess. Well, of course only after rebasing it and rerunning the tests to make sure they then pass again. |
Would be fine by me. |
3ebe958
to
2f313c4
Compare
Tests still fail, because the YangBaxter package does this: |
Which, for ease of keeping track, @fingolfin has made a PR to address at gap-packages/YangBaxter#64. |
Seeing as YangBaxter 0.9.0 has been released, I’m hoping that the tests will now pass. |
@fingolfin Could you rebase this please? Hopefully that will make the tests pass, and then we can merge 🙂 |
This removes the Matrix attribute; instead, methods for the Matrix *operation* are installed, which delegate suitably to MatrixOfReesMatrixSemigroup resp. MatrixOfZeroReesMatrixSemigroup, which now are independent attributes (instead of both being synonyms for Matrix). Also change Rees matrix semigroup code which access the attributes Rows and Columns to instead access RowsOfReesZeroMatrixSemigroup, etc., explicitly, to mirror the changes for Matrix, and to prepare for the eventuality that we might want to convert Rows and Columns into plain operations, too. Finally, tweak some manual entries for Rees matrix semigroups: mansections referencing themselves should still use <Ref> for that.
... to distinguish it from the Matrix operation which is part of MatrixObj.
This was only a mutable attribute as a workaround for the existence of a Matrix attribute for Rees matrix semigroups. Since that one is gone, we can also replace the workaround.
2f313c4
to
13e9d0f
Compare
This removes the Matrix attribute; instead, methods for the Matrix operation
are installed, which delegate suitably to MatrixOfReesMatrixSemigroup resp.
MatrixOfZeroReesMatrixSemigroup, which now are independent attributes (instead
of both being synonyms for Matrix).
Also change Rees matrix semigroup code which access the attributes Rows and
Columns to instead access RowsOfReesZeroMatrixSemigroup, etc., explicitly, to
mirror the changes for Matrix, and to prepare for the eventuality that we
might want to convert Rows and Columns into plain operations, too.
Finally, tweak some manual entries for Rees matrix semigroups: mansections
referencing themselves should still use
<Ref>
for that.The motivation for this is that we may want to allow using single-arg
Matrix
as a convenient way to construct MatrixObj instances; sayMatrix(old_style_mat)
could take a classic list-of-lists, and return an equivalent MatrixObj. That said, we might not actually do this; but simply the fact that Matrix is already an operation for 2, 3, ... args means that it is somewhat awkward to have it also be an attribute. So I'd rather avoid that.Perhaps we should do the same for Rows and Columns, just in case we want to provide similar operations for MatrixObj? Not sure about that, though. And even if we over such APIs, we could call them, say, RowsOfMatrix; and then, perhaps we'd want an iterator anyway, so it'd be RowIterator/ColumnIterator; so I am not sure it's worth the hassle to even think about this more at this stage? The main motivation to change them, too, at this stage, would be symmetry; i.e., trying to not surprise people using Rees matrix semigroups by odd differences between Matrix on the one hand, and Rows/Columns on the other.
This PR should NOT be merged before Semigroups merges semigroups/Semigroups#618 and then has a release.