@@ -3871,7 +3871,7 @@ void smt2_convt::convert_index(const index_exprt &expr)
3871
3871
out << " " ;
3872
3872
convert_expr (typecast_exprt (expr.index (), array_type.size ().type ()));
3873
3873
out << " )" ;
3874
- out << " #b1 #b0 )" ;
3874
+ out << " #b1)" ;
3875
3875
}
3876
3876
else
3877
3877
{
@@ -4405,19 +4405,29 @@ void smt2_convt::find_symbols(const exprt &expr)
4405
4405
if (defined_expressions.find (expr) == defined_expressions.end ())
4406
4406
{
4407
4407
const auto &array_of = to_array_of_expr (expr);
4408
+ const auto &array_type = array_of.type ();
4408
4409
4409
4410
const irep_idt id =
4410
4411
" array_of." + std::to_string (defined_expressions.size ());
4411
4412
out << " ; the following is a substitute for lambda i. x\n " ;
4412
4413
out << " (declare-fun " << id << " () " ;
4413
- convert_type (array_of. type () );
4414
+ convert_type (array_type );
4414
4415
out << " )\n " ;
4415
4416
4416
4417
// use a quantifier-based initialization instead of lambda
4417
4418
out << " (assert (forall ((i " ;
4418
- convert_type (array_of. type () .size ().type ());
4419
+ convert_type (array_type .size ().type ());
4419
4420
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
+ }
4421
4431
out << " )))\n " ;
4422
4432
4423
4433
defined_expressions[expr] = id;
@@ -4431,12 +4441,13 @@ void smt2_convt::find_symbols(const exprt &expr)
4431
4441
if (defined_expressions.find (expr) == defined_expressions.end ())
4432
4442
{
4433
4443
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 ();
4435
4446
4436
4447
const irep_idt id =
4437
4448
" array_comprehension." + std::to_string (defined_expressions.size ());
4438
4449
out << " (declare-fun " << id << " () " ;
4439
- convert_type (array_comprehension. type () );
4450
+ convert_type (array_type );
4440
4451
out << " )\n " ;
4441
4452
4442
4453
out << " ; the following is a substitute for lambda i . x(i)\n " ;
@@ -4455,7 +4466,16 @@ void smt2_convt::find_symbols(const exprt &expr)
4455
4466
out << " )) (= (select " << id << " " ;
4456
4467
convert_expr (array_comprehension.arg ());
4457
4468
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
+ }
4459
4479
out << " ))))\n " ;
4460
4480
4461
4481
defined_expressions[expr] = id;
@@ -4479,7 +4499,16 @@ void smt2_convt::find_symbols(const exprt &expr)
4479
4499
out << " (assert (= (select " << id << " " ;
4480
4500
convert_expr (from_integer (i, array_type.size ().type ()));
4481
4501
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
+ }
4483
4512
out << " ))" << " \n " ; // =, assert
4484
4513
}
4485
4514
0 commit comments