@@ -3871,7 +3871,7 @@ void smt2_convt::convert_index(const index_exprt &expr)
38713871 out << " " ;
38723872 convert_expr (typecast_exprt (expr.index (), array_type.size ().type ()));
38733873 out << " )" ;
3874- out << " #b1 #b0 )" ;
3874+ out << " #b1)" ;
38753875 }
38763876 else
38773877 {
@@ -4405,19 +4405,29 @@ void smt2_convt::find_symbols(const exprt &expr)
44054405 if (defined_expressions.find (expr) == defined_expressions.end ())
44064406 {
44074407 const auto &array_of = to_array_of_expr (expr);
4408+ const auto &array_type = array_of.type ();
44084409
44094410 const irep_idt id =
44104411 " array_of." + std::to_string (defined_expressions.size ());
44114412 out << " ; the following is a substitute for lambda i. x\n " ;
44124413 out << " (declare-fun " << id << " () " ;
4413- convert_type (array_of. type () );
4414+ convert_type (array_type );
44144415 out << " )\n " ;
44154416
44164417 // use a quantifier-based initialization instead of lambda
44174418 out << " (assert (forall ((i " ;
4418- convert_type (array_of. type () .size ().type ());
4419+ convert_type (array_type .size ().type ());
44194420 out << " )) (= (select " << id << " i) " ;
4420- convert_expr (array_of.what ());
4421+ if (array_type.subtype ().id () == ID_bool && !use_array_of_bool)
4422+ {
4423+ out << " (ite " ;
4424+ convert_expr (array_of.what ());
4425+ out << " #b1 #b0)" ;
4426+ }
4427+ else
4428+ {
4429+ convert_expr (array_of.what ());
4430+ }
44214431 out << " )))\n " ;
44224432
44234433 defined_expressions[expr] = id;
@@ -4431,12 +4441,13 @@ void smt2_convt::find_symbols(const exprt &expr)
44314441 if (defined_expressions.find (expr) == defined_expressions.end ())
44324442 {
44334443 const auto &array_comprehension = to_array_comprehension_expr (expr);
4434- const auto &array_size = array_comprehension.type ().size ();
4444+ const auto &array_type = array_comprehension.type ();
4445+ const auto &array_size = array_type.size ();
44354446
44364447 const irep_idt id =
44374448 " array_comprehension." + std::to_string (defined_expressions.size ());
44384449 out << " (declare-fun " << id << " () " ;
4439- convert_type (array_comprehension. type () );
4450+ convert_type (array_type );
44404451 out << " )\n " ;
44414452
44424453 out << " ; the following is a substitute for lambda i . x(i)\n " ;
@@ -4455,7 +4466,16 @@ void smt2_convt::find_symbols(const exprt &expr)
44554466 out << " )) (= (select " << id << " " ;
44564467 convert_expr (array_comprehension.arg ());
44574468 out << " ) " ;
4458- convert_expr (array_comprehension.body ());
4469+ if (array_type.subtype ().id () == ID_bool && !use_array_of_bool)
4470+ {
4471+ out << " (ite " ;
4472+ convert_expr (array_comprehension.body ());
4473+ out << " #b1 #b0)" ;
4474+ }
4475+ else
4476+ {
4477+ convert_expr (array_comprehension.body ());
4478+ }
44594479 out << " ))))\n " ;
44604480
44614481 defined_expressions[expr] = id;
@@ -4479,7 +4499,16 @@ void smt2_convt::find_symbols(const exprt &expr)
44794499 out << " (assert (= (select " << id << " " ;
44804500 convert_expr (from_integer (i, array_type.size ().type ()));
44814501 out << " ) " ; // select
4482- convert_expr (expr.operands ()[i]);
4502+ if (array_type.subtype ().id () == ID_bool && !use_array_of_bool)
4503+ {
4504+ out << " (ite " ;
4505+ convert_expr (expr.operands ()[i]);
4506+ out << " #b1 #b0)" ;
4507+ }
4508+ else
4509+ {
4510+ convert_expr (expr.operands ()[i]);
4511+ }
44834512 out << " ))" << " \n " ; // =, assert
44844513 }
44854514
0 commit comments