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:

Community
  • 1
  • 1
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58

1 Answers1

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.

Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58