Skip to content

Commit

Permalink
fix #6662
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Apr 9, 2023
1 parent af9c760 commit e6ea815
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ast/special_relations_decl_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func_decl * special_relations_decl_plugin::mk_func_decl(
if (!m_manager->is_bool(range)) {
m_manager->raise_exception("range type is expected to be Boolean for special relations");
}
m_has_special_relation = true;
func_decl_info info(m_family_id, k, num_parameters, parameters);
symbol name;
switch(k) {
Expand Down
5 changes: 5 additions & 0 deletions src/ast/special_relations_decl_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class special_relations_decl_plugin : public decl_plugin {
symbol m_plo;
symbol m_to;
symbol m_tc;
bool m_has_special_relation = false;
public:
special_relations_decl_plugin();

Expand All @@ -50,6 +51,8 @@ class special_relations_decl_plugin : public decl_plugin {
void get_op_names(svector<builtin_name> & op_names, symbol const & logic) override;

sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override { return nullptr; }

bool has_special_relation() const { return m_has_special_relation; }
};

enum sr_property {
Expand Down Expand Up @@ -82,6 +85,8 @@ class special_relations_util {
}
public:
special_relations_util(ast_manager& m) : m(m), m_fid(null_family_id) { }

bool has_special_relation() const { return static_cast<special_relations_decl_plugin*>(m.get_plugin(m.mk_family_id("specrels")))->has_special_relation(); }

bool is_special_relation(func_decl* f) const { return f->get_family_id() == fid(); }
bool is_special_relation(app* e) const { return is_special_relation(e->get_decl()); }
Expand Down
23 changes: 22 additions & 1 deletion src/smt/smt_model_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Revision History:
#include "ast/rewriter/rewriter_def.h"
#include "ast/ast_pp.h"
#include "ast/array_decl_plugin.h"
#include "ast/special_relations_decl_plugin.h"
#include "ast/ast_smt2_pp.h"
#include "smt/smt_model_checker.h"
#include "smt/smt_context.h"
Expand Down Expand Up @@ -358,7 +359,7 @@ namespace smt {

TRACE("model_checker", tout << "[complete] model-checker result: " << to_sat_str(r) << "\n";);
if (r != l_true) {
return r == l_false; // quantifier is satisfied by m_curr_model
return is_safe_for_mbqi(q) && r == l_false; // quantifier is satisfied by m_curr_model
}

model_ref complete_cex;
Expand Down Expand Up @@ -398,6 +399,26 @@ namespace smt {
return false;
}

bool model_checker::is_safe_for_mbqi(quantifier * q) const {
special_relations_util sp(m);
if (!sp.has_special_relation())
return true;
ast_fast_mark1 visited;
struct proc {
special_relations_util& sp;
bool found = false;
proc(special_relations_util& sp):sp(sp) {}
void operator()(app* f) {
found |= sp.is_special_relation(f);
}
void operator()(expr* e) {}
};
proc p(sp);
quick_for_each_expr(p, visited, q);
return !p.found;
}


void model_checker::init_aux_context() {
if (!m_fparams) {
m_fparams = alloc(smt_params, m_context->get_fparams());
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 @@ -87,6 +87,7 @@ namespace smt {
expr_mark m_visited;
bool contains_model_value(expr * e);
void add_instance(quantifier * q, expr_ref_vector const & bindings, unsigned max_generation, expr * def);
bool is_safe_for_mbqi(quantifier * q) const;

public:
model_checker(ast_manager & m, qi_params const & p, model_finder & mf);
Expand Down

0 comments on commit e6ea815

Please sign in to comment.