Skip to content

Commit 01d1ec5

Browse files
committed
Fixed SMT encoding of array_of_exprt
Instead of using quantifers to encode array_of expressions -- which, as indicated in the comments, doesn't seem to work on existing solvers -- we can use the `as const` construct.
1 parent f899754 commit 01d1ec5

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,27 +4367,23 @@ void smt2_convt::find_symbols(const exprt &expr)
43674367
out << ")" << "\n";
43684368
}
43694369
}
4370-
else if(expr.id()==ID_array_of)
4370+
else if(expr.id() == ID_array_of)
43714371
{
4372-
if(defined_expressions.find(expr)==defined_expressions.end())
4372+
if(defined_expressions.find(expr) == defined_expressions.end())
43734373
{
4374+
const array_of_exprt &array_of_expr = to_array_of_expr(expr);
4375+
43744376
const irep_idt id =
43754377
"array_of." + std::to_string(defined_expressions.size());
4376-
out << "; the following is a substitute for lambda i. x" << "\n";
4377-
out << "(declare-fun " << id << " () ";
4378-
convert_type(expr.type());
4379-
out << ")" << "\n";
4380-
4381-
// use a quantifier instead of the lambda
4382-
#if 0 // not really working in any solver yet!
4383-
out << "(assert (forall ((i ";
4384-
convert_type(array_index_type());
4385-
out << ")) (= (select " << id << " i) ";
4386-
convert_expr(expr.op0());
4387-
out << ")))" << "\n";
4388-
#endif
4378+
out << "(define-fun " << id << " () ";
4379+
convert_type(array_of_expr.type());
4380+
out << " ((as const ";
4381+
convert_type(array_of_expr.type());
4382+
out << ") ";
4383+
convert_expr(array_of_expr.what());
4384+
out << "))\n";
43894385

4390-
defined_expressions[expr]=id;
4386+
defined_expressions[expr] = id;
43914387
}
43924388
}
43934389
else if(expr.id()==ID_array)

0 commit comments

Comments
 (0)