Optimization 它是Z3中的一个bug吗?关于实际和全部应用的回答不正确

Optimization 它是Z3中的一个bug吗?关于实际和全部应用的回答不正确,optimization,z3,z3py,quantifiers,Optimization,Z3,Z3py,Quantifiers,我试图找到抛物线y=(x+2)**2-3的最小值,显然,当x==-2时,答案应该是y=-3。 但是z3给出了答案[x=0,y=1],这与ForAll断言不符 我对某事的假设是错误的吗 以下是python代码: from z3 import * x, y, z = Reals('x y z') print(Tactic('qe').apply(And(y == (x + 2) ** 2 - 3, ForAll([z], y <=

我试图找到抛物线y=(x+2)**2-3的最小值,显然,当x==-2时,答案应该是y=-3。 但是z3给出了答案[x=0,y=1],这与ForAll断言不符

我对某事的假设是错误的吗

以下是python代码:

from z3 import *

x, y, z = Reals('x y z')

print(Tactic('qe').apply(And(y == (x + 2) ** 2 - 3,
                             ForAll([z], y <= (z + 2) ** 2 - 3))))

solve(y == x * x + 4 * x +1,
      ForAll([z], y <= z * z + 4 * z +1))
结果表明,“量化宽松”策略消除了所有断言的真实性,尽管它并不总是真实的。 这就是解算器给出错误答案的原因吗? 我应该编写什么代码来查找这样一个表达式的最小(或最大)值

顺便说一句,Mac的Z3版本是4.3.2。

并使用“qfnra nlsat”和“smt”策略找到了部分解决方案

from z3 import *

x, y, z = Reals('x y z')

s1 = Then('qfnra-nlsat','smt').solver()
print s1.check(And(y == (x + 2) ** 2 - 3,
                             ForAll([z], y <= (z + 2) ** 2 - 3)))
print s1.model()

s2 = Then('qe', 'qfnra-nlsat','smt').solver()
print s2.check(And(y == (x + 2) ** 2 - 3,
                             ForAll([z], y <= (z + 2) ** 2 - 3)))
print s2.model()
“qe”策略和默认的解决方案似乎仍然存在缺陷。他们没有给出正确的结果。
需要进一步的评论和讨论。

感谢您创建这些示例。不过,我无法使用最新的不稳定分支重现这些bug。几个月前,我根据Monniaux的一份报告修复了qe模块中的一些错误。@NikolajBjorner那么,这意味着在下一个版本中,上面的问题会好起来吗?
from z3 import *

x, y, z = Reals('x y z')

s1 = Then('qfnra-nlsat','smt').solver()
print s1.check(And(y == (x + 2) ** 2 - 3,
                             ForAll([z], y <= (z + 2) ** 2 - 3)))
print s1.model()

s2 = Then('qe', 'qfnra-nlsat','smt').solver()
print s2.check(And(y == (x + 2) ** 2 - 3,
                             ForAll([z], y <= (z + 2) ** 2 - 3)))
print s2.model()
sat
[x = -2, y = -3]
sat
[x = 0, y = 1]