问题
It seems that Z3 Python interface doesn't like the ** operator , it can deal with x*x but not x**2 as shown in the example below
>>> x,y = x,y=Reals('x y')
>>> z3.prove(Implies(x -6 == 0,x**2 -36 == 0))
failed to prove
[x = 6]
>>> z3.prove(Implies(x -6 == 0,x*x -36 == 0))
proved
回答1:
You are probably using version 4.3.0 on Linux or OSX. Version 4.3.0 has a configuration problem on these platforms. If that is the case, I suggest you download version 4.3.1. Version 4.3.1 will prove both queries on Linux and OSX. In version 4.3.0 auto-configuration is not enabled by default on Linux and OSX. Thus, Z3 will always use a general purpose solver that is not complete for nonlinear arithmetic, nor has support for the power operator. When auto-configuration is enabled, Z3 detects that these two problems are in the nonlinear real arithmetic fragment, and switches to the nlsat solver.
BTW, to manually enable auto-configuration on version 4.3.0, you may use the command z3.set_option(auto_config=True)
.
来源:https://stackoverflow.com/questions/13446967/z3-python-treats-x2-different-than-xx