Am 01.09.2014 um 13:28 schrieb F. B.:
SymPy's default pattern matcher is not a structural one, i.e. it tries to
match according to some mathematical rules. A structural pattern matcher
would instead just match the structure of the expression-tree.

While it is necessary to have some mathematical awareness such as, give the
wild *w*:

    - associativity awareness (i.e. f(a, b, c) = f(a, f(b, c)) and similar):
    (a+b+c).match(a+w) ==> {w: b+c}
    - commutativity awareness:
    (a+b).match(w+a) ==> {w: b}
    - one-identity awareness (f is one-identical if f(x) = x for any x):
    x.match(Add(w, evaluate=False)) ==> {w: x}

You can inject math awareness into a structural pattern matcher by letting the structure declare its mathematical properties.

E.g. a function could have a one_identity_aware attribute, and the structural pattern matcher could have a primitive that inspects such attributes.

(I hope that was understandable.)

--
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/5404A4C7.9010507%40durchholz.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to