There is one important performance enhancement that is not implemented
in rewrite rules, namely autoevaluation. However here I am considering
the "canonicalization" work done by the autoevaluation and I will
imagine that performance is not an issue.

I think that while the state of the code that implements it in sympy
is bad, the notion itself is sufficiently well abstracted: in the
core, autoevaluation is all that is done by the constructor of an
object. This will be my definition of autoevaluation for the rest of
the post.

My question is, is it a good idea to add a very basic rule like
call_constructor that traverses the raw tree created by Basic.__new__
and that calls type(node)(args) in order to force the autoevaluation?

My knee-jerk reaction is that this is a bad idea and that
canonicalization done by the rules should have nothing to do with
autoevaluation, unlike what the core does. Basically rules should not
support the notion of autoevaluation. Let's leave the performance
issues for later.

However this brings another issue, which made me write this. If you
agree with me on the previous points, how will you implement the
following:

my_simplification_function() - a function that looks in the tree and
if it finds a Trace(very_special_matrix_a**2*stuff) returns
scalar*Trace(stuff).

points to consider:

1. I want to use only the following custom rule:
very_special_matrix_a**2 -> scalar*Identity

2. Trace will not be autoevaluated, so my rule will not factor out the
scalar out of the trace and will not remove the identity. How do I
implement a rule that does this. Doing it in my rules is not
appropriate as this should have already been implemented for the Trace
and MatMul classes. The question is, how to get a general rule that
does those already implemented canonicalization. It is basically what
autoevaluation does. How do I get the object specific canonicalization
rules?

3. How do I add the my_simplification_function to the simplify
function. _eval_simplify() does not work for this, because the objects
that need to be simplified are inside a very generic container. What
about creating  a full_simplify function that first lists all nodes,
ask the nodes whether they want to supply new simplification functions
and then call
simplify(chain(*newly_supplied_rules)(expr))


Most burning for me is issue number 2.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to