Boolean Nor
sympy.logic.boolalg.Nor(*args)
Nor is a conjunction of Not and Or. Nor = Not+Or. It examines each argument in turn, returning False if any of them are True and True if all of them are False. If any argument is True, returns False. If all arguments are False, this function returns True.
Python3
# import packages from sympy.abc import x, y from sympy.logic.boolalg import Nor nor_formula = ~(x | y) print (nor_formula) print (Nor(x, y)) # ~( True | False) == False print (Nor( True , False )) # ~(True | True) == False print (Nor( True , True )) # ~(False | False) == True print (Nor( False , False )) # ~(False | True) == False print (Nor( False , True )) |
Output:
~(x | y) ~(x | y) False False True False
What are the Logical Expressions in Sympy?
SymPy is a symbolic mathematics Python package. Its goal is to develop into a completely featured computer algebra system while keeping the code as basic as possible to make it understandable and extendable. The package is entirely written in python language. Logical expressions in sympy are expressed by using boolean functions. sympy.basic.booleanarg module of sympy contains boolean functions.
The common Python operators & (And), | (Or), and ~ (Not) can be used to create Boolean expressions. >> and can also be used to create implications. other boolean operations or gates are NAND, NOR, XOR, etc.