Skip to content

remove encoding of arrays of bools into bitvector #6206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions regression/cbmc/array_of_bool_as_bitvec/main.c

This file was deleted.

31 changes: 0 additions & 31 deletions regression/cbmc/array_of_bool_as_bitvec/test-smt2-outfile.desc

This file was deleted.

69 changes: 9 additions & 60 deletions src/solvers/smt2/smt2_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ smt2_convt::smt2_convt(
solvert _solver,
std::ostream &_out)
: use_FPA_theory(false),
use_array_of_bool(false),
use_as_const(false),
use_check_sat_assuming(false),
use_datatypes(false),
Expand Down Expand Up @@ -88,7 +87,6 @@ smt2_convt::smt2_convt(

case solvert::CPROVER_SMT2:
use_FPA_theory = true;
use_array_of_bool = true;
use_as_const = true;
use_check_sat_assuming = true;
emit_set_logic = false;
Expand All @@ -99,7 +97,6 @@ smt2_convt::smt2_convt(

case solvert::CVC4:
logic = "ALL";
use_array_of_bool = true;
use_as_const = true;
break;

Expand All @@ -110,7 +107,6 @@ smt2_convt::smt2_convt(
break;

case solvert::Z3:
use_array_of_bool = true;
use_as_const = true;
use_check_sat_assuming = true;
use_lambda_for_array = true;
Expand Down Expand Up @@ -4070,24 +4066,11 @@ void smt2_convt::convert_index(const index_exprt &expr)

if(use_array_theory(expr.array()))
{
if(expr.type().id() == ID_bool && !use_array_of_bool)
{
out << "(= ";
out << "(select ";
convert_expr(expr.array());
out << " ";
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
out << ")";
out << " #b1)";
}
else
{
out << "(select ";
convert_expr(expr.array());
out << " ";
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
out << ")";
}
out << "(select ";
convert_expr(expr.array());
out << " ";
convert_expr(typecast_exprt(expr.index(), array_type.size().type()));
out << ")";
}
else
{
Expand Down Expand Up @@ -4644,16 +4627,7 @@ void smt2_convt::find_symbols(const exprt &expr)
out << "(assert (forall ((i ";
convert_type(array_type.size().type());
out << ")) (= (select " << id << " i) ";
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
{
out << "(ite ";
convert_expr(array_of.what());
out << " #b1 #b0)";
}
else
{
convert_expr(array_of.what());
}
convert_expr(array_of.what());
out << ")))\n";

defined_expressions[expr] = id;
Expand Down Expand Up @@ -4692,16 +4666,7 @@ void smt2_convt::find_symbols(const exprt &expr)
out << ")) (= (select " << id << " ";
convert_expr(array_comprehension.arg());
out << ") ";
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
{
out << "(ite ";
convert_expr(array_comprehension.body());
out << " #b1 #b0)";
}
else
{
convert_expr(array_comprehension.body());
}
convert_expr(array_comprehension.body());
out << "))))\n";

defined_expressions[expr] = id;
Expand All @@ -4725,16 +4690,7 @@ void smt2_convt::find_symbols(const exprt &expr)
out << "(assert (= (select " << id << " ";
convert_expr(from_integer(i, array_type.size().type()));
out << ") "; // select
if(array_type.element_type().id() == ID_bool && !use_array_of_bool)
{
out << "(ite ";
convert_expr(expr.operands()[i]);
out << " #b1 #b0)";
}
else
{
convert_expr(expr.operands()[i]);
}
convert_expr(expr.operands()[i]);
out << "))" << "\n"; // =, assert
}

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

// we always use array theory for top-level arrays
const typet &subtype = array_type.element_type();

out << "(Array ";
convert_type(array_type.size().type());
out << " ";

if(subtype.id()==ID_bool && !use_array_of_bool)
out << "(_ BitVec 1)";
else
convert_type(array_type.element_type());

convert_type(array_type.element_type());
out << ")";
}
else if(type.id()==ID_bool)
Expand Down
1 change: 0 additions & 1 deletion src/solvers/smt2/smt2_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class smt2_convt : public stack_decision_proceduret
~smt2_convt() override = default;

bool use_FPA_theory;
bool use_array_of_bool;
bool use_as_const;
bool use_check_sat_assuming;
bool use_datatypes;
Expand Down