mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
add hint verification, combine bounds/farkas into one rule
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
36ad377a7d
commit
bffa7ff2f6
9 changed files with 59 additions and 49 deletions
|
@ -115,7 +115,6 @@ static void read_clause(Buffer & in, std::ostream& err, sat::literal_vector & li
|
|||
template<typename Buffer>
|
||||
static void read_pragma(Buffer & in, std::ostream& err, std::string& p, sat::proof_hint& h) {
|
||||
skip_whitespace(in);
|
||||
h.reset();
|
||||
if (*in != 'p')
|
||||
return;
|
||||
++in;
|
||||
|
@ -307,6 +306,7 @@ namespace dimacs {
|
|||
loop:
|
||||
skip_whitespace(in);
|
||||
m_record.m_pragma.clear();
|
||||
m_record.m_hint.reset();
|
||||
switch (*in) {
|
||||
case EOF:
|
||||
return false;
|
||||
|
|
|
@ -918,9 +918,6 @@ namespace sat {
|
|||
case hint_type::farkas_h:
|
||||
ous << "farkas ";
|
||||
break;
|
||||
case hint_type::bound_h:
|
||||
ous << "bound ";
|
||||
break;
|
||||
case hint_type::cut_h:
|
||||
ous << "cut ";
|
||||
break;
|
||||
|
@ -949,11 +946,6 @@ namespace sat {
|
|||
s += 6;
|
||||
return true;
|
||||
}
|
||||
if (0 == strncmp(s, "bound", 5)) {
|
||||
h.m_ty = hint_type::bound_h;
|
||||
s += 5;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
@ -97,7 +97,6 @@ namespace sat {
|
|||
enum class hint_type {
|
||||
null_h,
|
||||
farkas_h,
|
||||
bound_h,
|
||||
cut_h
|
||||
};
|
||||
|
||||
|
|
|
@ -81,13 +81,14 @@ namespace arith {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assumption:
|
||||
* It may be necessary to use the following assumption when checking Farkas claims
|
||||
* generated from bounds propagation:
|
||||
* A bound literal ax <= b is explained by a set of weighted literals
|
||||
* r1*(a1*x <= b1) + .... + r_k*(a_k*x <= b_k), where r_i > 0
|
||||
* such that there is a r >= 1
|
||||
* (r1*a1+..+r_k*a_k) = r*a, (r1*b1+..+r_k*b_k) <= r*b
|
||||
*/
|
||||
sat::proof_hint const* solver::explain(sat::hint_type ty) {
|
||||
sat::proof_hint const* solver::explain(sat::hint_type ty, sat::literal lit) {
|
||||
if (!ctx.use_drat())
|
||||
return nullptr;
|
||||
m_bounds_pragma.m_ty = ty;
|
||||
|
@ -105,6 +106,8 @@ namespace arith {
|
|||
}
|
||||
case equality_source: {
|
||||
auto [u, v] = m_equalities[idx];
|
||||
ctx.drat_log_expr(u->get_expr());
|
||||
ctx.drat_log_expr(v->get_expr());
|
||||
m_bounds_pragma.m_eqs.push_back({ev.coeff(), u->get_expr_id(), v->get_expr_id()});
|
||||
break;
|
||||
}
|
||||
|
@ -112,6 +115,8 @@ namespace arith {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (lit != sat::null_literal)
|
||||
m_bounds_pragma.m_literals.push_back({rational(1), ~lit});
|
||||
return &m_bounds_pragma;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ namespace arith {
|
|||
TRACE("arith", for (auto lit : m_core) tout << lit << ": " << s().value(lit) << "\n";);
|
||||
DEBUG_CODE(for (auto lit : m_core) { VERIFY(s().value(lit) == l_true); });
|
||||
++m_stats.m_bound_propagations1;
|
||||
assign(lit, m_core, m_eqs, explain(sat::hint_type::bound_h));
|
||||
assign(lit, m_core, m_eqs, explain(sat::hint_type::farkas_h, lit));
|
||||
}
|
||||
|
||||
if (should_refine_bounds() && first)
|
||||
|
@ -378,7 +378,7 @@ namespace arith {
|
|||
reset_evidence();
|
||||
m_explanation.clear();
|
||||
lp().explain_implied_bound(be, m_bp);
|
||||
assign(bound, m_core, m_eqs, explain(sat::hint_type::bound_h));
|
||||
assign(bound, m_core, m_eqs, explain(sat::hint_type::farkas_h, bound));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ namespace arith {
|
|||
app_ref b = mk_bound(m_lia->get_term(), m_lia->get_offset(), !m_lia->is_upper());
|
||||
IF_VERBOSE(4, verbose_stream() << "cut " << b << "\n");
|
||||
literal lit = expr2literal(b);
|
||||
assign(lit, m_core, m_eqs, explain(sat::hint_type::cut_h));
|
||||
assign(lit, m_core, m_eqs, explain(sat::hint_type::cut_h, lit));
|
||||
lia_check = l_false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace arith {
|
|||
|
||||
sat::proof_hint m_bounds_pragma;
|
||||
sat::proof_hint m_farkas2;
|
||||
sat::proof_hint const* explain(sat::hint_type ty);
|
||||
sat::proof_hint const* explain(sat::hint_type ty, sat::literal lit = sat::null_literal);
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -176,7 +176,6 @@ namespace euf {
|
|||
void log_antecedents(literal l, literal_vector const& r);
|
||||
void log_justification(literal l, th_explain const& jst);
|
||||
void drat_log_decl(func_decl* f);
|
||||
void drat_log_expr(expr* n);
|
||||
void drat_log_expr1(expr* n);
|
||||
ptr_vector<expr> m_drat_todo;
|
||||
obj_hashtable<ast> m_drat_asts;
|
||||
|
@ -345,6 +344,7 @@ namespace euf {
|
|||
sat::drat& get_drat() { return s().get_drat(); }
|
||||
void drat_bool_def(sat::bool_var v, expr* n);
|
||||
void drat_eq_def(sat::literal lit, expr* eq);
|
||||
void drat_log_expr(expr* n);
|
||||
|
||||
// decompile
|
||||
bool extract_pb(std::function<void(unsigned sz, literal const* c, unsigned k)>& card,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue