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

bool of symbolic inequality does not agree with documentation #33698

Open
DaveWitteMorris opened this issue Apr 12, 2022 · 4 comments
Open

bool of symbolic inequality does not agree with documentation #33698

DaveWitteMorris opened this issue Apr 12, 2022 · 4 comments

Comments

@DaveWitteMorris
Copy link
Member

The docstring of sage.symbolic.expression.__bool__ says that a relation f(x) op g(x) will evaluate to True if it is satisfied for all values of x, and will evaluate to False otherwise. ("We cannot return undecidable or throw an exception at the moment so False is returned for unknown outcomes.") But that is not how inequality behaves:

sage: bool(x != 1)  # false for `x = 1`, so should be `False`
True

The doctest for this behavior passes because inequality does behave as described if an assumption is added (and a previous doctest added an assumption):

sage: assume(x > 0)
sage: bool(x != 1)
False
sage: forget()
sage: assume(x < 0)
sage: bool(x != 1)
True

We need to either change the docstring or change the behaviour of inequality. Also, adding an assumption should not change the behaviour.

Related tickets:

Component: symbolics

Branch/Commit: public/33698r1 @ 245a3fc

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

@DaveWitteMorris
Copy link
Member Author

Branch: public/33698

@DaveWitteMorris
Copy link
Member Author

Changed branch from public/33698 to public/33698r1

@DaveWitteMorris
Copy link
Member Author

comment:3

I fixed the doctest in src/sage/symbolic/expression.pyx (by adding forget()), so a doctest fails now, because of the problem in the ticket description. (Sorry, I forgot to do "git commit" before my first push, but I think the branch is ok now.)


New commits:

245a3fctrac 33698: bool of symbolic inequality

@DaveWitteMorris
Copy link
Member Author

Commit: 245a3fc

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