|
5 | 5 | #include <util/simplify_expr.h>
|
6 | 6 | #include <util/expr_iterator.h>
|
7 | 7 |
|
| 8 | +exprt *string_constraintt::lower_bound() |
| 9 | +{ |
| 10 | + return lower_bound_value.is_nil() ? nullptr : &lower_bound_value; |
| 11 | +} |
| 12 | + |
| 13 | +exprt string_constraintt::get_lower_bound() const |
| 14 | +{ |
| 15 | + return lower_bound_value.is_nil() ? from_integer(0, upper_bound.type()) |
| 16 | + : lower_bound_value; |
| 17 | +} |
| 18 | + |
| 19 | +void string_constraintt::lower_bound(const exprt &e) |
| 20 | +{ |
| 21 | + lower_bound_value = e; |
| 22 | +} |
| 23 | + |
8 | 24 | void replace(string_constraintt &axiom, const replace_mapt &symbol_resolve)
|
9 | 25 | {
|
10 | 26 | replace_expr(symbol_resolve, axiom.index_guard);
|
11 | 27 | replace_expr(symbol_resolve, axiom.body);
|
12 | 28 | replace_expr(symbol_resolve, axiom.univ_var);
|
13 | 29 | replace_expr(symbol_resolve, axiom.upper_bound);
|
14 |
| - replace_expr(symbol_resolve, axiom.lower_bound); |
| 30 | + if(const auto lower_bound = axiom.lower_bound()) |
| 31 | + replace_expr(symbol_resolve, *lower_bound); |
15 | 32 | }
|
16 | 33 |
|
17 | 34 | exprt univ_within_bounds(const string_constraintt &axiom)
|
18 | 35 | {
|
19 | 36 | return and_exprt(
|
20 |
| - binary_relation_exprt(axiom.lower_bound, ID_le, axiom.univ_var), |
| 37 | + binary_relation_exprt(axiom.get_lower_bound(), ID_le, axiom.univ_var), |
21 | 38 | binary_relation_exprt(axiom.upper_bound, ID_gt, axiom.univ_var));
|
22 | 39 | }
|
23 | 40 |
|
24 | 41 | std::string to_string(const string_constraintt &expr)
|
25 | 42 | {
|
26 | 43 | std::ostringstream out;
|
27 | 44 | out << "forall " << format(expr.univ_var) << " in ["
|
28 |
| - << format(expr.lower_bound) << ", " << format(expr.upper_bound) << "). " |
29 |
| - << format(expr.index_guard) << " => " << format(expr.body); |
| 45 | + << format(expr.get_lower_bound()) << ", " << format(expr.upper_bound) |
| 46 | + << "). " << format(expr.index_guard) << " => " << format(expr.body); |
30 | 47 | return out.str();
|
31 | 48 | }
|
32 | 49 |
|
|
0 commit comments