On Sun, Oct 7, 2012 at 12:52 AM, Matthew Rocklin <[email protected]> wrote:
>
> I want to make the following more specific
>
>> Most classes like Add, MatAdd, etc... do serve two purposes as you say. My
>> names for these are as follows
>> Container -- they act as a typed tuple and contain args
>> Canonicalizer -- they take in different inputs like "x + y" and "y + x"
>> and produce a normalized form
>>
>> Rules do strip out a fair amount of canonicalization and leave the classes
>> as mostly just containers. You could use rules for everything and make the
>> classes just containers. This is a question of programming style though, I
>> don't think that it's objectively better or worse. If you wanted to do this
>> I think you would just make a new project. SymPy has its own thing going on
>> and it works pretty well. I've made a project that was based on just rules
>> for matrix expressions. It was neat, I had fun, but I don't expect the world
>> to suddenly decide that rules are how we should do things. Balance is
>> healthy.
>
> On creation our classes create a new node in our tree and hook up some
> children
> newnode = Add(*args)
> They also simplify and transform the args. So far I've used rules to pull
> out the simplification part. I call this canonicalize above.

Yes, that seems clear.

> Our classes serve a third purpose that I didn't mention before. They also
> have methods like MatMul._eval_transpose. If we wanted to we could swap
> these methods out for rules as well. This is what my silly prototype code
> here does
> https://github.com/mrocklin/matrix-algebra/blob/master/src/algebra.maude#L41

I've never heard of Maude before, thanks for providing the example!

> If we do this then classes are stripped down to just act as typed tuples in
> our graph and nothing more. This is a really interesting way to program.
> It's not clear that this is appropriate for SymPy though.

Well, this sounds like an aggressive, but still natural expansion of
rewriting rules.  It also gets similar to declarative programming a
great deal.  However, it really feels that it's not going to fit
nicely with SymPy because of the paradigm difference (OO vs. a
declarative paradigm).

> So lets define the current functionality of classes as Container +
> Canonicalizer + Method-collection. I think that it would be awesome if
> canonicalization was handled by rules. This is what I've done in matrix
> expressions. I haven't yet touched the methods yet though. I'm not sure what
> my plans are for them.

I see.  Handling canonicalisation in rules sounds like a very nice and
elegant solution.

Sergiu

-- 
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