Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Z3 替换公式上存在调用后的意外结果_Z3_Z3py - Fatal编程技术网

Z3 替换公式上存在调用后的意外结果

Z3 替换公式上存在调用后的意外结果,z3,z3py,Z3,Z3py,当对不同的变量和公式调用Z3py的Exists函数时,我得到了完全相同的结果。这是某种Python问题还是Z3在这里被破坏了?如何修复?以下示例说明了该问题: from z3 import * a, a0, a1, b, b0, b1 = Ints('a a0 a1 b b0 b1') x, y = Bools('x y') s = Solver() formula = Implies(x, And(a>0,b1<0)) substitution1 = substitute(form

当对不同的变量和公式调用Z3py的Exists函数时,我得到了完全相同的结果。这是某种Python问题还是Z3在这里被破坏了?如何修复?以下示例说明了该问题:

from z3 import *
a, a0, a1, b, b0, b1 = Ints('a a0 a1 b b0 b1')
x, y = Bools('x y')
s = Solver()
formula = Implies(x, And(a>0,b1<0))
substitution1 = substitute(formula,(a1,a0),(b1,b0))
substitution2 = substitute(formula,(a1,a0),(b1,b0),(a,a1),(b,b1))
print substitution1
print substitution2
exist1 = Exists([a,b],substitution1)
exist2 = Exists([a1,b1],substitution2)
print exist1
print exist2
从z3导入*
a、 a0,a1,b,b0,b1=Ints('a a0 a1 b b0 b1')
x、 y=布尔值('x y')
s=解算器()
公式=意味着(x和(a>0,b10,b0<0))
意味着(x和(a1>0,b0<0))
存在([a,b],意味着(x,和(a>0,b0<0)))
存在([a,b],意味着(x,和(a>0,b0<0)))

感谢您的报告。Z3在这方面实际上是正确的,但输出令人困惑。在内部,Z3使用deBrujin索引,绑定变量的名称无关紧要。当创建具有相同主体(和模式、无模式等)的量词时,将使用与以前看到的完全相同的表达式,以避免必须解决与以前相同的量化约束。这造成了混乱的局面,因为绑定变量的名称似乎突然改变了

在这里给出的示例中,两个量词的主体实际上是相同的,变量的名称并不重要。Z3可以为这些变量使用任何名称,但它选择使用第一次创建量词时使用的名称。我们可以通过添加

compare_arrays(to_quantifier(n1)->get_decl_names(),
               to_quantifier(n2)->get_decl_names(),
               to_quantifier(n1)->get_num_decls()) &&
在src/ast/ast.cpp:470。然而,这可能会对Z3在某些基准上的性能产生负面影响,因此我不会进行此更改。如果您想使用它,当然可以将其添加到Z3的本地副本中

compare_arrays(to_quantifier(n1)->get_decl_names(),
               to_quantifier(n2)->get_decl_names(),
               to_quantifier(n1)->get_num_decls()) &&