-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Improved use of category framework for IntegerModRing #15229
Comments
comment:1
I just notice: We have John, do you think it would make sense to set |
comment:2
If one did
then Question: Shouldn't The following seems reasonable to me:
|
comment:3
THis looks a very sensible soution to me. |
comment:4
Thank you, John. Concerning GF, I stand corrected: It only does a full factorisation after it has already been found that the modulus is a prime power. |
comment:5
Replying to @simon-king-jena:
That's probably OK because the factorization routine in question is quick in recognizing perfect powers and primes. Calling a generic factorization algorithm to find out what prime power we're dealing with is bad, of course. |
comment:6
As I point out on [#15223 comment:18], if we do (in a fresh sage session)
we have C1 is not C2. But if we run that same code again, we do find that C1 is C2. That's the normal result from So why would one care to specify the category upon construction if the thing doesn't matter? Worse, presently specifying Another solution to forcing category refinement then would be
where the spelling of So I think we can't have both automatic category refinement on global objects (indicating categories are not important for equality/identity) and category specification upon construction (which raises the expectation that they are and presently actually makes that the case). The consequence of automatic category refinement is that you can't actually control the category that you get back even if you specify it: you might get back an answer in a finer category if that refinement happened to have been made before. Quoting from #15223 again:
|
comment:7
Concerning making non-identical parents equal, e.g., if we were to have
Then
wreaks havoc: Since the construction parameters of P1 and P2 are equal, we'll have |
comment:8
Replying to @nbruin:
That's related with one of the question I raised in #15223:
Isn't GAP using a similar approach? It creates one object, and then its behaviour may change, when one learns more about it. Hence, in this scenario, we would like that I guess this is again a question to the number theorists (hence, John...): Would we like the following behaviour (not implemented yet)?
We would have a unique instance of
I wouldn't like that |
comment:9
Replying to @nbruin:
You are right. This would be no good. |
comment:10
Replying to @nbruin:
We can! Namely, if the additional argument is ignored for the cache, but is still used to refine the existing object.
If we decide to ignore the additional argument for the cache and only use it to refine the unique global object, then this is a desired consequence. But phrased like "you can't actually make Sage forget what it found out about the category of the quotient ring". |
comment:11
Replying to @simon-king-jena:
Perhaps it would make sense then to introduce a method Using such method, it would be possible to revert the changes, if the user was wrong in assuming that the modulus was prime. For example:
And then, R would be in the same state as with originally defining Perhaps erasing of wrong assumptions on primality can automatically be done in |
Branch: u/SimonKing/ticket/15229 |
comment:13
I have pushed a preliminary version of the branch. It addresses the three points from the ticket description. But, as Nils has reminded me, we should not use the additional argument for the cache key (because of polynomial rings over integer mod rings). This, and perhaps an automatic update of a globally unique version of |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
comment:15
Replying to @simon-king-jena: Sure, having a way to do
instead? If the only meaningful value is Concerning GAP's approach: I'm not familiar, but allowing the behaviour of global objects to significantly change sounds like a bad idea. It makes it really hard to argue about any piece of code if you have to take into account the whole history of the system all the time. As far as I understand, presently, category refinement is simply used as a "cache" of computed data, but that means one shouldn't attach much further value to it either. Note how easily it can change:
|
Changed commit from |
Changed branch from u/SimonKing/ticket/15229 to none |
comment:16
Ouch, that doesn't look good. I don't know why trac did that. I definitely didn't selected those things to happen. |
Branch: u/SimonKing/ticket/15229 |
comment:17
My "category eraser" works. With it, one can do the following:
Question (e.g. to Nicolas): Do we want to have such a category eraser? Then, refining the category of a quotient ring would not hurt so much, because it could easily be reverted when one finds that the refinement was a mistake. |
Commit: |
comment:18
Replying to @nbruin:
Dunno. Anyway, trac chose to revert the deletion. Hmm. It is ironical that trac reverted a mistake exactly when I suggested a new method to revert a mistaken category refinement... |
comment:19
I don't know about playing around with categories too much that way. Could we have something like the following:
That would seem bad to me. Of course, as a debugging tool it may be OK, but I don't thing unrefining a category should be an advertised/supported feature. There may be objects around that rely on the category of the object as it was (and it may well be too expensive to ensure the category gets re-refined any time it relies on it) |
comment:20
Replying to @nbruin:
Yes, of course. All these
You can see it in this way: If you are in the fourth line of your example, then you are in a total mess. Unsetting the category might help you to clean some mess after the mess was created, but it wouldn't be appropriate to expect that it can clean everything. However, being able to clean some mess is still better than nothing. |
comment:21
And, by the way, we have:
So, this might actually be an argument of using the |
comment:56
All tests pass, but I guess I should remove some trailing whitespace. |
comment:58
Oops, I didn't know that I had merged (an old version of) master into the branch. Meanwhile I have learnt that one shouldn't do such merges. In any case: There was some trailing whitespace, and there was a phrase that ended somewhere in the middle and needed completion. And this ticket needs review! |
Work Issues: rebase |
Changed branch from u/SimonKing/ticket/15229 to public/categories/improve_integer_mod_ring-15229 |
comment:63
This solves an issue noted in #15475 (and #11979). I've rebased it and (non-long) doctests in the file pass, what needs review to finalize this? New commits:
|
Changed work issues from rebase to none |
comment:66
I had a look and am mostly happy with this ticket, though I might still prefer to let coexisted different instances of Z/nZ. Two minor typos:
|
Reviewer: Jean-Pierre Flori |
Changed branch from public/categories/improve_integer_mod_ring-15229 to |
On sage-devel, some discussion on
IntegerModRing
and its relation to categories took place. I would summarize the discussion and its consequences as follows:IntegerModRing
is prime, so that the ring is a field, without Sage performing a primality test. However (not part of the discussion)GF(n)
does a primality test (actually it factors n---is this really needed?). So, the user can not simply useGF(n)
if n is a huge number that the user knows to be a prime number.IntegerModRing(n, category=Fields())
. This feature was asked for in Categories for IntegerMod rings #8562 and implemented in Categories for all rings #9138..is_field()
should do a primality test, unless it is already known that the ring is a field. It has been suggested in the discussion on sage-devel to let.is_field()
change the category of the ring. At the time of the discussion, this did not seem possible, but in Serious regression caused by #9138 #11900 this feature has been added.By #11900, refinement of category happens when it is tested whether the
IntegerModRing
is a field byR in Fields()
. However, there is some inconsistency:I think we would want that
R
andS
are in the same category after the category refinement ofS
.So, the first aim of this ticket is to make the categories consistent.
Secondly, comparison of
IntegerModRing
includes comparison of types. Originally, this has been introduced since one wantedGF(p)
andIntegerModRing(p)
evaluate differently. However, changing the category changes the type, and thus changes the ==-equivalence class. I think this must not happen. Hence, the second aim of this ticket is to make == independent of the category, while still lettingGF(p)
andIntegerModRing(p, category=Fields())
evaluate unequal.Thirdly, in the discussion on sage-devel, it was suggested to refine the category of R when
R.is_field()
returns true. Currently, refinement only happens whenR in Fields()
returns true. So, the third aim of this ticket to do the refinement as suggested.Cc to John Cremona, since it was he who brought the "category refinement in
is_field()
" topic up...CC: @JohnCremona @nthiery @jpflori @novoselt
Component: categories
Keywords: sd53 category integermodring
Author: Simon King
Branch/Commit:
048aec7
Reviewer: Jean-Pierre Flori
Issue created by migration from https://trac.sagemath.org/ticket/15229
The text was updated successfully, but these errors were encountered: