Skip to content
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

Incorrect element comparison for places/divisors/FormalSum #39356

Open
2 tasks done
vincentmacri opened this issue Jan 20, 2025 · 2 comments
Open
2 tasks done

Incorrect element comparison for places/divisors/FormalSum #39356

vincentmacri opened this issue Jan 20, 2025 · 2 comments

Comments

@vincentmacri
Copy link
Contributor

Steps To Reproduce

In Sage 10.5, run:

R.<x, y> = GF(5)[]
C = Curve(y^2 - x^3)
F = C.function_field()
D = F.places_finite()[0]
print(0 >= -D, 0 >= -D.divisor())

Expected Behavior

This should print True True.

Actual Behavior

This prints False False.

Additional Information

No response

Environment

  • OS: Fedora 41
  • Sage Version: 10.5

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@AdityaK1729
Copy link

Hi can I try to fix this?

@vincentmacri
Copy link
Contributor Author

Hi can I try to fix this?

You're welcome to try. Just a heads up, I don't think that the test case I reported in this issue report covers all instances of this bug as there are few variants of the divisor type and I'm not sure where the fix needs to be implemented.

In fact, I think this is actually a bug in FormalSum comparison, which divisors inherit from. Here's an example with FormalSum:

f1 = FormalSum([(1, 'a'), (2, 'b')])
f2 = FormalSum([(3, 'a')])
f2 > f1  # False, but should be True
f2 - f1 > 0  # True, which is correct and contradicts that f2 > f1 currently returns False

My guess for how to fix it would be to change _richcmp_ in src/sage/structure/formal_sum.py to account for comparing a FormalSum that doesn't have a particular term to a FormalSum that has that term with a negative coefficient.

@tscrim since you reviewed #37972 in which I made changes to FormalSum comparison, and I remember there were some coercion-related subtleties to that fix: is there anything you think @AdityaK1729 should be aware of before attempting to fix this?

@vincentmacri vincentmacri changed the title Incorrect element comparison for places/divisors Incorrect element comparison for places/divisors/formal sum Jan 31, 2025
@vincentmacri vincentmacri changed the title Incorrect element comparison for places/divisors/formal sum Incorrect element comparison for places/divisors/FormalSum Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants