Skip to content

Commit 4a1fab6

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 fc3d885 commit 4a1fab6

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
@@ -4552,21 +4552,32 @@ void smt2_convt::find_symbols(const exprt &expr)
45524552
convert_type(array_type);
45534553
out << ")\n";
45544554

4555-
// use a quantifier-based initialization instead of lambda
4556-
out << "(assert (forall ((i ";
4557-
convert_type(array_type.size().type());
4558-
out << ")) (= (select " << id << " i) ";
4559-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4560-
{
4561-
out << "(ite ";
4562-
convert_expr(array_of.what());
4563-
out << " #b1 #b0)";
4564-
}
4565-
else
4555+
// The code below only works in Z3 and CVC4, it was added (and
4556+
// approved/merged) despite breaking other solvers.
4557+
// This conditional removes this for other solvers
4558+
if(solver == solvert::CVC4 || solver == solvert::Z3)
45664559
{
4567-
convert_expr(array_of.what());
4560+
// use a quantifier-based initialization instead of lambda
4561+
out << "(assert (forall ((i ";
4562+
convert_type(array_type.size().type());
4563+
out << ")) (= (select " << id << " i) ";
4564+
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4565+
{
4566+
out << "(ite ";
4567+
convert_expr(array_of.what());
4568+
out << " #b1 #b0)";
4569+
}
4570+
else
4571+
{
4572+
convert_expr(array_of.what());
4573+
}
4574+
out << ")))\n";
45684575
}
4569-
out << ")))\n";
4576+
// else
4577+
// {
4578+
// // This is where an alternate for other solvers that does not use
4579+
// // quantifiers should go.
4580+
// }
45704581

45714582
defined_expressions[expr] = id;
45724583
}

0 commit comments

Comments
 (0)