-
-
Notifications
You must be signed in to change notification settings - Fork 652
implement naive default inverse methods for finite monoids #40024
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
implement naive default inverse methods for finite monoids #40024
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.
These are real failures by the bots. Magmas
implements a generic one()
by return self(1)
. Perhaps we should try that first (or more generally
def one(self):
try:
return super().one()
except (TypeError,, ValueError, AttributeError):
pass
it = (v for v in self if all(v * w == w for w in self))
return next(it)
I think there is an implicit general problem as the default iteration starts from one()
and multiplies by all of the generators. Of course, this is not unreasonable as we expect the user to implement one of these as part of the monoid. That being said, perhaps it is better to require one
be implemented in some more explicit way?
For both methods, perhaps we should cache that result? Also, wouldn't it be better raise a different error than StopIteration
if it is not invertible?
This is apparently not enough. Maybe I should remove this default one and keep only the default invert ? |
15b60d8
to
a7a6d45
Compare
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.
That's very curious and unexpected. Now I wonder how that code is even working. It would need some non-generic way to create things (either an iterator or be able to construct one()
somehow). I figured the super()
call was sufficient, but I guess we should in principle, check that the one from Magmas.Unital
is being called (or we could just explicitly add it in as return self(1)
instead).
Well, I guess we can just revert like this, but at least it didn't seem like a widespread problem... How much time do you want to spend on this?
Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
Thanks Travis, for your time and helpful feedback. I would indeed prefer not to spend more time. |
Documentation preview for this PR (built with commit e39604c; changes) is ready! 🎉 |
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.
Thank you. LGTM.
This is implementing very naive
one
and__invert__
methods in the category of finite monoids.📝 Checklist