mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 00:55:31 +00:00
merge with master
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
c513f3ca09
883 changed files with 13979 additions and 16480 deletions
|
@ -32,7 +32,7 @@ namespace nlarith {
|
|||
svector<comp> m_comps;
|
||||
|
||||
public:
|
||||
literal_set(ast_manager& m) : m_inf(m), m_sup(m), m_x(0), m_lits(m) {}
|
||||
literal_set(ast_manager& m) : m_inf(m), m_sup(m), m_x(nullptr), m_lits(m) {}
|
||||
unsigned size() const { return m_lits.size(); }
|
||||
|
||||
app_ref_vector& lits() { return m_lits; }
|
||||
|
@ -123,7 +123,7 @@ namespace nlarith {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!get_polys(contains_x, num_lits, lits, polys, comps, &branch_conds, 0)) {
|
||||
if (!get_polys(contains_x, num_lits, lits, polys, comps, &branch_conds, nullptr)) {
|
||||
TRACE("nlarith",
|
||||
tout << "could not extract polynomials " << mk_pp(x, m()) << "\n";
|
||||
for (unsigned i = 0; i < num_lits; ++i) {
|
||||
|
@ -1018,13 +1018,13 @@ namespace nlarith {
|
|||
app* m_x;
|
||||
public:
|
||||
basic_subst(imp& i, app* x) : isubst(i), m_x(x) {}
|
||||
virtual void mk_lt(poly const& p, app_ref& r) {
|
||||
void mk_lt(poly const& p, app_ref& r) override {
|
||||
imp& I = m_imp;
|
||||
app_ref result(I.m());
|
||||
I.mk_polynomial(m_x, p, result);
|
||||
r = I.mk_lt(result);
|
||||
}
|
||||
virtual void mk_eq(poly const& p, app_ref& r) {
|
||||
void mk_eq(poly const& p, app_ref& r) override {
|
||||
imp& I = m_imp;
|
||||
app_ref result(I.m());
|
||||
I.mk_polynomial(m_x, p, result);
|
||||
|
@ -1039,7 +1039,7 @@ namespace nlarith {
|
|||
|
||||
// p[e/x] < 0: (a*parity(d) < 0 /\ 0 < a*a - b*b*c) \/
|
||||
// (b*parity(d) <= 0 /\ (a*parity(d) < 0 \/ a*a - b*b*c < 0))
|
||||
virtual void mk_lt(poly const& p, app_ref& r) {
|
||||
void mk_lt(poly const& p, app_ref& r) override {
|
||||
imp& I = m_imp;
|
||||
ast_manager& m = I.m();
|
||||
app_ref a(m), b(m), c(m_s.m_c), d(m);
|
||||
|
@ -1061,7 +1061,7 @@ namespace nlarith {
|
|||
|
||||
|
||||
// p[e/x] = 0: a*b <= 0 & a*a - b*b*c = 0
|
||||
virtual void mk_eq(poly const& p, app_ref& r) {
|
||||
void mk_eq(poly const& p, app_ref& r) override {
|
||||
imp& I = m_imp;
|
||||
ast_manager& m = I.m();
|
||||
app_ref a(m), b(m), c(m_s.m_c),d(m), aabbc(m);
|
||||
|
@ -1076,7 +1076,7 @@ namespace nlarith {
|
|||
}
|
||||
|
||||
// p[e/x] <= 0: a*parity(d) <= 0 /\ 0 <= a*a - b*b*c \/ b*parity(d) <= 0 /\ a*a - b*b*c <= 0
|
||||
virtual void mk_le(poly const& p, app_ref& r) {
|
||||
void mk_le(poly const& p, app_ref& r) override {
|
||||
imp& I = m_imp;
|
||||
ast_manager& m = I.m();
|
||||
app_ref a(m), b(m), c(m_s.m_c), d(m);
|
||||
|
@ -1125,10 +1125,10 @@ namespace nlarith {
|
|||
public:
|
||||
plus_eps_subst(imp& i, isubst& s) : isubst(i), m_s(s) {}
|
||||
|
||||
virtual void mk_lt(poly const& p, app_ref& r) { mk_nu(p, r); }
|
||||
void mk_lt(poly const& p, app_ref& r) override { mk_nu(p, r); }
|
||||
|
||||
// /\ p[i] = 0
|
||||
virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); }
|
||||
void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); }
|
||||
};
|
||||
|
||||
class minus_eps_subst : public isubst {
|
||||
|
@ -1172,10 +1172,10 @@ namespace nlarith {
|
|||
public:
|
||||
minus_eps_subst(imp& i, isubst& s) : isubst(i), m_s(s) {}
|
||||
|
||||
virtual void mk_lt(poly const& p, app_ref& r) { mk_nu(p, true, r); }
|
||||
void mk_lt(poly const& p, app_ref& r) override { mk_nu(p, true, r); }
|
||||
|
||||
// /\ p[i] = 0
|
||||
virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); }
|
||||
void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); }
|
||||
};
|
||||
|
||||
class minus_inf_subst : public isubst {
|
||||
|
@ -1208,12 +1208,12 @@ namespace nlarith {
|
|||
public:
|
||||
minus_inf_subst(imp& i) : isubst(i) {}
|
||||
|
||||
virtual void mk_lt(poly const& p, app_ref& r) {
|
||||
void mk_lt(poly const& p, app_ref& r) override {
|
||||
r = mk_lt(p, p.size());
|
||||
}
|
||||
|
||||
// /\ p[i] = 0
|
||||
virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); }
|
||||
void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -1238,10 +1238,10 @@ namespace nlarith {
|
|||
public:
|
||||
plus_inf_subst(imp& i) : isubst(i) {}
|
||||
|
||||
virtual void mk_lt(poly const& p, app_ref& r) { r = mk_lt(p, p.size()); }
|
||||
void mk_lt(poly const& p, app_ref& r) override { r = mk_lt(p, p.size()); }
|
||||
|
||||
// /\ p[i] = 0
|
||||
virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); }
|
||||
void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1514,9 +1514,9 @@ namespace nlarith {
|
|||
new_atoms.reset();
|
||||
app_ref tmp(m());
|
||||
expr_ref_vector conjs(m());
|
||||
mk_exists_zero(literals, true, 0, conjs, new_atoms);
|
||||
mk_exists_zero(literals, true, nullptr, conjs, new_atoms);
|
||||
mk_same_sign (literals, true, conjs, new_atoms);
|
||||
mk_exists_zero(literals, false, 0, conjs, new_atoms);
|
||||
mk_exists_zero(literals, false, nullptr, conjs, new_atoms);
|
||||
mk_same_sign (literals, false, conjs, new_atoms);
|
||||
mk_lt(literals.x(), literals.x_inf(), conjs, new_atoms);
|
||||
mk_lt(literals.x_sup(), literals.x(), conjs, new_atoms);
|
||||
|
@ -1615,9 +1615,9 @@ namespace nlarith {
|
|||
public:
|
||||
simple_branch(ast_manager& m, app* cnstr):
|
||||
m_cnstr(cnstr, m), m_atoms(m) {}
|
||||
virtual ~simple_branch() {}
|
||||
virtual app* get_constraint() { return m_cnstr.get(); }
|
||||
virtual void get_updates(ptr_vector<app>& atoms, svector<util::atom_update>& updates) {
|
||||
~simple_branch() override {}
|
||||
app* get_constraint() override { return m_cnstr.get(); }
|
||||
void get_updates(ptr_vector<app>& atoms, svector<util::atom_update>& updates) override {
|
||||
for (unsigned i = 0; i < m_atoms.size(); ++i) {
|
||||
atoms.push_back(m_atoms[i].get());
|
||||
updates.push_back(m_updates[i]);
|
||||
|
@ -1635,7 +1635,7 @@ namespace nlarith {
|
|||
public:
|
||||
ins_rem_branch(ast_manager& m, app* a, app* r, app* cnstr):
|
||||
simple_branch(m, cnstr) { insert(a); remove(r); }
|
||||
virtual ~ins_rem_branch() {}
|
||||
~ins_rem_branch() override {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1922,7 +1922,7 @@ namespace nlarith {
|
|||
}
|
||||
extract_non_linear(atms.size(), atms.begin(), nlvars);
|
||||
if (nlvars.empty()) {
|
||||
lits = 0;
|
||||
lits = nullptr;
|
||||
return true;
|
||||
}
|
||||
app* x = nlvars.back();
|
||||
|
@ -1930,11 +1930,11 @@ namespace nlarith {
|
|||
expr* const* _atoms = (expr*const*)atms.begin();
|
||||
lits = alloc(util::literal_set, m());
|
||||
lits->set_x(x);
|
||||
if (get_polys(contains_x, atms.size(), _atoms, lits->polys(), lits->comps(), 0, &lits->lits())) {
|
||||
if (get_polys(contains_x, atms.size(), _atoms, lits->polys(), lits->comps(), nullptr, &lits->lits())) {
|
||||
return true;
|
||||
}
|
||||
dealloc(lits);
|
||||
lits = 0;
|
||||
lits = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
|
||||
void reset() {
|
||||
void reset() override {
|
||||
//m_solver.reset();
|
||||
m_asms.reset();
|
||||
m_cached_asms.reset();
|
||||
|
@ -764,7 +764,7 @@ namespace qe {
|
|||
for (; it != end; ++it) {
|
||||
expr * a = it->m_key;
|
||||
nlsat::bool_var b = it->m_value;
|
||||
if (a == 0 || !is_uninterp_const(a) || b == m_is_true.var() || !m_free_vars.contains(a) || m_aux_vars.contains(a))
|
||||
if (a == nullptr || !is_uninterp_const(a) || b == m_is_true.var() || !m_free_vars.contains(a) || m_aux_vars.contains(a))
|
||||
continue;
|
||||
lbool val = m_bmodel0.get(b, l_undef);
|
||||
if (val == l_undef)
|
||||
|
@ -780,8 +780,8 @@ namespace qe {
|
|||
m(m),
|
||||
m_mode(mode),
|
||||
m_params(p),
|
||||
m_solver(m.limit(), p),
|
||||
m_nftactic(0),
|
||||
m_solver(m.limit(), p, true),
|
||||
m_nftactic(nullptr),
|
||||
m_rmodel(m_solver.am()),
|
||||
m_rmodel0(m_solver.am()),
|
||||
m_valid_model(false),
|
||||
|
@ -796,21 +796,21 @@ namespace qe {
|
|||
m_nftactic = mk_tseitin_cnf_tactic(m);
|
||||
}
|
||||
|
||||
virtual ~nlqsat() {
|
||||
~nlqsat() override {
|
||||
}
|
||||
|
||||
void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
params_ref p2(p);
|
||||
p2.set_bool("factor", false);
|
||||
m_solver.updt_params(p2);
|
||||
}
|
||||
|
||||
void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
}
|
||||
|
||||
|
||||
void operator()(/* in */ goal_ref const & in,
|
||||
/* out */ goal_ref_buffer & result) {
|
||||
/* out */ goal_ref_buffer & result) override {
|
||||
|
||||
tactic_report report("nlqsat-tactic", *in);
|
||||
|
||||
|
@ -859,197 +859,29 @@ namespace qe {
|
|||
}
|
||||
|
||||
|
||||
void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
st.copy(m_st);
|
||||
st.update("qsat num rounds", m_stats.m_num_rounds);
|
||||
}
|
||||
|
||||
void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
m_stats.reset();
|
||||
m_solver.reset_statistics();
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
void cleanup() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
void set_logic(symbol const & l) {
|
||||
void set_logic(symbol const & l) override {
|
||||
}
|
||||
|
||||
void set_progress_callback(progress_callback * callback) {
|
||||
void set_progress_callback(progress_callback * callback) override {
|
||||
}
|
||||
|
||||
tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(nlqsat, m, m_mode, m_params);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/**
|
||||
|
||||
Algorithm:
|
||||
I := true
|
||||
while there is M, such that M |= ~B & I:
|
||||
find P, such that M => P => exists y . ~B & I
|
||||
; forall y B => ~P
|
||||
C := core of P with respect to A
|
||||
; A => ~ C => ~ P
|
||||
I := I & ~C
|
||||
|
||||
|
||||
Alternative Algorithm:
|
||||
R := false
|
||||
while there is M, such that M |= A & ~R:
|
||||
find I, such that M => I => forall y . B
|
||||
R := R | I
|
||||
|
||||
*/
|
||||
|
||||
lbool interpolate(expr* a, expr* b, expr_ref& result) {
|
||||
SASSERT(m_mode == interp_t);
|
||||
|
||||
reset();
|
||||
app_ref enableA(m), enableB(m);
|
||||
expr_ref A(m), B(m), fml(m);
|
||||
expr_ref_vector fmls(m), answer(m);
|
||||
|
||||
// varsB are private to B.
|
||||
nlsat::var_vector vars;
|
||||
uint_set fvars;
|
||||
private_vars(a, b, vars, fvars);
|
||||
|
||||
enableA = m.mk_const(symbol("#A"), m.mk_bool_sort());
|
||||
enableB = m.mk_not(enableA);
|
||||
A = m.mk_implies(enableA, a);
|
||||
B = m.mk_implies(enableB, m.mk_not(b));
|
||||
fml = m.mk_and(A, B);
|
||||
hoist(fml);
|
||||
|
||||
|
||||
|
||||
nlsat::literal _enableB = nlsat::literal(m_a2b.to_var(enableB), false);
|
||||
nlsat::literal _enableA = ~_enableB;
|
||||
|
||||
while (true) {
|
||||
m_mode = qsat_t;
|
||||
// enable B
|
||||
m_assumptions.reset();
|
||||
m_assumptions.push_back(_enableB);
|
||||
lbool is_sat = check_sat();
|
||||
|
||||
switch (is_sat) {
|
||||
case l_undef:
|
||||
return l_undef;
|
||||
case l_true:
|
||||
break;
|
||||
case l_false:
|
||||
result = mk_and(answer);
|
||||
return l_true;
|
||||
}
|
||||
|
||||
// disable B, enable A
|
||||
m_assumptions.reset();
|
||||
m_assumptions.push_back(_enableA);
|
||||
// add blocking clause to solver.
|
||||
|
||||
nlsat::scoped_literal_vector core(m_solver);
|
||||
|
||||
m_mode = elim_t;
|
||||
|
||||
mbp(vars, fvars, core);
|
||||
|
||||
// minimize core.
|
||||
nlsat::literal_vector _core(core.size(), core.c_ptr());
|
||||
_core.push_back(_enableA);
|
||||
is_sat = m_solver.check(_core); // TBD: only for quantifier-free A. Generalize output of elim_t to be a core.
|
||||
switch (is_sat) {
|
||||
case l_undef:
|
||||
return l_undef;
|
||||
case l_true:
|
||||
UNREACHABLE();
|
||||
case l_false:
|
||||
core.reset();
|
||||
core.append(_core.size(), _core.c_ptr());
|
||||
break;
|
||||
}
|
||||
negate_clause(core);
|
||||
// keep polarity of enableA, such that clause is only
|
||||
// used when checking satisfiability of B.
|
||||
for (unsigned i = 0; i < core.size(); ++i) {
|
||||
if (core[i].var() == _enableA.var()) core.set(i, ~core[i]);
|
||||
}
|
||||
add_clause(core); // Invariant is added as assumption for B.
|
||||
answer.push_back(clause2fml(core)); // TBD: remove answer literal.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief extract variables that are private to a (not used in b).
|
||||
vars cover the real variables, and fvars cover the Boolean variables.
|
||||
|
||||
TBD: We want fvars to be the complement such that returned core contains
|
||||
Shared boolean variables, but not the ones private to B.
|
||||
*/
|
||||
void private_vars(expr* a, expr* b, nlsat::var_vector& vars, uint_set& fvars) {
|
||||
app_ref_vector varsA(m), varsB(m);
|
||||
obj_hashtable<expr> varsAS;
|
||||
pred_abs abs(m);
|
||||
abs.get_free_vars(a, varsA);
|
||||
abs.get_free_vars(b, varsB);
|
||||
insert_set(varsAS, varsA);
|
||||
for (unsigned i = 0; i < varsB.size(); ++i) {
|
||||
if (varsAS.contains(varsB[i].get())) {
|
||||
varsB[i] = varsB.back();
|
||||
varsB.pop_back();
|
||||
--i;
|
||||
}
|
||||
}
|
||||
for (unsigned j = 0; j < varsB.size(); ++j) {
|
||||
app* v = varsB[j].get();
|
||||
if (m_a2b.is_var(v)) {
|
||||
fvars.insert(m_a2b.to_var(v));
|
||||
}
|
||||
else if (m_t2x.is_var(v)) {
|
||||
vars.push_back(m_t2x.to_var(v));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lbool maximize(app* _x, expr* _fml, scoped_anum& result, bool& unbounded) {
|
||||
expr_ref fml(_fml, m);
|
||||
reset();
|
||||
hoist(fml);
|
||||
nlsat::literal_vector lits;
|
||||
lbool is_sat = l_true;
|
||||
nlsat::var x = m_t2x.to_var(_x);
|
||||
m_mode = qsat_t;
|
||||
while (is_sat == l_true) {
|
||||
is_sat = check_sat();
|
||||
if (is_sat == l_true) {
|
||||
// m_asms is minimized set of literals that satisfy formula.
|
||||
nlsat::explain& ex = m_solver.get_explain();
|
||||
polynomial::manager& pm = m_solver.pm();
|
||||
anum_manager& am = m_solver.am();
|
||||
ex.maximize(x, m_asms.size(), m_asms.c_ptr(), result, unbounded);
|
||||
if (unbounded) {
|
||||
break;
|
||||
}
|
||||
// TBD: assert the new bound on x using the result.
|
||||
bool is_even = false;
|
||||
polynomial::polynomial_ref pr(pm);
|
||||
pr = pm.mk_polynomial(x);
|
||||
rational r;
|
||||
am.get_upper(result, r);
|
||||
// result is algebraic numeral, but polynomials are not defined over extension field.
|
||||
polynomial::polynomial* p = pr;
|
||||
nlsat::bool_var b = m_solver.mk_ineq_atom(nlsat::atom::GT, 1, &p, &is_even);
|
||||
nlsat::literal bound(b, false);
|
||||
m_solver.mk_clause(1, &bound);
|
||||
}
|
||||
}
|
||||
return is_sat;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
|
177
src/qe/qe.cpp
177
src/qe/qe.cpp
|
@ -130,8 +130,7 @@ namespace qe {
|
|||
visited.mark(e, true);
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < conjs.size(); ++i) {
|
||||
expr* e = conjs[i].get();
|
||||
for (expr* e : conjs) {
|
||||
bool cv = contains_var.is_marked(e);
|
||||
bool cu = contains_uf.is_marked(e);
|
||||
if (cv && cu) {
|
||||
|
@ -362,7 +361,7 @@ namespace qe {
|
|||
}
|
||||
app* ite;
|
||||
if (find_ite(fml, ite)) {
|
||||
expr* cond = 0, *th = 0, *el = 0;
|
||||
expr* cond = nullptr, *th = nullptr, *el = nullptr;
|
||||
VERIFY(m.is_ite(ite, cond, th, el));
|
||||
expr_ref tmp1(fml, m), tmp2(fml, m);
|
||||
m_replace->apply_substitution(ite, th, tmp1);
|
||||
|
@ -449,7 +448,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
expr* lookup(expr* e, bool p) {
|
||||
expr* r = 0;
|
||||
expr* r = nullptr;
|
||||
if (p && m_pos.find(e, r)) {
|
||||
return r;
|
||||
}
|
||||
|
@ -458,7 +457,7 @@ namespace qe {
|
|||
}
|
||||
m_todo.push_back(e);
|
||||
m_pols.push_back(p);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void insert(expr* e, bool p, expr* r) {
|
||||
|
@ -688,7 +687,7 @@ namespace qe {
|
|||
|
||||
bool visit(app* e) {
|
||||
bool all_visit = true;
|
||||
expr* f = 0;
|
||||
expr* f = nullptr;
|
||||
expr_ref tmp(m);
|
||||
if (!m_is_relevant(e)) {
|
||||
m_cache.insert(e, e);
|
||||
|
@ -971,7 +970,7 @@ namespace qe {
|
|||
|
||||
app* var() const { SASSERT(has_var()); return m_var; }
|
||||
|
||||
bool has_var() const { return 0 != m_var.get(); }
|
||||
bool has_var() const { return nullptr != m_var.get(); }
|
||||
|
||||
search_tree* parent() const { return m_parent; }
|
||||
|
||||
|
@ -989,11 +988,11 @@ namespace qe {
|
|||
todo.pop_back();
|
||||
if (st->m_children.empty() && st->fml() &&
|
||||
st->m_vars.empty() && !st->has_var()) {
|
||||
TRACE("qe", st->display(tout << "appending leaf\n"););
|
||||
result.push_back(st->fml());
|
||||
}
|
||||
for (unsigned i = 0; i < st->m_children.size(); ++i) {
|
||||
todo.push_back(st->m_children[i]);
|
||||
}
|
||||
for (auto * ch : st->m_children)
|
||||
todo.push_back(ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1020,15 +1019,13 @@ namespace qe {
|
|||
|
||||
void reset() {
|
||||
TRACE("qe",tout << "resetting\n";);
|
||||
for (unsigned i = 0; i < m_children.size(); ++i) {
|
||||
dealloc(m_children[i]);
|
||||
}
|
||||
for (auto* ch : m_children) dealloc(ch);
|
||||
m_pos.reset();
|
||||
m_neg.reset();
|
||||
m_children.reset();
|
||||
m_vars.reset();
|
||||
m_branch_index.reset();
|
||||
m_var = 0;
|
||||
m_var = nullptr;
|
||||
m_def.reset();
|
||||
m_num_branches = rational::zero();
|
||||
m_pure = true;
|
||||
|
@ -1046,9 +1043,10 @@ namespace qe {
|
|||
}
|
||||
|
||||
unsigned num_free_vars() const { return m_vars.size(); }
|
||||
app* const* free_vars() const { return m_vars.c_ptr(); }
|
||||
// app* const* free_vars() const { return m_vars.c_ptr(); }
|
||||
app_ref_vector const& free_vars() const { return m_vars; }
|
||||
app* free_var(unsigned i) const { return m_vars[i]; }
|
||||
void reset_free_vars() { m_vars.reset(); }
|
||||
void reset_free_vars() { TRACE("qe", tout << m_vars << "\n";); m_vars.reset(); }
|
||||
|
||||
atom_set const& pos_atoms() const { return m_pos; }
|
||||
atom_set const& neg_atoms() const { return m_neg; }
|
||||
|
@ -1119,7 +1117,7 @@ namespace qe {
|
|||
st->init(fml);
|
||||
st->m_vars.append(m_vars.size(), m_vars.c_ptr());
|
||||
SASSERT(invariant());
|
||||
TRACE("qe", tout << mk_pp(m_fml, m) << " child: " << mk_pp(fml, m) << "\n";);
|
||||
TRACE("qe", display_node(tout); st->display_node(tout););
|
||||
return st;
|
||||
}
|
||||
|
||||
|
@ -1133,7 +1131,7 @@ namespace qe {
|
|||
m_branch_index.insert(branch_id, index);
|
||||
st->m_vars.append(m_vars.size(), m_vars.c_ptr());
|
||||
SASSERT(invariant());
|
||||
//TRACE("qe", tout << mk_pp(m_fml, m) << " child: " << mk_pp(st->fml(), m) << "\n";);
|
||||
TRACE("qe", display_node(tout); st->display_node(tout););
|
||||
return st;
|
||||
}
|
||||
|
||||
|
@ -1141,27 +1139,29 @@ namespace qe {
|
|||
display(out, "");
|
||||
}
|
||||
|
||||
void display(std::ostream& out, char const* indent) const {
|
||||
|
||||
out << indent << "node\n";
|
||||
void display_node(std::ostream& out, char const* indent = "") const {
|
||||
out << indent << "node " << std::hex << this << std::dec << "\n";
|
||||
if (m_var) {
|
||||
out << indent << " var: " << mk_ismt2_pp(m_var.get(), m) << "\n";
|
||||
out << indent << " var: " << m_var << "\n";
|
||||
}
|
||||
for (unsigned i = 0; i < m_vars.size(); ++i) {
|
||||
out << indent << " free: " << mk_ismt2_pp(m_vars[i], m) << "\n";
|
||||
for (app* v : m_vars) {
|
||||
out << indent << " free: " << mk_pp(v, m) << "\n";
|
||||
}
|
||||
if (m_fml) {
|
||||
out << indent << " fml: " << mk_ismt2_pp(m_fml.get(), m) << "\n";
|
||||
out << indent << " fml: " << m_fml << "\n";
|
||||
}
|
||||
for (unsigned i = 0; i < m_def.size(); ++i) {
|
||||
out << indent << " def: " << m_def.var(i)->get_name() << " = " << mk_ismt2_pp(m_def.def(i), m) << "\n";
|
||||
}
|
||||
out << indent << " branches: " << m_num_branches << "\n";
|
||||
}
|
||||
|
||||
void display(std::ostream& out, char const* indent) const {
|
||||
display_node(out, indent);
|
||||
std::string new_indent(indent);
|
||||
new_indent += " ";
|
||||
for (unsigned i = 0; i < m_children.size(); ++i) {
|
||||
m_children[i]->display(out, new_indent.c_str());
|
||||
for (auto * ch : m_children) {
|
||||
ch->display(out, new_indent.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1214,6 +1214,7 @@ namespace qe {
|
|||
out << "(push)\n";
|
||||
pp.display_smt2(out, fml);
|
||||
out << "(pop)\n\n";
|
||||
#if 0
|
||||
DEBUG_CODE(
|
||||
smt_params params;
|
||||
params.m_simplify_bit2int = true;
|
||||
|
@ -1227,7 +1228,8 @@ namespace qe {
|
|||
std::cout << "; Validation failed:\n";
|
||||
std::cout << mk_pp(fml, m) << "\n";
|
||||
}
|
||||
);
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
for (unsigned i = 0; i < m_children.size(); ++i) {
|
||||
|
@ -1369,11 +1371,11 @@ namespace qe {
|
|||
m_trail(m),
|
||||
m_fml(m),
|
||||
m_subfml(m),
|
||||
m_root(0, m, m.mk_true()),
|
||||
m_current(0),
|
||||
m_root(nullptr, m, m.mk_true()),
|
||||
m_current(nullptr),
|
||||
m_new_vars(m),
|
||||
m_get_first(false),
|
||||
m_defs(0),
|
||||
m_defs(nullptr),
|
||||
m_nnf(m, get_is_relevant(), get_mk_atom())
|
||||
{
|
||||
params_ref params;
|
||||
|
@ -1381,7 +1383,7 @@ namespace qe {
|
|||
m_rewriter.updt_params(params);
|
||||
}
|
||||
|
||||
virtual ~quant_elim_plugin() {
|
||||
~quant_elim_plugin() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -1396,8 +1398,8 @@ namespace qe {
|
|||
m_var2branch.reset();
|
||||
m_root.reset();
|
||||
m_new_vars.reset();
|
||||
m_fml = 0;
|
||||
m_defs = 0;
|
||||
m_fml = nullptr;
|
||||
m_defs = nullptr;
|
||||
m_nnf.reset();
|
||||
}
|
||||
|
||||
|
@ -1486,9 +1488,7 @@ namespace qe {
|
|||
tout << "subformula: " << mk_ismt2_pp(m_subfml, m) << "\n";
|
||||
m_root.display(tout);
|
||||
m_root.display_validate(tout);
|
||||
for (unsigned i = 0; i < m_free_vars.size(); ++i) tout << mk_ismt2_pp(m_free_vars[i].get(), m) << " ";
|
||||
tout << "\n";
|
||||
);
|
||||
tout << "free: " << m_free_vars << "\n";);
|
||||
|
||||
free_vars.append(m_free_vars);
|
||||
if (!m_free_vars.empty() || m_solver.inconsistent()) {
|
||||
|
@ -1501,7 +1501,7 @@ namespace qe {
|
|||
}
|
||||
reset();
|
||||
m_solver.pop(1);
|
||||
f = 0;
|
||||
f = nullptr;
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) {
|
||||
|
@ -1536,24 +1536,24 @@ namespace qe {
|
|||
pop(*model_eval);
|
||||
}
|
||||
|
||||
ast_manager& get_manager() { return m; }
|
||||
ast_manager& get_manager() override { return m; }
|
||||
|
||||
atom_set const& pos_atoms() const { return m_current->pos_atoms(); }
|
||||
atom_set const& pos_atoms() const override { return m_current->pos_atoms(); }
|
||||
|
||||
atom_set const& neg_atoms() const { return m_current->neg_atoms(); }
|
||||
atom_set const& neg_atoms() const override { return m_current->neg_atoms(); }
|
||||
|
||||
unsigned get_num_vars() const { return m_current->num_free_vars(); }
|
||||
unsigned get_num_vars() const override { return m_current->num_free_vars(); }
|
||||
|
||||
app* get_var(unsigned idx) const { return m_current->free_var(idx); }
|
||||
app* get_var(unsigned idx) const override { return m_current->free_var(idx); }
|
||||
|
||||
app* const* get_vars() const { return m_current->free_vars(); }
|
||||
app_ref_vector const& get_vars() const override { return m_current->free_vars(); }
|
||||
|
||||
contains_app& contains(unsigned idx) { return contains(get_var(idx)); }
|
||||
contains_app& contains(unsigned idx) override { return contains(get_var(idx)); }
|
||||
|
||||
//
|
||||
// The variable at idx is eliminated (without branching).
|
||||
//
|
||||
void elim_var(unsigned idx, expr* _fml, expr* def) {
|
||||
void elim_var(unsigned idx, expr* _fml, expr* def) override {
|
||||
app* x = get_var(idx);
|
||||
expr_ref fml(_fml, m);
|
||||
TRACE("qe", tout << mk_pp(x,m) << " " << mk_pp(def, m) << "\n";);
|
||||
|
@ -1564,14 +1564,14 @@ namespace qe {
|
|||
normalize(*m_current);
|
||||
}
|
||||
|
||||
void add_var(app* x) {
|
||||
void add_var(app* x) override {
|
||||
m_new_vars.push_back(x);
|
||||
if (m_var2branch.contains(x)) {
|
||||
return;
|
||||
}
|
||||
contains_app* ca = alloc(contains_app, m, x);
|
||||
m_var2contains.insert(x, ca);
|
||||
app* bv = 0;
|
||||
app* bv = nullptr;
|
||||
if (m.is_bool(x) || m_bv.is_bv(x)) {
|
||||
bv = x;
|
||||
}
|
||||
|
@ -1583,7 +1583,7 @@ namespace qe {
|
|||
m_var2branch.insert(x, bv);
|
||||
}
|
||||
|
||||
virtual void add_constraint(bool use_current_val, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) {
|
||||
void add_constraint(bool use_current_val, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override {
|
||||
search_tree* node = m_current;
|
||||
if (!use_current_val) {
|
||||
node = m_current->parent();
|
||||
|
@ -1598,12 +1598,12 @@ namespace qe {
|
|||
add_literal(l3);
|
||||
expr_ref fml(m);
|
||||
fml = m.mk_or(m_literals.size(), m_literals.c_ptr());
|
||||
TRACE("qe", tout << mk_ismt2_pp(fml, m) << "\n";);
|
||||
TRACE("qe", tout << fml << "\n";);
|
||||
m_solver.assert_expr(fml);
|
||||
}
|
||||
|
||||
void blast_or(app* var, expr_ref& fml) {
|
||||
m_qe.eliminate_exists(1, &var, fml, m_free_vars, false, 0);
|
||||
void blast_or(app* var, expr_ref& fml) override {
|
||||
m_qe.eliminate_exists(1, &var, fml, m_free_vars, false, nullptr);
|
||||
}
|
||||
|
||||
lbool eliminate_exists(unsigned num_vars, app* const* vars, expr_ref& fml, bool get_first, guarded_defs* defs) {
|
||||
|
@ -1613,7 +1613,7 @@ namespace qe {
|
|||
private:
|
||||
|
||||
void add_literal(expr* l) {
|
||||
if (l != 0) {
|
||||
if (l != nullptr) {
|
||||
m_literals.push_back(l);
|
||||
}
|
||||
}
|
||||
|
@ -1654,9 +1654,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
app* get_branch_id(app* x) {
|
||||
app* result = 0;
|
||||
VERIFY (m_var2branch.find(x, result));
|
||||
return result;
|
||||
return m_var2branch[x];
|
||||
}
|
||||
|
||||
bool extract_partition(ptr_vector<app>& vars) {
|
||||
|
@ -1707,11 +1705,11 @@ namespace qe {
|
|||
return NEED_PROPAGATION;
|
||||
}
|
||||
m_current = m_current->child(branch);
|
||||
if (m_current->fml() == 0) {
|
||||
if (m_current->fml() == nullptr) {
|
||||
SASSERT(!m_current->has_var());
|
||||
if (apply) {
|
||||
expr_ref def(m);
|
||||
plugin(x).subst(contains(x), branch, fml, m_defs?&def:0);
|
||||
plugin(x).subst(contains(x), branch, fml, m_defs?&def:nullptr);
|
||||
SASSERT(!contains(x)(fml));
|
||||
m_current->consume_vars(m_new_vars);
|
||||
m_current->init(fml);
|
||||
|
@ -1912,6 +1910,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
m_current->set_var(x, k);
|
||||
TRACE("qe", tout << mk_pp(x, m) << " := " << k << "\n";);
|
||||
if (m_bv.is_bv(x)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1952,7 +1951,7 @@ namespace qe {
|
|||
vars.reset();
|
||||
closed = closed && (r != l_undef);
|
||||
}
|
||||
TRACE("qe", tout << mk_pp(fml, m) << "\n";);
|
||||
TRACE("qe", tout << fml << " free: " << m_current->free_vars() << "\n";);
|
||||
m_current->add_child(fml)->reset_free_vars();
|
||||
block_assignment();
|
||||
}
|
||||
|
@ -1961,9 +1960,7 @@ namespace qe {
|
|||
// variable queueing.
|
||||
|
||||
contains_app& contains(app* x) {
|
||||
contains_app* result = 0;
|
||||
VERIFY(m_var2contains.find(x, result));
|
||||
return *result;
|
||||
return *m_var2contains[x];
|
||||
}
|
||||
|
||||
bool find_min_weight(app*& x, rational& num_branches) {
|
||||
|
@ -2003,6 +2000,7 @@ namespace qe {
|
|||
bool solved = true;
|
||||
while (solved) {
|
||||
expr_ref fml(m_current->fml(), m);
|
||||
TRACE("qe", tout << fml << "\n";);
|
||||
conj_enum conjs(m, fml);
|
||||
solved = false;
|
||||
for (unsigned i = 0; !solved && i < m_plugins.size(); ++i) {
|
||||
|
@ -2037,7 +2035,7 @@ namespace qe {
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~quant_elim_new() {
|
||||
~quant_elim_new() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -2054,17 +2052,17 @@ namespace qe {
|
|||
}
|
||||
|
||||
|
||||
void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
for (unsigned i = 0; i < m_plugins.size(); ++i) {
|
||||
m_plugins[i]->collect_statistics(st);
|
||||
}
|
||||
}
|
||||
|
||||
void updt_params(params_ref const& p) {
|
||||
void updt_params(params_ref const& p) override {
|
||||
m_eliminate_variables_as_block = p.get_bool("eliminate_variables_as_block", m_eliminate_variables_as_block);
|
||||
}
|
||||
|
||||
void eliminate(bool is_forall, unsigned num_vars, app* const* vars, expr_ref& fml) {
|
||||
void eliminate(bool is_forall, unsigned num_vars, app* const* vars, expr_ref& fml) override {
|
||||
if (is_forall) {
|
||||
eliminate_forall_bind(num_vars, vars, fml);
|
||||
}
|
||||
|
@ -2094,14 +2092,14 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void set_assumption(expr* fml) {
|
||||
void set_assumption(expr* fml) override {
|
||||
m_assumption = fml;
|
||||
}
|
||||
|
||||
|
||||
virtual lbool eliminate_exists(
|
||||
lbool eliminate_exists(
|
||||
unsigned num_vars, app* const* vars, expr_ref& fml,
|
||||
app_ref_vector& free_vars, bool get_first, guarded_defs* defs) {
|
||||
app_ref_vector& free_vars, bool get_first, guarded_defs* defs) override {
|
||||
if (get_first) {
|
||||
return eliminate_block(num_vars, vars, fml, free_vars, get_first, defs);
|
||||
}
|
||||
|
@ -2199,7 +2197,7 @@ namespace qe {
|
|||
void eliminate_exists_bind(unsigned num_vars, app* const* vars, expr_ref& fml) {
|
||||
checkpoint();
|
||||
app_ref_vector free_vars(m);
|
||||
eliminate_exists(num_vars, vars, fml, free_vars, false, 0);
|
||||
eliminate_exists(num_vars, vars, fml, free_vars, false, nullptr);
|
||||
bind_variables(free_vars.size(), free_vars.c_ptr(), fml);
|
||||
}
|
||||
|
||||
|
@ -2221,7 +2219,7 @@ namespace qe {
|
|||
m_fparams(fp),
|
||||
m_params(p),
|
||||
m_trail(m),
|
||||
m_qe(0),
|
||||
m_qe(nullptr),
|
||||
m_assumption(m.mk_true())
|
||||
{
|
||||
}
|
||||
|
@ -2304,7 +2302,7 @@ namespace qe {
|
|||
|
||||
m_trail.push_back(result);
|
||||
todo.push_back(result);
|
||||
expr* e = 0, *r = 0;
|
||||
expr* e = nullptr, *r = nullptr;
|
||||
|
||||
while (!todo.empty()) {
|
||||
e = todo.back();
|
||||
|
@ -2474,8 +2472,8 @@ namespace qe {
|
|||
public:
|
||||
simplify_solver_context(ast_manager& m):
|
||||
m(m),
|
||||
m_vars(0),
|
||||
m_fml(0)
|
||||
m_vars(nullptr),
|
||||
m_fml(nullptr)
|
||||
{
|
||||
add_plugin(mk_bool_plugin(*this));
|
||||
add_plugin(mk_arith_plugin(*this, false, m_fparams));
|
||||
|
@ -2485,7 +2483,7 @@ namespace qe {
|
|||
m_fparams.updt_params(p);
|
||||
}
|
||||
|
||||
virtual ~simplify_solver_context() { reset(); }
|
||||
~simplify_solver_context() override { reset(); }
|
||||
|
||||
|
||||
void solve(expr_ref& fml, app_ref_vector& vars) {
|
||||
|
@ -2504,16 +2502,16 @@ namespace qe {
|
|||
while (solved);
|
||||
}
|
||||
|
||||
virtual ast_manager& get_manager() { return m; }
|
||||
ast_manager& get_manager() override { return m; }
|
||||
|
||||
virtual atom_set const& pos_atoms() const { return m_pos; }
|
||||
virtual atom_set const& neg_atoms() const { return m_neg; }
|
||||
atom_set const& pos_atoms() const override { return m_pos; }
|
||||
atom_set const& neg_atoms() const override { return m_neg; }
|
||||
|
||||
// Access current set of variables to solve
|
||||
virtual unsigned get_num_vars() const { return m_vars->size(); }
|
||||
virtual app* get_var(unsigned idx) const { return (*m_vars)[idx].get(); }
|
||||
virtual app*const* get_vars() const { return m_vars->c_ptr(); }
|
||||
virtual bool is_var(expr* e, unsigned& idx) const {
|
||||
unsigned get_num_vars() const override { return m_vars->size(); }
|
||||
app* get_var(unsigned idx) const override { return (*m_vars)[idx].get(); }
|
||||
app_ref_vector const& get_vars() const override { return *m_vars; }
|
||||
bool is_var(expr* e, unsigned& idx) const override {
|
||||
for (unsigned i = 0; i < m_vars->size(); ++i) {
|
||||
if ((*m_vars)[i].get() == e) {
|
||||
idx = i;
|
||||
|
@ -2523,12 +2521,12 @@ namespace qe {
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual contains_app& contains(unsigned idx) {
|
||||
contains_app& contains(unsigned idx) override {
|
||||
return *m_contains[idx];
|
||||
}
|
||||
|
||||
// callback to replace variable at index 'idx' with definition 'def' and updated formula 'fml'
|
||||
virtual void elim_var(unsigned idx, expr* fml, expr* def) {
|
||||
void elim_var(unsigned idx, expr* fml, expr* def) override {
|
||||
TRACE("qe", tout << mk_pp(m_vars->get(idx), m) << " " << mk_pp(fml, m) << "\n";);
|
||||
*m_fml = fml;
|
||||
m_vars->set(idx, m_vars->get(m_vars->size()-1));
|
||||
|
@ -2539,16 +2537,17 @@ namespace qe {
|
|||
}
|
||||
|
||||
// callback to add new variable to branch.
|
||||
virtual void add_var(app* x) {
|
||||
void add_var(app* x) override {
|
||||
TRACE("qe", tout << "add var: " << mk_pp(x, m) << "\n";);
|
||||
m_vars->push_back(x);
|
||||
}
|
||||
|
||||
// callback to add constraints in branch.
|
||||
virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) {
|
||||
void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
// eliminate finite domain variable 'var' from fml.
|
||||
virtual void blast_or(app* var, expr_ref& fml) {
|
||||
void blast_or(app* var, expr_ref& fml) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
@ -2606,7 +2605,7 @@ namespace qe {
|
|||
}
|
||||
m_ctx.solve(result, vars);
|
||||
if (old_q->is_forall()) {
|
||||
expr* e = 0;
|
||||
expr* e = nullptr;
|
||||
result = m.is_not(result, e)?e:mk_not(m, result);
|
||||
}
|
||||
var_shifter shift(m);
|
||||
|
@ -2622,7 +2621,7 @@ namespace qe {
|
|||
if (!vars.empty()) {
|
||||
result = m.mk_quantifier(old_q->is_forall(), vars.size(), sorts.c_ptr(), names.c_ptr(), result, 1);
|
||||
}
|
||||
result_pr = 0;
|
||||
result_pr = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ namespace qe {
|
|||
i_solver_context& m_s;
|
||||
public:
|
||||
is_relevant(i_solver_context& s):m_s(s) {}
|
||||
virtual bool operator()(expr* e);
|
||||
bool operator()(expr* e) override;
|
||||
};
|
||||
class mk_atom_fn : public i_nnf_atom {
|
||||
i_solver_context& m_s;
|
||||
public:
|
||||
mk_atom_fn(i_solver_context& s) : m_s(s) {}
|
||||
void operator()(expr* e, bool p, expr_ref& result);
|
||||
void operator()(expr* e, bool p, expr_ref& result) override;
|
||||
};
|
||||
|
||||
is_relevant m_is_relevant;
|
||||
|
@ -86,7 +86,7 @@ namespace qe {
|
|||
// Access current set of variables to solve
|
||||
virtual unsigned get_num_vars() const = 0;
|
||||
virtual app* get_var(unsigned idx) const = 0;
|
||||
virtual app*const* get_vars() const = 0;
|
||||
virtual app_ref_vector const& get_vars() const = 0;
|
||||
virtual bool is_var(expr* e, unsigned& idx) const;
|
||||
virtual contains_app& contains(unsigned idx) = 0;
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace qe {
|
|||
virtual void add_var(app* x) = 0;
|
||||
|
||||
// callback to add constraints in branch.
|
||||
virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) = 0;
|
||||
virtual void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) = 0;
|
||||
|
||||
// eliminate finite domain variable 'var' from fml.
|
||||
virtual void blast_or(app* var, expr_ref& fml) = 0;
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace qe {
|
|||
map<rational, expr*, rational::hash_proc, rational::eq_proc> values;
|
||||
bool found_eq = false;
|
||||
for (unsigned i = 0; !found_eq && i < to_app(lit)->get_num_args(); ++i) {
|
||||
expr* arg1 = to_app(lit)->get_arg(i), *arg2 = 0;
|
||||
expr* arg1 = to_app(lit)->get_arg(i), *arg2 = nullptr;
|
||||
rational r;
|
||||
expr_ref val = eval(arg1);
|
||||
if (!a.is_numeral(val, r)) return false;
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace qe {
|
|||
imp* m_imp;
|
||||
public:
|
||||
arith_project_plugin(ast_manager& m);
|
||||
virtual ~arith_project_plugin();
|
||||
virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual family_id get_family_id();
|
||||
virtual void operator()(model& model, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
~arith_project_plugin() override;
|
||||
bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
family_id get_family_id() override;
|
||||
void operator()(model& model, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
|
||||
|
||||
opt::inf_eps maximize(expr_ref_vector const& fmls, model& mdl, app* t, expr_ref& ge, expr_ref& gt);
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace qe {
|
|||
public:
|
||||
arith_util m_arith; // initialize before m_zero_i, etc.
|
||||
th_rewriter simplify;
|
||||
app_ref_vector m_vars_added;
|
||||
private:
|
||||
arith_eq_solver m_arith_solver;
|
||||
bv_util m_bv;
|
||||
|
@ -126,6 +127,7 @@ namespace qe {
|
|||
m_ctx(ctx),
|
||||
m_arith(m),
|
||||
simplify(m),
|
||||
m_vars_added(m),
|
||||
m_arith_solver(m),
|
||||
m_bv(m),
|
||||
m_zero_i(m_arith.mk_numeral(numeral(0), true), m),
|
||||
|
@ -783,6 +785,11 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
void add_var(app* v, bool track = true) {
|
||||
m_ctx.add_var(v);
|
||||
if (track) m_vars_added.push_back(v);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
@ -850,10 +857,11 @@ namespace qe {
|
|||
<< mk_pp(result, m) << "\n";);
|
||||
}
|
||||
|
||||
|
||||
void mk_big_or_symbolic(numeral up, app* x, expr* body, expr_ref& result) {
|
||||
app_ref z_bv(m);
|
||||
mk_big_or_symbolic(up, x, body, z_bv, result);
|
||||
m_ctx.add_var(z_bv);
|
||||
add_var(z_bv);
|
||||
}
|
||||
|
||||
void mk_big_or_symbolic_blast(numeral up, app* x, expr* body, expr_ref& result) {
|
||||
|
@ -883,7 +891,7 @@ namespace qe {
|
|||
|
||||
while (m_arith.is_add(p)) {
|
||||
bool found_x = false;
|
||||
expr* next_p = 0;
|
||||
expr* next_p = nullptr;
|
||||
for (unsigned i = 0; i < to_app(p)->get_num_args(); ++i) {
|
||||
expr* arg = to_app(p)->get_arg(i);
|
||||
if (contains_x(arg)) {
|
||||
|
@ -999,9 +1007,9 @@ namespace qe {
|
|||
bool solve_linear(expr* p, expr* fml) {
|
||||
vector<numeral> values;
|
||||
unsigned num_vars = m_ctx.get_num_vars();
|
||||
app*const* vars_ptr = m_ctx.get_vars();
|
||||
app_ref_vector const& vars = m_ctx.get_vars();
|
||||
|
||||
if (!is_linear(p, num_vars, vars_ptr, values)) {
|
||||
if (!is_linear(p, num_vars, vars.c_ptr(), values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1025,7 +1033,7 @@ namespace qe {
|
|||
// it has coefficient 'm' = values[index].
|
||||
SASSERT(values[index] >= rational(3));
|
||||
z = m.mk_fresh_const("x", m_arith.mk_int());
|
||||
m_ctx.add_var(z);
|
||||
add_var(z);
|
||||
p1 = m_arith.mk_mul(m_arith.mk_numeral(values[index], true), z);
|
||||
}
|
||||
else {
|
||||
|
@ -1279,7 +1287,7 @@ namespace qe {
|
|||
m_div_coeffs.reset();
|
||||
m_div_divisors.reset();
|
||||
m_div_atoms.reset();
|
||||
m_div_z = 0;
|
||||
m_div_z = nullptr;
|
||||
m_nested_div_terms.reset();
|
||||
m_nested_div_coeffs.reset();
|
||||
m_nested_div_divisors.reset();
|
||||
|
@ -1475,16 +1483,18 @@ public:
|
|||
expr* m_result;
|
||||
rational m_coeff;
|
||||
expr* m_term;
|
||||
ptr_vector<app> m_vars;
|
||||
|
||||
branch_formula(): m_fml(0), m_var(0), m_branch(0), m_result(0), m_term(0) {}
|
||||
branch_formula(): m_fml(nullptr), m_var(nullptr), m_branch(0), m_result(nullptr), m_term(nullptr) {}
|
||||
|
||||
branch_formula(expr* fml, app* var, unsigned b, expr* r, rational coeff, expr* term):
|
||||
branch_formula(expr* fml, app* var, unsigned b, expr* r, rational coeff, expr* term, app_ref_vector const& vars):
|
||||
m_fml(fml),
|
||||
m_var(var),
|
||||
m_branch(b),
|
||||
m_result(r),
|
||||
m_coeff(coeff),
|
||||
m_term(term)
|
||||
m_term(term),
|
||||
m_vars(vars.size(), vars.c_ptr())
|
||||
{}
|
||||
|
||||
unsigned mk_hash() const {
|
||||
|
@ -1526,14 +1536,14 @@ public:
|
|||
m_trail(m)
|
||||
{}
|
||||
|
||||
~arith_plugin() {
|
||||
~arith_plugin() override {
|
||||
bounds_cache::iterator it = m_bounds_cache.begin(), end = m_bounds_cache.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->get_value());
|
||||
}
|
||||
}
|
||||
|
||||
virtual void assign(contains_app& contains_x, expr* fml, rational const& vl) {
|
||||
void assign(contains_app& contains_x, expr* fml, rational const& vl) override {
|
||||
SASSERT(vl.is_unsigned());
|
||||
app* x = contains_x.x();
|
||||
unsigned v = vl.get_unsigned();
|
||||
|
@ -1544,6 +1554,7 @@ public:
|
|||
if (get_cache(x, fml, v, result)) {
|
||||
return;
|
||||
}
|
||||
m_util.m_vars_added.reset();
|
||||
|
||||
bounds_proc& bounds = get_bounds(x, fml);
|
||||
bool is_lower = get_bound_sizes(bounds, x, t_size, e_size);
|
||||
|
@ -1601,8 +1612,7 @@ public:
|
|||
expr_ref t(bounds.exprs(is_strict, is_lower)[index], m);
|
||||
rational a = bounds.coeffs(is_strict, is_lower)[index];
|
||||
|
||||
|
||||
|
||||
|
||||
mk_bounds(bounds, x, true, is_eq, is_strict, is_lower, index, a, t, result);
|
||||
mk_bounds(bounds, x, false, is_eq, is_strict, is_lower, index, a, t, result);
|
||||
|
||||
|
@ -1617,13 +1627,13 @@ public:
|
|||
{
|
||||
tout << vl << " " << mk_pp(bounds.atoms(is_strict, is_lower)[index],m) << "\n";
|
||||
tout << mk_pp(fml, m) << "\n";
|
||||
tout << mk_pp(result, m) << "\n";
|
||||
tout << result << "\n";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
virtual bool get_num_branches(contains_app& contains_x, expr* fml, rational& nb) {
|
||||
bool get_num_branches(contains_app& contains_x, expr* fml, rational& nb) override {
|
||||
app* x = contains_x.x();
|
||||
if (!update_bounds(contains_x, fml)) {
|
||||
return false;
|
||||
|
@ -1635,16 +1645,16 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& contains_x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
void subst(contains_app& contains_x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
SASSERT(vl.is_unsigned());
|
||||
if (def) {
|
||||
if (def) {
|
||||
get_def(contains_x, vl.get_unsigned(), fml, *def);
|
||||
}
|
||||
VERIFY(get_cache(contains_x.x(), fml, vl.get_unsigned(), fml));
|
||||
TRACE("qe", tout << mk_pp(contains_x.x(), m) << " " << vl << "\n" << mk_pp(fml, m) << "\n";);
|
||||
}
|
||||
|
||||
virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) {
|
||||
bool project(contains_app& x, model_ref& model, expr_ref& fml) override {
|
||||
if (!update_bounds(x, fml)) {
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " failed to update bounds\n";);
|
||||
return false;
|
||||
|
@ -1658,19 +1668,19 @@ public:
|
|||
}
|
||||
|
||||
|
||||
virtual unsigned get_weight(contains_app& contains_x, expr* fml) {
|
||||
unsigned get_weight(contains_app& contains_x, expr* fml) override {
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual bool solve(conj_enum& conjs, expr* fml) {
|
||||
bool solve(conj_enum& conjs, expr* fml) override {
|
||||
return m_util.solve(conjs, fml);
|
||||
}
|
||||
|
||||
virtual bool mk_atom(expr* e, bool p, expr_ref& result) {
|
||||
bool mk_atom(expr* e, bool p, expr_ref& result) override {
|
||||
return m_util.mk_atom(e, p, result);
|
||||
}
|
||||
|
||||
virtual bool is_uninterpreted(app* f) {
|
||||
bool is_uninterpreted(app* f) override {
|
||||
switch(f->get_decl_kind()) {
|
||||
case OP_NUM:
|
||||
case OP_LE:
|
||||
|
@ -1740,7 +1750,7 @@ public:
|
|||
x_subst x_t(m_util);
|
||||
bounds_proc& bounds = get_bounds(x, fml);
|
||||
branch_formula bf;
|
||||
VERIFY (m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0), bf));
|
||||
VERIFY (m_subst.find(branch_formula(fml, x, v, nullptr, rational::zero(), nullptr, m_util.m_vars_added), bf));
|
||||
x_t.set_term(bf.m_term);
|
||||
x_t.set_coeff(bf.m_coeff);
|
||||
|
||||
|
@ -1939,7 +1949,7 @@ public:
|
|||
}
|
||||
}
|
||||
assign(x, fml, vl);
|
||||
subst(x, vl, fml, 0);
|
||||
subst(x, vl, fml, nullptr);
|
||||
TRACE("qe", tout << mk_pp(fml, m) << "\n";);
|
||||
return true;
|
||||
}
|
||||
|
@ -1962,7 +1972,7 @@ public:
|
|||
vl = numeral(0);
|
||||
}
|
||||
assign(x, fml, vl);
|
||||
subst(x, vl, fml, 0);
|
||||
subst(x, vl, fml, nullptr);
|
||||
TRACE("qe", tout << mk_pp(fml, m) << "\n";);
|
||||
|
||||
return true;
|
||||
|
@ -2022,16 +2032,19 @@ public:
|
|||
m_trail.push_back(fml);
|
||||
m_trail.push_back(result);
|
||||
if (term) m_trail.push_back(term);
|
||||
m_subst.insert(branch_formula(fml, x, v, result, coeff, term));
|
||||
m_subst.insert(branch_formula(fml, x, v, result, coeff, term, m_util.m_vars_added));
|
||||
}
|
||||
|
||||
bool get_cache(app* x, expr* fml, unsigned v, expr_ref& result) {
|
||||
branch_formula bf;
|
||||
if (!m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0), bf)) {
|
||||
if (!m_subst.find(branch_formula(fml, x, v, nullptr, rational::zero(), nullptr, m_util.m_vars_added), bf)) {
|
||||
return false;
|
||||
}
|
||||
SASSERT(bf.m_result);
|
||||
result = bf.m_result;
|
||||
for (app* v : bf.m_vars) {
|
||||
m_util.add_var(v, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2043,7 +2056,7 @@ public:
|
|||
if (!bounds.div_z(d, z_bv, z)) {
|
||||
return;
|
||||
}
|
||||
m_ctx.add_var(z_bv);
|
||||
m_util.add_var(z_bv);
|
||||
|
||||
//
|
||||
// assert
|
||||
|
@ -2120,7 +2133,7 @@ public:
|
|||
app* z1_bv = bounds.nested_div_z_bv(i);
|
||||
app* z1 = bounds.nested_div_z(i);
|
||||
|
||||
m_ctx.add_var(z1_bv);
|
||||
m_util.add_var(z1_bv);
|
||||
|
||||
//
|
||||
// assert
|
||||
|
@ -2158,7 +2171,7 @@ public:
|
|||
}
|
||||
|
||||
bounds_proc& get_bounds(app* x, expr* fml) {
|
||||
bounds_proc* result = 0;
|
||||
bounds_proc* result = nullptr;
|
||||
VERIFY (m_bounds_cache.find(x, fml, result));
|
||||
return *result;
|
||||
}
|
||||
|
@ -2394,7 +2407,7 @@ public:
|
|||
}
|
||||
|
||||
bool update_bounds(contains_app& contains_x, expr* fml) {
|
||||
bounds_proc* bounds = 0;
|
||||
bounds_proc* bounds = nullptr;
|
||||
if (m_bounds_cache.find(contains_x.x(), fml, bounds)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2443,7 +2456,7 @@ public:
|
|||
m_util.set_enable_linear(true); // (produce_models);
|
||||
}
|
||||
|
||||
virtual ~nlarith_plugin() {
|
||||
~nlarith_plugin() override {
|
||||
bcs_t::iterator it = m_cache.begin(), end = m_cache.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->get_value());
|
||||
|
@ -2454,7 +2467,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool simplify(expr_ref& fml) {
|
||||
bool simplify(expr_ref& fml) override {
|
||||
expr_ref tmp(m), tmp2(m);
|
||||
m_factor_rw(fml, tmp);
|
||||
m_rewriter(tmp, tmp2);
|
||||
|
@ -2465,8 +2478,8 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
nlarith::branch_conditions *brs = 0;
|
||||
void assign(contains_app& x, expr* fml, rational const& vl) override {
|
||||
nlarith::branch_conditions *brs = nullptr;
|
||||
VERIFY (m_cache.find(x.x(), fml, brs));
|
||||
SASSERT(vl.is_unsigned());
|
||||
SASSERT(vl.get_unsigned() < brs->size());
|
||||
|
@ -2478,8 +2491,8 @@ public:
|
|||
m_ctx.add_constraint(true, result);
|
||||
}
|
||||
|
||||
virtual bool get_num_branches(contains_app& x,
|
||||
expr* fml, rational& num_branches) {
|
||||
bool get_num_branches(contains_app& x,
|
||||
expr* fml, rational& num_branches) override {
|
||||
nlarith::branch_conditions *brs;
|
||||
if (m_cache.find(x.x(), fml, brs)) {
|
||||
num_branches = rational(brs->size());
|
||||
|
@ -2502,8 +2515,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
nlarith::branch_conditions *brs = 0;
|
||||
void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
nlarith::branch_conditions *brs = nullptr;
|
||||
VERIFY (m_cache.find(x.x(), fml, brs));
|
||||
SASSERT(vl.is_unsigned());
|
||||
SASSERT(vl.get_unsigned() < brs->size());
|
||||
|
@ -2521,8 +2534,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
virtual unsigned get_weight(contains_app& x, expr* fml) {
|
||||
obj_map<app, unsigned>* weights = 0;
|
||||
unsigned get_weight(contains_app& x, expr* fml) override {
|
||||
obj_map<app, unsigned>* weights = nullptr;
|
||||
unsigned weight = 0;
|
||||
if (!m_weights.find(fml, weights)) {
|
||||
weights = alloc(weight_m);
|
||||
|
@ -2540,12 +2553,12 @@ public:
|
|||
return UINT_MAX;
|
||||
}
|
||||
|
||||
virtual bool solve(conj_enum& conjs, expr* fml) { return false; }
|
||||
bool solve(conj_enum& conjs, expr* fml) override { return false; }
|
||||
|
||||
// we don't need to modify the atom.
|
||||
virtual bool mk_atom(expr* e, bool p, expr_ref& result) { return false; }
|
||||
bool mk_atom(expr* e, bool p, expr_ref& result) override { return false; }
|
||||
|
||||
virtual bool is_uninterpreted(app* f) {
|
||||
bool is_uninterpreted(app* f) override {
|
||||
if (m_produce_models) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,23 +27,23 @@ namespace qe {
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~array_plugin() {}
|
||||
~array_plugin() override {}
|
||||
|
||||
|
||||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
void assign(contains_app& x, expr* fml, rational const& vl) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
virtual bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) {
|
||||
bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
virtual bool solve(conj_enum& conjs, expr* fml) {
|
||||
bool solve(conj_enum& conjs, expr* fml) override {
|
||||
|
||||
conj_enum::iterator it = conjs.begin(), end = conjs.end();
|
||||
for (; it != end; ++it) {
|
||||
|
@ -65,7 +65,7 @@ namespace qe {
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual bool is_uninterpreted(app* f) {
|
||||
bool is_uninterpreted(app* f) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace qe {
|
|||
imp* m_imp;
|
||||
|
||||
rw_cfg(ast_manager& m, array_util& a):
|
||||
m(m), a(a), m_lits(m), m_model(0) {}
|
||||
m(m), a(a), m_lits(m), m_model(nullptr) {}
|
||||
|
||||
br_status reduce_app(func_decl* f, unsigned n, expr* const* args, expr_ref& result, proof_ref & pr) {
|
||||
if (a.is_select(f) && a.is_store(args[0])) {
|
||||
|
|
|
@ -31,10 +31,10 @@ namespace qe {
|
|||
imp* m_imp;
|
||||
public:
|
||||
array_project_plugin(ast_manager& m);
|
||||
virtual ~array_project_plugin();
|
||||
virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual family_id get_family_id();
|
||||
~array_project_plugin() override;
|
||||
bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
family_id get_family_id() override;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -39,16 +39,16 @@ namespace qe {
|
|||
m_replace(m)
|
||||
{}
|
||||
|
||||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
void assign(contains_app& x, expr* fml, rational const& vl) override {
|
||||
SASSERT(vl.is_zero() || vl.is_one());
|
||||
}
|
||||
|
||||
virtual bool get_num_branches(contains_app& x, expr* fml, rational& nb) {
|
||||
bool get_num_branches(contains_app& x, expr* fml, rational& nb) override {
|
||||
nb = rational(2);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
SASSERT(vl.is_one() || vl.is_zero());
|
||||
expr* tf = (vl.is_one())?m.mk_true():m.mk_false();
|
||||
m_replace.apply_substitution(x.x(), tf, fml);
|
||||
|
@ -57,7 +57,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) {
|
||||
bool project(contains_app& x, model_ref& model, expr_ref& fml) override {
|
||||
model_evaluator model_eval(*model);
|
||||
expr_ref val_x(m);
|
||||
rational val;
|
||||
|
@ -65,11 +65,11 @@ namespace qe {
|
|||
CTRACE("qe", (!m.is_true(val_x) && !m.is_false(val_x)),
|
||||
tout << "Boolean is a don't care: " << mk_pp(x.x(), m) << "\n";);
|
||||
val = m.is_true(val_x)?rational::one():rational::zero();
|
||||
subst(x, val, fml, 0);
|
||||
subst(x, val, fml, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual unsigned get_weight(contains_app& contains_x, expr* fml) {
|
||||
unsigned get_weight(contains_app& contains_x, expr* fml) override {
|
||||
app* x = contains_x.x();
|
||||
bool p = m_ctx.pos_atoms().contains(x);
|
||||
bool n = m_ctx.neg_atoms().contains(x);
|
||||
|
@ -79,13 +79,13 @@ namespace qe {
|
|||
return 0;
|
||||
}
|
||||
|
||||
virtual bool solve(conj_enum& conjs,expr* fml) {
|
||||
bool solve(conj_enum& conjs,expr* fml) override {
|
||||
return
|
||||
solve_units(conjs, fml) ||
|
||||
solve_polarized(fml);
|
||||
}
|
||||
|
||||
virtual bool is_uninterpreted(app* a) {
|
||||
bool is_uninterpreted(app* a) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,16 +37,16 @@ namespace qe {
|
|||
m_bv(m)
|
||||
{}
|
||||
|
||||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
void assign(contains_app& x, expr* fml, rational const& vl) override {
|
||||
}
|
||||
|
||||
virtual bool get_num_branches(contains_app& x, expr* fml, rational& nb) {
|
||||
bool get_num_branches(contains_app& x, expr* fml, rational& nb) override {
|
||||
unsigned sz = m_bv.get_bv_size(x.x());
|
||||
nb = power(rational(2), sz);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
app_ref c(m_bv.mk_numeral(vl, m_bv.get_bv_size(x.x())), m);
|
||||
m_replace.apply_substitution(x.x(), c, fml);
|
||||
if (def) {
|
||||
|
@ -54,24 +54,24 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) {
|
||||
bool project(contains_app& x, model_ref& model, expr_ref& fml) override {
|
||||
model_evaluator model_eval(*model);
|
||||
expr_ref val_x(m);
|
||||
rational val(0);
|
||||
unsigned bv_size;
|
||||
model_eval(x.x(), val_x);
|
||||
m_bv.is_numeral(val_x, val, bv_size);
|
||||
subst(x, val, fml, 0);
|
||||
subst(x, val, fml, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual unsigned get_weight(contains_app& contains_x, expr* fml) {
|
||||
unsigned get_weight(contains_app& contains_x, expr* fml) override {
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool solve(conj_enum& conjs, expr* fml) { return false; }
|
||||
bool solve(conj_enum& conjs, expr* fml) override { return false; }
|
||||
|
||||
virtual bool is_uninterpreted(app* f) {
|
||||
bool is_uninterpreted(app* f) override {
|
||||
switch(f->get_decl_kind()) {
|
||||
case OP_BSDIV0:
|
||||
case OP_BUDIV0:
|
||||
|
|
|
@ -14,36 +14,36 @@ class qe_cmd : public parametric_cmd {
|
|||
public:
|
||||
qe_cmd(char const* name = "elim-quantifiers"):parametric_cmd(name) {}
|
||||
|
||||
virtual char const * get_usage() const { return "<term> (<keyword> <value>)*"; }
|
||||
char const * get_usage() const override { return "<term> (<keyword> <value>)*"; }
|
||||
|
||||
virtual char const * get_main_descr() const {
|
||||
char const * get_main_descr() const override {
|
||||
return "apply quantifier elimination to the supplied expression";
|
||||
}
|
||||
|
||||
virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) {
|
||||
void init_pdescrs(cmd_context & ctx, param_descrs & p) override {
|
||||
insert_timeout(p);
|
||||
p.insert("print", CPK_BOOL, "(default: true) print the simplified term.");
|
||||
p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics.");
|
||||
}
|
||||
|
||||
virtual ~qe_cmd() {
|
||||
~qe_cmd() override {
|
||||
}
|
||||
|
||||
virtual void prepare(cmd_context & ctx) {
|
||||
void prepare(cmd_context & ctx) override {
|
||||
parametric_cmd::prepare(ctx);
|
||||
m_target = 0;
|
||||
m_target = nullptr;
|
||||
}
|
||||
|
||||
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const {
|
||||
if (m_target == 0) return CPK_EXPR;
|
||||
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
|
||||
if (m_target == nullptr) return CPK_EXPR;
|
||||
return parametric_cmd::next_arg_kind(ctx);
|
||||
}
|
||||
|
||||
virtual void set_next_arg(cmd_context & ctx, expr * arg) {
|
||||
void set_next_arg(cmd_context & ctx, expr * arg) override {
|
||||
m_target = arg;
|
||||
}
|
||||
|
||||
virtual void execute(cmd_context & ctx) {
|
||||
void execute(cmd_context & ctx) override {
|
||||
proof_ref pr(ctx.m());
|
||||
qe::simplify_rewriter_star qe(ctx.m());
|
||||
expr_ref result(ctx.m());
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace qe {
|
|||
return false;
|
||||
}
|
||||
func_decl* c = a->get_decl();
|
||||
func_decl* r = m_util.get_constructor_recognizer(c);
|
||||
func_decl_ref r(m_util.get_constructor_is(c), m);
|
||||
ptr_vector<func_decl> const & acc = *m_util.get_constructor_accessors(c);
|
||||
SASSERT(acc.size() == a->get_num_args());
|
||||
//
|
||||
|
@ -380,7 +380,7 @@ namespace qe {
|
|||
}
|
||||
func_decl* c = l->get_decl();
|
||||
ptr_vector<func_decl> const& acc = *m_util.get_constructor_accessors(c);
|
||||
func_decl* rec = m_util.get_constructor_recognizer(c);
|
||||
func_decl* rec = m_util.get_constructor_is(c);
|
||||
expr_ref_vector conj(m);
|
||||
conj.push_back(m.mk_app(rec, r));
|
||||
for (unsigned i = 0; i < acc.size(); ++i) {
|
||||
|
@ -389,7 +389,7 @@ namespace qe {
|
|||
conj.push_back(m.mk_eq(l_i, r_i));
|
||||
}
|
||||
expr* e = m.mk_and(conj.size(), conj.c_ptr());
|
||||
m_map.insert(a, e, 0);
|
||||
m_map.insert(a, e, nullptr);
|
||||
TRACE("qe", tout << "replace: " << mk_pp(a, m) << " ==> \n" << mk_pp(e, m) << "\n";);
|
||||
return true;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ namespace qe {
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~datatype_plugin() {
|
||||
~datatype_plugin() override {
|
||||
{
|
||||
eqs_cache::iterator it = m_eqs_cache.begin(), end = m_eqs_cache.end();
|
||||
for (; it != end; ++it) {
|
||||
|
@ -451,7 +451,7 @@ namespace qe {
|
|||
|
||||
}
|
||||
|
||||
virtual bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) {
|
||||
bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) override {
|
||||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
if (m_datatype_util.is_recursive(s)) {
|
||||
|
@ -463,7 +463,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
|
||||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
void assign(contains_app& x, expr* fml, rational const& vl) override {
|
||||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
|
@ -475,7 +475,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override {
|
||||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
|
@ -487,20 +487,20 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual unsigned get_weight( contains_app& x, expr* fml) {
|
||||
unsigned get_weight( contains_app& x, expr* fml) override {
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
virtual bool solve( conj_enum& conj, expr* fml) {
|
||||
bool solve( conj_enum& conj, expr* fml) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool simplify( expr_ref& fml) {
|
||||
bool simplify( expr_ref& fml) override {
|
||||
lift_foreign_vars lift(m, m_datatype_util, m_ctx);
|
||||
return lift.lift(fml);
|
||||
}
|
||||
|
||||
virtual bool mk_atom(expr* e, bool p, expr_ref& result) {
|
||||
bool mk_atom(expr* e, bool p, expr_ref& result) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,7 @@ namespace qe {
|
|||
// replace x by C(y1,..,yn) where y1,..,yn are fresh variables.
|
||||
//
|
||||
void subst_constructor(contains_app& x, func_decl* c, expr_ref& fml, expr_ref* def) {
|
||||
subst_clos* sub = 0;
|
||||
subst_clos* sub = nullptr;
|
||||
|
||||
if (m_subst_cache.find(x.x(), c, sub)) {
|
||||
m_replace.apply_substitution(x.x(), sub->first, fml);
|
||||
|
@ -588,7 +588,7 @@ namespace qe {
|
|||
|
||||
unsigned sz = m_datatype_util.get_datatype_num_constructors(s);
|
||||
num_branches = rational(sz);
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
|
||||
//
|
||||
// If 'x' does not yet have a recognizer, then branch according to recognizers.
|
||||
|
@ -620,14 +620,14 @@ namespace qe {
|
|||
void assign_rec(contains_app& contains_x, expr* fml, rational const& vl) {
|
||||
app* x = contains_x.x();
|
||||
sort* s = x->get_decl()->get_range();
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
|
||||
//
|
||||
// If 'x' does not yet have a recognizer, then branch according to recognizers.
|
||||
//
|
||||
if (!has_recognizer(x, fml, r, c)) {
|
||||
c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned());
|
||||
r = m_datatype_util.get_constructor_recognizer(c);
|
||||
r = m_datatype_util.get_constructor_is(c);
|
||||
app* is_c = m.mk_app(r, x);
|
||||
// assert v => r(x)
|
||||
m_ctx.add_constraint(true, is_c);
|
||||
|
@ -665,7 +665,7 @@ namespace qe {
|
|||
app* x = contains_x.x();
|
||||
sort* s = x->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
|
||||
TRACE("qe", tout << mk_pp(x, m) << " " << vl << " " << mk_pp(fml, m) << " " << (def != 0) << "\n";);
|
||||
//
|
||||
|
@ -674,7 +674,7 @@ namespace qe {
|
|||
//
|
||||
if (!has_recognizer(x, fml, r, c)) {
|
||||
c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned());
|
||||
r = m_datatype_util.get_constructor_recognizer(c);
|
||||
r = m_datatype_util.get_constructor_is(c);
|
||||
app* is_c = m.mk_app(r, x);
|
||||
fml = m.mk_and(is_c, fml);
|
||||
app_ref fresh_x(m.mk_fresh_const("x", s), m);
|
||||
|
@ -748,7 +748,7 @@ namespace qe {
|
|||
sort* s = x.x()->get_decl()->get_range();
|
||||
unsigned sz = m_datatype_util.get_datatype_num_constructors(s);
|
||||
num_branches = rational(sz);
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
|
||||
if (sz != 1 && has_recognizer(x.x(), fml, r, c)) {
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
|
@ -768,14 +768,14 @@ namespace qe {
|
|||
if (sz == 1) {
|
||||
return;
|
||||
}
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
if (has_recognizer(x, fml, r, c)) {
|
||||
TRACE("qe", tout << mk_pp(x, m) << " has a recognizer\n";);
|
||||
return;
|
||||
}
|
||||
|
||||
c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned());
|
||||
r = m_datatype_util.get_constructor_recognizer(c);
|
||||
r = m_datatype_util.get_constructor_is(c);
|
||||
app* is_c = m.mk_app(r, x);
|
||||
|
||||
// assert v => r(x)
|
||||
|
@ -787,7 +787,7 @@ namespace qe {
|
|||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
SASSERT(!m_datatype_util.is_recursive(s));
|
||||
func_decl* c = 0, *r = 0;
|
||||
func_decl* c = nullptr, *r = nullptr;
|
||||
if (has_recognizer(x.x(), fml, r, c)) {
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
}
|
||||
|
@ -807,7 +807,7 @@ namespace qe {
|
|||
public:
|
||||
has_select(app* x, func_decl* c, datatype_util& u): m_x(x), m_c(c), m_util(u) {}
|
||||
|
||||
virtual bool operator()(expr* e) {
|
||||
bool operator()(expr* e) override {
|
||||
if (!is_app(e)) return false;
|
||||
app* a = to_app(e);
|
||||
if (!m_util.is_accessor(a)) return false;
|
||||
|
@ -824,13 +824,13 @@ namespace qe {
|
|||
}
|
||||
|
||||
datatype_atoms& get_eqs(app* x, expr* fml) {
|
||||
datatype_atoms* eqs = 0;
|
||||
datatype_atoms* eqs = nullptr;
|
||||
VERIFY (m_eqs_cache.find(x, fml, eqs));
|
||||
return *eqs;
|
||||
}
|
||||
|
||||
bool update_eqs(contains_app& contains_x, expr* fml) {
|
||||
datatype_atoms* eqs = 0;
|
||||
datatype_atoms* eqs = nullptr;
|
||||
if (m_eqs_cache.find(contains_x.x(), fml, eqs)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace qe {
|
|||
return false;
|
||||
}
|
||||
func_decl* c = a->get_decl();
|
||||
func_decl* rec = dt.get_constructor_recognizer(c);
|
||||
func_decl_ref rec(dt.get_constructor_is(c), m);
|
||||
ptr_vector<func_decl> const & acc = *dt.get_constructor_accessors(c);
|
||||
SASSERT(acc.size() == a->get_num_args());
|
||||
//
|
||||
|
@ -232,7 +232,7 @@ namespace qe {
|
|||
func_decl* c = to_app(l)->get_decl();
|
||||
ptr_vector<func_decl> const& acc = *dt.get_constructor_accessors(c);
|
||||
if (!is_app_of(r, c)) {
|
||||
lits.push_back(m.mk_app(dt.get_constructor_recognizer(c), r));
|
||||
lits.push_back(m.mk_app(dt.get_constructor_is(c), r));
|
||||
}
|
||||
for (unsigned i = 0; i < acc.size(); ++i) {
|
||||
lits.push_back(m.mk_eq(to_app(l)->get_arg(i), access(c, i, acc, r)));
|
||||
|
|
|
@ -31,10 +31,10 @@ namespace qe {
|
|||
imp* m_imp;
|
||||
public:
|
||||
datatype_project_plugin(ast_manager& m);
|
||||
virtual ~datatype_project_plugin();
|
||||
virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits);
|
||||
virtual family_id get_family_id();
|
||||
~datatype_project_plugin() override;
|
||||
bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override;
|
||||
family_id get_family_id() override;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace qe {
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~dl_plugin() {
|
||||
~dl_plugin() override {
|
||||
eqs_cache::iterator it = m_eqs_cache.begin(), end = m_eqs_cache.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->get_value());
|
||||
|
@ -65,7 +65,7 @@ namespace qe {
|
|||
|
||||
|
||||
|
||||
bool get_num_branches(contains_app & x,expr * fml,rational & num_branches) {
|
||||
bool get_num_branches(contains_app & x,expr * fml,rational & num_branches) override {
|
||||
if (!update_eqs(x, fml)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace qe {
|
|||
return true;
|
||||
}
|
||||
|
||||
void assign(contains_app & x,expr * fml,const rational & v) {
|
||||
void assign(contains_app & x,expr * fml,const rational & v) override {
|
||||
SASSERT(v.is_unsigned());
|
||||
eq_atoms& eqs = get_eqs(x.x(), fml);
|
||||
unsigned uv = v.get_unsigned();
|
||||
|
@ -94,7 +94,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
void subst(contains_app & x,const rational & v,expr_ref & fml, expr_ref* def) {
|
||||
void subst(contains_app & x,const rational & v,expr_ref & fml, expr_ref* def) override {
|
||||
SASSERT(v.is_unsigned());
|
||||
eq_atoms& eqs = get_eqs(x.x(), fml);
|
||||
unsigned uv = v.get_unsigned();
|
||||
|
@ -107,11 +107,11 @@ namespace qe {
|
|||
subst_large_domain(x, eqs, uv, fml);
|
||||
}
|
||||
if (def) {
|
||||
*def = 0; // TBD
|
||||
*def = nullptr; // TBD
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool solve(conj_enum& conjs, expr* fml) { return false; }
|
||||
bool solve(conj_enum& conjs, expr* fml) override { return false; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -169,13 +169,13 @@ namespace qe {
|
|||
|
||||
|
||||
eq_atoms& get_eqs(app* x, expr* fml) {
|
||||
eq_atoms* eqs = 0;
|
||||
eq_atoms* eqs = nullptr;
|
||||
VERIFY(m_eqs_cache.find(x, fml, eqs));
|
||||
return *eqs;
|
||||
}
|
||||
|
||||
bool update_eqs(contains_app& contains_x, expr* fml) {
|
||||
eq_atoms* eqs = 0;
|
||||
eq_atoms* eqs = nullptr;
|
||||
if (m_eqs_cache.find(contains_x.x(), fml, eqs)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ Revision History:
|
|||
#include "qe/qe_lite.h"
|
||||
#include "ast/expr_abstract.h"
|
||||
#include "ast/used_vars.h"
|
||||
#include "ast/occurs.h"
|
||||
#include "ast/rewriter/rewriter_def.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
|
@ -39,6 +38,30 @@ Revision History:
|
|||
#include "qe/qe_vartest.h"
|
||||
|
||||
namespace eq {
|
||||
|
||||
bool occurs_var(unsigned idx, expr* e) {
|
||||
ptr_buffer<expr> todo;
|
||||
todo.push_back(e);
|
||||
ast_mark mark;
|
||||
while (!todo.empty()) {
|
||||
expr* e = todo.back();
|
||||
todo.pop_back();
|
||||
if (mark.is_marked(e)) continue;
|
||||
mark.mark(e, true);
|
||||
if (is_var(e)) {
|
||||
if (to_var(e)->get_idx() == idx) return true;
|
||||
}
|
||||
else if (is_app(e)) {
|
||||
todo.append(to_app(e)->get_num_args(), to_app(e)->get_args());
|
||||
}
|
||||
else if (is_quantifier(e)) {
|
||||
quantifier* q = to_quantifier(e);
|
||||
if (occurs_var(idx + q->get_num_decls(), q->get_expr())) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class der {
|
||||
ast_manager & m;
|
||||
arith_util a;
|
||||
|
@ -65,7 +88,7 @@ namespace eq {
|
|||
for (unsigned i = 0; i < definitions.size(); i++) {
|
||||
var * v = vars[i];
|
||||
expr * t = definitions[i];
|
||||
if (t == 0 || has_quantifiers(t) || occurs(v, t))
|
||||
if (t == nullptr || has_quantifiers(t) || occurs_var(v->get_idx(), t))
|
||||
definitions[i] = 0;
|
||||
else
|
||||
found = true; // found at least one candidate
|
||||
|
@ -102,7 +125,7 @@ namespace eq {
|
|||
vidx = to_var(t)->get_idx();
|
||||
if (fr.second == 0) {
|
||||
CTRACE("der_bug", vidx >= definitions.size(), tout << "vidx: " << vidx << "\n";);
|
||||
// Remark: The size of definitions may be smaller than the number of variables occuring in the quantified formula.
|
||||
// Remark: The size of definitions may be smaller than the number of variables occurring in the quantified formula.
|
||||
if (definitions.get(vidx, 0) != 0) {
|
||||
if (visiting.is_marked(t)) {
|
||||
// cycle detected: remove t
|
||||
|
@ -419,7 +442,7 @@ namespace eq {
|
|||
|
||||
void create_substitution(unsigned sz) {
|
||||
m_subst_map.reset();
|
||||
m_subst_map.resize(sz, 0);
|
||||
m_subst_map.resize(sz, nullptr);
|
||||
for (unsigned i = 0; i < m_order.size(); i++) {
|
||||
expr_ref cur(m_map[m_order[i]], m);
|
||||
// do all the previous substitutions before inserting
|
||||
|
@ -521,7 +544,7 @@ namespace eq {
|
|||
}
|
||||
|
||||
if (m.proofs_enabled()) {
|
||||
pr = r == q ? 0 : m.mk_der(q, r);
|
||||
pr = r == q ? nullptr : m.mk_der(q, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,7 +692,7 @@ namespace eq {
|
|||
}
|
||||
}
|
||||
else {
|
||||
func_decl* rec = dt.get_constructor_recognizer(d);
|
||||
func_decl* rec = dt.get_constructor_is(d);
|
||||
conjs.push_back(m.mk_app(rec, r));
|
||||
ptr_vector<func_decl> const& acc = *dt.get_constructor_accessors(d);
|
||||
for (unsigned i = 0; i < acc.size(); ++i) {
|
||||
|
@ -679,9 +702,9 @@ namespace eq {
|
|||
}
|
||||
|
||||
bool is_unconstrained(var* x, expr* t, unsigned i, expr_ref_vector const& conjs) {
|
||||
bool occ = occurs(x, t);
|
||||
bool occ = occurs_var(x->get_idx(), t);
|
||||
for (unsigned j = 0; !occ && j < conjs.size(); ++j) {
|
||||
occ = (i != j) && occurs(x, conjs[j]);
|
||||
occ = (i != j) && occurs_var(x->get_idx(), conjs[j]);
|
||||
}
|
||||
return !occ;
|
||||
}
|
||||
|
@ -753,7 +776,7 @@ namespace eq {
|
|||
m(m),
|
||||
a(m),
|
||||
dt(m),
|
||||
m_is_variable(0),
|
||||
m_is_variable(nullptr),
|
||||
m_subst(m),
|
||||
m_new_exprs(m),
|
||||
m_subst_map(m),
|
||||
|
@ -765,7 +788,7 @@ namespace eq {
|
|||
|
||||
void operator()(quantifier * q, expr_ref & r, proof_ref & pr) {
|
||||
TRACE("qe_lite", tout << mk_pp(q, m) << "\n";);
|
||||
pr = 0;
|
||||
pr = nullptr;
|
||||
r = q;
|
||||
reduce_quantifier(q, r, pr);
|
||||
if (r != q) {
|
||||
|
@ -932,7 +955,7 @@ namespace ar {
|
|||
|
||||
public:
|
||||
|
||||
der(ast_manager& m): m(m), a(m), m_is_variable(0) {}
|
||||
der(ast_manager& m): m(m), a(m), m_is_variable(nullptr) {}
|
||||
|
||||
void operator()(expr_ref_vector& fmls) {
|
||||
for (unsigned i = 0; i < fmls.size(); ++i) {
|
||||
|
@ -951,7 +974,7 @@ namespace ar {
|
|||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// fm_tactic adapted to eliminate designated de-Brujin indices.
|
||||
// fm_tactic adapted to eliminate designated de-Bruijn indices.
|
||||
|
||||
namespace fm {
|
||||
typedef ptr_vector<app> clauses;
|
||||
|
@ -1450,7 +1473,7 @@ namespace fm {
|
|||
|
||||
fm(ast_manager & _m):
|
||||
m(_m),
|
||||
m_is_variable(0),
|
||||
m_is_variable(nullptr),
|
||||
m_allocator("fm-elim"),
|
||||
m_util(m),
|
||||
m_bvar2expr(m),
|
||||
|
@ -1511,7 +1534,7 @@ namespace fm {
|
|||
reset_constraints();
|
||||
m_bvar2expr.reset();
|
||||
m_bvar2sign.reset();
|
||||
m_bvar2expr.push_back(0); // bvar 0 is not used
|
||||
m_bvar2expr.push_back(nullptr); // bvar 0 is not used
|
||||
m_bvar2sign.push_back(0);
|
||||
m_expr2var.reset();
|
||||
m_is_int.reset();
|
||||
|
@ -1524,7 +1547,7 @@ namespace fm {
|
|||
m_new_fmls.reset();
|
||||
m_counter = 0;
|
||||
m_inconsistent = false;
|
||||
m_inconsistent_core = 0;
|
||||
m_inconsistent_core = nullptr;
|
||||
init_forbidden_set(g);
|
||||
}
|
||||
|
||||
|
@ -1560,7 +1583,7 @@ namespace fm {
|
|||
// 0 <= 0 -- > true
|
||||
if (c.m_c.is_pos() || (!c.m_strict && c.m_c.is_zero()))
|
||||
return m.mk_true();
|
||||
ineq = 0;
|
||||
ineq = nullptr;
|
||||
}
|
||||
else {
|
||||
bool int_cnstr = all_int(c);
|
||||
|
@ -1810,7 +1833,7 @@ namespace fm {
|
|||
for (unsigned i = 0; !m_inconsistent && i < sz; i++) {
|
||||
expr * f = g[i];
|
||||
if (is_occ(f))
|
||||
add_constraint(f, 0);
|
||||
add_constraint(f, nullptr);
|
||||
else
|
||||
m_new_fmls.push_back(f);
|
||||
}
|
||||
|
@ -2042,7 +2065,7 @@ namespace fm {
|
|||
display(tout, l);
|
||||
tout << "\n";
|
||||
display(tout, u); tout << "\n";);
|
||||
return 0; // no constraint needs to be created.
|
||||
return nullptr; // no constraint needs to be created.
|
||||
}
|
||||
|
||||
new_lits.reset();
|
||||
|
@ -2086,7 +2109,7 @@ namespace fm {
|
|||
display(tout, l);
|
||||
tout << "\n";
|
||||
display(tout, u); tout << "\n";);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
expr_dependency * new_dep = m.mk_join(l.m_dep, u.m_dep);
|
||||
|
@ -2098,7 +2121,7 @@ namespace fm {
|
|||
display(tout, u); tout << "\n";);
|
||||
m_inconsistent = true;
|
||||
m_inconsistent_core = new_dep;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constraint * new_cnstr = mk_constraint(new_lits.size(),
|
||||
|
@ -2168,7 +2191,7 @@ namespace fm {
|
|||
constraint const & l_c = *(l[i]);
|
||||
constraint const & u_c = *(u[j]);
|
||||
constraint * new_c = resolve(l_c, u_c, x);
|
||||
if (new_c != 0) {
|
||||
if (new_c != nullptr) {
|
||||
num_new_cnstrs++;
|
||||
new_constraints.push_back(new_c);
|
||||
}
|
||||
|
@ -2580,40 +2603,40 @@ public:
|
|||
m_imp = alloc(imp, m, p);
|
||||
}
|
||||
|
||||
virtual ~qe_lite_tactic() {
|
||||
~qe_lite_tactic() override {
|
||||
dealloc(m_imp);
|
||||
}
|
||||
|
||||
virtual tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(qe_lite_tactic, m, m_params);
|
||||
}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
m_params = p;
|
||||
// m_imp->updt_params(p);
|
||||
}
|
||||
|
||||
|
||||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
// m_imp->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
virtual void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) {
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) override {
|
||||
(*m_imp)(in, result);
|
||||
}
|
||||
|
||||
|
||||
virtual void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
// m_imp->collect_statistics(st);
|
||||
}
|
||||
|
||||
virtual void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
// m_imp->reset_statistics();
|
||||
}
|
||||
|
||||
|
||||
virtual void cleanup() {
|
||||
void cleanup() override {
|
||||
ast_manager & m = m_imp->m;
|
||||
dealloc(m_imp);
|
||||
m_imp = alloc(imp, m, m_params);
|
||||
|
|
|
@ -71,7 +71,7 @@ expr_ref project_plugin::pick_equality(ast_manager& m, model& model, expr* t) {
|
|||
vals.push_back(val);
|
||||
}
|
||||
UNREACHABLE();
|
||||
return expr_ref(0, m);
|
||||
return expr_ref(nullptr, m);
|
||||
}
|
||||
|
||||
void project_plugin::partition_values(model& model, expr_ref_vector const& vals, expr_ref_vector& lits) {
|
||||
|
|
|
@ -39,14 +39,14 @@ namespace qe {
|
|||
|
||||
class is_relevant_default : public i_expr_pred {
|
||||
public:
|
||||
bool operator()(expr* e) {
|
||||
bool operator()(expr* e) override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class mk_atom_default : public i_nnf_atom {
|
||||
public:
|
||||
virtual void operator()(expr* e, bool pol, expr_ref& result) {
|
||||
void operator()(expr* e, bool pol, expr_ref& result) override {
|
||||
if (pol) result = e;
|
||||
else result = result.get_manager().mk_not(e);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace qe {
|
|||
m_fml(m),
|
||||
m_projection_mode_param(true) {}
|
||||
|
||||
virtual ~solver_context() {
|
||||
~solver_context() override {
|
||||
std::for_each(m_contains_app.begin(), m_contains_app.end(), delete_proc<contains_app>());
|
||||
}
|
||||
|
||||
|
@ -111,28 +111,28 @@ namespace qe {
|
|||
|
||||
void set_projection_mode(bool p) { m_projection_mode_param = p; }
|
||||
|
||||
ast_manager& get_manager() { return m; }
|
||||
ast_manager& get_manager() override { return m; }
|
||||
|
||||
expr* fml() { return m_fml; }
|
||||
|
||||
// set of atoms in current formula.
|
||||
virtual atom_set const& pos_atoms() const { return m_pos; }
|
||||
virtual atom_set const& neg_atoms() const { return m_neg; }
|
||||
atom_set const& pos_atoms() const override { return m_pos; }
|
||||
atom_set const& neg_atoms() const override { return m_neg; }
|
||||
|
||||
// Access current set of variables to solve
|
||||
virtual unsigned get_num_vars() const { return m_vars.size(); }
|
||||
virtual app* get_var(unsigned idx) const { return m_vars[idx]; }
|
||||
virtual app*const* get_vars() const { return m_vars.c_ptr(); }
|
||||
virtual bool is_var(expr* e, unsigned& idx) const {
|
||||
unsigned get_num_vars() const override { return m_vars.size(); }
|
||||
app* get_var(unsigned idx) const override { return m_vars[idx]; }
|
||||
app_ref_vector const& get_vars() const override { return m_vars; }
|
||||
bool is_var(expr* e, unsigned& idx) const override {
|
||||
for (unsigned i = 0; i < m_vars.size(); ++i) {
|
||||
if (e == m_vars[i]) return (idx = i, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
virtual contains_app& contains(unsigned idx) { return *m_contains_app[idx]; }
|
||||
contains_app& contains(unsigned idx) override { return *m_contains_app[idx]; }
|
||||
|
||||
// callback to replace variable at index 'idx' with definition 'def' and updated formula 'fml'
|
||||
virtual void elim_var(unsigned idx, expr* fml, expr* def) {
|
||||
void elim_var(unsigned idx, expr* fml, expr* def) override {
|
||||
m_fml = fml;
|
||||
m_pos.reset();
|
||||
m_neg.reset();
|
||||
|
@ -143,13 +143,13 @@ namespace qe {
|
|||
}
|
||||
|
||||
// callback to add new variable to branch.
|
||||
virtual void add_var(app* x) {
|
||||
void add_var(app* x) override {
|
||||
m_vars.push_back(x);
|
||||
m_contains_app.push_back(alloc(contains_app, m, x));
|
||||
}
|
||||
|
||||
// callback to add constraints in branch.
|
||||
virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) {
|
||||
void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override {
|
||||
ptr_buffer<expr> args;
|
||||
if (l1) args.push_back(l1);
|
||||
if (l2) args.push_back(l2);
|
||||
|
@ -160,7 +160,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
// eliminate finite domain variable 'var' from fml.
|
||||
virtual void blast_or(app* var, expr_ref& fml) {
|
||||
void blast_or(app* var, expr_ref& fml) override {
|
||||
expr_ref result(m);
|
||||
expr_quant_elim qelim(m, m_super.m_fparams);
|
||||
qe::mk_exists(1, &var, fml);
|
||||
|
@ -179,7 +179,7 @@ namespace qe {
|
|||
m_super.m_rewriter(m_fml);
|
||||
TRACE("qe", model_v2_pp(tout, *model); tout << "\n";
|
||||
tout << mk_pp(m_fml, m) << "\n";);
|
||||
elim_var(i, m_fml, 0);
|
||||
elim_var(i, m_fml, nullptr);
|
||||
}
|
||||
|
||||
void project_var_full(unsigned i) {
|
||||
|
@ -191,7 +191,7 @@ namespace qe {
|
|||
m_fml = result;
|
||||
m_super.m_rewriter(m_fml);
|
||||
TRACE("qe", tout << mk_pp(m_fml, m) << "\n";);
|
||||
elim_var(i, m_fml, 0);
|
||||
elim_var(i, m_fml, nullptr);
|
||||
}
|
||||
|
||||
void project_var(unsigned i) {
|
||||
|
@ -223,18 +223,15 @@ namespace qe {
|
|||
m_fparams.m_model = true;
|
||||
}
|
||||
|
||||
virtual tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(sat_tactic, m);
|
||||
}
|
||||
|
||||
virtual ~sat_tactic() {
|
||||
~sat_tactic() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
virtual void operator()(
|
||||
goal_ref const& goal,
|
||||
goal_ref_buffer& result)
|
||||
{
|
||||
void operator()(goal_ref const& goal, goal_ref_buffer& result) override {
|
||||
try {
|
||||
checkpoint();
|
||||
reset();
|
||||
|
@ -266,7 +263,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
for (auto const * s : m_solvers) {
|
||||
s->collect_statistics(st);
|
||||
}
|
||||
|
@ -274,7 +271,7 @@ namespace qe {
|
|||
m_ctx_rewriter.collect_statistics(st);
|
||||
}
|
||||
|
||||
virtual void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
for (auto * s : m_solvers) {
|
||||
s->reset_statistics();
|
||||
}
|
||||
|
@ -282,9 +279,9 @@ namespace qe {
|
|||
m_ctx_rewriter.reset_statistics();
|
||||
}
|
||||
|
||||
virtual void cleanup() {}
|
||||
void cleanup() override {}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
m_extrapolate_strategy_param = p.get_uint("extrapolate_strategy", m_extrapolate_strategy_param);
|
||||
m_projection_mode_param = p.get_bool("projection_mode", m_projection_mode_param);
|
||||
m_strong_context_simplify_param = p.get_bool("strong_context_simplify", m_strong_context_simplify_param);
|
||||
|
@ -293,7 +290,7 @@ namespace qe {
|
|||
m_qe_rw.updt_params(p);
|
||||
}
|
||||
|
||||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
r.insert("extrapolate_strategy",CPK_UINT, "(default: 0 trivial extrapolation) 1 - nnf strengthening 2 - smt-test 3 - nnf_weakening");
|
||||
r.insert("projection_mode", CPK_BOOL, "(default: true - full) false - partial quantifier instantiation");
|
||||
r.insert("strong_context_simplify", CPK_BOOL, "(default: true) use strong context simplifier on result of quantifier elimination");
|
||||
|
@ -323,11 +320,11 @@ namespace qe {
|
|||
|
||||
smt::kernel& solver(unsigned i) { return *m_solvers[i]; }
|
||||
|
||||
void reset() {
|
||||
void reset() override {
|
||||
for (unsigned i = 0; i < m_solvers.size(); ++i) {
|
||||
dealloc(m_solvers[i]);
|
||||
}
|
||||
m_fml = 0;
|
||||
m_fml = nullptr;
|
||||
m_Ms.reset();
|
||||
m_fparamv.reset();
|
||||
m_solvers.reset();
|
||||
|
|
|
@ -67,7 +67,7 @@ class qe_tactic : public tactic {
|
|||
if (!has_quantifiers(f))
|
||||
continue;
|
||||
m_qe(m.mk_true(), f, new_f);
|
||||
new_pr = 0;
|
||||
new_pr = nullptr;
|
||||
if (produce_proofs) {
|
||||
new_pr = m.mk_modus_ponens(g->pr(i), new_pr);
|
||||
}
|
||||
|
@ -97,43 +97,43 @@ public:
|
|||
m_imp = alloc(imp, m, p);
|
||||
}
|
||||
|
||||
virtual tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(qe_tactic, m, m_params);
|
||||
}
|
||||
|
||||
virtual ~qe_tactic() {
|
||||
~qe_tactic() override {
|
||||
dealloc(m_imp);
|
||||
}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
m_params = p;
|
||||
m_imp->updt_params(p);
|
||||
}
|
||||
|
||||
|
||||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
r.insert("qe_nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution.");
|
||||
m_imp->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
virtual void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) {
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) override {
|
||||
(*m_imp)(in, result);
|
||||
m_st.reset();
|
||||
m_imp->collect_statistics(m_st);
|
||||
|
||||
}
|
||||
|
||||
virtual void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
st.copy(m_st);
|
||||
}
|
||||
|
||||
virtual void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
m_st.reset();
|
||||
}
|
||||
|
||||
|
||||
virtual void cleanup() {
|
||||
void cleanup() override {
|
||||
ast_manager & m = m_imp->m;
|
||||
dealloc(m_imp);
|
||||
m_imp = alloc(imp, m, m_params);
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
m_num_decls(num_decls),
|
||||
m_var_kind(BY_NUM_DECLS) {}
|
||||
|
||||
virtual bool operator()(expr* e) const {
|
||||
bool operator()(expr* e) const override {
|
||||
if (!is_var(e)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -626,6 +626,9 @@ namespace qe {
|
|||
SASSERT(validate_assumptions(*m_model.get(), asms));
|
||||
SASSERT(validate_model(asms));
|
||||
TRACE("qe", s.display(tout); display(tout << "\n", *m_model.get()); display(tout, asms); );
|
||||
if (m_level == 0) {
|
||||
m_model_save = m_model;
|
||||
}
|
||||
push();
|
||||
if (m_level == 1 && m_mode == qsat_maximize) {
|
||||
maximize_model();
|
||||
|
@ -693,7 +696,7 @@ namespace qe {
|
|||
m_level -= num_scopes;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_st.reset();
|
||||
m_fa.s().collect_statistics(m_st);
|
||||
m_ex.s().collect_statistics(m_st);
|
||||
|
@ -703,7 +706,7 @@ namespace qe {
|
|||
m_asms.reset();
|
||||
m_pred_abs.reset();
|
||||
m_vars.reset();
|
||||
m_model = 0;
|
||||
m_model = nullptr;
|
||||
m_fa.reset();
|
||||
m_ex.reset();
|
||||
m_free_vars.reset();
|
||||
|
@ -951,7 +954,7 @@ namespace qe {
|
|||
ptr_vector<expr> todo;
|
||||
trail.push_back(fml);
|
||||
todo.push_back(fml);
|
||||
expr* e = 0, *r = 0;
|
||||
expr* e = nullptr, *r = nullptr;
|
||||
|
||||
while (!todo.empty()) {
|
||||
check_cancel();
|
||||
|
@ -1191,27 +1194,27 @@ namespace qe {
|
|||
m_mode(mode),
|
||||
m_avars(m),
|
||||
m_free_vars(m),
|
||||
m_objective(0),
|
||||
m_value(0),
|
||||
m_objective(nullptr),
|
||||
m_value(nullptr),
|
||||
m_was_sat(false),
|
||||
m_gt(m)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
virtual ~qsat() {
|
||||
~qsat() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
}
|
||||
|
||||
void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
}
|
||||
|
||||
|
||||
void operator()(/* in */ goal_ref const & in,
|
||||
/* out */ goal_ref_buffer & result) {
|
||||
/* out */ goal_ref_buffer & result) override {
|
||||
tactic_report report("qsat-tactic", *in);
|
||||
ptr_vector<expr> fmls;
|
||||
expr_ref_vector defs(m);
|
||||
|
@ -1282,7 +1285,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
st.copy(m_st);
|
||||
m_fa.s().collect_statistics(st);
|
||||
m_ex.s().collect_statistics(st);
|
||||
|
@ -1291,23 +1294,23 @@ namespace qe {
|
|||
m_pred_abs.collect_statistics(st);
|
||||
}
|
||||
|
||||
void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
m_stats.reset();
|
||||
m_fa.reset();
|
||||
m_ex.reset();
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
void cleanup() override {
|
||||
reset();
|
||||
}
|
||||
|
||||
void set_logic(symbol const & l) {
|
||||
void set_logic(symbol const & l) override {
|
||||
}
|
||||
|
||||
void set_progress_callback(progress_callback * callback) {
|
||||
void set_progress_callback(progress_callback * callback) override {
|
||||
}
|
||||
|
||||
tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(qsat, m, m_params, m_mode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue