mirror of
https://github.com/Z3Prover/z3
synced 2025-06-23 22:33:40 +00:00
indentation
This commit is contained in:
parent
b9ddb11701
commit
b49ffb8a87
2 changed files with 97 additions and 83 deletions
|
@ -51,6 +51,9 @@ namespace arith {
|
|||
vector<row> m_eqs;
|
||||
vector<row> m_ineqs;
|
||||
vector<row> m_diseqs;
|
||||
symbol m_farkas;
|
||||
symbol m_implied_eq;
|
||||
symbol m_bound;
|
||||
|
||||
void add(row& r, expr* v, rational const& coeff) {
|
||||
rational coeff1;
|
||||
|
@ -147,6 +150,8 @@ namespace arith {
|
|||
m_todo.push_back({coeff*coeff1, e2});
|
||||
else if (a.is_mul(e, e1, e2) && a.is_uminus(e1, e3) && a.is_numeral(e3, coeff1))
|
||||
m_todo.push_back({-coeff*coeff1, e2});
|
||||
else if (a.is_mul(e, e1, e2) && a.is_uminus(e2, e3) && a.is_numeral(e3, coeff1))
|
||||
m_todo.push_back({ -coeff * coeff1, e1 });
|
||||
else if (a.is_mul(e, e1, e2) && a.is_numeral(e2, coeff1))
|
||||
m_todo.push_back({coeff*coeff1, e1});
|
||||
else if (a.is_add(e))
|
||||
|
@ -310,9 +315,13 @@ namespace arith {
|
|||
return rows.back();
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
proof_checker(ast_manager& m): m(m), a(m) {}
|
||||
proof_checker(ast_manager& m):
|
||||
m(m),
|
||||
a(m),
|
||||
m_farkas("farkas"),
|
||||
m_implied_eq("implied-eq"),
|
||||
m_bound("bound") {}
|
||||
|
||||
~proof_checker() override {}
|
||||
|
||||
|
@ -328,6 +337,7 @@ namespace arith {
|
|||
bool add_ineq(rational const& coeff, expr* e, bool sign) {
|
||||
if (!m_diseqs.empty())
|
||||
return add_literal(fresh(m_ineqs), abs(coeff), e, sign);
|
||||
else
|
||||
return add_literal(m_ineq, abs(coeff), e, sign);
|
||||
}
|
||||
|
||||
|
@ -374,10 +384,17 @@ namespace arith {
|
|||
else
|
||||
pos.mark(e, true);
|
||||
|
||||
if (jst->get_name() == symbol("farkas")) {
|
||||
if (jst->get_name() != m_farkas &&
|
||||
jst->get_name() != m_bound &&
|
||||
jst->get_name() != m_implied_eq) {
|
||||
IF_VERBOSE(0, verbose_stream() << "unhandled inference " << mk_pp(jst, m) << "\n");
|
||||
return false;
|
||||
}
|
||||
bool is_bound = jst->get_name() == m_bound;
|
||||
bool even = true;
|
||||
rational coeff;
|
||||
expr* x, *y;
|
||||
expr* x, * y;
|
||||
unsigned j = 0;
|
||||
for (expr* arg : *jst) {
|
||||
if (even) {
|
||||
if (!a.is_numeral(arg, coeff)) {
|
||||
|
@ -387,16 +404,22 @@ namespace arith {
|
|||
}
|
||||
else {
|
||||
bool sign = m.is_not(arg, arg);
|
||||
if (a.is_le(arg) || a.is_lt(arg) || a.is_ge(arg) || a.is_gt(arg))
|
||||
if (a.is_le(arg) || a.is_lt(arg) || a.is_ge(arg) || a.is_gt(arg)) {
|
||||
if (is_bound && j + 1 == jst->get_num_args())
|
||||
add_conseq(coeff, arg, sign);
|
||||
else
|
||||
add_ineq(coeff, arg, sign);
|
||||
}
|
||||
else if (m.is_eq(arg, x, y)) {
|
||||
if (sign)
|
||||
add_diseq(x, y);
|
||||
else
|
||||
add_eq(x, y);
|
||||
}
|
||||
else
|
||||
else {
|
||||
IF_VERBOSE(0, verbose_stream() << "not a recognized arithmetical relation " << mk_pp(arg, m) << "\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sign && !pos.is_marked(arg)) {
|
||||
units.push_back(m.mk_not(arg));
|
||||
|
@ -406,28 +429,21 @@ namespace arith {
|
|||
units.push_back(arg);
|
||||
neg.mark(arg, false);
|
||||
}
|
||||
|
||||
}
|
||||
even = !even;
|
||||
++j;
|
||||
}
|
||||
if (check_farkas()) {
|
||||
if (check())
|
||||
return true;
|
||||
}
|
||||
|
||||
IF_VERBOSE(0, verbose_stream() << "did not check farkas\n" << mk_pp(jst, m) << "\n"; display(verbose_stream()); );
|
||||
return false;
|
||||
}
|
||||
|
||||
// todo: rules for bounds and implied-by
|
||||
|
||||
IF_VERBOSE(0, verbose_stream() << "did not check " << mk_pp(jst, m) << "\n");
|
||||
IF_VERBOSE(0, verbose_stream() << "did not check condition\n" << mk_pp(jst, m) << "\n"; display(verbose_stream()); );
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_plugins(euf::proof_checker& pc) override {
|
||||
pc.register_plugin(symbol("farkas"), this);
|
||||
pc.register_plugin(symbol("bound"), this);
|
||||
pc.register_plugin(symbol("implied-eq"), this);
|
||||
pc.register_plugin(m_farkas, this);
|
||||
pc.register_plugin(m_bound, this);
|
||||
pc.register_plugin(m_implied_eq, this);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -308,7 +308,6 @@ namespace bv {
|
|||
euf::enode* n = bool_var2enode(l.var());
|
||||
if (!n->is_attached_to(get_id()))
|
||||
mk_var(n);
|
||||
|
||||
set_bit_eh(v, l, idx);
|
||||
}
|
||||
|
||||
|
@ -453,7 +452,9 @@ namespace bv {
|
|||
*
|
||||
* Alternative axiomatization:
|
||||
* e = sum bit2bool(i,n)*2^i + 2^n * (div(e, 2^n))
|
||||
* possibly term div(e,2^n) is not
|
||||
* possibly term div(e,2^n) is not correct with respect to adapted semantics?
|
||||
* if not, use fresh variable or similar. Overall should be much beter.
|
||||
* Note: based on superb question raised at workshop on 9/1/22.
|
||||
*/
|
||||
void solver::assert_int2bv_axiom(app* n) {
|
||||
expr* e = nullptr;
|
||||
|
@ -534,7 +535,7 @@ namespace bv {
|
|||
internalize_binary(a, bin);
|
||||
}
|
||||
|
||||
void solver::internalize_interp(app* n, std::function<expr*(expr*, expr*)>& ibin, std::function<expr*(expr*)>& iun) {
|
||||
void solver::internalize_interp(app* n, std::function<expr* (expr*, expr*)>& ibin, std::function<expr* (expr*)>& iun) {
|
||||
bv_rewriter_params p(s().params());
|
||||
expr* arg1 = n->get_arg(0);
|
||||
expr* arg2 = n->get_arg(1);
|
||||
|
@ -574,11 +575,9 @@ namespace bv {
|
|||
init_bits(n, bits);
|
||||
}
|
||||
|
||||
|
||||
void solver::internalize_binary(app* e, std::function<void(unsigned, expr* const*, expr* const*, expr_ref_vector&)>& fn) {
|
||||
SASSERT(e->get_num_args() >= 1);
|
||||
expr_ref_vector bits(m), new_bits(m), arg_bits(m);
|
||||
|
||||
get_arg_bits(e, 0, bits);
|
||||
for (unsigned i = 1; i < e->get_num_args(); ++i) {
|
||||
arg_bits.reset();
|
||||
|
@ -667,9 +666,8 @@ namespace bv {
|
|||
expr* arg = nullptr;
|
||||
VERIFY(bv.is_bit2bool(n, arg, idx));
|
||||
euf::enode* argn = expr2enode(arg);
|
||||
if (!argn->is_attached_to(get_id())) {
|
||||
if (!argn->is_attached_to(get_id()))
|
||||
mk_var(argn);
|
||||
}
|
||||
theory_var v_arg = argn->get_th_var(get_id());
|
||||
SASSERT(idx < get_bv_size(v_arg));
|
||||
sat::literal lit = expr2literal(n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue