对于这个非线性整数算术示例,为什么Z3返回unknown?
我有一个非线性整数算法的简单例子,即搜索毕达哥拉斯三元组。根据我在相关问题(见下文)中读到的内容,我希望Z3能够找到这个问题的解决方案,但它返回“未知”。以下是SMT-LIB v2中的示例:对于这个非线性整数算术示例,为什么Z3返回unknown?,z3,smt,Z3,Smt,我有一个非线性整数算法的简单例子,即搜索毕达哥拉斯三元组。根据我在相关问题(见下文)中读到的内容,我希望Z3能够找到这个问题的解决方案,但它返回“未知”。以下是SMT-LIB v2中的示例: (declare-fun x () Int) (declare-fun y () Int) (declare-fun z () Int) (declare-fun xSquared () Int) (declare-fun ySquared () Int) (declare-fun zSquared ()
(declare-fun x () Int)
(declare-fun y () Int)
(declare-fun z () Int)
(declare-fun xSquared () Int)
(declare-fun ySquared () Int)
(declare-fun zSquared () Int)
(declare-fun xSquaredPlusYSquared () Int)
(assert (= xSquared (* x x)))
(assert (= ySquared (* y y)))
(assert (= zSquared (* z z)))
(assert (= xSquaredPlusYSquared (+ xSquared ySquared)))
(assert (and (> x 0) (> y 0) (> z 0) (= xSquaredPlusYSquared zSquared)))
(check-sat)
(exit)
有几个相关的问题,最值得注意的是:
- 除非变量的范围有限,否则Z3似乎不会尝试通过钻头爆破来找到解决方案。用以下命令替换
(检查sat)
,将找到解决方案:
(check-sat-using (then (using-params add-bounds :add-bound-lower -100 :add-bound-upper 100) smt))
或者,可以添加assert语句,强制每个变量具有某个有限范围。似乎Z3不会尝试通过位爆破找到解决方案,除非变量具有有限范围。用以下命令替换
(检查sat)
,将找到解决方案:
(check-sat-using (then (using-params add-bounds :add-bound-lower -100 :add-bound-upper 100) smt))
或者,可以添加断言语句,强制每个变量具有有限的范围。答案似乎与此问题相关:答案似乎与此问题相关: