For anyone looking, the url is now
https://github.com/sympy/sympy/wiki/GSOC-2014-Application-Shipra-Banga-Building-the-New-Assumptions-Module.
Here are my comments on the proposal:
- You seem to be focusing pretty heavily on adding new facts to the
system. But I think this is actually a minor point. It will take a
considerable effort, to be sure, because there are quite a few facts,
but there are real issues to be considered which you haven't
addressed, like:
- How do you plan to make the system scale? You don't really make it
clear, but you are planning to extend the work I began at
https://github.com/sympy/sympy/pull/2508. This system already has
performance issues, and there are only a handful of facts implemented.
The old assumptions system has its limitations, but its actually quite
fast. This is clear from the fact that it is used everywhere in the
core. Take this very simple query:
Old assumptions:
In [1]: time Symbol('x', positive=False, real=True).is_negative
CPU times: user 160 µs, sys: 9 µs, total: 169 µs
Wall time: 176 µs
New assumptions:
In [5]: time ask(Q.negative(x), ~Q.positive(x) & Q.real(x))
CPU times: user 42.1 ms, sys: 4.01 ms, total: 46.1 ms
Wall time: 47.7 ms
Newask (my branch):
In [4]: time newask(Q.negative(x), ~Q.positive(x) & Q.real(x))
CPU times: user 86.9 ms, sys: 1.96 ms, total: 88.9 ms
Wall time: 87.8 ms
The new assumptions take two orders of magnitude longer than the old
assumptions, and my branch takes twice as long as the new assumptions.
If you look at Tom's proposal from last year, there's a reason that he
spends a lot of time talking about things like caching.
- Regarding the final switch (which, granted, you may not even get to
by the end of the summer), I think you understate its difficulty. I
give you some credit here: no one can really appreciate how difficult
this is until they attempt swapping out the assumptions system. I
didn't get it myself until I did
https://github.com/sympy/sympy/pull/2210. The assumptions are really
used by *everything*. That's the entire code-base of SymPy. You can
get a good ways by swapping out the syntax, so that the current
is_positive and so on calls the new assumptions, but then you have to
make sure that all the facts are either identical to the way they were
before, or places where they differ are changed (like with the
is_imaginary thing).
You also don't really discuss how you are going to handle the existing
old assumptions code. Does it make sense to keep around things like
the current implementation of pi.is_positive (it's just set explicitly
on the class)? I currently "use" the old assumptions for some classes
in my branch at
https://github.com/sympy/sympy/pull/2508/files#diff-bb2c25daed16ce71d13be11d912725edR217,
because this is more efficent than the new assumptions way, which just
calls evalf().
- I also doubt you will be able to get to this in the summer, but
another dream of the new assumptions is the ability to represent
relational assumptions, like x > 2. You should think about how to
implement this sort of thing.
In the end, don't consider the implementation at
https://github.com/sympy/sympy/pull/2508/ to be the truth handed down
from God on how the assumptions should be implemented. It's just
something that I hacked together. The earlier iterations were
definitely less elegant than what is there now, but I don't claim that
it can't be done even better, and I really don't claim that it should
be done differently in order to obtain scalability (which I think is
the most serious problem that needs to be solved in that branch).
Now, going back to adding facts to the system, this is still
important. There are some facts that need to be thought about a little
harder. For instance, consider the fact: "if all terms in an addition
are integers, the addition is even iff an even number of the terms are
odd". We might represent this symbolically as (Add,
Implies(AllArgs(Q.integer, Equivalent(Q.even,
EvenNumberOfArgs(Q.odd))))). The problem here is the EvenNumberOfArgs
part. To represent this, you need to use Xor, which requires an
exponential number of clauses. Are there tricks we can use (Tseitin
maybe) to get around this? Should we just put a default limitation on
the number of args that can be used? Or should we look at somehow
shipping this sort of thing off to a better suited solver than the SAT
solver?
Also think about how you would represent the following fact, from
https://github.com/sympy/sympy/pull/2952:
exp(x) is real if the imaginary part of x is a multiple of pi*I
And another interesting one. How would you make ask(Q.negative(x - 3),
Q.prime(x) & Q.even(x)) work?
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sympy+un...@googlegroups.com.
> To post to this group, send email to
sy...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/sympy.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/sympy/8a6d5105-7a67-400f-b5f7-dd8e41739a28%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.