Z3Py: randomized results (phase-selection) not random?

纵饮孤独 提交于 2020-04-30 07:34:48

问题


I tried to use bit vectors to get randomized results in model values like suggested by de Moura here but then with Z3Py instead of SMTLIB. I translated his example to:

from z3 import *
s = Solver()
x = BitVec('x', 16)
set_option('auto_config', False)
set_option('smt.phase_selection',5)
s.add(ULT(x,100))
s.check()
s.model()
s.check()
s.model()

However, the result seems to always be the same, i.e. - repetitive checking with s.check() does not alter the result. - even after a restart of the python interactive shell the result of the execution will be the same

Adding a change of the random seed did not alter the results: set_option('smt.random_seed', 123)

Does anyone have an idea why is not working as desired?

Thanks in advance!

Carsten


回答1:


This case is simply too simple. It's essentially solved by the preprocessor and never gets to a point where it needs to select a phase, so random phase selection has no effect. Leo's answer to the cited post is now a little bit out of date and Z3 has changed, so it doesn't immediately replicate using the latest unstable version because Z3 chooses to use a different solver. We can still get the random behavior if we force it to use the incremental solver by adding a (push) command though; here's an updated example that is seed dependent:

(set-option :auto_config false)
(set-option :smt.phase_selection 5)
(set-option :smt.random_seed 456)
(declare-const x (_ BitVec 16))
(assert (bvult x (_ bv100 16)))
(push)
(check-sat)
(get-model)
;; try again to get a different model
(check-sat)
(get-model)
;; try again to get a different model
(check-sat)
(get-model)


来源:https://stackoverflow.com/questions/24330928/z3py-randomized-results-phase-selection-not-random

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