|
8 | 8 |
|
9 | 9 | #include <testing-utils/catch.hpp>
|
10 | 10 |
|
11 |
| -#include <solvers/refinement/string_constraint_instantiation.h> |
12 |
| - |
13 |
| -#include <solvers/sat/satcheck.h> |
| 11 | +#include <numeric> |
| 12 | +#include <java_bytecode/java_bytecode_language.h> |
14 | 13 | #include <java_bytecode/java_types.h>
|
15 | 14 | #include <langapi/mode.h>
|
16 |
| -#include <java_bytecode/java_bytecode_language.h> |
| 15 | +#include <solvers/refinement/string_constraint_instantiation.h> |
| 16 | +#include <solvers/sat/satcheck.h> |
17 | 17 | #include <util/simplify_expr.h>
|
18 | 18 | #include <util/config.h>
|
19 | 19 |
|
@@ -193,28 +193,40 @@ SCENARIO("instantiate_not_contains",
|
193 | 193 | exprt res=generator.add_axioms_for_function_application(func);
|
194 | 194 | std::string axioms;
|
195 | 195 | std::vector<string_not_contains_constraintt> nc_axioms;
|
196 |
| - for(exprt axiom : generator.get_axioms()) |
197 |
| - { |
198 |
| - simplify(axiom, ns); |
199 |
| - if(axiom.id()==ID_string_constraint) |
200 |
| - { |
201 |
| - string_constraintt sc=to_string_constraint(axiom); |
202 |
| - axioms+=from_expr(ns, "", sc); |
203 |
| - } |
204 |
| - else if(axiom.id()==ID_string_not_contains_constraint) |
205 |
| - { |
206 |
| - string_not_contains_constraintt sc= |
207 |
| - to_string_not_contains_constraint(axiom); |
208 |
| - axioms+=from_expr(ns, "", sc); |
209 |
| - generator.witness[sc]= |
210 |
| - generator.fresh_symbol("w", t.witness_type()); |
| 196 | + |
| 197 | + const auto constraints = generator.get_constraints(); |
| 198 | + std::accumulate( |
| 199 | + constraints.begin(), |
| 200 | + constraints.end(), |
| 201 | + axioms, |
| 202 | + [&](const std::string &accu, string_constraintt sc) { // NOLINT |
| 203 | + simplify(sc, ns); |
| 204 | + return accu + from_expr(ns, "", sc) + "\n\n"; |
| 205 | + }); |
| 206 | + |
| 207 | + const auto nc_contraints = generator.get_not_contains_constraints(); |
| 208 | + axioms = std::accumulate( |
| 209 | + nc_contraints.begin(), |
| 210 | + nc_contraints.end(), |
| 211 | + axioms, |
| 212 | + [&]( |
| 213 | + const std::string &accu, string_not_contains_constraintt sc) { // NOLINT |
| 214 | + simplify(sc, ns); |
| 215 | + generator.witness[sc] = generator.fresh_symbol("w", t.witness_type()); |
211 | 216 | nc_axioms.push_back(sc);
|
212 |
| - } |
213 |
| - else |
214 |
| - axioms+=from_expr(ns, "", axiom); |
| 217 | + return accu + from_expr(ns, "", sc) + "\n\n"; |
| 218 | + }); |
| 219 | + |
| 220 | + const auto lemmas = generator.get_lemmas(); |
| 221 | + axioms = std::accumulate( |
| 222 | + lemmas.begin(), |
| 223 | + lemmas.end(), |
| 224 | + axioms, |
| 225 | + [&](const std::string &accu, exprt axiom) { // NOLINT |
| 226 | + simplify(axiom, ns); |
| 227 | + return accu + from_expr(ns, "", axiom) + "\n\n"; |
| 228 | + }); |
215 | 229 |
|
216 |
| - axioms+="\n\n"; |
217 |
| - } |
218 | 230 | INFO("Original axioms:\n");
|
219 | 231 | INFO(axioms);
|
220 | 232 |
|
|
0 commit comments