Skip to content

Commit 650d458

Browse files
committed
Fix quantifiers for arrays only works with Z3 and CVC4
This commit fixes an error introduced in diffblue#5974 where quantifiers were produced for all SMT2 solvers despite only being supported by Z3 and CVC4. The fix here reverts to the older behaviour for other solvers. Fixes diffblue#6263
1 parent 5c974cc commit 650d458

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4721,21 +4721,32 @@ void smt2_convt::find_symbols(const exprt &expr)
47214721
convert_type(array_type);
47224722
out << ")\n";
47234723

4724-
// use a quantifier-based initialization instead of lambda
4725-
out << "(assert (forall ((i ";
4726-
convert_type(array_type.size().type());
4727-
out << ")) (= (select " << id << " i) ";
4728-
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
4729-
{
4730-
out << "(ite ";
4731-
convert_expr(array_of.what());
4732-
out << " #b1 #b0)";
4733-
}
4734-
else
4724+
// The code below only works in Z3 and CVC4, it was added (and
4725+
// approved/merged) despite breaking other solvers.
4726+
// This conditional removes this for other solvers
4727+
if(solver == solvert::CVC4 || solver == solvert::Z3)
47354728
{
4736-
convert_expr(array_of.what());
4729+
// use a quantifier-based initialization instead of lambda
4730+
out << "(assert (forall ((i ";
4731+
convert_type(array_type.size().type());
4732+
out << ")) (= (select " << id << " i) ";
4733+
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
4734+
{
4735+
out << "(ite ";
4736+
convert_expr(array_of.what());
4737+
out << " #b1 #b0)";
4738+
}
4739+
else
4740+
{
4741+
convert_expr(array_of.what());
4742+
}
4743+
out << ")))\n";
47374744
}
4738-
out << ")))\n";
4745+
// else
4746+
// {
4747+
// // This is where an alternate for other solvers that does not use
4748+
// // quantifiers should go.
4749+
// }
47394750

47404751
defined_expressions[expr] = id;
47414752
}

0 commit comments

Comments
 (0)