mirror of
https://github.com/Z3Prover/z3
synced 2025-10-05 15:33:59 +00:00
merge with Z3Prover/z3/master
This commit is contained in:
commit
f7b50ef796
452 changed files with 29240 additions and 34285 deletions
|
@ -70,6 +70,7 @@ z3_add_component(smt
|
|||
euclid
|
||||
fpa
|
||||
grobner
|
||||
nlsat
|
||||
lp
|
||||
macros
|
||||
normal_forms
|
||||
|
|
|
@ -334,6 +334,7 @@ void asserted_formulas::find_macros_core() {
|
|||
reduce_and_solve();
|
||||
}
|
||||
|
||||
|
||||
void asserted_formulas::apply_quasi_macros() {
|
||||
TRACE("before_quasi_macros", display(tout););
|
||||
vector<justified_expr> new_fmls;
|
||||
|
@ -419,7 +420,7 @@ void asserted_formulas::simplify_fmls::operator()() {
|
|||
|
||||
|
||||
void asserted_formulas::reduce_and_solve() {
|
||||
IF_IVERBOSE(10, verbose_stream() << "(smt.reducing)\n";);
|
||||
IF_VERBOSE(10, verbose_stream() << "(smt.reducing)\n";);
|
||||
flush_cache(); // collect garbage
|
||||
m_reduce_asserted_formulas();
|
||||
}
|
||||
|
@ -499,6 +500,7 @@ unsigned asserted_formulas::propagate_values(unsigned i) {
|
|||
|
||||
void asserted_formulas::update_substitution(expr* n, proof* pr) {
|
||||
expr* lhs, *rhs, *n1;
|
||||
proof_ref pr1(m);
|
||||
if (is_ground(n) && (m.is_eq(n, lhs, rhs) || m.is_iff(n, lhs, rhs))) {
|
||||
compute_depth(lhs);
|
||||
compute_depth(rhs);
|
||||
|
@ -509,12 +511,12 @@ void asserted_formulas::update_substitution(expr* n, proof* pr) {
|
|||
}
|
||||
if (is_gt(rhs, lhs)) {
|
||||
TRACE("propagate_values", tout << "insert " << mk_pp(rhs, m) << " -> " << mk_pp(lhs, m) << "\n";);
|
||||
m_scoped_substitution.insert(rhs, lhs, m.proofs_enabled() ? m.mk_symmetry(pr) : nullptr);
|
||||
pr1 = m.proofs_enabled() ? m.mk_symmetry(pr) : nullptr;
|
||||
m_scoped_substitution.insert(rhs, lhs, pr1);
|
||||
return;
|
||||
}
|
||||
TRACE("propagate_values", tout << "incompatible " << mk_pp(n, m) << "\n";);
|
||||
}
|
||||
proof_ref pr1(m);
|
||||
if (m.is_not(n, n1)) {
|
||||
pr1 = m.proofs_enabled() ? m.mk_iff_false(pr) : nullptr;
|
||||
m_scoped_substitution.insert(n1, m.mk_false(), pr1);
|
||||
|
@ -525,6 +527,7 @@ void asserted_formulas::update_substitution(expr* n, proof* pr) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief implement a Knuth-Bendix ordering on expressions.
|
||||
*/
|
||||
|
@ -630,6 +633,7 @@ unsigned asserted_formulas::get_total_size() const {
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
void pp(asserted_formulas & f) {
|
||||
f.display(std::cout);
|
||||
|
|
|
@ -39,6 +39,7 @@ void smt_params::updt_local_params(params_ref const & _p) {
|
|||
m_timeout = p.timeout();
|
||||
m_rlimit = p.rlimit();
|
||||
m_max_conflicts = p.max_conflicts();
|
||||
m_restart_max = p.restart_max();
|
||||
m_core_validate = p.core_validate();
|
||||
m_logic = _p.get_sym("logic", m_logic);
|
||||
m_string_solver = p.string_solver();
|
||||
|
|
|
@ -99,6 +99,7 @@ struct smt_params : public preprocessor_params,
|
|||
unsigned m_phase_caching_off;
|
||||
bool m_minimize_lemmas;
|
||||
unsigned m_max_conflicts;
|
||||
unsigned m_restart_max;
|
||||
bool m_simplify_clauses;
|
||||
unsigned m_tick;
|
||||
bool m_display_features;
|
||||
|
|
|
@ -21,6 +21,7 @@ def_module_params(module_name='smt',
|
|||
('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
|
||||
('rlimit', UINT, 0, 'resource limit (0 means no limit)'),
|
||||
('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts before giving up.'),
|
||||
('restart.max', UINT, UINT_MAX, 'maximal number of restarts.'),
|
||||
('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'),
|
||||
('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'),
|
||||
('mbqi.max_cexs_incr', UINT, 0, 'increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI'),
|
||||
|
@ -38,7 +39,7 @@ def_module_params(module_name='smt',
|
|||
('bv.reflect', BOOL, True, 'create enode for every bit-vector term'),
|
||||
('bv.enable_int2bv', BOOL, True, 'enable support for int2bv and bv2int operators'),
|
||||
('arith.random_initial_value', BOOL, False, 'use random initial values in the simplex-based procedure for linear arithmetic'),
|
||||
('arith.solver', UINT, 2, 'arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination'),
|
||||
('arith.solver', UINT, 2, 'arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination 4 - utvpi, 5 - infinitary lra, 6 - lra solver'),
|
||||
('arith.nl', BOOL, True, '(incomplete) nonlinear arithmetic support based on Groebner basis and interval propagation'),
|
||||
('arith.nl.gb', BOOL, True, 'groebner Basis computation, this option is ignored when arith.nl=false'),
|
||||
('arith.nl.branching', BOOL, True, 'branching on integer variables in non linear clusters'),
|
||||
|
|
|
@ -23,12 +23,13 @@ Revision History:
|
|||
#include "util/params.h"
|
||||
|
||||
enum arith_solver_id {
|
||||
AS_NO_ARITH,
|
||||
AS_DIFF_LOGIC,
|
||||
AS_ARITH,
|
||||
AS_DENSE_DIFF_LOGIC,
|
||||
AS_UTVPI,
|
||||
AS_OPTINF
|
||||
AS_NO_ARITH, // 0
|
||||
AS_DIFF_LOGIC, // 1
|
||||
AS_ARITH, // 2
|
||||
AS_DENSE_DIFF_LOGIC, // 3
|
||||
AS_UTVPI, // 4
|
||||
AS_OPTINF, // 5
|
||||
AS_LRA // 6
|
||||
};
|
||||
|
||||
enum bound_prop_mode {
|
||||
|
|
|
@ -628,10 +628,7 @@ namespace smt {
|
|||
*/
|
||||
void context::remove_parents_from_cg_table(enode * r1) {
|
||||
// Remove parents from the congruence table
|
||||
enode_vector::iterator it = r1->begin_parents();
|
||||
enode_vector::iterator end = r1->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode * parent : r1->get_parents()) {
|
||||
#if 0
|
||||
{
|
||||
static unsigned num_eqs = 0;
|
||||
|
@ -676,10 +673,7 @@ namespace smt {
|
|||
*/
|
||||
void context::reinsert_parents_into_cg_table(enode * r1, enode * r2, enode * n1, enode * n2, eq_justification js) {
|
||||
enode_vector & r2_parents = r2->m_parents;
|
||||
enode_vector::iterator it = r1->begin_parents();
|
||||
enode_vector::iterator end = r1->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode * parent : r1->get_parents()) {
|
||||
if (!parent->is_marked())
|
||||
continue;
|
||||
parent->unset_mark();
|
||||
|
@ -1011,10 +1005,7 @@ namespace smt {
|
|||
r2->m_parents.shrink(r2_num_parents);
|
||||
|
||||
// try to reinsert parents of r1 that are not cgr
|
||||
it = r1->begin_parents();
|
||||
end = r1->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode * parent : r1->get_parents()) {
|
||||
TRACE("add_eq_parents", tout << "visiting: #" << parent->get_owner_id() << "\n";);
|
||||
if (parent->is_cgc_enabled()) {
|
||||
enode * cg = parent->m_cg;
|
||||
|
@ -1210,10 +1201,7 @@ namespace smt {
|
|||
bool context::is_diseq_slow(enode * n1, enode * n2) const {
|
||||
if (n1->get_num_parents() > n2->get_num_parents())
|
||||
std::swap(n1, n2);
|
||||
enode_vector::iterator it = n1->begin_parents();
|
||||
enode_vector::iterator end = n1->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode * parent : n1->get_parents()) {
|
||||
if (parent->is_eq() && is_relevant(parent->get_owner()) && get_assignment(enode2bool_var(parent)) == l_false &&
|
||||
((parent->get_arg(0)->get_root() == n1->get_root() && parent->get_arg(1)->get_root() == n2->get_root()) ||
|
||||
(parent->get_arg(1)->get_root() == n1->get_root() && parent->get_arg(0)->get_root() == n2->get_root()))) {
|
||||
|
@ -1245,10 +1233,7 @@ namespace smt {
|
|||
return false;
|
||||
if (r1->get_num_parents() < SMALL_NUM_PARENTS) {
|
||||
TRACE("is_ext_diseq", tout << mk_bounded_pp(n1->get_owner(), m_manager) << " " << mk_bounded_pp(n2->get_owner(), m_manager) << " " << depth << "\n";);
|
||||
enode_vector::iterator it1 = r1->begin_parents();
|
||||
enode_vector::iterator end1 = r1->end_parents();
|
||||
for (; it1 != end1; ++it1) {
|
||||
enode * p1 = *it1;
|
||||
for (enode* p1 : r1->get_parents()) {
|
||||
if (!is_relevant(p1))
|
||||
continue;
|
||||
if (p1->is_eq())
|
||||
|
@ -1258,10 +1243,7 @@ namespace smt {
|
|||
func_decl * f = p1->get_decl();
|
||||
TRACE("is_ext_diseq", tout << "p1: " << mk_bounded_pp(p1->get_owner(), m_manager) << "\n";);
|
||||
unsigned num_args = p1->get_num_args();
|
||||
enode_vector::iterator it2 = r2->begin_parents();
|
||||
enode_vector::iterator end2 = r2->end_parents();
|
||||
for (; it2 != end2; ++it2) {
|
||||
enode * p2 = *it2;
|
||||
for (enode * p2 : r2->get_parents()) {
|
||||
if (!is_relevant(p2))
|
||||
continue;
|
||||
if (p2->is_eq())
|
||||
|
@ -1299,10 +1281,7 @@ namespace smt {
|
|||
}
|
||||
almost_cg_table & table = *(m_almost_cg_tables[depth]);
|
||||
table.reset(r1, r2);
|
||||
enode_vector::iterator it1 = r1->begin_parents();
|
||||
enode_vector::iterator end1 = r1->end_parents();
|
||||
for (; it1 != end1; ++it1) {
|
||||
enode * p1 = *it1;
|
||||
for (enode* p1 : r1->get_parents()) {
|
||||
if (!is_relevant(p1))
|
||||
continue;
|
||||
if (p1->is_eq())
|
||||
|
@ -1313,10 +1292,7 @@ namespace smt {
|
|||
}
|
||||
if (table.empty())
|
||||
return false;
|
||||
enode_vector::iterator it2 = r2->begin_parents();
|
||||
enode_vector::iterator end2 = r2->end_parents();
|
||||
for (; it2 != end2; ++it2) {
|
||||
enode * p2 = *it2;
|
||||
for (enode * p2 : r2->get_parents()) {
|
||||
if (!is_relevant(p2))
|
||||
continue;
|
||||
if (p2->is_eq())
|
||||
|
@ -1523,10 +1499,7 @@ namespace smt {
|
|||
}
|
||||
TRACE("push_new_th_diseqs", tout << "#" << r->get_owner_id() << " v" << v << "\n";);
|
||||
theory_id th_id = th->get_id();
|
||||
enode_vector::iterator it = r->begin_parents();
|
||||
enode_vector::iterator end = r->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode * parent : r->get_parents()) {
|
||||
CTRACE("parent_bug", parent == 0, tout << "#" << r->get_owner_id() << ", num_parents: " << r->get_num_parents() << "\n"; display(tout););
|
||||
if (parent->is_eq()) {
|
||||
bool_var bv = get_bool_var_of_id(parent->get_owner_id());
|
||||
|
@ -1830,6 +1803,15 @@ namespace smt {
|
|||
m_bvar_inc *= INV_ACTIVITY_LIMIT;
|
||||
}
|
||||
|
||||
expr* context::next_decision() {
|
||||
bool_var var;
|
||||
lbool phase;
|
||||
m_case_split_queue->next_case_split(var, phase);
|
||||
if (var == null_bool_var) return m_manager.mk_true();
|
||||
m_case_split_queue->unassign_var_eh(var);
|
||||
return bool_var2expr(var);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Execute next clase split, return false if there are no
|
||||
more case splits to be performed.
|
||||
|
@ -1990,6 +1972,15 @@ namespace smt {
|
|||
m_watches[(~cls->get_literal(idx)).index()].remove_clause(cls);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Remove boolean variable from watch lists.
|
||||
*/
|
||||
void context::remove_watch(bool_var v) {
|
||||
literal lit(v);
|
||||
m_watches[lit.index()].reset();
|
||||
m_watches[(~lit).index()].reset();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Update the index used for backward subsumption.
|
||||
*/
|
||||
|
@ -2201,9 +2192,7 @@ namespace smt {
|
|||
TRACE("cached_generation", tout << "caching: #" << n->get_id() << " " << e->get_generation() << "\n";);
|
||||
m_cached_generation.insert(n, e->get_generation());
|
||||
}
|
||||
unsigned num_args = to_app(n)->get_num_args();
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
expr * arg = to_app(n)->get_arg(i);
|
||||
for (expr * arg : *to_app(n)) {
|
||||
if (is_app(arg) || is_quantifier(arg))
|
||||
todo.push_back(arg);
|
||||
}
|
||||
|
@ -3407,6 +3396,7 @@ namespace smt {
|
|||
m_num_conflicts = 0;
|
||||
m_num_conflicts_since_restart = 0;
|
||||
m_num_conflicts_since_lemma_gc = 0;
|
||||
m_num_restarts = 0;
|
||||
m_restart_threshold = m_fparams.m_restart_initial;
|
||||
m_restart_outer_threshold = m_fparams.m_restart_initial;
|
||||
m_agility = 0.0;
|
||||
|
@ -3504,6 +3494,7 @@ namespace smt {
|
|||
|
||||
bool context::restart(lbool& status, unsigned curr_lvl) {
|
||||
|
||||
|
||||
if (m_last_search_failure != OK) {
|
||||
if (status != l_false) {
|
||||
// build candidate model before returning
|
||||
|
@ -3537,7 +3528,7 @@ namespace smt {
|
|||
inc_limits();
|
||||
if (status == l_true || !m_fparams.m_restart_adaptive || m_agility < m_fparams.m_restart_agility_threshold) {
|
||||
SASSERT(!inconsistent());
|
||||
IF_VERBOSE(2, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations
|
||||
IF_VERBOSE(2, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations
|
||||
<< " :decisions " << m_stats.m_num_decisions
|
||||
<< " :conflicts " << m_stats.m_num_conflicts << " :restart " << m_restart_threshold;
|
||||
if (m_fparams.m_restart_strategy == RS_IN_OUT_GEOMETRIC) {
|
||||
|
@ -3546,9 +3537,10 @@ namespace smt {
|
|||
if (m_fparams.m_restart_adaptive) {
|
||||
verbose_stream() << " :agility " << m_agility;
|
||||
}
|
||||
verbose_stream() << ")" << std::endl; verbose_stream().flush(););
|
||||
verbose_stream() << ")\n");
|
||||
// execute the restart
|
||||
m_stats.m_num_restarts++;
|
||||
m_num_restarts++;
|
||||
if (m_scope_lvl > curr_lvl) {
|
||||
pop_scope(m_scope_lvl - curr_lvl);
|
||||
SASSERT(at_search_level());
|
||||
|
@ -3565,6 +3557,11 @@ namespace smt {
|
|||
status = l_false;
|
||||
return false;
|
||||
}
|
||||
if (m_num_restarts >= m_fparams.m_restart_max) {
|
||||
status = l_undef;
|
||||
m_last_search_failure = NUM_CONFLICTS;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_fparams.m_simplify_clauses)
|
||||
simplify_clauses();
|
||||
|
@ -3870,6 +3867,9 @@ namespace smt {
|
|||
svector<bool> expr_signs;
|
||||
for (unsigned i = 0; i < num_lits; i++) {
|
||||
literal l = lits[i];
|
||||
if (get_assignment(l) != l_false) {
|
||||
std::cout << l << " " << get_assignment(l) << "\n";
|
||||
}
|
||||
SASSERT(get_assignment(l) == l_false);
|
||||
expr_lits.push_back(bool_var2expr(l.var()));
|
||||
expr_signs.push_back(l.sign());
|
||||
|
@ -4232,10 +4232,7 @@ namespace smt {
|
|||
theory_var_list * l = n->get_th_var_list();
|
||||
theory_id th_id = l->get_th_id();
|
||||
|
||||
enode_vector::const_iterator it = n->begin_parents();
|
||||
enode_vector::const_iterator end = n->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode* parent : n->get_parents()) {
|
||||
family_id fid = parent->get_owner()->get_family_id();
|
||||
if (fid != th_id && fid != m_manager.get_basic_family_id()) {
|
||||
TRACE("is_shared", tout << mk_pp(n->get_owner(), m_manager) << "\nis shared because of:\n" << mk_pp(parent->get_owner(), m_manager) << "\n";);
|
||||
|
|
|
@ -320,6 +320,7 @@ namespace smt {
|
|||
}
|
||||
#endif
|
||||
|
||||
clause_vector const& get_lemmas() const { return m_lemmas; }
|
||||
|
||||
literal get_literal(expr * n) const;
|
||||
|
||||
|
@ -622,8 +623,6 @@ namespace smt {
|
|||
|
||||
void remove_cls_occs(clause * cls);
|
||||
|
||||
void mark_as_deleted(clause * cls);
|
||||
|
||||
void del_clause(clause * cls);
|
||||
|
||||
void del_clauses(clause_vector & v, unsigned old_size);
|
||||
|
@ -648,6 +647,14 @@ namespace smt {
|
|||
|
||||
void reassert_units(unsigned units_to_reassert_lim);
|
||||
|
||||
public:
|
||||
// \brief exposed for PB solver to participate in GC
|
||||
|
||||
void remove_watch(bool_var v);
|
||||
|
||||
void mark_as_deleted(clause * cls);
|
||||
|
||||
|
||||
// -----------------------------------
|
||||
//
|
||||
// Internalization
|
||||
|
@ -890,6 +897,8 @@ namespace smt {
|
|||
unsigned m_num_conflicts;
|
||||
unsigned m_num_conflicts_since_restart;
|
||||
unsigned m_num_conflicts_since_lemma_gc;
|
||||
unsigned m_num_restarts;
|
||||
unsigned m_num_simplifications;
|
||||
unsigned m_restart_threshold;
|
||||
unsigned m_restart_outer_threshold;
|
||||
unsigned m_luby_idx;
|
||||
|
@ -1031,6 +1040,8 @@ namespace smt {
|
|||
|
||||
enode * get_enode_eq_to(func_decl * f, unsigned num_args, enode * const * args);
|
||||
|
||||
expr* next_decision();
|
||||
|
||||
protected:
|
||||
bool decide();
|
||||
|
||||
|
|
|
@ -341,10 +341,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
void context::display_parent_eqs(std::ostream & out, enode * n) const {
|
||||
enode_vector::iterator it = n->begin_parents();
|
||||
enode_vector::iterator end = n->end_parents();
|
||||
for (; it != end; ++it) {
|
||||
enode * parent = *it;
|
||||
for (enode* parent : n->get_parents()) {
|
||||
if (parent->is_eq())
|
||||
display_eq_detail(out, parent);
|
||||
}
|
||||
|
@ -586,7 +583,7 @@ namespace smt {
|
|||
case b_justification::CLAUSE: {
|
||||
clause * cls = j.get_clause();
|
||||
out << "clause ";
|
||||
if (cls) display_literals(out, cls->get_num_literals(), cls->begin_literals());
|
||||
if (cls) out << literal_vector(cls->get_num_literals(), cls->begin_literals());
|
||||
break;
|
||||
}
|
||||
case b_justification::JUSTIFICATION: {
|
||||
|
|
|
@ -227,15 +227,28 @@ namespace smt {
|
|||
return m_args;
|
||||
}
|
||||
|
||||
class args {
|
||||
class const_args {
|
||||
enode const& n;
|
||||
public:
|
||||
args(enode const& n):n(n) {}
|
||||
args(enode const* n):n(*n) {}
|
||||
enode_vector::const_iterator begin() const { return n.get_args(); }
|
||||
enode_vector::const_iterator end() const { return n.get_args() + n.get_num_args(); }
|
||||
const_args(enode const& n):n(n) {}
|
||||
const_args(enode const* n):n(*n) {}
|
||||
enode_vector::const_iterator begin() const { return n.m_args; }
|
||||
enode_vector::const_iterator end() const { return n.m_args + n.get_num_args(); }
|
||||
};
|
||||
|
||||
class args {
|
||||
enode & n;
|
||||
public:
|
||||
args(enode & n):n(n) {}
|
||||
args(enode * n):n(*n) {}
|
||||
enode_vector::iterator begin() const { return n.m_args; }
|
||||
enode_vector::iterator end() const { return n.m_args + n.get_num_args(); }
|
||||
};
|
||||
|
||||
const_args get_const_args() const { return const_args(this); }
|
||||
|
||||
// args get_args() { return args(this); }
|
||||
|
||||
// unsigned get_id() const {
|
||||
// return m_id;
|
||||
// }
|
||||
|
@ -305,15 +318,27 @@ namespace smt {
|
|||
return m_commutative;
|
||||
}
|
||||
|
||||
class parents {
|
||||
class const_parents {
|
||||
enode const& n;
|
||||
public:
|
||||
parents(enode const& _n):n(_n) {}
|
||||
parents(enode const* _n):n(*_n) {}
|
||||
const_parents(enode const& _n):n(_n) {}
|
||||
const_parents(enode const* _n):n(*_n) {}
|
||||
enode_vector::const_iterator begin() const { return n.begin_parents(); }
|
||||
enode_vector::const_iterator end() const { return n.end_parents(); }
|
||||
};
|
||||
|
||||
class parents {
|
||||
enode& n;
|
||||
public:
|
||||
parents(enode & _n):n(_n) {}
|
||||
parents(enode * _n):n(*_n) {}
|
||||
enode_vector::iterator begin() const { return n.begin_parents(); }
|
||||
enode_vector::iterator end() const { return n.end_parents(); }
|
||||
};
|
||||
|
||||
parents get_parents() { return parents(this); }
|
||||
|
||||
const_parents get_const_parents() const { return const_parents(this); }
|
||||
|
||||
unsigned get_num_parents() const {
|
||||
return m_parents.size();
|
||||
|
|
|
@ -611,7 +611,6 @@ namespace smt {
|
|||
case OP_XOR:
|
||||
UNREACHABLE();
|
||||
case OP_OEQ:
|
||||
case OP_INTERP:
|
||||
UNREACHABLE();
|
||||
default:
|
||||
break;
|
||||
|
@ -1345,6 +1344,7 @@ namespace smt {
|
|||
cls->swap_lits(1, w2_idx);
|
||||
TRACE("mk_th_lemma", display_clause(tout, cls); tout << "\n";);
|
||||
}
|
||||
// display_clause(std::cout, cls); std::cout << "\n";
|
||||
m_lemmas.push_back(cls);
|
||||
add_watch_literal(cls, 0);
|
||||
add_watch_literal(cls, 1);
|
||||
|
|
|
@ -174,11 +174,15 @@ namespace smt {
|
|||
void get_guessed_literals(expr_ref_vector & result) {
|
||||
m_kernel.get_guessed_literals(result);
|
||||
}
|
||||
|
||||
|
||||
expr* next_decision() {
|
||||
return m_kernel.next_decision();
|
||||
}
|
||||
|
||||
void collect_statistics(::statistics & st) const {
|
||||
m_kernel.collect_statistics(st);
|
||||
}
|
||||
|
||||
|
||||
void reset_statistics() {
|
||||
}
|
||||
|
||||
|
@ -343,6 +347,10 @@ namespace smt {
|
|||
m_imp->get_guessed_literals(result);
|
||||
}
|
||||
|
||||
expr* kernel::next_decision() {
|
||||
return m_imp->next_decision();
|
||||
}
|
||||
|
||||
void kernel::display(std::ostream & out) const {
|
||||
m_imp->display(out);
|
||||
}
|
||||
|
|
|
@ -212,6 +212,11 @@ namespace smt {
|
|||
*/
|
||||
void get_guessed_literals(expr_ref_vector & result);
|
||||
|
||||
/**
|
||||
\brief return the next case split literal.
|
||||
*/
|
||||
expr* next_decision();
|
||||
|
||||
/**
|
||||
\brief (For debubbing purposes) Prints the state of the kernel
|
||||
*/
|
||||
|
|
|
@ -387,6 +387,7 @@ namespace smt {
|
|||
enode * n = *it3;
|
||||
if (is_uninterp_const(n->get_owner()) && m_context->is_relevant(n)) {
|
||||
func_decl * d = n->get_owner()->get_decl();
|
||||
TRACE("mg_top_sort", tout << d->get_name() << " " << (m_hidden_ufs.contains(d)?"hidden":"visible") << "\n";);
|
||||
if (m_hidden_ufs.contains(d)) continue;
|
||||
expr * val = get_value(n);
|
||||
m_model->register_decl(d, val);
|
||||
|
|
|
@ -736,8 +736,6 @@ namespace smt {
|
|||
}
|
||||
|
||||
void setup::setup_r_arith() {
|
||||
// to disable theory lra
|
||||
// m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params));
|
||||
m_context.register_plugin(alloc(smt::theory_lra, m_manager, m_params));
|
||||
}
|
||||
|
||||
|
@ -803,6 +801,9 @@ namespace smt {
|
|||
case AS_OPTINF:
|
||||
m_context.register_plugin(alloc(smt::theory_inf_arith, m_manager, m_params));
|
||||
break;
|
||||
case AS_LRA:
|
||||
setup_r_arith();
|
||||
break;
|
||||
default:
|
||||
if (m_params.m_arith_int_only && int_only)
|
||||
m_context.register_plugin(alloc(smt::theory_i_arith, m_manager, m_params));
|
||||
|
|
|
@ -30,9 +30,35 @@ Notes:
|
|||
namespace smt {
|
||||
|
||||
class smt_solver : public solver_na2as {
|
||||
|
||||
struct cuber {
|
||||
smt_solver& m_solver;
|
||||
unsigned m_round;
|
||||
expr_ref m_result;
|
||||
cuber(smt_solver& s):
|
||||
m_solver(s),
|
||||
m_round(0),
|
||||
m_result(s.get_manager()) {}
|
||||
expr_ref cube() {
|
||||
switch (m_round) {
|
||||
case 0:
|
||||
m_result = m_solver.m_context.next_decision();
|
||||
break;
|
||||
case 1:
|
||||
m_result = m_solver.get_manager().mk_not(m_result);
|
||||
break;
|
||||
default:
|
||||
m_result = m_solver.get_manager().mk_false();
|
||||
break;
|
||||
}
|
||||
++m_round;
|
||||
return m_result;
|
||||
}
|
||||
};
|
||||
|
||||
smt_params m_smt_params;
|
||||
smt::kernel m_context;
|
||||
progress_callback * m_callback;
|
||||
cuber* m_cuber;
|
||||
symbol m_logic;
|
||||
bool m_minimizing_core;
|
||||
bool m_core_extend_patterns;
|
||||
|
@ -45,6 +71,7 @@ namespace smt {
|
|||
solver_na2as(m),
|
||||
m_smt_params(p),
|
||||
m_context(m, m_smt_params),
|
||||
m_cuber(nullptr),
|
||||
m_minimizing_core(false),
|
||||
m_core_extend_patterns(false),
|
||||
m_core_extend_patterns_max_distance(UINT_MAX),
|
||||
|
@ -61,15 +88,24 @@ namespace smt {
|
|||
smt_solver * result = alloc(smt_solver, m, p, m_logic);
|
||||
smt::kernel::copy(m_context, result->m_context);
|
||||
|
||||
for (auto & kv : m_name2assertion)
|
||||
result->m_name2assertion.insert(translator(kv.m_key),
|
||||
translator(kv.m_value));
|
||||
|
||||
if (mc0())
|
||||
result->set_model_converter(mc0()->translate(translator));
|
||||
|
||||
for (auto & kv : m_name2assertion) {
|
||||
expr* val = translator(kv.m_value);
|
||||
expr* t = translator(kv.m_key);
|
||||
result->m_name2assertion.insert(t, val);
|
||||
result->solver_na2as::assert_expr(val, t);
|
||||
m.inc_ref(val);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
~smt_solver() override {
|
||||
dec_ref_values(get_manager(), m_name2assertion);
|
||||
dealloc(m_cuber);
|
||||
}
|
||||
|
||||
void updt_params(params_ref const & p) override {
|
||||
|
@ -99,15 +135,15 @@ namespace smt {
|
|||
return m_context.find_mutexes(vars, mutexes);
|
||||
}
|
||||
|
||||
void assert_expr(expr * t) override {
|
||||
void assert_expr_core(expr * t) override {
|
||||
m_context.assert_expr(t);
|
||||
}
|
||||
|
||||
void assert_expr(expr * t, expr * a) override {
|
||||
void assert_expr_core2(expr * t, expr * a) override {
|
||||
if (m_name2assertion.contains(a)) {
|
||||
throw default_exception("named assertion defined twice");
|
||||
}
|
||||
solver_na2as::assert_expr(t, a);
|
||||
solver_na2as::assert_expr_core2(t, a);
|
||||
get_manager().inc_ref(t);
|
||||
m_name2assertion.insert(a, t);
|
||||
}
|
||||
|
@ -177,7 +213,7 @@ namespace smt {
|
|||
add_nonlocal_pattern_literals_to_core(r);
|
||||
}
|
||||
|
||||
void get_model(model_ref & m) override {
|
||||
void get_model_core(model_ref & m) override {
|
||||
m_context.get_model(m);
|
||||
}
|
||||
|
||||
|
@ -202,7 +238,6 @@ namespace smt {
|
|||
ast_manager & get_manager() const override { return m_context.m(); }
|
||||
|
||||
void set_progress_callback(progress_callback * callback) override {
|
||||
m_callback = callback;
|
||||
m_context.set_progress_callback(callback);
|
||||
}
|
||||
|
||||
|
@ -215,6 +250,26 @@ namespace smt {
|
|||
return m_context.get_formula(idx);
|
||||
}
|
||||
|
||||
expr_ref_vector cube(expr_ref_vector& vars, unsigned cutoff) override {
|
||||
ast_manager& m = get_manager();
|
||||
if (!m_cuber) {
|
||||
m_cuber = alloc(cuber, *this);
|
||||
}
|
||||
expr_ref result = m_cuber->cube();
|
||||
expr_ref_vector lits(m);
|
||||
if (m.is_false(result)) {
|
||||
dealloc(m_cuber);
|
||||
m_cuber = nullptr;
|
||||
}
|
||||
if (m.is_true(result)) {
|
||||
dealloc(m_cuber);
|
||||
m_cuber = nullptr;
|
||||
return lits;
|
||||
}
|
||||
lits.push_back(result);
|
||||
return lits;
|
||||
}
|
||||
|
||||
struct collect_fds_proc {
|
||||
ast_manager & m;
|
||||
func_decl_set & m_fds;
|
||||
|
|
|
@ -69,12 +69,8 @@ public:
|
|||
|
||||
void reset_statistics() override { m_num_steps = 0; }
|
||||
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result,
|
||||
model_converter_ref & mc,
|
||||
proof_converter_ref & pc,
|
||||
expr_dependency_ref & core) override {
|
||||
mc = nullptr; pc = nullptr; core = nullptr;
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) override {
|
||||
reduce(*(in.get()));
|
||||
in->inc_depth();
|
||||
result.push_back(in.get());
|
||||
|
|
|
@ -16,19 +16,21 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include "tactic/tactic.h"
|
||||
#include "tactic/tactical.h"
|
||||
#include "util/lp/lp_params.hpp"
|
||||
#include "ast/rewriter/rewriter_types.h"
|
||||
#include "ast/ast_util.h"
|
||||
#include "smt/smt_kernel.h"
|
||||
#include "smt/params/smt_params.h"
|
||||
#include "smt/params/smt_params_helper.hpp"
|
||||
#include "util/lp/lp_params.hpp"
|
||||
#include "ast/rewriter/rewriter_types.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "ast/ast_util.h"
|
||||
#include "solver/solver2tactic.h"
|
||||
#include "smt/smt_solver.h"
|
||||
#include "tactic/tactic.h"
|
||||
#include "tactic/tactical.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
#include "solver/solver2tactic.h"
|
||||
#include "solver/solver.h"
|
||||
#include "solver/mus.h"
|
||||
#include "solver/parallel_tactic.h"
|
||||
#include "solver/parallel_params.hpp"
|
||||
|
||||
typedef obj_map<expr, expr *> expr2expr_map;
|
||||
|
||||
|
@ -145,13 +147,9 @@ public:
|
|||
|
||||
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result,
|
||||
model_converter_ref & mc,
|
||||
proof_converter_ref & pc,
|
||||
expr_dependency_ref & core) override {
|
||||
goal_ref_buffer & result) override {
|
||||
try {
|
||||
IF_VERBOSE(10, verbose_stream() << "(smt.tactic start)\n";);
|
||||
mc = nullptr; pc = nullptr; core = nullptr;
|
||||
SASSERT(in->is_well_sorted());
|
||||
ast_manager & m = in->m();
|
||||
TRACE("smt_tactic", tout << this << "\nAUTO_CONFIG: " << fparams().m_auto_config << " HIDIV0: " << fparams().m_hi_div0 << " "
|
||||
|
@ -169,7 +167,7 @@ public:
|
|||
expr_ref_vector clauses(m);
|
||||
expr2expr_map bool2dep;
|
||||
ptr_vector<expr> assumptions;
|
||||
ref<filter_model_converter> fmc;
|
||||
ref<generic_model_converter> fmc;
|
||||
if (in->unsat_core_enabled()) {
|
||||
extract_clauses_and_dependencies(in, clauses, assumptions, bool2dep, fmc);
|
||||
TRACE("mus", in->display_with_dependencies(tout);
|
||||
|
@ -220,9 +218,13 @@ public:
|
|||
model_ref md;
|
||||
m_ctx->get_model(md);
|
||||
buffer<symbol> r;
|
||||
m_ctx->get_relevant_labels(nullptr, r);
|
||||
mc = model_and_labels2model_converter(md.get(), r);
|
||||
m_ctx->get_relevant_labels(0, r);
|
||||
labels_vec rv;
|
||||
rv.append(r.size(), r.c_ptr());
|
||||
model_converter_ref mc;
|
||||
mc = model_and_labels2model_converter(md.get(), rv);
|
||||
mc = concat(fmc.get(), mc.get());
|
||||
in->add(mc.get());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -269,8 +271,10 @@ public:
|
|||
model_ref md;
|
||||
m_ctx->get_model(md);
|
||||
buffer<symbol> r;
|
||||
m_ctx->get_relevant_labels(nullptr, r);
|
||||
mc = model_and_labels2model_converter(md.get(), r);
|
||||
m_ctx->get_relevant_labels(0, r);
|
||||
labels_vec rv;
|
||||
rv.append(r.size(), r.c_ptr());
|
||||
in->add(model_and_labels2model_converter(md.get(), rv));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
|
@ -299,3 +303,18 @@ tactic * mk_smt_tactic_using(bool auto_config, params_ref const & _p) {
|
|||
return using_params(r, p);
|
||||
}
|
||||
|
||||
tactic * mk_psmt_tactic(ast_manager& m, params_ref const& p, symbol const& logic) {
|
||||
parallel_params pp(p);
|
||||
return pp.enable() ? mk_parallel_tactic(mk_smt_solver(m, p, logic), p) : mk_smt_tactic(p);
|
||||
}
|
||||
|
||||
tactic * mk_psmt_tactic_using(ast_manager& m, bool auto_config, params_ref const& _p, symbol const& logic) {
|
||||
parallel_params pp(_p);
|
||||
params_ref p = _p;
|
||||
p.set_bool("auto_config", auto_config);
|
||||
return using_params(pp.enable() ? mk_parallel_tactic(mk_smt_solver(m, p, logic), p) : mk_smt_tactic(p), p);
|
||||
}
|
||||
|
||||
tactic * mk_parallel_smt_tactic(ast_manager& m, params_ref const& p) {
|
||||
return mk_parallel_tactic(mk_smt_solver(m, p, symbol::null), p);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,13 @@ tactic * mk_smt_tactic(params_ref const & p = params_ref());
|
|||
// syntax sugar for using_params(mk_smt_tactic(), p) where p = (:auto_config, auto_config)
|
||||
tactic * mk_smt_tactic_using(bool auto_config = true, params_ref const & p = params_ref());
|
||||
|
||||
tactic * mk_psmt_tactic(ast_manager& m, params_ref const& p, symbol const& logic = symbol::null);
|
||||
tactic * mk_psmt_tactic_using(ast_manager& m, bool auto_config, params_ref const& p, symbol const& logic = symbol::null);
|
||||
tactic * mk_parallel_smt_tactic(ast_manager& m, params_ref const& p);
|
||||
|
||||
|
||||
/*
|
||||
ADD_TACTIC("smt", "apply a SAT based SMT solver.", "mk_smt_tactic(p)")
|
||||
ADD_TACTIC("psmt", "builtin strategy for SMT tactic in parallel.", "mk_parallel_smt_tactic(m, p)")
|
||||
*/
|
||||
#endif
|
||||
|
|
|
@ -39,11 +39,8 @@ struct unit_subsumption_tactic : public tactic {
|
|||
|
||||
void cleanup() override {}
|
||||
|
||||
void operator()(/* in */ goal_ref const & in,
|
||||
/* out */ goal_ref_buffer & result,
|
||||
/* out */ model_converter_ref & mc,
|
||||
/* out */ proof_converter_ref & pc,
|
||||
/* out */ expr_dependency_ref & core) override {
|
||||
void operator()(/* in */ goal_ref const & in,
|
||||
/* out */ goal_ref_buffer & result) override {
|
||||
reduce_core(in, result);
|
||||
}
|
||||
|
||||
|
@ -109,9 +106,7 @@ struct unit_subsumption_tactic : public tactic {
|
|||
}
|
||||
|
||||
void insert_result(goal_ref& result) {
|
||||
for (unsigned i = 0; i < m_deleted.size(); ++i) {
|
||||
result->update(m_deleted[i], m.mk_true()); // TBD proof?
|
||||
}
|
||||
for (auto d : m_deleted) result->update(d, m.mk_true()); // TBD proof?
|
||||
}
|
||||
|
||||
void init(goal_ref const& g) {
|
||||
|
|
|
@ -31,6 +31,7 @@ Revision History:
|
|||
#include "smt/params/theory_arith_params.h"
|
||||
#include "smt/arith_eq_adapter.h"
|
||||
#include "smt/proto_model/numeral_factory.h"
|
||||
#include "smt/smt_context.h"
|
||||
#include "util/obj_pair_hashtable.h"
|
||||
#include "smt/old_interval.h"
|
||||
#include "math/grobner/grobner.h"
|
||||
|
@ -1078,10 +1079,10 @@ namespace smt {
|
|||
// Optimization
|
||||
//
|
||||
// -----------------------------------
|
||||
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_numeral const& val);
|
||||
inf_eps_rational<inf_rational> maximize(theory_var v, expr_ref& blocker, bool& has_shared) override;
|
||||
inf_eps_rational<inf_rational> value(theory_var v) override;
|
||||
theory_var add_objective(app* term) override;
|
||||
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_numeral const& val);
|
||||
void enable_record_conflict(expr* bound);
|
||||
void record_conflict(unsigned num_lits, literal const * lits,
|
||||
unsigned num_eqs, enode_pair const * eqs,
|
||||
|
|
|
@ -23,7 +23,7 @@ Revision History:
|
|||
#include "smt/theory_arith.h"
|
||||
#include "smt/smt_farkas_util.h"
|
||||
#include "ast/rewriter/th_rewriter.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
|
||||
namespace smt {
|
||||
|
||||
|
@ -1117,14 +1117,14 @@ namespace smt {
|
|||
This allows to handle inequalities with non-standard numbers.
|
||||
*/
|
||||
template<typename Ext>
|
||||
expr_ref theory_arith<Ext>::mk_ge(filter_model_converter& fm, theory_var v, inf_numeral const& val) {
|
||||
expr_ref theory_arith<Ext>::mk_ge(generic_model_converter& fm, theory_var v, inf_numeral const& val) {
|
||||
ast_manager& m = get_manager();
|
||||
context& ctx = get_context();
|
||||
std::ostringstream strm;
|
||||
strm << val << " <= " << mk_pp(get_enode(v)->get_owner(), get_manager());
|
||||
app* b = m.mk_const(symbol(strm.str().c_str()), m.mk_bool_sort());
|
||||
if (!ctx.b_internalized(b)) {
|
||||
fm.insert(b->get_decl());
|
||||
fm.hide(b->get_decl());
|
||||
bool_var bv = ctx.mk_bool_var(b);
|
||||
ctx.set_var_theory(bv, get_id());
|
||||
// ctx.set_enode_flag(bv, true);
|
||||
|
|
|
@ -200,10 +200,12 @@ namespace smt {
|
|||
SASSERT(is_int(v));
|
||||
SASSERT(!get_value(v).is_int());
|
||||
m_stats.m_branches++;
|
||||
TRACE("arith_int", tout << "branching v" << v << " = " << get_value(v) << "\n";
|
||||
display_var(tout, v););
|
||||
numeral k = ceil(get_value(v));
|
||||
rational _k = k.to_rational();
|
||||
TRACE("arith_int", tout << "branching v" << v << " = " << get_value(v) << "\n";
|
||||
display_var(tout, v);
|
||||
tout << "k = " << k << ", _k = "<< _k << std::endl;
|
||||
);
|
||||
expr_ref bound(get_manager());
|
||||
expr* e = get_enode(v)->get_owner();
|
||||
bound = m_util.mk_ge(e, m_util.mk_numeral(_k, m_util.is_int(e)));
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace smt {
|
|||
inf_eps_rational<inf_rational> value(theory_var v) override;
|
||||
theory_var add_objective(app* term) override;
|
||||
virtual expr_ref mk_gt(theory_var v, inf_eps const& val);
|
||||
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val);
|
||||
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val);
|
||||
|
||||
// -----------------------------------
|
||||
//
|
||||
|
|
|
@ -1055,7 +1055,7 @@ namespace smt {
|
|||
|
||||
template<typename Ext>
|
||||
expr_ref theory_dense_diff_logic<Ext>::mk_ge(
|
||||
filter_model_converter& fm, theory_var v, inf_eps const& val) {
|
||||
generic_model_converter& fm, theory_var v, inf_eps const& val) {
|
||||
return mk_ineq(v, val, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -321,10 +321,10 @@ namespace smt {
|
|||
//
|
||||
// -----------------------------------
|
||||
|
||||
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val);
|
||||
inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) override;
|
||||
inf_eps value(theory_var v) override;
|
||||
theory_var add_objective(app* term) override;
|
||||
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val);
|
||||
|
||||
bool internalize_objective(expr * n, rational const& m, rational& r, objective_term & objective);
|
||||
|
||||
|
|
|
@ -1338,7 +1338,7 @@ expr_ref theory_diff_logic<Ext>::mk_gt(theory_var v, inf_eps const& val) {
|
|||
}
|
||||
|
||||
template<typename Ext>
|
||||
expr_ref theory_diff_logic<Ext>::mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val) {
|
||||
expr_ref theory_diff_logic<Ext>::mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val) {
|
||||
return mk_ineq(v, val, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ Revision History:
|
|||
#include "smt/smt_model_generator.h"
|
||||
#include "smt/arith_eq_adapter.h"
|
||||
#include "util/nat_set.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
|
||||
namespace lra_lp {
|
||||
enum bound_kind { lower_t, upper_t };
|
||||
|
@ -2417,7 +2417,7 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
|
||||
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val) {
|
||||
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val) {
|
||||
rational r = val.get_rational();
|
||||
bool is_strict = val.get_infinitesimal().is_pos();
|
||||
app_ref b(m);
|
||||
|
@ -2429,7 +2429,7 @@ namespace smt {
|
|||
b = a.mk_ge(mk_obj(v), a.mk_numeral(r, is_int));
|
||||
}
|
||||
if (!ctx().b_internalized(b)) {
|
||||
fm.insert(b->get_decl());
|
||||
fm.hide(b);
|
||||
bool_var bv = ctx().mk_bool_var(b);
|
||||
ctx().set_var_theory(bv, get_id());
|
||||
// ctx().set_enode_flag(bv, true);
|
||||
|
@ -2620,7 +2620,7 @@ namespace smt {
|
|||
theory_var theory_lra::add_objective(app* term) {
|
||||
return m_imp->add_objective(term);
|
||||
}
|
||||
expr_ref theory_lra::mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val) {
|
||||
expr_ref theory_lra::mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val) {
|
||||
return m_imp->mk_ge(fm, v, val);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,12 +86,10 @@ namespace smt {
|
|||
void collect_statistics(::statistics & st) const override;
|
||||
|
||||
// optimization
|
||||
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val);
|
||||
inf_eps value(theory_var) override;
|
||||
inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) override;
|
||||
theory_var add_objective(app* term) override;
|
||||
virtual expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ Notes:
|
|||
#ifndef THEORY_OPT_H_
|
||||
#define THEORY_OPT_H_
|
||||
|
||||
class filter_model_converter;
|
||||
class generic_model_converter;
|
||||
namespace smt {
|
||||
class theory_opt {
|
||||
public:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@ Notes:
|
|||
#include "smt/smt_theory.h"
|
||||
#include "ast/pb_decl_plugin.h"
|
||||
#include "smt/smt_clause.h"
|
||||
#include "smt/smt_b_justification.h"
|
||||
#include "smt/params/theory_pb_params.h"
|
||||
#include "math/simplex/simplex.h"
|
||||
|
||||
|
@ -37,10 +38,10 @@ namespace smt {
|
|||
class negate_ineq;
|
||||
class remove_var;
|
||||
class undo_bound;
|
||||
|
||||
class card_justification;
|
||||
|
||||
typedef rational numeral;
|
||||
typedef simplex::simplex<simplex::mpz_ext> simplex;
|
||||
typedef simplex::row row;
|
||||
typedef simplex::row_iterator row_iterator;
|
||||
typedef unsynch_mpq_inf_manager eps_manager;
|
||||
typedef _scoped_numeral<eps_manager> scoped_eps_numeral;
|
||||
|
||||
|
@ -181,27 +182,88 @@ namespace smt {
|
|||
|
||||
};
|
||||
|
||||
struct row_info {
|
||||
unsigned m_slack; // slack variable in simplex tableau
|
||||
numeral m_bound; // bound
|
||||
arg_t m_rep; // representative
|
||||
row_info(theory_var slack, numeral const& b, arg_t const& r):
|
||||
m_slack(slack), m_bound(b), m_rep(r) {}
|
||||
row_info(): m_slack(0) {}
|
||||
// cardinality constraint args >= bound
|
||||
// unit propagation on cardinality constraints is valid if the literals
|
||||
// from k() up to size are false.
|
||||
// In this case the literals 0..k()-1 need to be true.
|
||||
// The literals in position 0..k() are watched.
|
||||
// whenever they are assigned to false, then find a literal among
|
||||
// k() + 1.. sz() to swap with.
|
||||
// If none are available, then perform unit propagation.
|
||||
//
|
||||
class card {
|
||||
literal m_lit; // literal repesenting predicate
|
||||
literal_vector m_args;
|
||||
unsigned m_bound;
|
||||
unsigned m_num_propagations;
|
||||
unsigned m_all_propagations;
|
||||
unsigned m_compilation_threshold;
|
||||
lbool m_compiled;
|
||||
bool m_aux;
|
||||
|
||||
public:
|
||||
card(literal l, unsigned bound, bool is_aux):
|
||||
m_lit(l),
|
||||
m_bound(bound),
|
||||
m_num_propagations(0),
|
||||
m_all_propagations(0),
|
||||
m_compilation_threshold(0),
|
||||
m_compiled(l_false),
|
||||
m_aux(is_aux)
|
||||
{
|
||||
SASSERT(bound > 0);
|
||||
}
|
||||
|
||||
literal lit() const { return m_lit; }
|
||||
literal lit(unsigned i) const { return m_args[i]; }
|
||||
unsigned k() const { return m_bound; }
|
||||
unsigned size() const { return m_args.size(); }
|
||||
unsigned all_propagations() const { return m_all_propagations; }
|
||||
unsigned num_propagations() const { return m_num_propagations; }
|
||||
void add_arg(literal l);
|
||||
|
||||
void init_watch(theory_pb& th, bool is_true);
|
||||
|
||||
lbool assign(theory_pb& th, literal lit);
|
||||
|
||||
void negate();
|
||||
|
||||
app_ref to_expr(theory_pb& th);
|
||||
|
||||
void inc_propagations(theory_pb& th);
|
||||
|
||||
void reset_propagations() { m_all_propagations += m_num_propagations; m_num_propagations = 0; }
|
||||
|
||||
bool is_aux() const { return m_aux; }
|
||||
|
||||
private:
|
||||
|
||||
bool validate_conflict(theory_pb& th);
|
||||
|
||||
bool validate_assign(theory_pb& th, literal_vector const& lits, literal l);
|
||||
|
||||
void set_conflict(theory_pb& th, literal l);
|
||||
};
|
||||
|
||||
typedef ptr_vector<ineq> watch_list;
|
||||
typedef ptr_vector<card> card_watch;
|
||||
typedef ptr_vector<ineq> ineq_watch;
|
||||
typedef map<arg_t, bool_var, arg_t::hash, arg_t::eq> arg_map;
|
||||
|
||||
|
||||
struct var_info {
|
||||
watch_list* m_lit_watch[2];
|
||||
watch_list* m_var_watch;
|
||||
ineq* m_ineq;
|
||||
ineq_watch* m_lit_watch[2];
|
||||
ineq_watch* m_var_watch;
|
||||
ineq* m_ineq;
|
||||
|
||||
card_watch* m_lit_cwatch[2];
|
||||
card* m_card;
|
||||
|
||||
var_info(): m_var_watch(nullptr), m_ineq(nullptr)
|
||||
var_info(): m_var_watch(0), m_ineq(0), m_card(0)
|
||||
{
|
||||
m_lit_watch[0] = nullptr;
|
||||
m_lit_watch[1] = nullptr;
|
||||
m_lit_cwatch[0] = nullptr;
|
||||
m_lit_cwatch[1] = nullptr;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
|
@ -209,38 +271,39 @@ namespace smt {
|
|||
dealloc(m_lit_watch[1]);
|
||||
dealloc(m_var_watch);
|
||||
dealloc(m_ineq);
|
||||
dealloc(m_lit_cwatch[0]);
|
||||
dealloc(m_lit_cwatch[1]);
|
||||
dealloc(m_card);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
theory_pb_params m_params;
|
||||
|
||||
svector<var_info> m_var_infos;
|
||||
arg_map m_ineq_rep; // Simplex: representative inequality
|
||||
u_map<row_info> m_ineq_row_info; // Simplex: row information per variable
|
||||
uint_set m_vars; // Simplex: 0-1 variables.
|
||||
simplex m_simplex; // Simplex: tableau
|
||||
literal_vector m_explain_lower; // Simplex: explanations for lower bounds
|
||||
literal_vector m_explain_upper; // Simplex: explanations for upper bounds
|
||||
unsynch_mpq_inf_manager m_mpq_inf_mgr; // Simplex: manage inf_mpq numerals
|
||||
mutable unsynch_mpz_manager m_mpz_mgr; // Simplex: manager mpz numerals
|
||||
unsigned_vector m_ineqs_trail;
|
||||
unsigned_vector m_ineqs_lim;
|
||||
literal_vector m_literals; // temporary vector
|
||||
pb_util m_util;
|
||||
pb_util pb;
|
||||
stats m_stats;
|
||||
ptr_vector<ineq> m_to_compile; // inequalities to compile.
|
||||
unsigned m_conflict_frequency;
|
||||
bool m_learn_complements;
|
||||
bool m_enable_compilation;
|
||||
bool m_enable_simplex;
|
||||
rational m_max_compiled_coeff;
|
||||
|
||||
bool m_cardinality_lemma;
|
||||
unsigned m_restart_lim;
|
||||
unsigned m_restart_inc;
|
||||
uint_set m_occs;
|
||||
|
||||
// internalize_atom:
|
||||
literal compile_arg(expr* arg);
|
||||
void add_watch(ineq& c, unsigned index);
|
||||
void del_watch(watch_list& watch, unsigned index, ineq& c, unsigned ineq_index);
|
||||
void init_watch(bool_var v);
|
||||
|
||||
// general purpose pb constraints
|
||||
void add_watch(ineq& c, unsigned index);
|
||||
void del_watch(ineq_watch& watch, unsigned index, ineq& c, unsigned ineq_index);
|
||||
void init_watch_literal(ineq& c);
|
||||
void init_watch_var(ineq& c);
|
||||
void clear_watch(ineq& c);
|
||||
|
@ -249,14 +312,35 @@ namespace smt {
|
|||
void unwatch_literal(literal w, ineq* c);
|
||||
void unwatch_var(bool_var v, ineq* c);
|
||||
void remove(ptr_vector<ineq>& ineqs, ineq* c);
|
||||
bool assign_watch_ge(bool_var v, bool is_true, watch_list& watch, unsigned index);
|
||||
|
||||
bool assign_watch_ge(bool_var v, bool is_true, ineq_watch& watch, unsigned index);
|
||||
void assign_watch(bool_var v, bool is_true, ineq& c);
|
||||
void assign_ineq(ineq& c, bool is_true);
|
||||
void assign_eq(ineq& c, bool is_true);
|
||||
|
||||
// cardinality constraints
|
||||
// these are cheaper to handle than general purpose PB constraints
|
||||
// and in the common case PB constraints with small coefficients can
|
||||
// be handled using cardinality constraints.
|
||||
|
||||
unsigned_vector m_card_trail;
|
||||
unsigned_vector m_card_lim;
|
||||
bool is_cardinality_constraint(app * atom);
|
||||
bool internalize_card(app * atom, bool gate_ctx);
|
||||
void card2conjunction(card const& c);
|
||||
void card2disjunction(card const& c);
|
||||
|
||||
void watch_literal(literal lit, card* c);
|
||||
void unwatch_literal(literal w, card* c);
|
||||
void add_clause(card& c, literal_vector const& lits);
|
||||
void add_assign(card& c, literal l);
|
||||
void remove(ptr_vector<card>& cards, card* c);
|
||||
void clear_watch(card& c);
|
||||
bool gc();
|
||||
std::ostream& display(std::ostream& out, card const& c, bool values = false) const;
|
||||
|
||||
|
||||
// simplex:
|
||||
literal set_explain(literal_vector& explains, unsigned var, literal expl);
|
||||
bool update_bound(bool_var v, literal explain, bool is_lower, mpq_inf const& bound);
|
||||
bool check_feasible();
|
||||
|
||||
std::ostream& display(std::ostream& out, ineq const& c, bool values = false) const;
|
||||
|
@ -284,31 +368,58 @@ namespace smt {
|
|||
// Conflict resolution, cutting plane derivation.
|
||||
//
|
||||
unsigned m_num_marks;
|
||||
literal_vector m_resolved;
|
||||
unsigned m_conflict_lvl;
|
||||
arg_t m_lemma;
|
||||
literal_vector m_ineq_literals;
|
||||
svector<bool_var> m_marked;
|
||||
|
||||
// bool_var |-> index into m_lemma
|
||||
unsigned_vector m_conseq_index;
|
||||
static const unsigned null_index;
|
||||
bool is_marked(bool_var v) const;
|
||||
void set_mark(bool_var v, unsigned idx);
|
||||
void unset_mark(bool_var v);
|
||||
void unset_marks();
|
||||
// Conflict PB constraints
|
||||
svector<int> m_coeffs;
|
||||
svector<bool_var> m_active_vars;
|
||||
int m_bound;
|
||||
literal_vector m_antecedents;
|
||||
tracked_uint_set m_active_var_set;
|
||||
expr_ref_vector m_antecedent_exprs;
|
||||
svector<bool> m_antecedent_signs;
|
||||
expr_ref_vector m_cardinality_exprs;
|
||||
svector<bool> m_cardinality_signs;
|
||||
|
||||
bool resolve_conflict(ineq& c);
|
||||
void process_antecedent(literal l, numeral coeff);
|
||||
void process_ineq(ineq& c, literal conseq, numeral coeff);
|
||||
void remove_from_lemma(unsigned idx);
|
||||
void normalize_active_coeffs();
|
||||
void inc_coeff(literal l, int offset);
|
||||
int get_coeff(bool_var v) const;
|
||||
int get_abs_coeff(bool_var v) const;
|
||||
int arg_max(int& coeff);
|
||||
|
||||
literal_vector& get_literals() { m_literals.reset(); return m_literals; }
|
||||
|
||||
vector<svector<bool_var> > m_coeff2args;
|
||||
unsigned_vector m_active_coeffs;
|
||||
bool init_arg_max();
|
||||
void reset_arg_max();
|
||||
|
||||
void reset_coeffs();
|
||||
void add_cardinality_lemma();
|
||||
literal get_asserting_literal(literal conseq);
|
||||
|
||||
bool resolve_conflict(card& c, literal_vector const& conflict_clause);
|
||||
void process_antecedent(literal l, int offset);
|
||||
void process_card(card& c, int offset);
|
||||
void cut();
|
||||
bool is_proof_justification(justification const& j) const;
|
||||
|
||||
|
||||
void hoist_maximal_values();
|
||||
|
||||
bool validate_lemma();
|
||||
void validate_final_check();
|
||||
void validate_final_check(ineq& c);
|
||||
void validate_assign(ineq const& c, literal_vector const& lits, literal l) const;
|
||||
void validate_watch(ineq const& c) const;
|
||||
bool validate_unit_propagation(card const& c);
|
||||
bool validate_antecedents(literal_vector const& lits);
|
||||
bool validate_implies(app_ref& A, app_ref& B);
|
||||
app_ref active2expr();
|
||||
app_ref literal2expr(literal lit);
|
||||
app_ref card2expr(card& c) { return c.to_expr(*this); }
|
||||
app_ref justification2expr(b_justification& js, literal conseq);
|
||||
|
||||
bool proofs_enabled() const { return get_manager().proofs_enabled(); }
|
||||
justification* justify(literal l1, literal l2);
|
||||
|
@ -337,7 +448,8 @@ namespace smt {
|
|||
model_value_proc * mk_value(enode * n, model_generator & mg) override;
|
||||
void init_model(model_generator & m) override;
|
||||
bool include_func_interp(func_decl* f) override { return false; }
|
||||
|
||||
bool can_propagate() override;
|
||||
void propagate() override;
|
||||
static literal assert_ge(context& ctx, unsigned k, unsigned n, literal const* xs);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -238,8 +238,7 @@ theory_seq::~theory_seq() {
|
|||
}
|
||||
|
||||
void theory_seq::init(context* ctx) {
|
||||
theory::init(ctx);
|
||||
m_mk_aut.set_solver(alloc(seq_expr_solver, m, get_context().get_fparams()));
|
||||
theory::init(ctx);
|
||||
}
|
||||
|
||||
final_check_status theory_seq::final_check_eh() {
|
||||
|
@ -4168,6 +4167,9 @@ eautomaton* theory_seq::get_automaton(expr* re) {
|
|||
if (m_re2aut.find(re, result)) {
|
||||
return result;
|
||||
}
|
||||
if (!m_mk_aut.has_solver()) {
|
||||
m_mk_aut.set_solver(alloc(seq_expr_solver, m, get_context().get_fparams()));
|
||||
}
|
||||
result = m_mk_aut(re);
|
||||
if (result) {
|
||||
display_expr disp(m);
|
||||
|
|
|
@ -1423,9 +1423,9 @@ namespace smt {
|
|||
// len(hd) = i
|
||||
// str.indexof(tl, N, 0)
|
||||
|
||||
expr * H; // "haystack"
|
||||
expr * N; // "needle"
|
||||
expr * i; // start index
|
||||
expr * H = nullptr; // "haystack"
|
||||
expr * N = nullptr; // "needle"
|
||||
expr * i = nullptr; // start index
|
||||
u.str.is_index(e, H, N, i);
|
||||
|
||||
expr_ref minus_one(m_autil.mk_numeral(rational::minus_one(), true), m);
|
||||
|
@ -6645,7 +6645,8 @@ namespace smt {
|
|||
expr * sub1;
|
||||
expr * sub2;
|
||||
if (u.re.is_to_re(re, sub1)) {
|
||||
SASSERT(u.str.is_string(sub1));
|
||||
if (!u.str.is_string(sub1))
|
||||
throw default_exception("regular expressions must be built from string literals");
|
||||
zstring str;
|
||||
u.str.is_string(sub1, str);
|
||||
return str.length();
|
||||
|
@ -6768,7 +6769,7 @@ namespace smt {
|
|||
expr * sub2;
|
||||
if (u.re.is_to_re(re, sub1)) {
|
||||
SASSERT(u.str.is_string(sub1));
|
||||
zstring(str);
|
||||
zstring str;
|
||||
u.str.is_string(sub1, str);
|
||||
lens.insert(str.length());
|
||||
} else if (u.re.is_concat(re, sub1, sub2)) {
|
||||
|
@ -6842,7 +6843,8 @@ namespace smt {
|
|||
expr * sub1;
|
||||
expr * sub2;
|
||||
if (u.re.is_to_re(re, sub1)) {
|
||||
SASSERT(u.str.is_string(sub1));
|
||||
if (!u.str.is_string(sub1))
|
||||
throw default_exception("regular expressions must be built from string literals");
|
||||
zstring str;
|
||||
u.str.is_string(sub1, str);
|
||||
rational strlen(str.length());
|
||||
|
@ -6951,8 +6953,8 @@ namespace smt {
|
|||
ast_manager & m = get_manager();
|
||||
|
||||
expr_ref_vector rhs(m);
|
||||
expr * str;
|
||||
expr * re;
|
||||
expr * str = nullptr;
|
||||
expr * re = nullptr;
|
||||
u.str.is_in_re(str_in_re, str, re);
|
||||
expr_ref strlen(mk_strlen(str), m);
|
||||
|
||||
|
@ -9929,8 +9931,8 @@ namespace smt {
|
|||
bool regex_axiom_add = false;
|
||||
for (obj_hashtable<expr>::iterator it = regex_terms.begin(); it != regex_terms.end(); ++it) {
|
||||
expr * str_in_re = *it;
|
||||
expr * str;
|
||||
expr * re;
|
||||
expr * str = nullptr;
|
||||
expr * re = nullptr;
|
||||
u.str.is_in_re(str_in_re, str, re);
|
||||
lbool current_assignment = ctx.get_assignment(str_in_re);
|
||||
TRACE("str", tout << "regex term: " << mk_pp(str, m) << " in " << mk_pp(re, m) << " : " << current_assignment << std::endl;);
|
||||
|
@ -9944,7 +9946,7 @@ namespace smt {
|
|||
|
||||
if (regex_term_to_length_constraint.contains(str_in_re)) {
|
||||
// use existing length constraint
|
||||
expr * top_level_length_constraint;
|
||||
expr * top_level_length_constraint = nullptr;
|
||||
regex_term_to_length_constraint.find(str_in_re, top_level_length_constraint);
|
||||
|
||||
ptr_vector<expr> extra_length_vars;
|
||||
|
@ -10473,8 +10475,8 @@ namespace smt {
|
|||
// that's consistent with the current length information
|
||||
for (ptr_vector<expr>::iterator term_it = str_in_re_terms.begin();
|
||||
term_it != str_in_re_terms.end(); ++term_it) {
|
||||
expr * _unused;
|
||||
expr * re;
|
||||
expr * _unused = nullptr;
|
||||
expr * re = nullptr;
|
||||
SASSERT(u.str.is_in_re(*term_it));
|
||||
u.str.is_in_re(*term_it, _unused, re);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Notes:
|
|||
|
||||
namespace smt {
|
||||
|
||||
theory_wmaxsat::theory_wmaxsat(ast_manager& m, filter_model_converter& mc):
|
||||
theory_wmaxsat::theory_wmaxsat(ast_manager& m, generic_model_converter& mc):
|
||||
theory(m.mk_family_id("weighted_maxsat")),
|
||||
m_mc(mc),
|
||||
m_vars(m),
|
||||
|
@ -92,7 +92,7 @@ namespace smt {
|
|||
ast_manager& m = get_manager();
|
||||
app_ref var(m), wfml(m);
|
||||
var = m.mk_fresh_const("w", m.mk_bool_sort());
|
||||
m_mc.insert(var->get_decl());
|
||||
m_mc.hide(var);
|
||||
wfml = m.mk_or(var, fml);
|
||||
ctx.assert_expr(wfml);
|
||||
m_rweights.push_back(w);
|
||||
|
|
|
@ -22,7 +22,7 @@ Notes:
|
|||
|
||||
#include "smt/smt_theory.h"
|
||||
#include "smt/smt_clause.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
|
||||
namespace smt {
|
||||
class theory_wmaxsat : public theory {
|
||||
|
@ -32,7 +32,7 @@ namespace smt {
|
|||
void reset() { memset(this, 0, sizeof(*this)); }
|
||||
stats() { reset(); }
|
||||
};
|
||||
filter_model_converter& m_mc;
|
||||
generic_model_converter& m_mc;
|
||||
mutable unsynch_mpz_manager m_mpz;
|
||||
app_ref_vector m_vars; // Auxiliary variables per soft clause
|
||||
expr_ref_vector m_fmls; // Formulas per soft clause
|
||||
|
@ -56,7 +56,7 @@ namespace smt {
|
|||
svector<bool> m_assigned, m_enabled;
|
||||
stats m_stats;
|
||||
public:
|
||||
theory_wmaxsat(ast_manager& m, filter_model_converter& mc);
|
||||
theory_wmaxsat(ast_manager& m, generic_model_converter& mc);
|
||||
~theory_wmaxsat() override;
|
||||
void get_assignment(svector<bool>& result);
|
||||
expr* assert_weighted(expr* fml, rational const& w);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue