Why does Z3 return unknown for this nonlinear integer arithmetic example?

时光毁灭记忆、已成空白 提交于 2019-12-13 02:37:47

问题


I have a simple example in nonlinear integer arithmetic, namely a search for Pythagorean triples. Based on what I read in related questions (see below), I'd expect Z3 to find a solution to this problem, but it returns 'unknown'. Here is the example in 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 () 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)

There are a few related questions, most notably:

  • How does Z3 handle non-linear integer arithmetic?

  • Need help understanding the equation

  • Combining nonlinear Real with linear Int

  • Z3 support for nonlinear arithmetic

  • z3 limitations in handling nonlinear real arithmetics


回答1:


It seems that Z3 won't attempt finding a solution by bit-blasting unless variables have a finite range. Replacing (check-sat) with the following command will find the solution:

(check-sat-using (then (using-params add-bounds :add-bound-lower -100 :add-bound-upper 100) smt))

Alternatively, one can add assert statements forcing each variable to have some finite range.



来源:https://stackoverflow.com/questions/33281590/why-does-z3-return-unknown-for-this-nonlinear-integer-arithmetic-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!