On Sat, Jun 20, 2009 at 2:30 PM, Fabian Pedregosa<[email protected]> wrote: > > Hi Ronan! > > > Ronan Lamy wrote: >> I've noticed that the boolean functions Or and And in the new >> sympy.logic subpackage are defined to raise ValueError when called >> with 0 or 1 argument. However, there are perfectly sound mathematical >> definitions for those cases: >> Or() -> False >> Or(A) -> A >> And() -> True >> And(A) -> A >> >> Using these would allow one to write things like: >> assert solve(Eq(poly, 0)) == Or(*[Eq(r, 0) for r in roots(poly)]) >> >> and I don't see any drawback. What's the reason for the current >> choice? > > The mathematical definition of And that I used defined it as a function > B^2 --> B, so I did not know what should be expected if called with 0 or > 1 arguments. However, we can change that if it can improve the module. > > Just tell me, what is the mathematical reason behind Or() -> False, > And() -> True ?
And, Or should accept any number of arguments. It means that for any lists A and B, op(*(A+B)) = op(op(*A), op(*B)), which is very convenient. Also Xor satisfies this property (it gives the parity) and should be defined with Xor() = False, Xor(x) = x. Fredrik --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
