Boolean Equivalent
sympy.logic.boolalg.Equivalent(*args)
Refers to an Equivalence relation. If x and y are both True or False, Equivalent(x, y) is True. If all of the arguments are logically equivalent, True is returned. Otherwise, False is returned.
Python3
from sympy.abc import x, y, z from sympy.logic.boolalg import Equivalent, And, Or print (Equivalent(x, y, z)) # true != false so it returns false print (Equivalent( True , False )) # True == True so it returns true print (Equivalent( True , True )) # False == False so it returns true print (Equivalent( False , False )) # False !=True so it returns false print (Equivalent( False , True )) # true ==true == true so it returns true print (Equivalent( True , Or( True , False ), And( True , True ))) |
Output:
Equivalent(x, y, z) False True True False True
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.