Z3 中具有函数作为属性的数据类型 Python

Datatypes with functions as attributes in Z3 Python

我正在使用 Z3 的 Python 绑定,并尝试创建一个 Z3 数据类型,其属性是函数。例如,我可能会执行以下命令:

Foo = Datatype('Foo')
Foo.declare('foo', [('my_function', Function('f', IntSort(), BoolSort()))])
Foo.create()

这是尝试创建具有属性 my_function 的数据类型 Foo,我可以在其中调用 my_function x(如果 x 是类型的变量Foo) 为了得到一些从整数到布尔的函数。

然而,我运行在第二行出现以下错误:

z3types.Z3Exception: Valid list of accessors expected. An accessor is a pair of the form (String, Datatype|Sort)

是否可以用函数声明 Z3 数据类型作为属性,也许使用不同的语法?

或者是不允许的事情? post function declaration in z3 向我暗示 Z3 中不允许使用高阶函数,因此可能不允许向数据类型添加函数,以防止使用这些数据类型创建高阶函数。

您可以使用 Array 类型来编码函数空间。

Foo = Datatype('Foo')
Foo.declare('foo', ('my_function', ArraySort(IntSort(), BoolSort())))
print Foo.create()