Skip to content

Commit

Permalink
static add axioms for string assings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz A.J. Wrona committed Sep 19, 2017
1 parent 1531f0e commit d03866d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
36 changes: 28 additions & 8 deletions src/solvers/refinement/string_refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,17 @@ static bool is_char_array(const namespacet &ns, const typet &type)
/// \param rhs: right and side of the equality
/// \return true if the assignemnt needs to be handled by the parent class
/// via `set_to`
bool string_refinementt::add_axioms_for_string_assigns(
const exprt &lhs, const exprt &rhs)
bool add_axioms_for_string_assigns(
replace_mapt& symbol_resolve,
std::map<exprt, std::list<exprt>> &reverse_symbol_resolve,
string_constraint_generatort& generator,
messaget::mstreamt &stream,
const namespacet &ns,
const exprt &lhs,
const exprt &rhs)
{
if(is_char_array(ns, rhs.type()))
{
for (const auto& lemma : set_char_array_equality(lhs, rhs))
add_lemma(lemma, false);

if(rhs.id() == ID_symbol || rhs.id() == ID_array)
{
add_symbol_to_symbol_map(
Expand Down Expand Up @@ -440,7 +443,8 @@ bool string_refinementt::add_axioms_for_string_assigns(
}
else
{
warning() << "ignoring char array " << from_expr(ns, "", rhs) << eom;
stream << "ignoring char array " << from_expr(ns, "", rhs)
<< messaget::eom;
return true;
}
}
Expand Down Expand Up @@ -651,8 +655,24 @@ void string_refinementt::set_to(const exprt &expr, bool value)
}
}

if(value && !add_axioms_for_string_assigns(lhs, subst_rhs))
return;
if(value)
{
if(is_char_array(ns, rhs.type()))
{
for (const auto& lemma : set_char_array_equality(lhs, rhs))
add_lemma(lemma, false);
}
const bool not_handled=add_axioms_for_string_assigns(
symbol_resolve,
reverse_symbol_resolve,
generator,
warning(),
ns,
lhs,
subst_rhs);
if (!not_handled)
return;
}

// Push the substituted equality to the list of axioms to be given to
// supert::set_to.
Expand Down
2 changes: 0 additions & 2 deletions src/solvers/refinement/string_refinement.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,5 @@ class string_refinementt final: public bv_refinementt
void add_lemma(const exprt &lemma,
bool simplify=true,
bool add_to_index_set=true);

bool add_axioms_for_string_assigns(const exprt &lhs, const exprt &rhs);
};
#endif

0 comments on commit d03866d

Please sign in to comment.