Setting logic for solver in Z3 (API)

2019-07-15 03:37发布

问题:

I notice that the Z3 C++ (and C) API allows you to supply the logic to be used.

I have two questions about this that I couldn't answer by looking online:

  1. Are these supposed to be the standard SMT-LIB logics i.e. QF_LRA
  2. When are these worth supplying i.e. when will Z3 actually use this information

My context is mainly QF no BV but everything else possible, I am using the SMT solver incrementally and I can always work out what logic I will be in at the start.

回答1:

Z3 will also try to figure out what the logic is (when run with default options), but it doesn't have custom tactics for all combinations of theories (see default_tactic.cpp and smt_strategic_solver.cpp). When you are not sure what Z3 will decide to do, then it's best to set the tactic right up front, so that you will get errors if you try to use things that are not in that logic. It will also use that information to set up the smt kernel, e.g., enabling various preprocessors, various solver features, and chosing heuristics (see e.g., smt_setup.cpp).



回答2:

Try it out and see!

Usually it does make a big difference. Setting the logic means the solver will use a specialized tactic to solve the formula, instead of going through the generic loop. Z3 will also try to guess the logic, but it's usually better to just provide it upfront.



标签: z3 smt