sync elementary assumptions on expressions with Sage #81
Comments
The SymPy assumptions system is still in a state of flux. You should take good ideas from it, but don't assume that it is, in its current state, well-designed or even what we would like to have. I'm definitely convinced in the approach I take in sympy/sympy#2508 in terms of its deductive power, but the performance is such that I still think some of the implementation details could be improved. I'm fairly convinced that a layered approach is the right way to go. Full featured algorithms should be balanced against faster but less capable algorithms. This is something we are still trying to fully figure out how to do right in SymPy. I suspect that it's probably good to expose this to the user somehow. In this thread, I talk about distinguishing between mathematical and structural algorithms. You can get away with Probably having separate assumptions "entry points" is smart as well. Sometimes, when you write, say Regarding the notion of making a distinction between "known undecidable" and "unknown", for logical purposes, the two are identical. I can't imagine any algorithm that requires knowledge of which is the case for a None output to be tractable for any practical purposes. It is possible, I believe, to guess an answer about this, although some additional algorithms are needed which "know" more about the assumptions themselves. What you need is something that will find a model for the given query and its negation. I don't know of any smart algorithms to do this beyond random value checking, perhaps using the SAT solver model as a guide. This may just be a question of API. For instance, say f(x) is some expression and suppose that |
Have you had a look at SMT solvers? They have all the layers, from boolean to linear to nonlinear and mixed. As to exposing the functionality to users I found a Python interface to these solvers, So, while this answers how to find a model for a given query (copy the methods developed by SMT solvers), the question remains how to include the SMT solver functionality in the CAS. In Sage it's probably easier because we are not restricted to Python, but we won't simply attach yet another package either because lot of functionality needed already is there (SAT, Gröbner bases, LP, CAD) or at least optionally installable, no need to duplicate it. It remains to define the restricted but fast interface for internal use. I'm not clear on this at the moment. |
I haven't had time to think too hard about it yet, but I definitely think an SMT solver would make certain things easier. |
I just read the Abraham slides. I think this is definitely the way forward. The only thing is we have to make basic deductions very fast (like |
For fast basic deductions we have in GiNaC/Pynac class-wide |
That's a bad idea. If you do that, then you can't do any kind of non-trivial logical deductions. Remember that You have to treat true and false and facts and their negations on equal footing. Either can be useful for deducting things, even deducting things in the positive (because facts themselves can have negations in them). |
You would be right, but this is really a quite basic implementation. Really only the
|
Separating out "is this true" from "is this false" can potentially be a performance optimization, although I'm personally skeptical about it, one, because you in general need to know both anyway to make deductions, and two, because it introduces some major gotchas. |
Ignoring Sage's
assume
statements is a bug.The Sage side is http://trac.sagemath.org/ticket/19035
As to assumptions without Maxima, try to leave most of the handling in Sage, just copy to Pynac and use. Although this concerns Sage only(?), let's have a look at what SymPy does beforehand.
sympy/sympy#2508
https://github.com/sympy/sympy/wiki/Assumptions
In principle the full spectrum of hypothesis-testing methods ranges from simple flag/binary result (like in GiNaC) to a full blown automatic proof system with Yes/No/undecidable/unknown, trading speed for correctness/knowledge. Also, there seems no way to "just have a fast system that does not know much, but knows when it knows nothing", i.e. a fast system without false negatives.
SymPy's new assumption code uses SAT algorithms and a knowledge base with a facade decoupled from the objects in question; it still hard-coded meta facts like Pynac; it gives back
True
/False
/None
; their Python implementation reportedly is already too slow even before they will include relation handling. Also (from shiprabanga's comment from Apr 5 2014) the newest implementation does not distinguish betweenknown undecidable
andunknown
, both areNone
.The additional constraints to any effort in Pynac are:
symbolic/assumptions.py
); both systems have to coexist until Maxima is completely removed, i.e. never, because it will certainly be kept as alternativeOn the up side, with respect to SymPy the API is fixed (
symbolic/assumptions.py
), there are no aspirations to present reasoning capablities to the user, apart from theExpression.is_...
methods,bool(relation)
and the assumption consistency check. This way the (slow) buildup of constraints and the consistency check on addition of assumptions is confined to Sage'sassume()
command while Pynac's finite questioning API should allow for efficient caching of results. Finally the user won't expectbool(rel)
to be super fast (it's not atm). This means the consistency check bears the burden of producing useful facts for efficient later questioning. I'm completely speculating here. However, it seems safe to assume we can transfer assumptions from Sage in a useful way as a first step.The text was updated successfully, but these errors were encountered: