Skip to content

Commit 61f0e1b

Browse files
Making check_axioms for string_constraints and
not_contains_constraints more uniform
1 parent f2122c6 commit 61f0e1b

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,9 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
12081208
const union_find_replacet &symbol_resolve)
12091209
{
12101210
const auto eom=messaget::eom;
1211+
static const std::string indent = " ";
1212+
static const std::string indent2 = " ";
1213+
12111214
stream << "string_refinementt::check_axioms:" << eom;
12121215

12131216
stream << "symbol_resolve:" << eom;
@@ -1245,36 +1248,37 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
12451248

12461249
exprt negaxiom=negation_of_constraint(axiom_in_model);
12471250

1248-
stream << " " << i << ".\n"
1249-
<< " - axiom:\n"
1250-
<< " " << from_expr(ns, "", axiom) << '\n';
1251-
stream << " - axiom_in_model:\n"
1252-
<< " " << from_expr(ns, "", axiom_in_model) << '\n';
1253-
stream << " - negated_axiom:\n"
1254-
<< " " << from_expr(ns, "", negaxiom) << '\n';
1251+
stream << indent << i << ".\n"
1252+
<< indent2 << "- axiom:\n"
1253+
<< indent2 << indent << from_expr(ns, "", axiom) << '\n';
1254+
stream << indent2 << "- axiom_in_model:\n"
1255+
<< indent2 << indent << from_expr(ns, "", axiom_in_model) << '\n';
1256+
stream << indent2 << "- negated_axiom:\n"
1257+
<< indent2 << indent << from_expr(ns, "", negaxiom) << '\n';
12551258
negaxiom = simplify_expr(negaxiom, ns);
1256-
stream << " - simplified_negaxiom:\n"
1257-
<< " " << from_expr(ns, "", negaxiom) << '\n';
1259+
stream << indent2 << "- simplified_negaxiom:\n"
1260+
<< indent2 << indent << from_expr(ns, "", negaxiom) << '\n';
12581261

12591262
exprt with_concretized_arrays =
12601263
concretize_arrays_in_expression(negaxiom, max_string_length, ns);
1261-
stream << " - negated_axiom_with_concretized_array_access:\n"
1262-
<< " " << from_expr(ns, "", with_concretized_arrays) << '\n';
1264+
stream << indent2 << "- negated_axiom_with_concretized_array_access:\n"
1265+
<< indent2 << indent << from_expr(ns, "", with_concretized_arrays)
1266+
<< '\n';
12631267

12641268
substitute_array_access(with_concretized_arrays);
1265-
stream << " - negated_axiom_without_array_access:\n"
1266-
<< " " << from_expr(ns, "", with_concretized_arrays) << '\n';
1269+
stream << indent2 << "- negated_axiom_without_array_access:\n"
1270+
<< indent2 << indent << from_expr(ns, "", with_concretized_arrays)
1271+
<< eom;
12671272

12681273
if(const auto &witness=
12691274
find_counter_example(ns, ui, with_concretized_arrays, univ_var))
12701275
{
1271-
stream << " - violated_for: "
1272-
<< univ_var.get_identifier()
1273-
<< "=" << from_expr(ns, "", *witness) << '\n';
1276+
stream << indent2 << "- violated_for: " << univ_var.get_identifier()
1277+
<< "=" << from_expr(ns, "", *witness) << eom;
12741278
violated[i]=*witness;
12751279
}
12761280
else
1277-
stream << " - correct" << '\n';
1281+
stream << indent2 << "- correct" << eom;
12781282
}
12791283

12801284
// Maps from indexes of violated not_contains axiom to a witness of violation
@@ -1304,21 +1308,31 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13041308
to_array_string_expr(get(s0)),
13051309
to_array_string_expr(get(s1)));
13061310

1307-
exprt negaxiom = negation_of_not_contains_constraint(
1308-
to_string_not_contains_constraint(simplify_expr(nc_axiom_in_model, ns)),
1309-
univ_var);
1310-
stream << " " << i << ".\n"
1311-
<< " - axiom: " << from_expr(ns, "", nc_axiom) << "\n";
1312-
stream << " - axiom_in_model: " << from_expr(ns, "", nc_axiom_in_model)
1313-
<< "\n";
1314-
stream << " - negated_constraint: " << from_expr(ns, "", negaxiom) << eom;
1311+
exprt negaxiom =
1312+
negation_of_not_contains_constraint(nc_axiom_in_model, univ_var);
1313+
stream << indent << i << ".\n"
1314+
<< indent2 << "- axiom:\n"
1315+
<< indent2 << indent << from_expr(ns, "", nc_axiom) << '\n';
1316+
stream << indent2 << "- axiom_in_model:\n"
1317+
<< indent2 << indent << from_expr(ns, "", nc_axiom_in_model) << '\n';
1318+
stream << indent2 << "- negated_axiom:\n"
1319+
<< indent2 << indent << from_expr(ns, "", negaxiom) << '\n';
1320+
1321+
negaxiom = simplify_expr(negaxiom, ns);
1322+
stream << indent2 << "- simplified_negaxiom:\n"
1323+
<< indent2 << indent << from_expr(ns, "", negaxiom) << '\n';
1324+
negaxiom = concretize_arrays_in_expression(negaxiom, max_string_length, ns);
1325+
stream << indent2 << "- negated_axiom_with_concretized_array_access:\n"
1326+
<< indent2 << indent << from_expr(ns, "", negaxiom) << '\n';
1327+
13151328
substitute_array_access(negaxiom);
1329+
stream << indent2 << "- negated_axiom_without_array_access:\n"
1330+
<< indent2 << indent << from_expr(ns, "", negaxiom) << eom;
13161331

13171332
if(const auto witness = find_counter_example(ns, ui, negaxiom, univ_var))
13181333
{
1319-
stream << "string constraint can be violated for "
1320-
<< univ_var.get_identifier() << "=" << from_expr(ns, "", *witness)
1321-
<< eom;
1334+
stream << indent2 << "- violated_for: " << univ_var.get_identifier()
1335+
<< "=" << from_expr(ns, "", *witness) << eom;
13221336
violated_not_contains[i]=*witness;
13231337
}
13241338
}

0 commit comments

Comments
 (0)