Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set the priority of boolean variables in z3?

Tags:

z3

Since the question is a little hard to describe, I will use a small example to describe my question. Suppose there is a propositional formula set whose elements are Boolean variables a,b and c. When using z3 to get a truth assignment of this formula set, does there exist some way to set the priority of the variables? I mean that if the priority is a>b>c, then during the searching process z3 firstly assumes a is true and if a is impossible to be true it assumes b is true and so on. In another words, if z3 gives a truth assignment: not a,b,c under the aforementioned priority it means a is impossible to be true because a is high-priority compared with b. Hope I describe the question clearly.

like image 351
Dingbao Xie Avatar asked Oct 06 '22 10:10

Dingbao Xie


1 Answers

There is not easy way to do it in the current release (v4.3.1). The only way I can see is to hack/modify the Z3 source code (http://z3.codeplex.com). We agree that setting priorities is a useful feature for some applications, however there are some problems.

First, Z3 applies several transformations (aka preprocessing steps) before solving a problem. Variables are created and eliminated. Thus, a case-split priority for the original problem may be meaningless for the actual problem (the one generated after applying all transformations) that is solved by Z3.

One dramatic example is a formula containing only Bit-vectors. By default, Z3 will reduce this formula into Propositional logic and invoke a Propositional SAT solver. In this reduction, all Bit-vector variables are eliminated.

Z3 is a collection of solvers and preprocessors. By default, Z3 will select a solver automatically for the user. Some of these solvers use completely different algorithms. So, the provided priority may be useless for the solver being used.

As GManNickG pointed out, it is possible to set the phase selection strategy for a particular solver. See the post provided in his comment for additional details.

like image 146
Leonardo de Moura Avatar answered Oct 10 '22 02:10

Leonardo de Moura