I'm interested in the python library, which allows symbolic manipulation, where the characters and can be unknown of arbitrary type.
This is the code I want to write:
>>> myexpression = symbol("foo") == "bar" >>> print myexpression foo == "bar" >>> print myexpression(foo="quux") False >>> myexpression.or_(True) True
Or some approximate approximation of this. Actually it doesnβt even need to be smart, I would be happy enough to name a lot of additional introspection methods to get something like the above (for example, even if the logical tautology is not directly simplified)
My first instinct was to look sympy , but the library seems to make a strong assumption that symbolic variables should be numbers; and I would like to at least work with sequences and sets:
>>> myexpression = sympy.Eq(sympy.Symbol("foo"), 5) >>> myexpression foo == 5 >>> myexpression = sympy.Eq(sympy.Symbol("foo"), "bar") Traceback (most recent call last): ... sympy.core.sympify.SympifyError: SympifyError: 'bar'
Is there a way to make sympy understand non-numeric variables or another library that can do such things?
python sympy
SingleNegationElimination
source share