【发布时间】:2021-08-06 15:20:38
【问题描述】:
如何使用 Z3 python API 编写与此代码等效的代码?
(define-fun mymax ((a Int) (b Int)) Int
(ite (> a b) a b))
(assert (= (mymax 100 7) 100))
(check-sat)
(get-model)
不幸的是,Function 方法是 Python 中的 declare_fun,而不是 define_fun:它不接受包含函数定义的参数。如果我们能写这样的东西就好了:
mymax = Function('mymax', IntSort(), IntSort(), IntSort(),
Lambda([a,b], If(a>b, a, b))
(我可以声明mymax并为其添加适当的约束,但是当函数大而复杂时,z3必须搜索它的定义,这看起来效率不高。我宁愿给z3定义)
【问题讨论】:
标签: z3py