Hi Vincent, sorry for my previous post, as you discussed the example already.
On 2016-11-15, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > There is still a semantic problem to solve the following > > sage: Unknown or False > False No. Unknown or False is Unknown. The shortcuts would be False and x = False True and x = x True or x = True False or x = x Unfortunately I don't see a shortcut when the first item is Unknown, for "and" resp. "or". But there is a further shortcut for xor: Unknown xor x = Unknown The shortcut False xor x = x follows from the and/or shortcuts, hence, is not new. I believe "True xor x = not x" is not a shortcut, since the result is obtained from an *operation* applied to the second argument. Hence, implementing a shortcut for __and__ determines all shortcuts needed for bools, but you need to implement a shortcut in yet another method (namely __xor__) to determine further shortcuts needed for trools. > Python is using __nonzero__ to deal with these or/and/not operators. > This method __nonzero__ implicitly defines the conversion to booleans. > And Python sets > > x or y := x if bool(x) is True and y otherwise Is it not calling x.__or__(y), which could be overridden? > It might be changed to > > x or y := > x if trool(x) is True > y if trool(x) is False > x if trool(x) is Unknown and trool(y) is not True > y if trool(x) is Unknown and trool(y) is True > > I guess it is what you called "shortcut". In this form it is a max > operation with True -> 1, Unknown -> 1/2, False -> 0. I guess a shortcut means: If the first argument is suitable, then the value of the expression either is a constant (True/False/Unknown) or is equal to the second argument. If you need to evaluate trool(y) or not(y) to evaluate the expression, then it is not a shortcut, IMHO. Cheers, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.