substitution in Z3Py

2019-08-03 04:25发布

It seems that the substitute(f,t) function in Z3Py performs simplification on f first before doing the substitution. Is there a way to disallow this?

I would like the following behavior to occur:

f = And(x,Not(x))
result = substitute(f,*[(Not(x),BoolVal(True))])  #sub Not(x) => True
#if we simplify f first then the result = False,  but if we do the substitution first then result = x

标签: python z3
1条回答
何必那么认真
2楼-- · 2019-08-03 05:03

Unfortunately, the substitute procedure is implemented using the simplifier which can apply substitutions during the simplification. The substitute Python procedure invokes the Z3 C API Z3_substitute in the file api_ast.cpp. Internally, the simplifier is called th_rewriter (theory rewriter).

That being said, I agree this is not nice and may be very inconvenient in some cases. I will change that for the next release.

查看更多
登录 后发表回答