Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Z3 be used to preprocess problems?

Tags:

python

z3

Doing new research on SMT solvers is many times hindered by the fact that the available problems require lots of tricks and pre-processing techniques not directly related to decision procedures. These are often unpublished or take time to implement and optimize properly, and in addition makes comparison and understanding of different solvers quite difficult.

Is it possible to use Z3 as a pre-processor that would take a problem and dump it out in a pre-processed form (one that z3 itself uses to solve the problem)?

I don't see any command line options, but I am guessing that there might be some way to achieve this, via strategies, through the python interface, or even writing some extra code.

like image 980
Dejan Jovanović Avatar asked Oct 06 '22 18:10

Dejan Jovanović


1 Answers

Yes, Z3 can be used as a pre-processor. The command apply allows the user to apply a tactic and dump it as a SMT 2.0 benchmark. Here is an example (also available online at http://rise4fun.com/Z3/eutO):

(declare-const x Real)
(declare-const y Real)

(assert (forall ((n Real)) (or (< x n) (< n y))))
(assert (= (< x y) (< x 100.0)))

(apply (then qe nnf) :print false :print-benchmark true)

In the example above, qe (quantifier elimination) and nnf (negation-normal-form) tactics are applied to the input problem.

Some additional points:

  • Several tactics only produce equisatisfiable results. Thus, a model for the resultant benchmark is not necessarily a model for the original formula. We can ask Z3 to dump the associated "model-converter" (option :print-model-converter true). The model converter encodes the steps used by Z3 to convert a model for the resultant formula into a model for the original formula. However, there is no standard for printing model converters, and Z3 cannot read these descriptions. Of course, we can glue everything together using the programmatic APIs.

  • A small set of tactics produce under (only sat results can be trusted) or over (only unsat results can be trusted) approximations. They are usually used in model or proof finding. When Z3 displays the resultant goal, it will inform with the result is precise (sat and unsat can be trusted).

like image 83
Leonardo de Moura Avatar answered Oct 10 '22 04:10

Leonardo de Moura