0

I had a question on smt-solvers (like Z3) and was wondering if you know any Z3-tactic which can help me achieve my objective.

I want to know whether it is possible to force Z3 to explore some variables before exploring other variables.

For examples, I have a scenario where my MaxSMT problem has the following hard constraints

X1 + X4 >=3
X2 + 7  >=3
X3 + 8  >=3

And the soft-constraint is

X4 == 0

Here I want to force the smt-solver to first explore candidate space with different values for variable X1. (I believe by default Z3 will randomly explore different values of X1, X2, X3, X4)

So my question is - is there any tactic in Z3 that allows me to tell the Z3-solver what candidate space (set of variables) should it try exploring first?

brokendreams
  • 827
  • 2
  • 10
  • 29

2 Answers2

0

The max-smt engine allows user parameterization in z3, but unfortunately it isn't clear if any of these tweaks would allow you to do what you want. But you can at least ask for what the "tweaks" are by using the z3 -p command and looking through the list. I found the following params:

[module] opt, description: optimization parameters
    maxres.add_upper_bound_block (bool) (default: false)
    maxres.hill_climb (bool) (default: true)
    maxres.max_core_size (unsigned int) (default: 3)
    maxres.max_correction_set_size (unsigned int) (default: 3)
    maxres.max_num_cores (unsigned int) (default: 4294967295)
    maxres.maximize_assignment (bool) (default: false)
    maxres.pivot_on_correction_set (bool) (default: true)
    maxres.wmax (bool) (default: false)
    maxsat_engine (symbol) (default: maxres)

(There are others, but these seem most relevant.)

To see how these impact the search, your best bet is probably to read through the source code: https://github.com/Z3Prover/z3/blob/master/src/opt/maxres.cpp

Alternatively, you can try asking at z3 github site (https://github.com/Z3Prover/z3/issues), and the authors might point you in a better direction.

alias
  • 28,120
  • 2
  • 23
  • 40
  • Apparently, the variable `x1`, for which s/he wants to impose some priority, is not part of any *soft-constraint*, so I am not sure why you propose those options.. could you please elaborate on that? When I read the question I had the impression the OP imagines that `z3` works similarly to FDCP solvers, with internal value propagators on the domains of variables `x1`, `x2`, `x3` and `x4` and explicit value assignments (*a la* `mcsat`, so to speak). – Patrick Trentin Dec 23 '18 at 08:52
  • @PatrickTrentin I interpreted as "case split on these variables first" sort of an approach; as opposed to good old explicit value search. In the regular DPLL approach, one can definitely have preferences on which variables to try first when it comes to decisions. But you are correct that I'm not sure if any of this would help with MaxSMT. – alias Dec 23 '18 at 09:03
  • Sure, it's exactly the same mechanism, only that *SMT* solvers typically use only *Boolean* variables as decision variables (as opposed to FDCP tools which can use *Integer* variables as decision variables), so one would have to introduce explicit Boolean predicates and then configure `z3` to have a *preference* to use them as decision variables.. no? – Patrick Trentin Dec 23 '18 at 09:12
  • 1
    @PatrickTrentin You should turn your observations into an answer! You have much better insight into this than I do. I also noticed the author posed the same question in the z3 github issue tracker (no answer yet), so that can provide some more insight as well: https://github.com/Z3Prover/z3/issues/2047 – alias Dec 23 '18 at 19:40
0

One option is to use the cube method of the Solver class. It allows you to specify the variables to use for case split.

Pierre Carbonnelle
  • 2,305
  • 19
  • 25