我正在研究C++ Z3 unsat核心,
Z3_parse_smtlib_string(ctx,
"(benchmark tst :extrafuns ((b1 Bool) (b2 Bool) (b3 Bool) (x Int) (y Int)) :formula (=> b1 (> x y)) :formula (=> b2 (= x 0)) :formula (=> b3 (> y 0)))",0, 0, 0,0, 0, 0);
num_formulas = Z3_get_smtlib_num_formulas(ctx);
std::vector<expr> assumptions;
for (i = 0; i < num_formulas; i++)
{
Z3_ast f = Z3_get_smtlib_formula(ctx, i);
z3::expr e(ctx, f);
assumptions.push_back(e);
s.add(e);
}
s.check(3,&assumptions[0]) ;
expr_vector core = s.unsat_core();
std::cout << "size: " << core.size() << "\n";
for (unsigned i = 0; i < core.size(); i++)
{
std::cout << core[i] << "\n";
}然而,它提出了一个警告:一个假设必须是一个命题变量,或者是一个变量的否定。此外,返回的unsat核心大小为0。
发布于 2016-11-07 10:31:28
我通过引入跟踪断言找到了生成unsat核心的解决方案,
https://stackoverflow.com/questions/40458415
复制相似问题