-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Ring not considered module over itself #31713
Comments
comment:1
Something to document rather than to fix, if you ask me. Similarly, a field is not in the category of vector spaces sage: QQ in VectorSpaces(QQ)
False
sage: QQ^1 in VectorSpaces(QQ)
True |
comment:2
I would like to define a morphisms in the category of modules from a ring to a module over that ring. But now we get:
Any way to circumvent this then? Similarly for the dual btw. |
comment:3
I don't consider this to be a bug, but a consequence of how we often secretly equate things in mathematics. It seems like you just need to be a little more careful with what objects you are working with if you want it to be a module morphism (rather than an action). |
comment:4
Replying to @tscrim:
But that doesn't answer my question how I can define a morphism (i.e. module homomorphism) from a ring to a module over the same ring. This must be somehow possible in Sage. Fine, this works with |
comment:5
Can you turn the scalar field with scalars in some ring |
comment:6
Replying to @slel:
As far as I know, you can't, unfortunately. And I don't think there is a need to change anything or add this features. The only thing I need is a module homomorphism starting/ending from/to the scalar field algebra. It's really annoying that this is not working... |
comment:7
Despite my initial comment, I'm fine with (Given how little I know about categories |
comment:8
Replying to @mjungmath:
If you want a more hack way around it, you can modify the Again, if you want a module morphism, then you need to construct it as a module. Otherwise you have to have a ring morphism (which is what is used to define the action of
That sounds more like a problem with the implementation of scalar fields because the free module code should work with any field as linear algebra works over any field. Note that |
comment:9
This makes total sense. What about a coercion that exactly does this, coercing a ring |
Commit: |
comment:11
I have uploaded a draft for the coercion. Please take a look. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:14
The last step, set |
comment:15
I have another idea. I think, we need a Then we deal with the coercion via |
Dependencies: #31721 |
comment:17
To be very clear about this, this is not a coercion, but a conversion. I also don't think we should simply check that Changing the default behavior of I don't like perma-nailing categories into memory. This should be avoided as much as possible. I highly doubt the calls to those categories in |
comment:18
Replying to @tscrim:
The reason is that for example
won't work otherwise. Rings that do not inherit from As for perma-nailing, that wasn't my idea. It happens everywhere in the code. |
comment:19
Replying to @mjungmath:
One should indeed try to avoid instantiating instanced of parametrized categories (such as categories that have a base ring and/or dimensions) because they can lead to unbounded memory use over time. See #15801. There are good solutions for that: Rather than It may well be that subsequent developers were not aware of the real issues addressed in #15801 and, inspired by a desire for mathematical precision, have reintroduced automatic instantiation of parametrized categories. These are bugs that should be corrected. |
comment:20
Replying to @mjungmath:
Then add these methods to make it work as it suggests an incomplete implementation.
Then import it from those locations because if we decide to stop nailing it in, then we only have to change it in one place and then fix the errors in all of the files. Do not nail anything more than what already is done. Just because it is done elsewhere does not make it a good practice. |
comment:21
Replying to @tscrim:
Either way: the category
That can be done in #31722. |
comment:22
That does not follow. It is not a category implementation but a class that is using those parents. There is no refactoring needed nor documentation needed to be added there. Now there is a good reason to nail |
comment:23
Replying to @tscrim:
Do you have a more objective reason than just taste? I agree that linking categories willy-nilly is not a good idea, but for the most part I don't think it's going to cause memory leaks: if I recall correctly, most categories are immortal once they get created anyway. So the leak is creating them in the first place :-). For categories like It may well be that using |
comment:24
Replying to @nbruin:
Indeed, categories should not be immortal. Although some of them might effectively be that way since we have standard rings and fields in Sage that nobody would suggest we do lazily (
For the non-parameterized categories, this is less of an issue, but I don't want to allow more use of this without a good reason. Most importantly, I would want to do this in one place and one place only. Everything else should just be an import of that specific instance.
I agree generally, but I don't want this to do be done in many places and make it seem like it is a good practice. It makes it harder to refactor and other developers might start to think they can do this for any category they want, which I don't think we should advocate. Which they then move onto more parents being allowed. I know this is a slippery-slope argument, so it doesn't have much merit, but it is something I am a bit concerned about. |
comment:25
Replying to @tscrim:
If I recall correctly, categories are fundamentally immortal once they participate in the dynamic classes that are derived from them (isn't this always?) The category hierarchy is just too involved to be reliably fully dynamic (in the sense that parts of it can be removed and garbage collected). I suspect that this might be rather fundamental: once you participate in Python's MRO inheritance mechanism, you'd probably already get permanently nailed there. Python is definitely not designed with a non-monotonously growing class hierarchy in mind, so I expect that the caching and storing strategies put in place to implement it, prevent decreases (by "accidental design" I expect -- as a consequence of other design decisions made; not as an intentional design goal) This was implicitly acknowledged in #15801. We suffer from similar effects in the coercion network and the conversion caching: it's just very hard to keep a graph in such a way that you can efficiently find paths and force path independence of other properties along these paths (the coercion maps; unambiguous inheritance) and still allow for nodes to vanish from the graph as well - in particular if you'd like independence to hold through time (at least limited to a run) as well. [and another source -- caches that enforce global uniqueness :-)] |
comment:26
Setting a new milestone for this ticket based on a cursory review. |
We have the following bug:
but on the other hand
works.
Depends on #31721
CC: @tscrim @mkoeppe @dimpase @slel @DaveWitteMorris
Component: categories
Branch/Commit: u/gh-mjungmath/ring_not_considered_module_over_itself @
0ef2060
Issue created by migration from https://trac.sagemath.org/ticket/31713
The text was updated successfully, but these errors were encountered: