Skip to content

Commit 2063358

Browse files
Remove java dependency
Lower bound should not use java_type
1 parent 60c7a94 commit 2063358

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/solvers/refinement/string_constraint.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
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.is_nil() ? from_integer(0, upper_bound.type())
11+
: lower_bound;
12+
}
13+
814
void replace(string_constraintt &axiom, const replace_mapt &symbol_resolve)
915
{
1016
replace_expr(symbol_resolve, axiom.index_guard);
@@ -17,16 +23,16 @@ void replace(string_constraintt &axiom, const replace_mapt &symbol_resolve)
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: 4 additions & 3 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+
exprt lower_bound = nil_exprt(); // nil_exprt 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

src/solvers/refinement/string_refinement.cpp

Lines changed: 2 additions & 2 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(

0 commit comments

Comments
 (0)