how to change logic symbols
I have (x0 + x1) and want to make (x0 ^ x1) Is there any functions which will help me do this ?
asked 2019-10-10 18:01:22 +0100
Anonymous
I have (x0 + x1) and want to make (x0 ^ x1) Is there any functions which will help me do this ?
Your question is unclear, since for symbolic function, ^
stands for the exponentiation, not logic and
. What is the meaning of ^
in your case ? Which kind of output object do you expect ? Do you want to plug it in another software (Sage does not handle logic formula very well) ? If you want strings, you can do:
sage: var('x0,x1')
(x0, x1)
sage: a = (x0 + x1) ; a
x0 + x1
sage: str(a).replace('+','^')
x0 ^ x1
But priorities of ^
with respect to *
is not the same as the one of +
with *
, so you need to be careful with that.
If you want the result to be a symbolic expression and ^
be the exponentiation, and respect priority of operations despite possibily missing parentheses, you will have to use https://doc.sagemath.org/html/en/refe... (but i won't write a dedicated code unless you makes your question more precise).
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2019-10-10 18:01:22 +0100
Seen: 172 times
Last updated: Oct 10 '19