-
-
Notifications
You must be signed in to change notification settings - Fork 614
Allow actions of a parent on itself #18758
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
Comments
comment:1
See comment 24 at #18756 for why I think we should have a dependency. |
Dependencies: #18756 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:4
More precisely: The example from the ticket description shouldn't be called RingStructure but MagmaStructure, it should be defined in |
comment:5
Remark: Two problems: There is an import statement in the multiplication method, which, if I recall correctly, is not for free. And it first checks the presence of a So, it would be interesting to see if the following approach yields faster code:
So, rather than providing a |
comment:6
I haven't pushed my branch yet. Anyway, what I can do is the following:
Explanation:
As you can see, of course a specialised cythoned Before I push my branch, I'll see what happens if I provide |
comment:7
Replying to @simon-king-jena:
To be clear: It would still be the case that In particular, the existing user code will not change. |
comment:8
Replying to @simon-king-jena:
This is what happens:
In other words, using Of course, Before pushing my branch, I plan to add tests and documentation. The documentation will go to Can you suggest a place to put documentation on coercion so that it is actually found by sage.combinat users? |
comment:9
I had a look at sage.combinat, and it turns out that the situation is not sooooo bad as I thought.
I suggest to sanitise Permutation here, but keep Word for a later ticket. |
comment:10
PS: Having a pushout construction for permutations would also be nice. Again, it would be for a later ticket. |
comment:11
PPS: Is it actually |
comment:12
It will not be easy to make my proposed changes work throughout the sage library. There are zillions of errors in sage.modular (I am sure this is because it was previously worked around coercion...). Well, we will see. |
This comment has been minimized.
This comment has been minimized.
comment:14
With the branch, that I have still not pushed, I get
Not so bad, actually... |
Author: Simon King |
Commit: |
comment:16
I have changed the logic in the Most important change: The coercion model now makes actual use of single underscore methods! You may be surprised by the implied statement that previously the coercion model did not use them. In fact, it didn't. Up to now, the single underscore methods have only been used as short-cuts in |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:18
Here are some timings. The code used:
Here are different settings, where in each case I also compare with vanilla sage-6.8.beta5.
|
comment:19
Hello, There are some clear troubles with the patchbot... some elements do not know how to multiply anymore. Vincent |
comment:20
Also, the doctest coverage is not 100%. |
comment:21
Replying to @videlec:
In two of the failing tests, it is just the error message that has changed. In the third, it could be that something needs to be done. |
comment:22
If I recall correctly, some people have worked on similar issues. But I am not sure about the ticket numbers. Hence, is what I propose here done already? |
Currently,
ModuleElement.__mul__
raises an error when both elements have the same parent. Hence, in order to define a ring structure, one must not start withModuleElement
, which is bad, since sometimes the concrete structure only depends on the category (see CombinatorialFreeModule).The approach to be implemented here:
ModuleElement.__mul__
andRingElement.__mul__
should provide short-cuts in cases where there is an obvious way to be faster than calling the coercion model, and otherwise it is the job of the coercion model (NOT ofModuleElement.__mul__
) to complain if the two elements come from the same parent without an action being defined.Hence, it should be possible to start with
ModuleElement
and get a ring structure on top of it by an appropriate action of the parent on itself. Here is an example that should be made work:Moreover, it should be possible to define the actions using ParentMethods in the category framework. I.e.,
_get_action_
should be moved from Parent to Sets.ParentMethods. This is why #18756 (where the whole idea started) is a dependency.More precisely: The above
RingStructure
(perhaps with some sanity test similar tosage.structure.coerce_action.ModuleAction
) should be defined in sage.structure.coerce_actions and used byRings.ParentMethods._get_action_
.Summary
Magmas()
. However, it should become faster and it should in future be easier to import the multiplication from a fast cython module._mul_
and initialises inMagmas()
. Overriding__mul__
(which in some situations was still needed) should in future be even more useless._add_
.Depends on #18756
CC: @nthiery @sagetrac-sage-combinat
Component: coercion
Keywords: actions on itself
Author: Simon King
Branch/Commit: u/SimonKing/allow_actions_of_parent_on_itself @
d71a456
Issue created by migration from https://trac.sagemath.org/ticket/18758
The text was updated successfully, but these errors were encountered: