3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

fixes #186, remove ite-lifting from opt_context to detect weighted maxsat

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-08-06 11:52:59 +02:00
parent e59ec5fefd
commit f96c0b6963
8 changed files with 109 additions and 22 deletions

View file

@ -2038,11 +2038,13 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const
}
}
}
check_args(decl, num_args, new_args.c_ptr());
SASSERT(new_args.size() == num_args);
new_node = new (mem) app(decl, num_args, new_args.c_ptr());
r = register_node(new_node);
}
else {
check_args(decl, num_args, args);
new_node = new (mem) app(decl, num_args, args);
r = register_node(new_node);
}
@ -2064,6 +2066,22 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const
return r;
}
void ast_manager::check_args(func_decl* f, unsigned n, expr* const* es) {
for (unsigned i = 0; i < n; i++) {
sort * actual_sort = get_sort(es[i]);
sort * expected_sort = f->is_associative() ? f->get_domain(0) : f->get_domain(i);
if (expected_sort != actual_sort) {
std::ostringstream buffer;
buffer << "Sort mismatch at argument #" << (i+1)
<< " for function " << mk_pp(f,*this)
<< " supplied sort is "
<< mk_pp(actual_sort, *this);
throw ast_exception(buffer.str().c_str());
}
}
}
inline app * ast_manager::mk_app_core(func_decl * decl, expr * arg1, expr * arg2) {
expr * args[2] = { arg1, arg2 };
return mk_app_core(decl, 2, args);

View file

@ -1460,6 +1460,9 @@ protected:
bool coercion_needed(func_decl * decl, unsigned num_args, expr * const * args);
void check_args(func_decl* f, unsigned n, expr* const* es);
public:
ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = 0, bool is_format_manager = false);
ast_manager(proof_gen_mode, std::fstream * trace_stream, bool is_format_manager = false);

View file

@ -280,3 +280,9 @@ bool pb_util::has_unit_coefficients(func_decl* f) const {
}
return true;
}
app* pb_util::mk_fresh_bool() {
symbol name = m.mk_fresh_var_name("pb");
func_decl_info info(m_fid, OP_PB_AUX_BOOL, 0, 0);
return m.mk_const(m.mk_func_decl(name, 0, (sort *const*)0, m.mk_bool_sort(), info));
}

View file

@ -35,6 +35,7 @@ enum pb_op_kind {
OP_PB_LE, // pseudo-Boolean <= (generalizes at_most_k)
OP_PB_GE, // pseudo-Boolean >=
OP_PB_EQ, // equality
OP_PB_AUX_BOOL, // auxiliary internal Boolean variable.
LAST_PB_OP
};
@ -71,6 +72,7 @@ public:
virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
unsigned arity, sort * const * domain, sort * range);
virtual void get_op_names(svector<builtin_name> & op_names, symbol const & logic);
};
@ -101,6 +103,7 @@ public:
bool is_ge(func_decl* a) const;
bool is_ge(expr* a) const { return is_app(a) && is_ge(to_app(a)->get_decl()); }
bool is_ge(expr* a, rational& k) const;
bool is_aux_bool(expr* e) const { return is_app_of(e, m_fid, OP_PB_AUX_BOOL); }
rational get_coeff(expr* a, unsigned index) const { return get_coeff(to_app(a)->get_decl(), index); }
rational get_coeff(func_decl* a, unsigned index) const;
bool has_unit_coefficients(func_decl* f) const;
@ -111,6 +114,8 @@ public:
bool is_eq(expr* e) const { return is_app(e) && is_eq(to_app(e)->get_decl()); }
bool is_eq(expr* e, rational& k) const;
app* mk_fresh_bool();
private:
rational to_rational(parameter const& p) const;