Initial implementation of the query system

Category: General, sympy, Tecnologí­a

I sent some patches to sympy-patches with an initial implementation of the query system. You can check it out by pulling from my branch: git pull http://fseoane.net/git/sympy.git master into your sympy repo. Some examples of what you can do (sample isympy session): In [1]: query(x, positive=True) Returns None, as we do not know whether x is positive or not. `` In [2]: query(abs(x), positive=True) Out[2]: True`` because abs() is always positive. Because exp() is always positive, the following should also be True: `` In [3]: query(exp(x), positive=True)`` but why then does it return None ?. Well, it simply is not True that exp() is always positive, it is always positive for real values, but SymPy does not assume that x is real, so you would have to specify that. This is now done with the keyword assumptions: `` In [5]: query(exp(x), positive=True, assumptions=Assume(x, real=True)) Out[5]: True`` As you can see, now assumptions are independent objects and are not tied to symbols any more. For more examples, see the file sympy/query/tests/test_query.py still in the TODO list: - support for global assumptions - solve more complex implications, like query(x, positive=True, assumptions=Assume(x, even=True)) where it should build the chain of implications even => integer => rational => real. This chain of implications currently stops at rational for efficiency reasons, because the number of facts grows in each step which makes the number of possible paths grow exponentially.