3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

make proto-model evaluation use model_evaluator instead of legacy evaluator

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-03-05 10:14:15 -08:00
parent 6fef24edb4
commit 70f13ced33
22 changed files with 528 additions and 297 deletions

View file

@ -30,12 +30,14 @@ Revision History:
proto_model::proto_model(ast_manager & m, simplifier & s, params_ref const & p):
model_core(m),
m_simplifier(s),
m_afid(m.mk_family_id(symbol("array"))) {
m_afid(m.mk_family_id(symbol("array"))),
m_eval(*this) {
register_factory(alloc(basic_factory, m));
m_user_sort_factory = alloc(user_sort_factory, m);
register_factory(m_user_sort_factory);
m_model_partial = model_params(p).partial();
m_use_new_eval = model_params(p).new_eval();
}
@ -157,6 +159,19 @@ bool proto_model::is_select_of_model_value(expr* e) const {
So, if model_completion == true, the evaluator never fails if it doesn't contain quantifiers.
*/
bool proto_model::eval(expr * e, expr_ref & result, bool model_completion) {
if (m_use_new_eval) {
m_eval.set_model_completion(model_completion);
try {
m_eval(e, result);
return true;
}
catch (model_evaluator_exception & ex) {
(void)ex;
TRACE("model_evaluator", tout << ex.msg() << "\n";);
return false;
}
}
bool is_ok = true;
SASSERT(is_well_sorted(m_manager, e));
TRACE("model_eval", tout << mk_pp(e, m_manager) << "\n";

View file

@ -29,6 +29,7 @@ Revision History:
#define PROTO_MODEL_H_
#include"model_core.h"
#include"model_evaluator.h"
#include"value_factory.h"
#include"plugin_manager.h"
#include"simplifier.h"
@ -44,8 +45,10 @@ class proto_model : public model_core {
family_id m_afid; //!< array family id: hack for displaying models in V1.x style
func_decl_set m_aux_decls;
ptr_vector<expr> m_tmp;
model_evaluator m_eval;
bool m_model_partial;
bool m_use_new_eval;
expr * mk_some_interp_for(func_decl * d);

View file

@ -95,7 +95,8 @@ namespace smt {
expr * e = *it;
eqs.push_back(m.mk_eq(sk, e));
}
m_aux_context->assert_expr(m.mk_or(eqs.size(), eqs.c_ptr()));
expr_ref fml(m.mk_or(eqs.size(), eqs.c_ptr()), m);
m_aux_context->assert_expr(fml);
}
#define PP_DEPTH 8
@ -105,9 +106,13 @@ namespace smt {
The variables are replaced by skolem constants. These constants are stored in sks.
*/
void model_checker::assert_neg_q_m(quantifier * q, expr_ref_vector & sks) {
expr_ref tmp(m);
m_curr_model->eval(q->get_expr(), tmp, true);
if (!m_curr_model->eval(q->get_expr(), tmp, true)) {
return;
}
//std::cout << tmp << "\n";
TRACE("model_checker", tout << "q after applying interpretation:\n" << mk_ismt2_pp(tmp, m) << "\n";);
ptr_buffer<expr> subst_args;
unsigned num_decls = q->get_num_decls();
@ -261,10 +266,11 @@ namespace smt {
lbool r = m_aux_context->check();
TRACE("model_checker", tout << "[complete] model-checker result: " << to_sat_str(r) << "\n";);
if (r == l_false) {
if (r != l_true) {
m_aux_context->pop(1);
return true; // quantifier is satisfied by m_curr_model
return r == l_false; // quantifier is satisfied by m_curr_model
}
model_ref complete_cex;
m_aux_context->get_model(complete_cex);
@ -276,7 +282,7 @@ namespace smt {
while (true) {
lbool r = m_aux_context->check();
TRACE("model_checker", tout << "[restricted] model-checker (" << (num_new_instances+1) << ") result: " << to_sat_str(r) << "\n";);
if (r == l_false)
if (r != l_true)
break;
model_ref cex;
m_aux_context->get_model(cex);

View file

@ -1619,6 +1619,7 @@ namespace smt {
m_found_underspecified_op(false),
m_arith_eq_adapter(*this, params, m_util),
m_asserted_qhead(0),
m_row_vars_top(0),
m_to_patch(1024),
m_blands_rule(false),
m_random(params.m_arith_random_seed),
@ -1631,7 +1632,6 @@ namespace smt {
m_liberal_final_check(true),
m_changed_assignment(false),
m_assume_eq_head(0),
m_row_vars_top(0),
m_nl_rounds(0),
m_nl_gb_exhausted(false),
m_nl_new_exprs(m),

View file

@ -1591,7 +1591,6 @@ bool theory_seq::solve_ne(unsigned idx) {
}
bool theory_seq::solve_nc(unsigned idx) {
context& ctx = get_context();
nc const& n = m_ncs[idx];
dependency* deps = n.deps();