On Thu, Mar 22, 2012 at 11:08 PM, Joachim Durchholz <j...@durchholz.org> wrote: > Am 20.03.2012 15:24, schrieb Sergiu Ivanov: > >> I'm trying to say >> >> that I think that a group should be defined as an algebraic structure >> with a single operation which has a number of properties; thus we may >> define a class UniversalAlgebra, then derive Semigroup from it, then >> Monoid, then Group. This would be similar to defining log as a >> subclass of Function. > > > I have seen this kind of approach work excellently in Eiffel.
Excellent news :-) I'm glad to hear it's not only me who thinks this way is among the appropriate ways. > Unfortunately, it will run into trouble as soon as we need to inherit the > same algebraic data structure in two different roles. > For a handy example, Group cannot simply inherit from Monoid, since it > builds on two different monoids, the additive one (operator: +; neutral > element: Zero) and the multiplicative one (operator: *; neutral element: > One). > > This can be circumvented: don't make Group inherit from Monoid twice, make > Group contain two Monoid members. Yes, sounds good to me. (By the way, we are probably talking about rings, because groups have only one operation; this doesn't matter too much though, everyone has got the idea, I think.) > The question now is how to deal with those cases that could indeed be done > via inheritance (Monoid and Semigroup). [...] > Alternative 2: Make it a member, just for uniformity. Lowers the entry > barrier: new coders won't have to learn different coding patterns depending > on ancestry. This option sounds like the best choice to me. Do you envision much trouble with this approach? To me, it looks rather straightforward. Sergiu -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.