mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
b92bd89a45
50 changed files with 1926 additions and 885 deletions
|
@ -373,7 +373,7 @@ namespace smt {
|
|||
expr* n = vars[i];
|
||||
bool neg = m_manager.is_not(n, n);
|
||||
if (b_internalized(n)) {
|
||||
lits.insert(literal(get_bool_var(n), !neg).index());
|
||||
lits.insert(literal(get_bool_var(n), neg).index());
|
||||
}
|
||||
}
|
||||
while (!lits.empty()) {
|
||||
|
|
|
@ -1281,7 +1281,7 @@ namespace smt {
|
|||
The deletion event handler is ignored if binary clause optimization is applicable.
|
||||
*/
|
||||
clause * context::mk_clause(unsigned num_lits, literal * lits, justification * j, clause_kind k, clause_del_eh * del_eh) {
|
||||
TRACE("mk_clause", tout << "creating clause:\n"; display_literals(tout, num_lits, lits); tout << "\n";);
|
||||
TRACE("mk_clause", tout << "creating clause:\n"; display_literals_verbose(tout, num_lits, lits); tout << "\n";);
|
||||
switch (k) {
|
||||
case CLS_AUX: {
|
||||
literal_buffer simp_lits;
|
||||
|
|
|
@ -222,6 +222,12 @@ namespace smt {
|
|||
m_imp->assert_expr(e);
|
||||
}
|
||||
|
||||
void kernel::assert_expr(expr_ref_vector const& es) {
|
||||
for (unsigned i = 0; i < es.size(); ++i) {
|
||||
m_imp->assert_expr(es[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void kernel::assert_expr(expr * e, proof * pr) {
|
||||
m_imp->assert_expr(e, pr);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ namespace smt {
|
|||
This method uses the "asserted" proof as a justification for e.
|
||||
*/
|
||||
void assert_expr(expr * e);
|
||||
|
||||
|
||||
void assert_expr(expr_ref_vector const& es);
|
||||
/**
|
||||
\brief Assert the given assertion with the given proof as a justification.
|
||||
*/
|
||||
|
|
|
@ -1709,7 +1709,7 @@ namespace smt {
|
|||
SASSERT(!maintain_integrality || valid_assignment());
|
||||
SASSERT(satisfy_bounds());
|
||||
}
|
||||
TRACE("opt", display(tout););
|
||||
TRACE("opt_verbose", display(tout););
|
||||
return (best_efforts>0 || ctx.get_cancel_flag())?BEST_EFFORT:result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1385,7 +1385,7 @@ namespace smt {
|
|||
m_branch_cut_counter++;
|
||||
// TODO: add giveup code
|
||||
if (m_branch_cut_counter % m_params.m_arith_branch_cut_ratio == 0) {
|
||||
TRACE("opt", display(tout););
|
||||
TRACE("opt_verbose", display(tout););
|
||||
move_non_base_vars_to_bounds();
|
||||
if (!make_feasible()) {
|
||||
TRACE("arith_int", tout << "failed to move variables to bounds.\n";);
|
||||
|
|
|
@ -704,8 +704,8 @@ namespace smt {
|
|||
bool bounded = false;
|
||||
unsigned n = 0;
|
||||
numeral range;
|
||||
for (unsigned i = 0; i < m_nl_monomials.size(); i++) {
|
||||
theory_var v = m_nl_monomials[i];
|
||||
for (unsigned j = 0; j < m_nl_monomials.size(); ++j) {
|
||||
theory_var v = m_nl_monomials[j];
|
||||
if (is_real(v))
|
||||
continue;
|
||||
bool computed_epsilon = false;
|
||||
|
@ -2336,8 +2336,8 @@ namespace smt {
|
|||
bool theory_arith<Ext>::max_min_nl_vars() {
|
||||
var_set already_found;
|
||||
svector<theory_var> vars;
|
||||
for (unsigned i = 0; i < m_nl_monomials.size(); i++) {
|
||||
theory_var v = m_nl_monomials[i];
|
||||
for (unsigned j = 0; j < m_nl_monomials.size(); ++j) {
|
||||
theory_var v = m_nl_monomials[j];
|
||||
mark_var(v, vars, already_found);
|
||||
expr * n = var2expr(v);
|
||||
SASSERT(is_pure_monomial(n));
|
||||
|
|
|
@ -321,7 +321,8 @@ namespace smt {
|
|||
if (m_simplex.upper_valid(v)) {
|
||||
m_simplex.get_upper(v, last_bound);
|
||||
if (m_mpq_inf_mgr.gt(bound, last_bound)) {
|
||||
literal lit = m_explain_upper.get(v, null_literal);
|
||||
literal lit = m_explain_upper.get(v, null_literal);
|
||||
TRACE("pb", tout << ~lit << " " << ~explain << "\n";);
|
||||
get_context().mk_clause(~lit, ~explain, justify(~lit, ~explain));
|
||||
return false;
|
||||
}
|
||||
|
@ -342,6 +343,7 @@ namespace smt {
|
|||
m_simplex.get_lower(v, last_bound);
|
||||
if (m_mpq_inf_mgr.gt(last_bound, bound)) {
|
||||
literal lit = m_explain_lower.get(v, null_literal);
|
||||
TRACE("pb", tout << ~lit << " " << ~explain << "\n";);
|
||||
get_context().mk_clause(~lit, ~explain, justify(~lit, ~explain));
|
||||
return false;
|
||||
}
|
||||
|
@ -405,6 +407,7 @@ namespace smt {
|
|||
if (proofs_enabled()) {
|
||||
js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr());
|
||||
}
|
||||
TRACE("pb", tout << lits << "\n";);
|
||||
ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0);
|
||||
|
||||
return false;
|
||||
|
@ -515,11 +518,10 @@ namespace smt {
|
|||
++log;
|
||||
n *= 2;
|
||||
}
|
||||
unsigned th = args.size()*log; // 10*
|
||||
unsigned th = args.size()*log;
|
||||
c->m_compilation_threshold = th;
|
||||
IF_VERBOSE(2, verbose_stream() << "(smt.pb setting compilation threhshold to " << th << ")\n";);
|
||||
IF_VERBOSE(2, verbose_stream() << "(smt.pb setting compilation threshold to " << th << ")\n";);
|
||||
TRACE("pb", tout << "compilation threshold: " << th << "\n";);
|
||||
//compile_ineq(*c);
|
||||
}
|
||||
else {
|
||||
c->m_compilation_threshold = UINT_MAX;
|
||||
|
@ -1247,9 +1249,9 @@ namespace smt {
|
|||
literal_vector in;
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
rational n = c.coeff(i);
|
||||
lbool val = ctx.get_assignment(c.lit());
|
||||
if (val != l_undef &&
|
||||
ctx.get_assign_level(thl) == ctx.get_base_level()) {
|
||||
literal lit = c.lit(i);
|
||||
lbool val = ctx.get_assignment(lit);
|
||||
if (val != l_undef && ctx.get_assign_level(lit) == ctx.get_base_level()) {
|
||||
if (val == l_true) {
|
||||
unsigned m = n.get_unsigned();
|
||||
if (k < m) {
|
||||
|
@ -1264,38 +1266,35 @@ namespace smt {
|
|||
n -= rational::one();
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("pb", tout << in << " >= " << k << "\n";);
|
||||
|
||||
unsigned num_compiled_vars, num_compiled_clauses;
|
||||
|
||||
psort_expr ps(ctx, *this);
|
||||
psort_nw<psort_expr> sortnw(ps);
|
||||
sortnw.m_stats.reset();
|
||||
|
||||
if (ctx.get_assignment(thl) == l_true &&
|
||||
ctx.get_assign_level(thl) == ctx.get_base_level()) {
|
||||
psort_expr ps(ctx, *this);
|
||||
psort_nw<psort_expr> sortnw(ps);
|
||||
sortnw.m_stats.reset();
|
||||
at_least_k = sortnw.ge(false, k, in.size(), in.c_ptr());
|
||||
TRACE("pb", tout << ~thl << " " << at_least_k << "\n";);
|
||||
ctx.mk_clause(~thl, at_least_k, justify(~thl, at_least_k));
|
||||
num_compiled_vars = sortnw.m_stats.m_num_compiled_vars;
|
||||
num_compiled_clauses = sortnw.m_stats.m_num_compiled_clauses;
|
||||
}
|
||||
else {
|
||||
psort_expr ps(ctx, *this);
|
||||
psort_nw<psort_expr> sortnw(ps);
|
||||
sortnw.m_stats.reset();
|
||||
literal at_least_k = sortnw.ge(true, k, in.size(), in.c_ptr());
|
||||
TRACE("pb", tout << ~thl << " " << at_least_k << "\n";);
|
||||
ctx.mk_clause(~thl, at_least_k, justify(~thl, at_least_k));
|
||||
ctx.mk_clause(~at_least_k, thl, justify(thl, ~at_least_k));
|
||||
num_compiled_vars = sortnw.m_stats.m_num_compiled_vars;
|
||||
num_compiled_clauses = sortnw.m_stats.m_num_compiled_clauses;
|
||||
}
|
||||
m_stats.m_num_compiled_vars += num_compiled_vars;
|
||||
m_stats.m_num_compiled_clauses += num_compiled_clauses;
|
||||
m_stats.m_num_compiled_vars += sortnw.m_stats.m_num_compiled_vars;
|
||||
m_stats.m_num_compiled_clauses += sortnw.m_stats.m_num_compiled_clauses;
|
||||
|
||||
IF_VERBOSE(1, verbose_stream()
|
||||
<< "(smt.pb compile sorting network bound: "
|
||||
<< k << " literals: " << in.size()
|
||||
<< " clauses: " << num_compiled_clauses
|
||||
<< " vars: " << num_compiled_vars << ")\n";);
|
||||
|
||||
TRACE("pb", tout << thl << "\n";);
|
||||
// auxiliary clauses get removed when popping scopes.
|
||||
// we have to recompile the circuit after back-tracking.
|
||||
c.m_compiled = l_false;
|
||||
|
@ -1305,7 +1304,6 @@ namespace smt {
|
|||
|
||||
|
||||
void theory_pb::init_search_eh() {
|
||||
m_to_compile.reset();
|
||||
}
|
||||
|
||||
void theory_pb::push_scope_eh() {
|
||||
|
@ -1334,6 +1332,7 @@ namespace smt {
|
|||
m_ineq_rep.erase(r_info.m_rep);
|
||||
}
|
||||
}
|
||||
m_to_compile.erase(c);
|
||||
dealloc(c);
|
||||
}
|
||||
m_ineqs_lim.resize(new_lim);
|
||||
|
@ -1459,6 +1458,7 @@ namespace smt {
|
|||
if (proofs_enabled()) {
|
||||
js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr());
|
||||
}
|
||||
TRACE("pb", tout << lits << "\n";);
|
||||
ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0);
|
||||
}
|
||||
|
||||
|
@ -1765,6 +1765,7 @@ namespace smt {
|
|||
for (unsigned i = 0; i < m_ineq_literals.size(); ++i) {
|
||||
m_ineq_literals[i].neg();
|
||||
}
|
||||
TRACE("pb", tout << m_ineq_literals << "\n";);
|
||||
ctx.mk_clause(m_ineq_literals.size(), m_ineq_literals.c_ptr(), justify(m_ineq_literals), CLS_AUX_LEMMA, 0);
|
||||
break;
|
||||
default: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue