from sympy import * from sympy.logic.boolalg import Not a, b = symbols('a b') expr = And(a, b) neg_expr = Not(expr)
expr1 = And(a, b) expr2 = And(Not(a), Not(b))
expr1 = Or(a, b) expr2 = Or(Not(a), Not(b))
expr1 = Implies(a, b) expr2 = Implies(And(a, b), c)
expr1 = Equivalent(a, b) expr2 = Equivalent(And(a, Not(b)), Not(a))Overall, the sympy.logic.boolalg package is a powerful tool for performing boolean algebraic operations in Python.