使用下面的代碼:z3py:如何在z3py中設置使用的邏輯?
import z3
solver = z3.Solver(ctx=z3.Context())
#solver = z3.Solver()
Direction = z3.Datatype('Direction')
Direction.declare('up')
Direction.declare('down')
Direction = Direction.create()
Cell = z3.Datatype('Cell')
Cell.declare('cons', ('front', Direction), ('back', z3.IntSort()))
Cell = Cell.create()
mycell = z3.Const("mycell", Cell)
solver.add(Cell.cons(Direction.up, 10) == Cell.cons(Direction.up, 10))
我得到以下錯誤:當只有使用z3.Solver()
沒有給出一個新的z3.Context
作爲參數的代碼工作
Traceback (most recent call last):
File "thedt2opttest.py", line 17, in <module>
solver.add(Cell.cons(Direction.up, 10) == Cell.cons(Direction.up, 10))
File "/home/john/tools/z3-master/build/python/z3/z3.py", line 6052, in add
self.assert_exprs(*args)
File "/home/john/tools/z3-master/build/python/z3/z3.py", line 6040, in assert_exprs
arg = s.cast(arg)
File "/home/john/tools/z3-master/build/python/z3/z3.py", line 1304, in cast
_z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
File "/home/john/tools/z3-master/build/python/z3/z3.py", line 90, in _z3_assert
raise Z3Exception(msg)
z3types.Z3Exception: Value cannot be converted into a Z3 Boolean value
。
可有人請回答下列問題:
- 是這裏有什麼區別?
- 如何在z3py中設置邏輯?
- 我應該使用哪種邏輯與數據類型?