Empty model in z3

冷暖自知 提交于 2021-02-08 15:44:10

问题


z3py snippet:

x = Int('x')

s = Solver()
s.add(x <= x)
print s.check()
print s.model()
print s.model().sexpr()

http://rise4fun.com/Z3Py/mfPU

Output:

sat
[]

Any value of x would do but z3 returns empty model. Does a missing free variable x in the model indicates that any integer value is a valid model?


回答1:


Yes, in Z3, if a constant (such as x) does not appear in the model, then it is a "don't care". That is, any value of x will satisfy the formula. When evaluating the value of a constant, we can enable "model completion". That is, Z3 will use an arbitrary interpretation for "don't care" symbols. Here is an example http://rise4fun.com/Z3Py/bvVO

x = Int('x')
s = Solver()
s.add(x <= x)
print s.check()
m = s.model()
print m.evaluate(x)
print m.evaluate(x, model_completion=True)
print m


来源:https://stackoverflow.com/questions/12908067/empty-model-in-z3

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