-
-
Notifications
You must be signed in to change notification settings - Fork 570
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
Ideals of $\mathbb Z[x]$ #37409
Comments
This ideal inherits its comparison function from |
I laughed sage: R.<x> = ZZ[]
....: R.ideal(1) == R.ideal(1, 2)
False |
It is perfectly fair for This is basically a(nother) case of not having a good way to say "IDK", and so it simply returns |
I disagree: As the existence of this issue demonstrates, it is unexpected and causes confusion. If we wanted to compare the generators, we'd compare the generators.
I'm not sure what this refers to, can you elaborate?
The generally accepted way to communicate "IDK" is to throw a On a related note, there really should be a distinction between mathematically meaningful comparisons and simple comparisons for programming purposes, cf. #35546 (comment). |
Surprising behavior does not imply wrong behavior. Of course, it should be avoided, but we need to accept it sometimes. Here, there are two issues: (1) Sometimes one needs to be careful with
This might invoke a full Grobner basis computation when you simply want to check they are more trivially not equal. Of course, there are alternatives in this specific case, but there are uses for
There is also the issue that Python stipulates that
That is not true. Would you really want generic ideals to raise an error anytime they cannot compare in the strict mathematical sense? Then they couldn't be used as keys for dicts either. These would be the consequences I can immediately think of, but there are likely many more that would render these generic implementations completely unusable.
Defining natural comparisons is hard. There can be many different versions that have different uses. We usually just have to chose one, explain what it is, and explain how to use other choices. It also shows up in subtle ways in different methods. |
It is OK to do math in a All you need is a You can't fake an answer instead of admitting the inability. Similar issue: #36266 |
The most important thing is that it is not the responsibility of any common user of SageMath to distinguish whether it is a real |
#36266 is a different issue (it seems nobody has changed the implementation with the appropriate category from a very quick look). Python doesn't allow for trilean logic (which I would like to have, but others have tried and found it complicated from what I heard), and raising an error propagates breakage that might otherwise be okay (in fact, would make large amounts of things like, e.g., symbolics unusable). On the contrary, a good mathematician would look for a certificate (in this case, something in one ideal that isn't in the other). Even more so, things can be fully implemented but can lead to "wrong" results because a different convention is used in Sage than the user did for their conjectures (this is from a true story). This is why we believe in open source; we can look at the code and see how things like Forgive the Clinton-esque comment, but it depends on what the definition of TL;DR |
For comparison:
This is because it uses the (lib)singular implementation, which has the GB implemented (and so the comparisons of ideals as sets through |
Let's say the current implementation of
Not every user is a good programmer. Even so, USERS should only be exposed to documentation and the open (in the software engineering sense) interface of this software. To them, there is no clear line between "feature" and "bug". |
Let me apologize that this community of volunteers has not produced sufficient documentation that meets your high expectations. You are welcome to try and improve it.
In principle, I agree with you except the last part. If a user cannot understand the difference of desired behavior and undesired behavior, then I believe they will likely have difficulties understanding difficult mathematics that can have far more subtle points. In this case though, one doesn't need to be a good programmer to understand what the comparison code is doing. That being said, this here is definitely a case where we can improve our documentation by saying the generic implementation uses only the generators for comparisons. |
I should apologize for the inappropriate word |
The biggest issue is that the generic implementation does something entirely different from the specialized implementations. What comparison of ideals should be doing is ultimately a matter of opinion (although I do have a very strong opinion on this), but the fact that specialized implementations behave differently from the generic fallback is definitely harmful. It means, for example, that comparison suddenly starts returning wildly different results if you change the code to a slightly different base ring (or even just a different implementation of the same base ring). Subtle details like that are certainly not transparent to most users, and they would realistically cause lots of bugs/suffering even if they were properly documented. There should be a clear specification of what comparison does, and all implementations should either adhere to it or give up and throw a |
Responding to some of your earlier comments @tscrim (please don't interpret my writing style as antagonistic, I'm just trying to communicate my point as clearly as possible):
In which way is a
Again, if users wanted to compare the generators, they would compare the generators. An implementation of comparing the actual ideals can still have a fast path to check for equal generating sets. If computing a Gröbner basis is what it takes to properly compare two ideals, then so be it.
This example is about comparing rings, not ideals, which is an entirely different question: By construction Sage will only compare ideals with the same base ring (possibly by applying a coercion).
If that's what it takes, so be it. If users are happy with hashing a set of generators, they can hash the generators.
Yes!
I agree that there exist cases where no single obvious notion of comparison exists. Ideals, however, have exactly one such notion, and it is to compare them as subsets of the ring. |
I concur that having subclasses not performing the same comparison is an issue. The other side is that we want to actually be able to use the generic class when there is no known algorithm to compare otherwise. (There are generic GB algorithms, but they might not even terminate in more general settings.) By making the equality comparison raise a Another case to consider: the ideals may have a GB algorithm that runs for forever, but we don’t know ahead of time if this is true or not. Should they error out? Run for some fixed finite time and then error our if they still don’t know? Running further with that argument that IDK => error: Note that if things that we don’t know how to compare raise errors, then this should also be the case for I know I am reiterating stuff I said before, but I think it is important. I also think those concerns outweigh the consequences of having subclass comparisons differ from the generic comparisons as we have many other important cases where IDK means returning Note that my example with I agree with you about the user’s wanting to check generators, then that is what they should explicitly check. I am happy to have this discussion, and having @yyyyx4, @YijunYuan, @grhkm21, etc. (even strongly/aggressively) defend their POV is useful, nor do I think badly of you for it. (I also agree with @YijunYuan’s sentiment that Sage’s docs should be improved.) |
Setting aside the question of what should be the default behavior for ideals, the fix for this particular issue is clear: one needs to implement a class of ideals in polynomial rings over Z by exposing functionality in Singular. A roughly comparable situation is #29512 where we implemented ideals in Laurent polynomial rings. |
Big +1 on having a specialized subclass for ideals of poly rings over |
In fact we already have such a subclass, it's just that it's defined for multivariate polynomials:
It even works with a single variable if you force the issue:
So maybe it is enough to patch the univariate polynomial code so that ideals get created correctly. |
Indeed (I think I noted this somewhere), but I would expect there to be a fairly easy way to implement this directly using the fact that we are working over a PID. I am not sure right now exactly how to use this (or if it could be weaker, such as just being a domain). |
Thank you for pointing this out because it reminds me of the following issue I once had: |
Seems to be related to #23621 . |
Steps To Reproduce
Expected Behavior
The output should be$1=(1−2x)+2x∈I$ .
True
instead ofFalse
because we haveActual Behavior
The output is
False
.Additional Information
No response
Environment
Checklist
The text was updated successfully, but these errors were encountered: