Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regression/smt2_solver/distinct/distinct.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(assert (distinct (_ bv0 8) (_ bv1 8)))
(check-sat)
6 changes: 6 additions & 0 deletions regression/smt2_solver/distinct/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
distinct.smt2

^EXIT=0$
^SIGNAL=0$
^sat$
2 changes: 2 additions & 0 deletions regression/smt2_solver/distinct2/distinct2.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(assert (distinct (_ bv0 8) (_ bv1 8)(_ bv2 8) (_ bv1 8)))
(check-sat)
6 changes: 6 additions & 0 deletions regression/smt2_solver/distinct2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
distinct2.smt2

^EXIT=0$
^SIGNAL=0$
^unsat$
2 changes: 2 additions & 0 deletions regression/smt2_solver/distinct3/distinct3.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(assert (distinct (_ bv0 8)(_ bv0 8)(_ bv2 8) (_ bv2 8)))
(check-sat)
6 changes: 6 additions & 0 deletions regression/smt2_solver/distinct3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
distinct3.smt2

^EXIT=0$
^SIGNAL=0$
^unsat$
18 changes: 17 additions & 1 deletion src/solvers/smt2/smt2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,23 @@ void smt2_parsert::setup_expressions()

expressions["distinct"] = [this] {
// pair-wise different constraint, multi-ary
return multi_ary("distinct", operands());
auto op = operands();
if(op.size() == 2)
return binary_predicate(ID_notequal, op);
else
{
std::vector<exprt> pairwise_constraints;
for(std::size_t i = 0; i < op.size(); i++)
{
for(std::size_t j = i; j < op.size(); j++)
{
if(i != j)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could start at j = i + 1 and skip this check if you wanted.

pairwise_constraints.push_back(
binary_exprt(op[i], ID_notequal, op[j], bool_typet()));
}
}
return multi_ary(ID_and, pairwise_constraints);
}
};

expressions["ite"] = [this] {
Expand Down