z3py:如何在z3py中设置使用的逻辑?

时间:2017-04-27 12:38:03

标签: z3 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))

我收到以下错误:

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

当仅使用z3.Solver()而不给出新的z3.Context作为参数时,代码正在运行。

有人可以回答以下问题:

  • 这里有什么区别?
  • 如何在z3py中设置逻辑?
  • 我应该对数据类型使用哪种逻辑?

0 个答案:

没有答案