mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 19:35:50 +00:00
integrating duality
This commit is contained in:
parent
8488ca24d2
commit
feb5360999
9 changed files with 473 additions and 5 deletions
|
@ -171,6 +171,7 @@ namespace Duality {
|
|||
const std::vector<expr> &assumptions,
|
||||
const std::vector<expr> &theory
|
||||
){}
|
||||
virtual ~LogicSolver(){}
|
||||
};
|
||||
|
||||
/** This solver uses iZ3. */
|
||||
|
@ -205,8 +206,8 @@ namespace Duality {
|
|||
}
|
||||
#endif
|
||||
|
||||
iZ3LogicSolver(context c){
|
||||
ctx = ictx = new interpolating_context(c);
|
||||
iZ3LogicSolver(context &c){
|
||||
ctx = ictx = &c;
|
||||
slvr = islvr = new interpolating_solver(*ictx);
|
||||
need_goals = false;
|
||||
islvr->SetWeakInterpolants(true);
|
||||
|
@ -221,7 +222,7 @@ namespace Duality {
|
|||
#endif
|
||||
}
|
||||
~iZ3LogicSolver(){
|
||||
delete ictx;
|
||||
// delete ictx;
|
||||
delete islvr;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -590,7 +590,12 @@ namespace Duality {
|
|||
if (res == l_false)
|
||||
{
|
||||
DecodeTree(root, interpolant->getChildren()[0], persist);
|
||||
delete interpolant;
|
||||
}
|
||||
|
||||
delete tree;
|
||||
if(goals)
|
||||
delete goals;
|
||||
|
||||
timer_stop("Solve");
|
||||
return res;
|
||||
|
@ -828,6 +833,7 @@ namespace Duality {
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
#ifdef Z3OPS
|
||||
static Z3_subterm_truth *stt;
|
||||
#endif
|
||||
|
|
|
@ -267,6 +267,8 @@ namespace Duality {
|
|||
// print_profile(std::cout);
|
||||
delete indset;
|
||||
delete heuristic;
|
||||
delete unwinding;
|
||||
delete reporter;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1284,6 +1286,8 @@ namespace Duality {
|
|||
DerivationTree dt(this,unwinding,reporter,heuristic,FullExpand);
|
||||
bool res = dt.Derive(unwinding,node,UseUnderapprox,true); // build full tree
|
||||
if(!res) throw "Duality internal error in BuildFullCex";
|
||||
if(cex.tree)
|
||||
delete cex.tree;
|
||||
cex.tree = dt.tree;
|
||||
cex.root = dt.top;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,33 @@ expr context::make_quant(decl_kind op, const std::vector<expr> &bvs, const expr
|
|||
return cook(result.get());
|
||||
}
|
||||
|
||||
expr context::make_quant(decl_kind op, const std::vector<sort> &_sorts, const std::vector<symbol> &_names, const expr &body){
|
||||
if(_sorts.size() == 0) return body;
|
||||
|
||||
|
||||
std::vector< ::symbol> names;
|
||||
std::vector< ::sort *> types;
|
||||
std::vector< ::expr *> bound_asts;
|
||||
unsigned num_bound = _sorts.size();
|
||||
|
||||
for (unsigned i = 0; i < num_bound; ++i) {
|
||||
names.push_back(_names[i]);
|
||||
types.push_back(to_sort(_sorts[i].raw()));
|
||||
}
|
||||
expr_ref result(m());
|
||||
result = m().mk_quantifier(
|
||||
op == Forall,
|
||||
names.size(), &types[0], &names[0], to_expr(body.raw()),
|
||||
0,
|
||||
::symbol(),
|
||||
::symbol(),
|
||||
0, 0,
|
||||
0, 0
|
||||
);
|
||||
return cook(result.get());
|
||||
}
|
||||
|
||||
|
||||
decl_kind func_decl::get_decl_kind() const {
|
||||
return ctx().get_decl_kind(*this);
|
||||
}
|
||||
|
@ -453,6 +480,10 @@ expr context::make_quant(decl_kind op, const std::vector<expr> &bvs, const expr
|
|||
for(unsigned i = 0; i < _interpolants.size(); i++)
|
||||
linearized_interpolants[i] = expr(ctx(),_interpolants[i]);
|
||||
|
||||
// since iz3interpolant returns interpolants with one ref count, we decrement here
|
||||
for(unsigned i = 0; i < _interpolants.size(); i++)
|
||||
m().dec_ref(_interpolants[i]);
|
||||
|
||||
unlinearize_interpolants(0,assumptions,linearized_interpolants,interpolant);
|
||||
interpolant->setTerm(ctx().bool_val(false));
|
||||
}
|
||||
|
|
|
@ -234,6 +234,7 @@ namespace Duality {
|
|||
expr make(decl_kind op, const expr &arg0, const expr &arg1, const expr &arg2);
|
||||
|
||||
expr make_quant(decl_kind op, const std::vector<expr> &bvs, const expr &body);
|
||||
expr make_quant(decl_kind op, const std::vector<sort> &_sorts, const std::vector<symbol> &_names, const expr &body);
|
||||
|
||||
|
||||
decl_kind get_decl_kind(const func_decl &t);
|
||||
|
@ -771,7 +772,10 @@ namespace Duality {
|
|||
solver(context & c);
|
||||
solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; }
|
||||
solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver;}
|
||||
~solver() { }
|
||||
~solver() {
|
||||
if(m_solver)
|
||||
dealloc(m_solver);
|
||||
}
|
||||
operator ::solver*() const { return m_solver; }
|
||||
solver & operator=(solver const & s) {
|
||||
m_ctx = s.m_ctx;
|
||||
|
@ -1202,6 +1206,11 @@ namespace Duality {
|
|||
num = _num;
|
||||
}
|
||||
|
||||
~TermTree(){
|
||||
for(unsigned i = 0; i < children.size(); i++)
|
||||
delete children[i];
|
||||
}
|
||||
|
||||
private:
|
||||
expr term;
|
||||
std::vector<TermTree *> children;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue