Skip to content

Commit 7f11ccf

Browse files
author
Lukasz A.J. Wrona
committed
static set_char_array_equality
1 parent 229568a commit 7f11ccf

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,24 @@ void add_symbol_to_symbol_map(
336336

337337
/// add axioms if the rhs is a character array
338338
/// \par parameters: the rhs and lhs of an equality over character arrays
339-
void string_refinementt::set_char_array_equality(
340-
const exprt &lhs, const exprt &rhs)
339+
std::vector<exprt> set_char_array_equality(const exprt &lhs, const exprt &rhs)
341340
{
342341
PRECONDITION(lhs.id()==ID_symbol);
343342

344343
if(rhs.id()==ID_array && rhs.type().id()==ID_array)
345344
{
345+
std::vector<exprt> lemmas;
346346
const typet &index_type=to_array_type(rhs.type()).size().type();
347347
for(size_t i=0, ilim=rhs.operands().size(); i!=ilim; ++i)
348348
{
349349
// Introduce axioms to map symbolic rhs to its char array.
350350
index_exprt arraycell(rhs, from_integer(i, index_type));
351351
equal_exprt arrayeq(arraycell, rhs.operands()[i]);
352-
add_lemma(arrayeq, false);
352+
lemmas.push_back(arrayeq);
353353
}
354+
return lemmas;
354355
}
356+
return { };
355357
// At least for Java (as it is currently pre-processed), we need not consider
356358
// other cases, because all character arrays find themselves on the rhs of an
357359
// equality. Note that this might not be the case for other languages.
@@ -402,7 +404,9 @@ bool string_refinementt::add_axioms_for_string_assigns(
402404
{
403405
if(is_char_array(ns, rhs.type()))
404406
{
405-
set_char_array_equality(lhs, rhs);
407+
for (const auto& lemma : set_char_array_equality(lhs, rhs))
408+
add_lemma(lemma, false);
409+
406410
if(rhs.id() == ID_symbol || rhs.id() == ID_array)
407411
{
408412
add_symbol_to_symbol_map(

src/solvers/refinement/string_refinement.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ class string_refinementt final: public bv_refinementt
102102

103103
void debug_model();
104104

105-
void set_char_array_equality(const exprt &lhs, const exprt &rhs);
106-
107105
exprt get_array(const exprt &arr, const exprt &size) const;
108106
exprt get_array(const exprt &arr) const;
109107

0 commit comments

Comments
 (0)