Hum, interesting indeed. In the hypothetical case we accept python's True/False/None as valid atoms, I think the following contract could work - at least in the logic module:
- *No non-atomic expression can internally embed True, False or None*. The only expressions containing True, False None that sympy can return are True, False, None. This does not mean that the user can't construct expressions containing these, they just get simplified at construction time, which is always feasible. Obviously that does not solve the True >> True problem - but hey, whatever we do, if True and False are the base Python objects as they should probably be(?), this is inevitable, so I'm fine with that. On Saturday, July 28, 2012 11:30:12 AM UTC-7, Ronan Lamy wrote: > > Le samedi 28 juillet 2012 à 10:29 -0700, Alex a écrit : > > This does not change the problem: LatticeOp and AssocOp are > > inconsistent. Currently the logic module understands > > and handles boolean values. Either sympy needs to consistently > > consider booleans as valid, first-class atoms, > > either we can encapsulate these in sympy objects (kind of distasteful > > in my opinion). > > I agree about the need for consistency. However, sticking non-sympy > objects inside sympy objects is problematic (that's a long-running > debate) and True has the wrong interface anyway: > In [1]: True >> True > Out[1]: 0 > > So, encapsulating bools is the way to go, but it's hard, because there > is a lot of code that relies on them not being encapsulated. > > > Btw, changing _sympify to sympify does not cause any issue as far as > > testing is concerned, so test cases indicating wanted and unwanted > > behaviors should be added. Currently, True - sympify(1) == 0 .... > > There's nothing we can do about that, the interpreter calls int(S(1)), > which returns 1, an instance of 'int', and then computes True - 1. > On the other hand: > In [7]: True - x > --------------------------------------------------------------------------- > > TypeError Traceback (most recent call > last) > /home/ronan/dev/sympy/<ipython-input-7-58bde0218d6d> in <module>() > ----> 1 True - x > > TypeError: unsupported operand type(s) for -: 'bool' and 'Symbol' > > > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/SizOi_6epFQJ. 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.
