I am using the z3 C++ API and have some problems regarding nonlinear integer arithmetic where z3 seems to treat power and multiplication differently.
E.g. x*x*x > y*y
is sat
, but x^3 > y^2
is unknown
:
#include <z3++.h>
#include <iostream>
using namespace std;
int main() {
z3::context c;
auto x = c.int_const("x");
auto y = c.int_const("y");
z3::solver sol(c);
sol.add(x*x*x > y*y);
cout << sol << " : " << sol.check() << endl;
sol.reset();
sol.add(z3::pw(x,3) > z3::pw(y,2));
cout << sol << " : " << sol.check() << endl;
}
I've already read about some python issues (Z3 python treats x**2 different than x*x?), but I use version 4.4.0 of z3 where that should be fixed.
I came across this problem when trying to solve x^51 > y^17. I know that nonlinear integer arithmetic is undecidable in general, but I was a bit surprised that z3 found no solution for this (even if rewritten as multiplication). So I would like to know if the above is a bug, or if there is any way to get better results from z3 in C++ for these examples.