문제

from z3 import *
x = Int('x') #declaration
y = Int('y') #declaration
solve((x ^ y)==2) #solving

i was unable to perform xor operation in z3 using python.please help tell what is the correct way of writing if i am doing it wrong else suggest some other way of doing it.please reply as soon as possible.

도움이 되었습니까?

해결책

You can use ^ on integers in Python:

>>> 2^3
1

However, z3 does not use integers, but their own Int objects, and they don't support xor. You have to use the BitVec type.

x = BitVec('x', 32)
y = BitVec('y', 32)

solve(x^y==2, show=True)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top