Skip to content

Commit

Permalink
extend distinct check to ADT
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Sep 1, 2022
1 parent 61f7dc3 commit f2afb36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ast/datatype_decl_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,28 @@ namespace datatype {
}
}

bool plugin::are_distinct(app * a, app * b) const {
if (a == b)
return false;
if (is_unique_value(a) && is_unique_value(b))
return true;
if (u().is_constructor(a) && u().is_constructor(b)) {
if (a->get_decl() != b->get_decl())
return true;
for (unsigned i = a->get_num_args(); i-- > 0; ) {
if (!is_app(a->get_arg(i)))
continue;
if (!is_app(b->get_arg(i)))
continue;
app* _a = to_app(a->get_arg(i));
app* _b = to_app(b->get_arg(i));
if (m_manager->are_distinct(_a, _b))
return true;
}
}
return false;
}

expr * plugin::get_some_value(sort * s) {
SASSERT(u().is_datatype(s));
func_decl * c = u().get_non_rec_constructor(s);
Expand Down
2 changes: 2 additions & 0 deletions src/ast/datatype_decl_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ namespace datatype {
bool is_value(app* e) const override { return is_value_aux(false, e); }

bool is_unique_value(app * e) const override { return is_value_aux(true, e); }

bool are_distinct(app * a, app * b) const override;

void get_op_names(svector<builtin_name> & op_names, symbol const & logic) override;

Expand Down

0 comments on commit f2afb36

Please sign in to comment.