Skip to content

Commit d03866d

Browse files
author
Lukasz A.J. Wrona
committed
static add axioms for string assings
1 parent 1531f0e commit d03866d

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,17 @@ static bool is_char_array(const namespacet &ns, const typet &type)
403403
/// \param rhs: right and side of the equality
404404
/// \return true if the assignemnt needs to be handled by the parent class
405405
/// via `set_to`
406-
bool string_refinementt::add_axioms_for_string_assigns(
407-
const exprt &lhs, const exprt &rhs)
406+
bool add_axioms_for_string_assigns(
407+
replace_mapt& symbol_resolve,
408+
std::map<exprt, std::list<exprt>> &reverse_symbol_resolve,
409+
string_constraint_generatort& generator,
410+
messaget::mstreamt &stream,
411+
const namespacet &ns,
412+
const exprt &lhs,
413+
const exprt &rhs)
408414
{
409415
if(is_char_array(ns, rhs.type()))
410416
{
411-
for (const auto& lemma : set_char_array_equality(lhs, rhs))
412-
add_lemma(lemma, false);
413-
414417
if(rhs.id() == ID_symbol || rhs.id() == ID_array)
415418
{
416419
add_symbol_to_symbol_map(
@@ -440,7 +443,8 @@ bool string_refinementt::add_axioms_for_string_assigns(
440443
}
441444
else
442445
{
443-
warning() << "ignoring char array " << from_expr(ns, "", rhs) << eom;
446+
stream << "ignoring char array " << from_expr(ns, "", rhs)
447+
<< messaget::eom;
444448
return true;
445449
}
446450
}
@@ -651,8 +655,24 @@ void string_refinementt::set_to(const exprt &expr, bool value)
651655
}
652656
}
653657

654-
if(value && !add_axioms_for_string_assigns(lhs, subst_rhs))
655-
return;
658+
if(value)
659+
{
660+
if(is_char_array(ns, rhs.type()))
661+
{
662+
for (const auto& lemma : set_char_array_equality(lhs, rhs))
663+
add_lemma(lemma, false);
664+
}
665+
const bool not_handled=add_axioms_for_string_assigns(
666+
symbol_resolve,
667+
reverse_symbol_resolve,
668+
generator,
669+
warning(),
670+
ns,
671+
lhs,
672+
subst_rhs);
673+
if (!not_handled)
674+
return;
675+
}
656676

657677
// Push the substituted equality to the list of axioms to be given to
658678
// supert::set_to.

src/solvers/refinement/string_refinement.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,5 @@ class string_refinementt final: public bv_refinementt
9797
void add_lemma(const exprt &lemma,
9898
bool simplify=true,
9999
bool add_to_index_set=true);
100-
101-
bool add_axioms_for_string_assigns(const exprt &lhs, const exprt &rhs);
102100
};
103101
#endif

0 commit comments

Comments
 (0)