Prove 2 formulas equivalent under some conditions?

╄→尐↘猪︶ㄣ 提交于 2019-12-07 12:55:26

问题


Two formulas a1 == a + b and a1 == b are equivalent if a == 0. I want to find this required condition (a == 0) with Z3 python. I wrote the code below:

from z3 import *

def equivalence(F, G):
    s = Solver()
    s.add(Not(F == G))
    r = s.check()
    if r == unsat:
        print 'Equ'
        print s.model()
    else:
        print 'Not Equ'

a, b = BitVecs('a b', 32)

g = True
tmp = BitVec('tmp', 32)
g = And(g, tmp == a)
tmp1 = BitVec('tmp1', 32)
g = And(g, tmp1 == b)
tmp2 = BitVec('tmp2', 32)
g = And(g, tmp2 == (tmp1 + tmp))
a1 = BitVec('a1', 32) 
g = And(g, a1 == tmp2)

f = True
f = And(f, a1 == b)

equivalence(Exists([a], g), f)

However, the above code always returns "Not Equ" as the output. Then obviously I cannot get the model (a === 0) as the condition for "f" and "g" to be equivalent, either.

Any idea on where the code is wrong, and how to fix it? Thanks so much!


回答1:


The code in the post does not correspond to the question that is asked. A similar question was asked and answered on the smt-lib mailing list.



来源:https://stackoverflow.com/questions/17082592/prove-2-formulas-equivalent-under-some-conditions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!