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

Tweak Rees matrix semigroups code #3664

Merged
merged 4 commits into from
Nov 18, 2019

Conversation

fingolfin
Copy link
Member

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; say Matrix(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.

@fingolfin fingolfin added do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) topic: library release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Sep 18, 2019
Copy link
Contributor

@ThomasBreuer ThomasBreuer left a 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.

doc/ref/reesmat.xml Outdated Show resolved Hide resolved
doc/ref/reesmat.xml Outdated Show resolved Hide resolved
DeclareSynonymAttr("MatrixOfReesMatrixSemigroup", Matrix);
DeclareSynonymAttr("MatrixOfReesZeroMatrixSemigroup", Matrix);
DeclareAttribute("MatrixOfReesMatrixSemigroup", IsReesMatrixSubsemigroup);
DeclareAttribute("MatrixOfReesZeroMatrixSemigroup", IsReesZeroMatrixSubsemigroup);
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Member Author

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 ;-).

@wilfwilson
Copy link
Member

Thanks for pointing out the mutability difference. I would be surprised if the immutable result causes anything to break, but we'll see.

@fingolfin
Copy link
Member Author

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).

Good point, I actually forgot about that! I'll update this PR to also remove that "mutable attribute Matrix".

lib/reesmat.gi Outdated Show resolved Hide resolved
lib/reesmat.gi Outdated Show resolved Hide resolved
@james-d-mitchell
Copy link
Contributor

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”.

@fingolfin
Copy link
Member Author

@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.

@wilfwilson
Copy link
Member

@james-d-mitchell made a new release (thanks!), hopefully it will be picked up soon by the package distribution system.

@fingolfin
Copy link
Member Author

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.

@wilfwilson
Copy link
Member

Would be fine by me.

@fingolfin
Copy link
Member Author

Tests still fail, because the YangBaxter package does this: DeclareAttribute("Matrix", IsCycleSet);

@wilfwilson
Copy link
Member

Which, for ease of keeping track, @fingolfin has made a PR to address at gap-packages/YangBaxter#64.

@wilfwilson
Copy link
Member

Seeing as YangBaxter 0.9.0 has been released, I’m hoping that the tests will now pass.

@wilfwilson
Copy link
Member

@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.
@wilfwilson wilfwilson removed the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Nov 18, 2019
@wilfwilson wilfwilson changed the title Tweak Rees matrix semigroups code (DO NOT MERGE) Tweak Rees matrix semigroups code Nov 18, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0002%) to 84.514% when pulling 13e9d0f on fingolfin:mh/ReesMatrix into 70b459f on gap-system:master.

@wilfwilson wilfwilson merged commit 643013c into gap-system:master Nov 18, 2019
@fingolfin fingolfin deleted the mh/ReesMatrix branch November 18, 2019 21:45
@ThomasBreuer ThomasBreuer self-assigned this Feb 17, 2021
@ThomasBreuer ThomasBreuer added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Feb 17, 2021
@ThomasBreuer ThomasBreuer removed their assignment Feb 17, 2021
@fingolfin fingolfin added release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes and removed release notes: added PRs introducing changes that have since been mentioned in the release notes labels Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants