Input arguments of Z3_benchmark_to_smtlib_string()

2019-07-10 03:18发布

I am trying to use the function Z3_benchmark_to_smtlib_string(). Here are the arguments I am using:

Z3_benchmark_to_smtlib_string(
                   ctx,          /* this one is valid */
                   "test",       /* this one is random, I don't understand it */
                   "QF_UFBV",    /* I got this name from the smtlib website, valid ? */
                   "sat",        /* not sure about this one either */
                   NULL,         /* not sure about this one either */
                   nb_assumptions, /* should be ok */
                   assumptions,    /* should be ok too */
                   NULL);          /* not sure about this one, is this mandatory ? */

Any help would be welcome.

In parallel, I am using displaying my assumptions on the fly, using:

Z3_set_ast_print_mode(ctx,Z3_PRINT_SMTLIB2_COMPLIANT);

en get strange characters like : ?x21, ?x24, ?x37, (see below). Any hint to solve this issue ?

Thanks in advance,

A.G.

(let ((?x21 (bvand (_ bv582 32) (ite (= ((_ sign_extend 24) (_ bv98 8)) ((_ sign_extend 24) |Mem5[8]|)) (_ bv64 32) (_ bv0 32))))) (let ((?x24 (bvand ?x21 (ite (bvsgt ((_ sign_extend 24) (_ bv98 8)) ((_ sign_extend 24) |Mem5[8]|)) (_ bv128 32) (_ bv0 32))))) (let ((?x37 (bvand ?x24 (ite (= ((_ sign_extend 24) (_ bv97 8)) ((_ sign_extend 24) |Mem6[8]|)) (_ bv64 32) (_ bv0 32))))) (bvand ?x37 (ite (bvsgt ((_ sign_extend 24) (_ bv97 8)) ((_ sign_extend 24) |Mem6[8]|)) (_ bv128 32) (_ bv0 32))))))

标签: z3
1条回答
Rolldiameter
2楼-- · 2019-07-10 03:41

This function is quite old. It was created when SMT 2.0 didn't exist. A SMT 1.0 benchmark looks like that:

(benchmark example
:status sat
:logic QF_LIA
:extrafuns ((x1 Int) (x2 Int) (x3 Int) (x4 Int) (x5 Int))
:assumption (>= (- x1 x2) 1)
:assumption (>= (- x1 x2) 3)
:assumption (= x3 x5)
:formula (= x2 (* 6 x4))
)

The function you are using was meant for producing a benchmark in this format. That is why we have parameters such as name, logic, status, etc. They correspond to the annotations in the example above. Moreover, a SMT 1.0 problem consists of 0 or more assumptions and 1 formula.

When SMT 2.0 was introduced, this method was extended to print benchmarks in SMT 2.0 format when we have

Z3_set_ast_print_mode(ctx,Z3_PRINT_SMTLIB2_COMPLIANT);

The strange characters are just auxiliary let declarations used to avoid an exponential blowup when printing formulas. Note that, Z3 ASTs are DAGs and not trees. It is very easy to create a DAG using the C API that has a lot of sharing. Example:

 a_1 = Z3_mk_bvadd(b, c)
 a_2 = Z3_mk_bvmul(a1, a1)
 a_3 = Z3_mk_bvadd(a2, a2)
 a_4 = Z3_mk_bvmul(a3, a3)
 ...

The AST a_100 is a very compact object in memory. If we try to print it as a tree without using the auxiliary let declarations, the output will be very huge.

Note that the output produced by this function was never meant to be consumed by humans. It is mainly used to generate benchmarks for the SMT-LIB repository.

查看更多
登录 后发表回答