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

1

1

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:

Diaphoretic answered 22/10, 2015 at 12:56 Comment(1)
The answer seems to be related to this question: https://mcmap.net/q/1782007/-goal-unsupported-by-tacticDiaphoretic
D
0

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.

Diaphoretic answered 22/10, 2015 at 17:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.