Skip to content

Commit 9b06e39

Browse files
Remove java dependency
Lower bound should not use java_type
1 parent 7da7dc9 commit 9b06e39

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/solvers/refinement/string_constraint.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,34 @@
55
#include <util/simplify_expr.h>
66
#include <util/expr_iterator.h>
77

8+
exprt string_constraintt::get_lower_bound() const
9+
{
10+
return lower_bound ? *lower_bound : from_integer(0, upper_bound.type());
11+
}
12+
813
void replace(string_constraintt &axiom, const replace_mapt &symbol_resolve)
914
{
1015
replace_expr(symbol_resolve, axiom.index_guard);
1116
replace_expr(symbol_resolve, axiom.body);
1217
replace_expr(symbol_resolve, axiom.univ_var);
1318
replace_expr(symbol_resolve, axiom.upper_bound);
14-
replace_expr(symbol_resolve, axiom.lower_bound);
19+
if(axiom.lower_bound)
20+
replace_expr(symbol_resolve, *axiom.lower_bound);
1521
}
1622

1723
exprt univ_within_bounds(const string_constraintt &axiom)
1824
{
1925
return and_exprt(
20-
binary_relation_exprt(axiom.lower_bound, ID_le, axiom.univ_var),
26+
binary_relation_exprt(axiom.get_lower_bound(), ID_le, axiom.univ_var),
2127
binary_relation_exprt(axiom.upper_bound, ID_gt, axiom.univ_var));
2228
}
2329

2430
std::string to_string(const string_constraintt &expr)
2531
{
2632
std::ostringstream out;
2733
out << "forall " << format(expr.univ_var) << " in ["
28-
<< format(expr.lower_bound) << ", " << format(expr.upper_bound) << "). "
29-
<< format(expr.index_guard) << " => " << format(expr.body);
34+
<< format(expr.get_lower_bound()) << ", " << format(expr.upper_bound)
35+
<< "). " << format(expr.index_guard) << " => " << format(expr.body);
3036
return out.str();
3137
}
3238

src/solvers/refinement/string_constraint.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Author: Romain Brenguier, [email protected]
2828
#include <util/refined_string_type.h>
2929
#include <util/string_expr.h>
3030
#include <langapi/language_util.h>
31-
#include <java_bytecode/java_types.h>
3231
#include <util/union_find_replace.h>
3332

3433
/// ### Universally quantified string constraint
@@ -65,9 +64,11 @@ class string_constraintt final
6564
exprt index_guard = true_exprt(); // Index guard
6665
exprt body; // value constraint
6766
symbol_exprt univ_var;
68-
// \todo avoid depending on java type
69-
exprt lower_bound = from_integer(0, java_int_type());
7067
exprt upper_bound;
68+
optionalt<exprt> lower_bound; // empty defaults to 0
69+
70+
/// \return lower_bound if it has been set, expression for 0 otherwise
71+
exprt get_lower_bound() const;
7172
};
7273

7374
inline void
@@ -77,7 +78,8 @@ replace(string_constraintt &axiom, const union_find_replacet &symbol_resolve)
7778
symbol_resolve.replace_expr(axiom.body);
7879
symbol_resolve.replace_expr(axiom.univ_var);
7980
symbol_resolve.replace_expr(axiom.upper_bound);
80-
symbol_resolve.replace_expr(axiom.lower_bound);
81+
if(axiom.lower_bound)
82+
symbol_resolve.replace_expr(*axiom.lower_bound);
8183
}
8284

8385
exprt univ_within_bounds(const string_constraintt &axiom);

src/solvers/refinement/string_refinement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ static exprt negation_of_not_contains_constraint(
13931393
static exprt negation_of_constraint(const string_constraintt &axiom)
13941394
{
13951395
// If the for all is vacuously true, the negation is false.
1396-
const exprt &lb = axiom.lower_bound;
1396+
const exprt &lb = axiom.get_lower_bound();
13971397
const exprt &ub = axiom.upper_bound;
13981398
if(lb.id()==ID_constant && ub.id()==ID_constant)
13991399
{
@@ -1529,7 +1529,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
15291529
{
15301530
const string_constraintt &axiom=axioms.universal[i];
15311531
const symbol_exprt &univ_var = axiom.univ_var;
1532-
const exprt &bound_inf = axiom.lower_bound;
1532+
const exprt &bound_inf = axiom.get_lower_bound();
15331533
const exprt &bound_sup = axiom.upper_bound;
15341534
const exprt &prem = axiom.index_guard;
15351535
INVARIANT(
@@ -2133,7 +2133,7 @@ static exprt instantiate(
21332133
const exprt r = compute_inverse_function(stream, axiom.univ_var, val, *idx);
21342134
implies_exprt instance(
21352135
and_exprt(
2136-
binary_relation_exprt(axiom.univ_var, ID_ge, axiom.lower_bound),
2136+
binary_relation_exprt(axiom.univ_var, ID_ge, axiom.get_lower_bound()),
21372137
binary_relation_exprt(axiom.univ_var, ID_lt, axiom.upper_bound),
21382138
axiom.index_guard),
21392139
axiom.body);

0 commit comments

Comments
 (0)