Skip to content

Commit 7d92f48

Browse files
Merge pull request #1163 from romainbrenguier/feature/string-solver-debug-info
Debug information in string solver
2 parents dca9775 + 317baac commit 7d92f48

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -826,35 +826,35 @@ std::string string_refinementt::string_of_array(const array_exprt &arr)
826826
return result.str();
827827
}
828828

829-
/// Fill in `current_model` by mapping the variables created by the solver to
830-
/// constant expressions given by the current model
831-
void string_refinementt::fill_model()
829+
/// Display part of the current model by mapping the variables created by the
830+
/// solver to constant expressions given by the current model
831+
void string_refinementt::debug_model()
832832
{
833+
const std::string indent(" ");
833834
for(auto it : symbol_resolve)
834835
{
835836
if(refined_string_typet::is_refined_string_type(it.second.type()))
836837
{
838+
debug() << "- " << from_expr(ns, "", to_symbol_expr(it.first)) << ":\n";
837839
string_exprt refined=to_string_expr(it.second);
838-
// TODO: check whith this is necessary:
839-
replace_expr(symbol_resolve, refined);
840+
debug() << indent << indent << "in_map: "
841+
<< from_expr(ns, "", refined) << eom;
842+
debug() << indent << indent << "resolved: "
843+
<< from_expr(ns, "", refined) << eom;
840844
const exprt &econtent=refined.content();
841845
const exprt &elength=refined.length();
842846

843847
exprt len=supert::get(elength);
844848
len=simplify_expr(len, ns);
845849
exprt arr=get_array(econtent, len);
846-
847-
current_model[elength]=len;
848-
current_model[econtent]=arr;
849-
debug() << from_expr(ns, "", to_symbol_expr(it.first)) << "="
850-
<< from_expr(ns, "", refined);
851-
852850
if(arr.id()==ID_array)
853-
debug() << " = \"" << string_of_array(to_array_expr(arr))
854-
<< "\" (size:" << from_expr(ns, "", len) << ")"<< eom;
851+
debug() << indent << indent << "as_string: \""
852+
<< string_of_array(to_array_expr(arr)) << "\"\n";
855853
else
856-
debug() << " = " << from_expr(ns, "", arr)
857-
<< " (size:" << from_expr(ns, "", len) << ")" << eom;
854+
debug() << indent << indent << "as_char_array: "
855+
<< from_expr(ns, "", arr) << "\n";
856+
857+
debug() << indent << indent << "size: " << from_expr(ns, "", len) << eom;
858858
}
859859
else
860860
{
@@ -865,32 +865,28 @@ void string_refinementt::fill_model()
865865
"handled"));
866866
exprt arr=it.second;
867867
replace_expr(symbol_resolve, arr);
868-
replace_expr(current_model, arr);
868+
debug() << "- " << from_expr(ns, "", to_symbol_expr(it.first)) << ":\n";
869+
debug() << indent << indent << "resolved: "
870+
<< from_expr(ns, "", arr) << "\n";
869871
exprt arr_model=get_array(arr);
870-
current_model[it.first]=arr_model;
871-
872-
debug() << from_expr(ns, "", to_symbol_expr(it.first)) << "="
873-
<< from_expr(ns, "", arr) << " = "
874-
<< from_expr(ns, "", arr_model) << "" << eom;
872+
debug() << indent << indent << "char_array: "
873+
<< from_expr(ns, "", arr_model) << eom;
875874
}
876875
}
877876

878877
for(auto it : generator.boolean_symbols)
879878
{
880-
debug() << "" << it.get_identifier() << " := "
879+
debug() << " - " << it.get_identifier() << ": "
881880
<< from_expr(ns, "", supert::get(it)) << eom;
882-
current_model[it]=supert::get(it);
883881
}
884882

885883
for(auto it : generator.index_symbols)
886884
{
887-
debug() << "" << it.get_identifier() << " := "
888-
<< from_expr(ns, "", supert::get(it)) << eom;
889-
current_model[it]=supert::get(it);
885+
debug() << " - " << it.get_identifier() << ": "
886+
<< from_expr(ns, "", supert::get(it)) << eom;
890887
}
891888
}
892889

893-
894890
/// Create a new expression where 'with' expressions on arrays are replaced by
895891
/// 'if' expressions. e.g. for an array access arr[x], where: `arr :=
896892
/// array_of(12) with {0:=24} with {2:=42}` the constructed expression will be:
@@ -1125,7 +1121,7 @@ bool string_refinementt::check_axioms()
11251121
<< "===========================================" << eom;
11261122
debug() << "string_refinementt::check_axioms: build the"
11271123
<< " interpretation from the model of the prop_solver" << eom;
1128-
fill_model();
1124+
debug_model();
11291125

11301126
// Maps from indexes of violated universal axiom to a witness of violation
11311127
std::map<size_t, exprt> violated;

src/solvers/refinement/string_refinement.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class string_refinementt: public bv_refinementt
9494
std::map<exprt, exprt_listt> reverse_symbol_resolve;
9595
std::list<std::pair<exprt, bool>> non_string_axioms;
9696

97-
// Valuation in the current model of the symbols that have been created
98-
// by the solver
99-
replace_mapt current_model;
100-
10197
// Length of char arrays found during concretization
10298
std::map<exprt, exprt> found_length;
10399
// Content of char arrays found during concretization
@@ -127,7 +123,7 @@ class string_refinementt: public bv_refinementt
127123
const exprt &val,
128124
const symbol_exprt &univ_var);
129125
exprt negation_of_constraint(const string_constraintt &axiom);
130-
void fill_model();
126+
void debug_model();
131127
bool check_axioms();
132128
bool is_axiom_sat(
133129
const exprt &axiom, const symbol_exprt& var, exprt &witness);

0 commit comments

Comments
 (0)