Skip to content

Commit

Permalink
introduce fresh term when none is available in context or model to fix
Browse files Browse the repository at this point in the history
…#2456

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Aug 4, 2019
1 parent c7dc420 commit 59f69bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/smt/smt_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ Revision History:
namespace smt {

bool checker::all_args(app * a, bool is_true) {
unsigned num_args = a->get_num_args();
for (unsigned i = 0; i < num_args; i++) {
if (!check(a->get_arg(i), is_true))
for (expr* arg : *a) {
if (!check(arg, is_true))
return false;
}
return true;
}

bool checker::any_arg(app * a, bool is_true) {
unsigned num_args = a->get_num_args();
for (unsigned i = 0; i < num_args; i++) {
if (check(a->get_arg(i), is_true))
for (expr* arg : *a) {
if (check(arg, is_true))
return true;
}
return false;
Expand Down
16 changes: 14 additions & 2 deletions src/smt/smt_model_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ namespace smt {
return t;
}

expr * model_checker::get_type_compatible_term(expr * val) {
for (auto const& kv : m_value2expr) {
if (m.get_sort(kv.m_key) == m.get_sort(val) &&
!contains_model_value(kv.m_key)) {
return kv.m_key;
}
}
app* fresh_term = m.mk_fresh_const("sk", m.get_sort(val));
m_context->ensure_internalized(fresh_term);
m_value2expr.insert(val, fresh_term);
return fresh_term;
}

void model_checker::init_value2expr() {
if (m_value2expr.empty()) {
// populate m_value2expr
Expand Down Expand Up @@ -207,8 +220,7 @@ namespace smt {
}
}
if (contains_model_value(sk_value)) {
TRACE("model_checker", tout << "value is private to model: " << sk_value << "\n";);
return false;
sk_value = get_type_compatible_term(sk_value);
}
func_decl * f = nullptr;
if (autil.is_as_array(sk_value, f) && cex->get_func_interp(f)) {
Expand Down
1 change: 1 addition & 0 deletions src/smt/smt_model_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace smt {
void init_aux_context();
void init_value2expr();
expr * get_term_from_ctx(expr * val);
expr * get_type_compatible_term(expr * val);
expr_ref replace_value_from_ctx(expr * e);
void restrict_to_universe(expr * sk, obj_hashtable<expr> const & universe);
void assert_neg_q_m(quantifier * q, expr_ref_vector & sks);
Expand Down

0 comments on commit 59f69bb

Please sign in to comment.