Esempio n. 1
0
 def eval(cls, arg):
     if isinstance(arg, Number) or arg in (True, False):
         return false if arg else true
     if arg.is_Not:
         return arg.args[0]
     # Simplify Relational objects.
     if isinstance(arg, C.Equality):
         return C.Unequality(*arg.args)
     if isinstance(arg, C.Unequality):
         return C.Equality(*arg.args)
     if isinstance(arg, C.StrictLessThan):
         return C.GreaterThan(*arg.args)
     if isinstance(arg, C.StrictGreaterThan):
         return C.LessThan(*arg.args)
     if isinstance(arg, C.LessThan):
         return C.StrictGreaterThan(*arg.args)
     if isinstance(arg, C.GreaterThan):
         return C.StrictLessThan(*arg.args)
Esempio n. 2
0
 def eval(cls, arg):
     if isinstance(arg, Number) or arg in (True, False):
         return false if arg else true
     # apply De Morgan Rules
     if arg.func is And:
         return Or(*[Not(a) for a in arg.args])
     if arg.func is Or:
         return And(*[Not(a) for a in arg.args])
     if arg.func is Not:
         return arg.args[0]
     # Simplify Relational objects.
     if isinstance(arg, C.Equality):
         return C.Unequality(*arg.args)
     if isinstance(arg, C.Unequality):
         return C.Equality(*arg.args)
     if isinstance(arg, C.StrictLessThan):
         return C.GreaterThan(*arg.args)
     if isinstance(arg, C.StrictGreaterThan):
         return C.LessThan(*arg.args)
     if isinstance(arg, C.LessThan):
         return C.StrictGreaterThan(*arg.args)
     if isinstance(arg, C.GreaterThan):
         return C.StrictLessThan(*arg.args)