Am 03.09.2014 um 02:07 schrieb Richard Fateman:
Sure. Unlikely to be easy to do by simply hacking on trees. Here's a
classic pattern:
a*x^2+b*x+c. a,b,c are pattern variables. x, in this context, is a
symbolic constant.
You might like to also impose a,b,c free of x, and a is non-zero, to
complete the pattern "quadratic in x"
match this against the expression
(45*x+10)^2/5 +q*x+pi
Yes this can be done, but can you do it by placing attributes on + and *?
Easily, actually.
Just store the entire pattern, including preconditions, in the attribute
of the top-level node (+ in this case).
Actually Python makes this relatively easy since reifying functions is
fussless and reifying expressions as lambdas is lightweight (can't beat
Haskell or Lisp in that area, of course).
This would probably also make it easier to check for pattern overlap.
I suppose there is also the question of whether you want this to match or
not.
That's a strategy question: Which of multiple applicable rules do we
want to apply?
RUBI requires that at most one rule be applicable at a time (i.e. no
pattern overlap), so strategy is encoded in the preconditions of the
rules and it's a non-issue.
--
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 [email protected].
To post to this group, send email to [email protected].
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/5406B278.1030604%40durchholz.org.
For more options, visit https://groups.google.com/d/optout.