On Friday, July 4, 2014 4:12:25 PM UTC, Matthew wrote: > > Only semi-related, but here is a small pattern matching project. It's > strictly for non-associative operators and so not appropriate for SymPy. > It does function decently though > > https://github.com/mrocklin/unification >
By the way, the associativity may be handled by flattening both the expression and the pattern before starting the matching algorithm, and the applying the conglomeration (that is, canonicalize both expression and pattern). Mathematica has the attribute Flat to declare a node flat, so that the flattening happens upon construction and all of the node's arguments are considered associative wrt that node. The same for the attribute Orderless, which considers all of the nodes to be commutative. I am wondering whether we should consider the associative property as associated to the node/operator (as Mathematica does), or whether it should be assigned to the tuple (operator, type of argument). I think that it's OK to have a support for mixed commutativity of arguments (which Mathematica does not natively support), but I think that associativity should be a property of the node (it would become too garbled otherwise). Consider that the commutativity/non-commutativity can be further generalized by associating a subgroup of the symmetric group to the node, specifying more complex commutativity properties. SymPy already has support for canonicalization of such cases, added by Pernici two years ago. Unfortunately pattern matching would become even more garbled if this were to be included. -- 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/74796501-98d7-4840-a6b1-183ee9bedb2b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.