Skip to content

Commit 052b420

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 9b72a5c commit 052b420

File tree

4 files changed

+9
-109
lines changed

4 files changed

+9
-109
lines changed

regression/cbmc/array_of_bool_as_bitvec/main.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/solvers/smt2/smt2_conv.cpp

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ smt2_convt::smt2_convt(
5959
solvert _solver,
6060
std::ostream &_out)
6161
: use_FPA_theory(false),
62-
use_array_of_bool(false),
6362
use_as_const(false),
6463
use_check_sat_assuming(false),
6564
use_datatypes(false),
@@ -88,7 +87,6 @@ smt2_convt::smt2_convt(
8887

8988
case solvert::CPROVER_SMT2:
9089
use_FPA_theory = true;
91-
use_array_of_bool = true;
9290
use_as_const = true;
9391
use_check_sat_assuming = true;
9492
emit_set_logic = false;
@@ -99,7 +97,6 @@ smt2_convt::smt2_convt(
9997

10098
case solvert::CVC4:
10199
logic = "ALL";
102-
use_array_of_bool = true;
103100
use_as_const = true;
104101
break;
105102

@@ -110,7 +107,6 @@ smt2_convt::smt2_convt(
110107
break;
111108

112109
case solvert::Z3:
113-
use_array_of_bool = true;
114110
use_as_const = true;
115111
use_check_sat_assuming = true;
116112
use_lambda_for_array = true;
@@ -4059,24 +4055,11 @@ void smt2_convt::convert_index(const index_exprt &expr)
40594055

40604056
if(use_array_theory(expr.array()))
40614057
{
4062-
if(expr.type().id() == ID_bool && !use_array_of_bool)
4063-
{
4064-
out << "(= ";
4065-
out << "(select ";
4066-
convert_expr(expr.array());
4067-
out << " ";
4068-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4069-
out << ")";
4070-
out << " #b1)";
4071-
}
4072-
else
4073-
{
4074-
out << "(select ";
4075-
convert_expr(expr.array());
4076-
out << " ";
4077-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4078-
out << ")";
4079-
}
4058+
out << "(select ";
4059+
convert_expr(expr.array());
4060+
out << " ";
4061+
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4062+
out << ")";
40804063
}
40814064
else
40824065
{
@@ -4630,16 +4613,7 @@ void smt2_convt::find_symbols(const exprt &expr)
46304613
out << "(assert (forall ((i ";
46314614
convert_type(array_type.size().type());
46324615
out << ")) (= (select " << id << " i) ";
4633-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4634-
{
4635-
out << "(ite ";
4636-
convert_expr(array_of.what());
4637-
out << " #b1 #b0)";
4638-
}
4639-
else
4640-
{
4641-
convert_expr(array_of.what());
4642-
}
4616+
convert_expr(array_of.what());
46434617
out << ")))\n";
46444618

46454619
defined_expressions[expr] = id;
@@ -4678,16 +4652,7 @@ void smt2_convt::find_symbols(const exprt &expr)
46784652
out << ")) (= (select " << id << " ";
46794653
convert_expr(array_comprehension.arg());
46804654
out << ") ";
4681-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4682-
{
4683-
out << "(ite ";
4684-
convert_expr(array_comprehension.body());
4685-
out << " #b1 #b0)";
4686-
}
4687-
else
4688-
{
4689-
convert_expr(array_comprehension.body());
4690-
}
4655+
convert_expr(array_comprehension.body());
46914656
out << "))))\n";
46924657

46934658
defined_expressions[expr] = id;
@@ -4711,16 +4676,7 @@ void smt2_convt::find_symbols(const exprt &expr)
47114676
out << "(assert (= (select " << id << " ";
47124677
convert_expr(from_integer(i, array_type.size().type()));
47134678
out << ") "; // select
4714-
if(array_type.subtype().id() == ID_bool && !use_array_of_bool)
4715-
{
4716-
out << "(ite ";
4717-
convert_expr(expr.operands()[i]);
4718-
out << " #b1 #b0)";
4719-
}
4720-
else
4721-
{
4722-
convert_expr(expr.operands()[i]);
4723-
}
4679+
convert_expr(expr.operands()[i]);
47244680
out << "))" << "\n"; // =, assert
47254681
}
47264682

@@ -4865,16 +4821,11 @@ void smt2_convt::convert_type(const typet &type)
48654821
CHECK_RETURN(array_type.size().is_not_nil());
48664822

48674823
// we always use array theory for top-level arrays
4868-
const typet &subtype = array_type.subtype();
4869-
48704824
out << "(Array ";
48714825
convert_type(array_type.size().type());
48724826
out << " ";
48734827

4874-
if(subtype.id()==ID_bool && !use_array_of_bool)
4875-
out << "(_ BitVec 1)";
4876-
else
4877-
convert_type(array_type.subtype());
4828+
convert_type(array_type.subtype());
48784829

48794830
out << ")";
48804831
}

src/solvers/smt2/smt2_conv.h

Lines changed: 0 additions & 1 deletion
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)