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

Meta-ticket: Use the SymPy assumptions facility #31958

Open
mkoeppe opened this issue Jun 11, 2021 · 5 comments
Open

Meta-ticket: Use the SymPy assumptions facility #31958

mkoeppe opened this issue Jun 11, 2021 · 5 comments

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Jun 11, 2021

SymPy has a clean and general design for assumptions.
https://docs.sympy.org/latest/modules/assumptions/index.html

We should connect to it. Based on #31926 (#24171, #31931, #31938), we should be able to express everything in it that Sage's assumptions can do, so perhaps we can replace what we have in Sage completely by SymPy.

Tickets:

Symptoms:

CC: @egourgoulhon

Component: symbolics

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

@mkoeppe mkoeppe added this to the sage-9.4 milestone Jun 11, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Aug 30, 2021

comment:6

One issue with using sympy for the implementation is that loading it would add quite a bit to the start up time:

$ time ./sage -c quit

real	0m1.620s
user	0m1.249s
sys	0m0.450s
$ time ./sage -c "import sympy"

real	0m1.980s
user	0m1.570s
sys	0m0.514s

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 14, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 1, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 7, 2023
@williamstein
Copy link
Contributor

Here is a closely related example to #27998, though it is a bit worse, since instead of an error, you get the wrong answer.

var("x,y")
assume(x>0)
assume(y>0)
print("x^2=1 and y^2=1")
show(solve([x^2==1, y^2==1], x, y))

OUTPUT:

(x, y)
x^2=1 and y^2=1
[[x == 1, y == 1], [x == -1, y == 1], [x == 1, y == -1], [x == -1, y == -1]]

Then answer should be [[x == 1, y == 1]].

Note that sympy of course works perfectly fine for this problem, so this is a vote for this ticket:

import sympy
x = sympy.Symbol('x', positive=True)
y = sympy.Symbol('y', positive=True)
sympy.solve([x^2-1, y^2-1], x, y)

OUTPUT: 
[(1, 1)]

More details: https://cocalc.com/wstein/support/assumptions/files/bug.sagews

@mkoeppe mkoeppe removed this from the sage-10.0 milestone Mar 16, 2023
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