Пример #1
0
 def convert_to_bin_operands(expr: Expression) -> Expression:
     expr_type = type(expr)
     if expr_type is Symbol:
         return expr
     elif expr_type is NOT:
         return NOT(convert_to_bin_operands(expr.args[0]))
     elif len(expr.args) == 2:
         return expr_type(convert_to_bin_operands(expr.args[0]),
                          convert_to_bin_operands(expr.args[1]))
     else:
         return expr_type(
             convert_to_bin_operands(expr.args[0]),
             convert_to_bin_operands(expr_type(*expr.args[1:])))
def test_NOT_inverts_TRUE():
    assert NOT(TRUE) == FALSE
Пример #3
0
 def expr_negation(expr: Expression) -> Expression:
     if isinstance(expr, NOT):
         return expr.args[0]
     return NOT(expr)