+1. I like your thoughts for extensions to the assumptions system. Aaron Meurer
On Tue, Jun 3, 2014 at 10:50 AM, F. B. <franz.bona...@gmail.com> wrote: > More than the logic contained in PRESS, I would get inspiration for the > programming style. > > The current sympy solve has a lot of manual dispatching through "IF" and > recursion. The code is hard to read, and you also need a debugger to > understand what happens to expressions. I would suggest to either use a > logical style (like PROLOG rules, there is the logpy project which is trying > to implement that paradigm in Python), or pattern dispatch (as in Wolfram > Mathematica). > > An example of a possible implementation of a solver using pattern dispatch: > > @patterndispatch(cos(A), x, assumptions=Q.has(A, x) & Q.instanceof(x, > Symbol)) > def solve(f, x): > return # solutions to cos(A) == 0, call solve(A - zeros of cos(), x) > > @patterndispatch(cos(A)+B, x, assumptions=Q.has(A, x) & not Q.has(B, x) & > Q.instanceof(x, Symbol) > def solve(f, x): > # code > > This would make the code a lot more readable, solutions would be mapped to > very specific cases, and there would no need to manually create lots of IFs, > because the @patterndispatch decorator would store and use the dispatching > information properly (e.g. in a directed acyclic graph). This was the style > pursued by Wolfram Mathematica and it proved very successful. > > Alternatively, the logic programming style of PRESS could be implemented > into SymPy by creating a dependence to LogPy. > > I really believe that the code should become more readable. I would favour > the introduction of a pattern dispatching decorator with joint assumptions. > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@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/3ff4d2f1-7040-4b20-939e-e0836570ddb3%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@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/CAKgW%3D6L6Wo%3D2WUuAeyqbZsz_3nCvZ%3D8mMxbQT5QWg%2BGX9ay7hQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.