On 31.03.2012 15:41, Sergiu Ivanov wrote:
On Fri, Mar 30, 2012 at 11:52 PM, Aaron Meurer<[email protected]>  wrote:

In what way can it not represent any ring?

Sorry, I chose the wrong word.

Indeed the class Ring can represent any ring, just as a Domain (the
parent class of Ring) can represent any algebraic domain.

However, the Ring class knows nothing of the ring operations.  Instead
(at least in my reading), it relies on the objects to implement the
corresponding operations.  This creates an algebraically weird bound
between elements and the ring operations, while oddly leaving the ring
aside.  Therefore, if I define a type of elements MyElement, it can
only be a member of one ring.  Moreover, I cannot define a ring and an
abelian group (with a group operation different from the addition in
the ring) over a set of MyElements, because the operations are bound
to MyElements instead of being tied with the ring or the group.


[Sorry to make this become the sort of "tiring discussion" I was warning of...]

I agree that, mathematically, the operations should be part of the ring structure, and not of the elements. But in practice, that is not terribly useful. What is easier to read / better OOP practice: ring.multiply(poly1, poly2) or poly1*poly2?

In particular it is easy to create ligthweight wrapper classes around existing classes if you ever wish to perform other operations than the usual ones (see for example class ModularInteger).

I should say that I find designing this kind of stuff highly confusing. Since all the "real stuff" is in the elements, why bother with a ring class at all? It turns out (every time I try to think about it) that its most important role is *conversion*: e.g. creating the correct representation of "1".

There is yet a different aspect to this problem.  When working with
algebraic structures we are certainly willing to know some stuff about
the operations, like whether they are commutative, associative, etc.
With the current design of Ring in polys, one will again have to
include all this metadata into the type of the elements of the ring,
which is obviously very bad.

I do understand that the design of Ring has solid background and I in
no way attempt to say that it has been implemented wrong.  However, I
seriously doubt that this class can actually serve as a good
representation of an abstract ring.

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