Skip to content

Commit b6c30ba

Browse files
Remove handling of hash_code in string solver
This can no longer be produced by the preprocessing, so it is not needed in the constraint generation.
1 parent 432c2a7 commit b6c30ba

5 files changed

+0
-57
lines changed

src/solvers/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,6 @@ allocates a new string before calling a primitive.
430430
* `cprover_string_equals_ignore_case` :
431431
\copybrief add_axioms_for_equals_ignore_case(symbol_generatort &fresh_symbol,const function_application_exprt &f, array_poolt &array_pool)
432432
\link add_axioms_for_equals_ignore_case(symbol_generatort &fresh_symbol,const function_application_exprt &f, array_poolt &array_pool) More... \endlink
433-
* `cprover_string_hash_code` :
434-
\copybrief string_constraint_generatort::add_axioms_for_hash_code
435-
\link string_constraint_generatort::add_axioms_for_hash_code More... \endlink
436433
* `cprover_string_is_prefix` :
437434
\copybrief add_axioms_for_is_prefix
438435
\link add_axioms_for_is_prefix More... \endlink

src/solvers/strings/string_constraint_generator.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,9 @@ class string_constraint_generatort final
8282

8383
exprt associate_length_to_array(const function_application_exprt &f);
8484

85-
// Add axioms corresponding to the String.hashCode java function
86-
// The specification is partial: the actual value is not actually computed
87-
// but we ensure that hash codes of equal strings are equal.
88-
std::pair<exprt, string_constraintst> add_axioms_for_hash_code(
89-
const function_application_exprt &f,
90-
array_poolt &pool);
91-
9285
// MEMBERS
9386
const messaget message;
9487

95-
// To each string on which hash_code was called we associate a symbol
96-
// representing the return value of the hash_code function.
97-
std::map<array_string_exprt, exprt> hash_code_of_string;
98-
9988
// Pool used for the intern method
10089
std::map<array_string_exprt, symbol_exprt> intern_of_string;
10190
};

src/solvers/strings/string_constraint_generator_comparison.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -176,46 +176,6 @@ std::pair<exprt, string_constraintst> add_axioms_for_equals_ignore_case(
176176
return {typecast_exprt(eq, f.type()), std::move(constraints)};
177177
}
178178

179-
/// Value that is identical for strings with the same content
180-
///
181-
/// Add axioms stating that if two strings are equal then the values
182-
/// returned by this function are equal.
183-
/// These axioms are, for each string `s` on which hash was called:
184-
/// * \f$ hash(str)=hash(s) \lor |str| \ne |s|
185-
/// \lor (|str|=|s| \land \exists i<|s|.\ s[i]\ne str[i]) \f$
186-
/// \param f: function application with argument refined_string `str`
187-
/// \param pool: pool of arrays representing strings
188-
/// \return integer expression `hash(str)`
189-
std::pair<exprt, string_constraintst>
190-
string_constraint_generatort::add_axioms_for_hash_code(
191-
const function_application_exprt &f,
192-
array_poolt &pool)
193-
{
194-
PRECONDITION(f.arguments().size() == 1);
195-
string_constraintst hash_constraints;
196-
const array_string_exprt str = get_string_expr(pool, f.arguments()[0]);
197-
const typet &return_type = f.type();
198-
const typet &index_type = str.length().type();
199-
200-
auto pair = hash_code_of_string.insert(
201-
std::make_pair(str, fresh_symbol("hash", return_type)));
202-
const exprt hash = pair.first->second;
203-
204-
for(auto it : hash_code_of_string)
205-
{
206-
const symbol_exprt i = fresh_symbol("index_hash", index_type);
207-
const equal_exprt c1(it.second, hash);
208-
const notequal_exprt c2(it.first.length(), str.length());
209-
const and_exprt c3(
210-
equal_exprt(it.first.length(), str.length()),
211-
and_exprt(
212-
notequal_exprt(str[i], it.first[i]),
213-
and_exprt(length_gt(str, i), is_positive(i))));
214-
hash_constraints.existential.push_back(or_exprt(c1, or_exprt(c2, c3)));
215-
}
216-
return {hash, std::move(hash_constraints)};
217-
}
218-
219179
/// Lexicographic comparison of two strings
220180
///
221181
/// Add axioms ensuring the result corresponds to that of the `String.compareTo`

src/solvers/strings/string_constraint_generator_main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ string_constraint_generatort::add_axioms_for_function_application(
241241
return add_axioms_for_is_suffix(fresh_symbol, expr, true, array_pool);
242242
else if(id == ID_cprover_string_contains_func)
243243
return add_axioms_for_contains(fresh_symbol, expr, array_pool);
244-
else if(id == ID_cprover_string_hash_code_func)
245-
return add_axioms_for_hash_code(expr, array_pool);
246244
else if(id == ID_cprover_string_index_of_func)
247245
return add_axioms_for_index_of(fresh_symbol, expr, array_pool);
248246
else if(id == ID_cprover_string_last_index_of_func)

src/util/irep_ids.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ IREP_ID_ONE(cprover_string_equals_ignore_case_func)
609609
IREP_ID_ONE(cprover_string_empty_string_func)
610610
IREP_ID_ONE(cprover_string_endswith_func)
611611
IREP_ID_ONE(cprover_string_format_func)
612-
IREP_ID_ONE(cprover_string_hash_code_func)
613612
IREP_ID_ONE(cprover_string_index_of_func)
614613
IREP_ID_ONE(cprover_string_intern_func)
615614
IREP_ID_ONE(cprover_string_insert_func)

0 commit comments

Comments
 (0)