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

Fix bool(expr1 != expr2) for nontrivially equal expressions #34341

Closed
sagetrac-tmonteil mannequin opened this issue Aug 11, 2022 · 8 comments
Closed

Fix bool(expr1 != expr2) for nontrivially equal expressions #34341

sagetrac-tmonteil mannequin opened this issue Aug 11, 2022 · 8 comments

Comments

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Aug 11, 2022

As reported on sage-devel:

sage: a = x^2 + 2*x + 1
sage: b = (x + 1)^2
sage: c = a != b
sage: bool(c)
True 

Note that

sage: bool(c.expand())
False

This is due to calling is_trivial_zero instead
of is_zero in the __bool__ method for symbolic expressions.

The fix provided by this ticket is not intended to fix other existing bool(expr1 != expr2) issues (e.g. #33698).

CC: @hemmecke @rwst

Component: symbolics

Author: Thierry Monteil

Branch/Commit: 5ca40a8

Reviewer: Samuel Lelièvre

Issue created by migration from https://trac.sagemath.org/ticket/34341

@sagetrac-tmonteil sagetrac-tmonteil mannequin added this to the sage-9.7 milestone Aug 11, 2022
@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Aug 11, 2022

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Aug 11, 2022

Commit: 5ca40a8

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Aug 11, 2022

Author: Thierry Monteil

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Aug 11, 2022

New commits:

5ca40a8#34341 : fix bool(x^2 + 2*x + 1 != (x + 1)^2)

@sagetrac-tmonteil sagetrac-tmonteil mannequin changed the title boo(expr1 != expr2) misbehaves when the expressions are nontrivially equal bool(expr1 != expr2) misbehaves when the expressions are nontrivially equal Aug 11, 2022
@slel

This comment has been minimized.

@slel
Copy link
Member

slel commented Aug 11, 2022

comment:5

Thanks for fixing this.

@slel
Copy link
Member

slel commented Aug 11, 2022

Reviewer: Samuel Lelièvre

@slel slel changed the title bool(expr1 != expr2) misbehaves when the expressions are nontrivially equal Fix bool(expr1 != expr2) for nontrivially equal expressions Aug 11, 2022
@vbraun
Copy link
Member

vbraun commented Aug 30, 2022

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