Opened 5 years ago
Closed 4 years ago
#24726 closed defect (wontfix)
Sage silently accepts symbolic expressions with two comparison operators
Reported by: | Thierry Monteil | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | symbolics | Keywords: | |
Cc: | Ralf Stephan, Samuel Lelièvre | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
See the following example:
sage: 0 <= x <= 1/2 0 <= x
This should raise an error. Note that it can create confusion when used in assumptions:
sage: assume(0 <= x <= 1/2) sage: bool(x <= 1/2) False
This has been reported on this ask question.
Change History (10)
comment:1 Changed 5 years ago by
Milestone: | sage-8.2 → sage-duplicate/invalid/wontfix |
---|---|
Status: | new → needs_review |
comment:2 Changed 5 years ago by
Status: | needs_review → positive_review |
---|
comment:3 follow-up: 4 Changed 5 years ago by
I got your point, but it is not clear for me that this implies that there is nothing to do on the symbolic ring to mitigate the issue.
comment:4 Changed 5 years ago by
Replying to tmonteil:
I got your point, but it is not clear for me that this implies that there is nothing to do on the symbolic ring to mitigate the issue.
As long as bool(0 <= x)
returns False
, it is not possible to fix this.
comment:5 follow-up: 8 Changed 5 years ago by
We could let the Sage preparser turn multiple inequalities in assume
statements into multiple assumptions.
comment:6 Changed 5 years ago by
Milestone: | sage-duplicate/invalid/wontfix → sage-8.2 |
---|---|
Status: | positive_review → needs_info |
That's an interesting idea. And it could raise an error outside assumptions. Let's at least wait for that PEP before closing this.
comment:7 Changed 5 years ago by
Cc: | Samuel Lelièvre added |
---|---|
Summary: | Sage silenly accepts symbolic expressions with two comparison operators → Sage silently accepts symbolic expressions with two comparison operators |
comment:8 Changed 5 years ago by
Replying to slelievre:
We could let the Sage preparser turn multiple inequalities in
assume
statements into multiple assumptions.
Why special-case assume
? The problem already occurs before calling assume
:
sage: 0 <= x <= 1/2 0 <= x
comment:9 Changed 5 years ago by
And if you do want to hack the preparser for that, I would do it with the PEP 535 semantics.
comment:10 Changed 4 years ago by
Milestone: | sage-8.2 → sage-duplicate/invalid/wontfix |
---|---|
Resolution: | → wontfix |
Status: | needs_info → closed |
Since PEP 535 is not particularly likely to come soon, I suggest to close this as "wontfix".
This is not a solvable problem. The problem is that Python treats
as
Since
bool(0 <= x)
isFalse
, this returns(0 <= x)
.There is proposal at PEP 535 to fix this, but it's not clear whether it will be accepted.