Skip to content

Commit 72a537a

Browse files
committed
TG-672 Remove some unused concretizing code
1 parent 95efc6f commit 72a537a

File tree

1 file changed

+3
-110
lines changed

1 file changed

+3
-110
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 3 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -429,118 +429,11 @@ std::pair<bool, std::vector<exprt>> add_axioms_for_string_assigns(
429429
return { true, std::vector<exprt>() };
430430
}
431431

432-
/// If the expression is of type string, then adds constants to the index set to
433-
/// force the solver to pick concrete values for each character, and fill the
434-
/// maps `found_length` and `found_content`.
435-
///
436-
/// The way this is done is by looking for the length of the string,
437-
/// then for each `i` in the index set, look at the value found by
438-
/// the solver and put it in the `result` table.
439-
/// For indexes that are not present in the index set, we put the
440-
/// same value as the next index that is present in the index set.
441-
/// We do so by traversing the array backward, remembering the
442-
/// last value that has been initialized.
443-
static void concretize_string(
444-
const std::function<exprt(const exprt &)> get,
445-
std::map<exprt, exprt> &found_length,
446-
std::map<exprt, array_exprt> &found_content,
447-
const replace_mapt &symbol_resolve,
448-
const std::map<exprt, std::set<exprt>> &index_set,
449-
const std::size_t max_string_length,
450-
messaget::mstreamt &stream,
451-
const namespacet &ns,
452-
const exprt &expr)
453-
{
454-
if(const auto str=expr_cast<string_exprt>(expr))
455-
{
456-
const exprt length=get(str->length());
457-
exprt content=str->content();
458-
replace_expr(symbol_resolve, content);
459-
found_length[content]=length;
460-
const auto string_length=expr_cast_v<std::size_t>(length);
461-
INVARIANT(
462-
string_length<=max_string_length,
463-
string_refinement_invariantt("string length must be less than the max "
464-
"length"));
465-
const auto it=index_set.find(str->content());
466-
if(it==index_set.end() || it->second.empty())
467-
return;
468-
469-
std::map<std::size_t, exprt> map;
470-
471-
for(const auto &i : it->second)
472-
{
473-
const exprt simple_i=simplify_expr(get(i), ns);
474-
if(const auto index=expr_cast<std::size_t>(simple_i))
475-
{
476-
const exprt str_i=simplify_expr((*str)[simple_i], ns);
477-
const exprt value=simplify_expr(get(str_i), ns);
478-
map.emplace(*index, value);
479-
}
480-
else
481-
{
482-
stream << "concretize_string: ignoring out of bound index: "
483-
<< from_expr(ns, "", simple_i) << messaget::eom;
484-
}
485-
}
486-
array_exprt arr(to_array_type(content.type()));
487-
arr.operands()=fill_in_map_as_vector(map);
488-
stream << "Concretized " << from_expr(ns, "", str->content())
489-
<< "=" << from_expr(ns, "", arr) << messaget::eom;
490-
found_content[content]=arr;
491-
}
492-
}
493-
494-
/// For each string whose length has been solved, add constants to the index set
495-
/// to force the solver to pick concrete values for each character, and fill the
496-
/// map `found_length`
497-
std::vector<exprt> concretize_results(
498-
const std::function<exprt(const exprt &)> get,
499-
std::map<exprt, exprt> &found_length,
500-
std::map<exprt, array_exprt> &found_content,
501-
const replace_mapt &symbol_resolve,
502-
const std::map<exprt, std::set<exprt>> &index_set,
503-
const std::size_t max_string_length,
504-
messaget::mstreamt &stream,
505-
const namespacet &ns,
506-
const std::set<string_exprt> &created_strings,
507-
const std::map<exprt, std::set<exprt>> &current_index_set,
508-
const std::vector<string_constraintt> &universal_axioms)
509-
{
510-
for(const auto &it : symbol_resolve)
511-
{
512-
concretize_string(
513-
get,
514-
found_length,
515-
found_content,
516-
symbol_resolve,
517-
index_set,
518-
max_string_length,
519-
stream,
520-
ns,
521-
it.second);
522-
}
523-
for(const auto &expr : created_strings)
524-
{
525-
concretize_string(
526-
get,
527-
found_length,
528-
found_content,
529-
symbol_resolve,
530-
index_set,
531-
max_string_length,
532-
stream,
533-
ns,
534-
expr);
535-
}
536-
return generate_instantiations(stream, current_index_set, universal_axioms);
537-
}
538-
539432
/// For each string whose length has been solved, add constants to the map
540433
/// `found_length`
541434
void concretize_lengths(
542435
std::map<exprt, exprt> &found_length,
543-
const std::function<exprt(const exprt &)> get,
436+
const std::function<exprt(const exprt &)> &get,
544437
const replace_mapt &symbol_resolve,
545438
const std::set<string_exprt> &created_strings)
546439
{
@@ -2032,8 +1925,8 @@ exprt substitute_array_lists(exprt expr, size_t string_max_length)
20321925
/// \return an expression
20331926
exprt string_refinementt::get(const exprt &expr) const
20341927
{
2035-
const auto super_get=[this](const exprt &expr)
2036-
{ return supert::get(expr); };
1928+
const std::function<exprt(const exprt &)> super_get=[this](const exprt &expr)
1929+
{ return (exprt) supert::get(expr); };
20371930
exprt ecopy(expr);
20381931
replace_expr(symbol_resolve, ecopy);
20391932
if(is_char_array(ns, ecopy.type()))

0 commit comments

Comments
 (0)