Hi Robert, >> One of the main problem here is that PEP 335 "Overloadable Boolean >> Operators" >> is not yet accepted. So right now there is no way to implement a three >> state >> logic, is there one ? If not, Is there a way we can push on python dev to >> have >> this PEP accepted ? > > It's unclear how this would work with the current short-circuit semantics > of and and or.
Here are the truth table in MuPAD, all computed in short-circuit semantics. >> bool3 := [FALSE, UNKNOWN, TRUE]; >> print ([(a and b) $ b in bool3]) $ a in bool3 [FALSE, FALSE, FALSE] [FALSE, UNKNOWN, UNKNOWN] [FALSE, UNKNOWN, TRUE] >> print ([(a or b) $ b in bool3]) $ a in bool3 [FALSE, UNKNOWN, TRUE] [UNKNOWN, UNKNOWN, TRUE] [TRUE, TRUE, TRUE] To have a precise short-circuit semantic. Consider that False < Unknown < True and define "and" = "min" and "or" = "max". The natural short-circuit evaluation for min and max works as expected. in preudocode: if a is False: return False else if a <= b: return a else: return b in preudocode: if a is True : return True else if a >= b: return a else: return b > However, if Unknown was returned such that bool(Unknown) was False, then the > information would be preserved at least a little bit longer. This could indeed be a fallback. Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org