Skip to content

Commit b1d3d55

Browse files
committed
remove encoding of arrays of bools into bitvector
The encoding of arrays of booleans as arrays of (_ bitvec 1) was necessary when solvers did not support arrays of booleans. This support is now broadly available, removing the need for this code path.
1 parent 8e692ae commit b1d3d55

File tree

4 files changed

+9
-108
lines changed

4 files changed

+9
-108
lines changed

regression/cbmc/array_of_bool_as_bitvec/main.c

-19
This file was deleted.

regression/cbmc/array_of_bool_as_bitvec/test-smt2-outfile.desc

-31
This file was deleted.

src/solvers/smt2/smt2_conv.cpp

+9-57
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ smt2_convt::smt2_convt(
5757
solvert _solver,
5858
std::ostream &_out)
5959
: use_FPA_theory(false),
60-
use_array_of_bool(false),
6160
use_as_const(false),
6261
use_check_sat_assuming(false),
6362
use_datatypes(false),
@@ -86,7 +85,6 @@ smt2_convt::smt2_convt(
8685

8786
case solvert::CPROVER_SMT2:
8887
use_FPA_theory = true;
89-
use_array_of_bool = true;
9088
use_as_const = true;
9189
use_check_sat_assuming = true;
9290
emit_set_logic = false;
@@ -106,7 +104,6 @@ smt2_convt::smt2_convt(
106104
break;
107105

108106
case solvert::Z3:
109-
use_array_of_bool = true;
110107
use_as_const = true;
111108
use_check_sat_assuming = true;
112109
use_lambda_for_array = true;
@@ -3895,24 +3892,11 @@ void smt2_convt::convert_index(const index_exprt &expr)
38953892

38963893
if(use_array_theory(expr.array()))
38973894
{
3898-
if(expr.type().id() == ID_bool && !use_array_of_bool)
3899-
{
3900-
out << "(= ";
3901-
out << "(select ";
3902-
convert_expr(expr.array());
3903-
out << " ";
3904-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
3905-
out << ")";
3906-
out << " #b1)";
3907-
}
3908-
else
3909-
{
3910-
out << "(select ";
3911-
convert_expr(expr.array());
3912-
out << " ";
3913-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
3914-
out << ")";
3915-
}
3895+
out << "(select ";
3896+
convert_expr(expr.array());
3897+
out << " ";
3898+
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
3899+
out << ")";
39163900
}
39173901
else
39183902
{
@@ -4455,16 +4439,7 @@ void smt2_convt::find_symbols(const exprt &expr)
44554439
out << "(assert (forall ((i ";
44564440
convert_type(array_type.size().type());
44574441
out << ")) (= (select " << id << " i) ";
4458-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4459-
{
4460-
out << "(ite ";
4461-
convert_expr(array_of.what());
4462-
out << " #b1 #b0)";
4463-
}
4464-
else
4465-
{
4466-
convert_expr(array_of.what());
4467-
}
4442+
convert_expr(array_of.what());
44684443
out << ")))\n";
44694444

44704445
defined_expressions[expr] = id;
@@ -4503,16 +4478,7 @@ void smt2_convt::find_symbols(const exprt &expr)
45034478
out << ")) (= (select " << id << " ";
45044479
convert_expr(array_comprehension.arg());
45054480
out << ") ";
4506-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4507-
{
4508-
out << "(ite ";
4509-
convert_expr(array_comprehension.body());
4510-
out << " #b1 #b0)";
4511-
}
4512-
else
4513-
{
4514-
convert_expr(array_comprehension.body());
4515-
}
4481+
convert_expr(array_comprehension.body());
45164482
out << "))))\n";
45174483

45184484
defined_expressions[expr] = id;
@@ -4536,16 +4502,7 @@ void smt2_convt::find_symbols(const exprt &expr)
45364502
out << "(assert (= (select " << id << " ";
45374503
convert_expr(from_integer(i, array_type.size().type()));
45384504
out << ") "; // select
4539-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4540-
{
4541-
out << "(ite ";
4542-
convert_expr(expr.operands()[i]);
4543-
out << " #b1 #b0)";
4544-
}
4545-
else
4546-
{
4547-
convert_expr(expr.operands()[i]);
4548-
}
4505+
convert_expr(expr.operands()[i]);
45494506
out << "))" << "\n"; // =, assert
45504507
}
45514508

@@ -4690,16 +4647,11 @@ void smt2_convt::convert_type(const typet &type)
46904647
CHECK_RETURN(array_type.size().is_not_nil());
46914648

46924649
// we always use array theory for top-level arrays
4693-
const typet &subtype = array_type.subtype();
4694-
46954650
out << "(Array ";
46964651
convert_type(array_type.size().type());
46974652
out << " ";
46984653

4699-
if(subtype.id()==ID_bool && !use_array_of_bool)
4700-
out << "(_ BitVec 1)";
4701-
else
4702-
convert_type(array_type.subtype());
4654+
convert_type(array_type.subtype());
47034655

47044656
out << ")";
47054657
}

src/solvers/smt2/smt2_conv.h

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class smt2_convt : public stack_decision_proceduret
5858
~smt2_convt() override = default;
5959

6060
bool use_FPA_theory;
61-
bool use_array_of_bool;
6261
bool use_as_const;
6362
bool use_check_sat_assuming;
6463
bool use_datatypes;

0 commit comments

Comments
 (0)