Skip to content

Commit 475a878

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 5469136 commit 475a878

File tree

4 files changed

+9
-111
lines changed

4 files changed

+9
-111
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 & 60 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;
@@ -4070,24 +4066,11 @@ void smt2_convt::convert_index(const index_exprt &expr)
40704066

40714067
if(use_array_theory(expr.array()))
40724068
{
4073-
if(expr.type().id() == ID_bool && !use_array_of_bool)
4074-
{
4075-
out << "(= ";
4076-
out << "(select ";
4077-
convert_expr(expr.array());
4078-
out << " ";
4079-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4080-
out << ")";
4081-
out << " #b1)";
4082-
}
4083-
else
4084-
{
4085-
out << "(select ";
4086-
convert_expr(expr.array());
4087-
out << " ";
4088-
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4089-
out << ")";
4090-
}
4069+
out << "(select ";
4070+
convert_expr(expr.array());
4071+
out << " ";
4072+
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
4073+
out << ")";
40914074
}
40924075
else
40934076
{
@@ -4644,16 +4627,7 @@ void smt2_convt::find_symbols(const exprt &expr)
46444627
out << "(assert (forall ((i ";
46454628
convert_type(array_type.size().type());
46464629
out << ")) (= (select " << id << " i) ";
4647-
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
4648-
{
4649-
out << "(ite ";
4650-
convert_expr(array_of.what());
4651-
out << " #b1 #b0)";
4652-
}
4653-
else
4654-
{
4655-
convert_expr(array_of.what());
4656-
}
4630+
convert_expr(array_of.what());
46574631
out << ")))\n";
46584632

46594633
defined_expressions[expr] = id;
@@ -4692,16 +4666,7 @@ void smt2_convt::find_symbols(const exprt &expr)
46924666
out << ")) (= (select " << id << " ";
46934667
convert_expr(array_comprehension.arg());
46944668
out << ") ";
4695-
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
4696-
{
4697-
out << "(ite ";
4698-
convert_expr(array_comprehension.body());
4699-
out << " #b1 #b0)";
4700-
}
4701-
else
4702-
{
4703-
convert_expr(array_comprehension.body());
4704-
}
4669+
convert_expr(array_comprehension.body());
47054670
out << "))))\n";
47064671

47074672
defined_expressions[expr] = id;
@@ -4725,16 +4690,7 @@ void smt2_convt::find_symbols(const exprt &expr)
47254690
out << "(assert (= (select " << id << " ";
47264691
convert_expr(from_integer(i, array_type.size().type()));
47274692
out << ") "; // select
4728-
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
4729-
{
4730-
out << "(ite ";
4731-
convert_expr(expr.operands()[i]);
4732-
out << " #b1 #b0)";
4733-
}
4734-
else
4735-
{
4736-
convert_expr(expr.operands()[i]);
4737-
}
4693+
convert_expr(expr.operands()[i]);
47384694
out << "))" << "\n"; // =, assert
47394695
}
47404696

@@ -4879,17 +4835,10 @@ void smt2_convt::convert_type(const typet &type)
48794835
CHECK_RETURN(array_type.size().is_not_nil());
48804836

48814837
// we always use array theory for top-level arrays
4882-
const typet &subtype = array_type.element_type();
4883-
48844838
out << "(Array ";
48854839
convert_type(array_type.size().type());
48864840
out << " ";
4887-
4888-
if(subtype.id()==ID_bool && !use_array_of_bool)
4889-
out << "(_ BitVec 1)";
4890-
else
4891-
convert_type(array_type.element_type());
4892-
4841+
convert_type(array_type.element_type());
48934842
out << ")";
48944843
}
48954844
else if(type.id()==ID_bool)

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)