Is it reasoanble to have SR.var() inject an assumption into assumptions()?

69 views
Skip to first unread message

Stan

unread,
Jun 14, 2017, 12:14:39 PM6/14/17
to sage-devel
As mentioned in https://trac.sagemath.org/ticket/23138, the assume() command takes a lot of time, which is very annoying when defining a lot of variables using var() including a domain information. var('x', domain='real') passes the domain information to ginac and adds it as an assumption to assumptions(), so that it can be considered by maxima. However, since assumptions() can both store much more information than just the domain information, and on the other hand all the information is lost when someone executes forget(), I am wondering if this code should not be removed from src/sage/symbolic/ring.pyx, Lines 1017-1027, in favour of a more persistent domains() database, which could be injected into assumptions() by the user if needed. Any thoughts on this?

Cheers
Stan

Ralf Stephan

unread,
Jun 15, 2017, 2:17:48 AM6/15/17
to sage-devel
The "more persistent domains() database" exists already in part as GiNaC/Pynac info flags that are set in parallel to Maxima's assumptions. They can be queried with ex.is_real() etc...What is not saved in Pynac are less elementary assumptions like x>1, y+z==pi. Now instead of caching all assumptions in a database (either Python or C++) and sending to Maxima on demand in bulk, another possibility could be, as you say, to just remove the assume calls on variable creation because they are all elementary assumptions. Then when Maxima needs them for integration, solving etc take the information from Pynac and do assumes for just those variables that are needed. Am I missing something?

Stan Schymanski

unread,
Jun 20, 2017, 10:04:49 AM6/20/17
to sage-...@googlegroups.com

Actually, ex.is_real() queries the assumptions() data base, not the GiNaC/Pynac info flags. Example:

var('test', domain='real')
print test.is_real()
forget()
print test.is_real()

Returns:
True
False

I think your proposal below would be great. Remove assume() from variable creation, but get the information from Pynac and convert to assumptions when calling maxima.
--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/-A8ZzSKvYsA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

-- 
________________________________________

Stan Schymanski
Riedstrasse 60
8604 Volketswil
Schweiz

Ph: +41 (0)43 5420487
_________________________________________

Ralf Stephan

unread,
Jun 20, 2017, 1:06:07 PM6/20/17
to sage-...@googlegroups.com

Ralf Stephan

unread,
Jun 20, 2017, 1:10:17 PM6/20/17
to sage-devel
In other words no, ex.is_real() does query only the Pynac database.

Stan Schymanski

unread,
Jun 20, 2017, 5:30:06 PM6/20/17
to sage-...@googlegroups.com

Wow, I must have misunderstood, thanks! I just checked https://github.com/sagemath/sage/blob/master/src/sage/symbolic/assumptions.py and I find only a few references to Pynac, exclusively in the documentation string. Acceptable features are all taken from maxima: `maxima('features')`

So you are saying that the assumptions() are used by both Pynac and maxima? You're right, there is also
https://github.com/sagemath/sage/blob/master/src/sage/symbolic/expression.pyx#L1786

Since assume() affects both pynac and maxima evaluations, I guess that taking it out of `var()` is not a good idea. How else could we make `var(..., domain=...)` faster?

Ralf Stephan

unread,
Jun 21, 2017, 4:07:11 AM6/21/17
to sage-devel
See the branch in https://trac.sagemath.org/ticket/23138 and discuss there.
Reply all
Reply to author
Forward
0 new messages