11
11
#include < solvers/refinement/string_constraint_instantiation.h>
12
12
13
13
#include < solvers/sat/satcheck.h>
14
- #include < solvers/refinement/bv_refinement.h>
15
14
#include < java_bytecode/java_types.h>
16
15
#include < langapi/mode.h>
17
16
#include < java_bytecode/java_bytecode_language.h>
18
- #include < util/namespace.h>
19
- #include < util/symbol_table.h>
20
17
#include < util/simplify_expr.h>
21
18
22
19
// / \class Types used throughout the test. Currently it is impossible to
@@ -48,7 +45,7 @@ const tt t;
48
45
// / Creates a `constant_exprt` of the proper length type.
49
46
// / \param [in] i: integer to convert
50
47
// / \return corresponding `constant_exprt`
51
- constant_exprt from_integer (const mp_integer i)
48
+ constant_exprt from_integer (const mp_integer & i)
52
49
{
53
50
return from_integer (i, t.length_type ());
54
51
}
@@ -81,6 +78,17 @@ std::set<exprt> full_index_set(const string_exprt &s)
81
78
return ret;
82
79
}
83
80
81
+ // / Create the cartesian product of two sets.
82
+ template <class T , class U >
83
+ std::set<std::pair<T, U>> product (const std::set<T> ts, const std::set<U> us)
84
+ {
85
+ std::set<std::pair<T, U>> s;
86
+ for (const auto &t : ts)
87
+ for (const auto &u : us)
88
+ s.insert (std::pair<T, U>(t, u));
89
+ return s;
90
+ }
91
+
84
92
// / Simplifies, and returns the conjunction of the lemmas.
85
93
// / \param [in] lemmas: lemmas to process
86
94
// / \param [in] ns: namespace for simplifying
@@ -152,7 +160,7 @@ SCENARIO("instantiate_not_contains",
152
160
153
161
// Generating the corresponding axioms and simplifying, recording info
154
162
symbol_tablet symtab;
155
- namespacet empty_ns (symtab);
163
+ const namespacet empty_ns (symtab);
156
164
string_constraint_generatort::infot info;
157
165
string_constraint_generatort generator (info, ns);
158
166
exprt res=generator.add_axioms_for_function_application (func);
@@ -196,7 +204,7 @@ SCENARIO("instantiate_not_contains",
196
204
for (const auto &axiom : nc_axioms)
197
205
{
198
206
const std::vector<exprt> l=instantiate_not_contains (
199
- axiom, index_set_ab, index_set_b, generator);
207
+ axiom, product ( index_set_ab, index_set_b) , generator);
200
208
lemmas.insert (lemmas.end (), l.begin (), l.end ());
201
209
}
202
210
@@ -239,7 +247,7 @@ SCENARIO("instantiate_not_contains",
239
247
240
248
// Create witness for axiom
241
249
symbol_tablet symtab;
242
- namespacet empty_ns (symtab);
250
+ const namespacet empty_ns (symtab);
243
251
string_constraint_generatort::infot info;
244
252
string_constraint_generatort generator (info, ns);
245
253
generator.witness [vacuous]=
@@ -255,7 +263,7 @@ SCENARIO("instantiate_not_contains",
255
263
256
264
// Instantiate the lemmas
257
265
std::vector<exprt> lemmas=instantiate_not_contains (
258
- vacuous, index_set_a, index_set_a, generator);
266
+ vacuous, product ( index_set_a, index_set_a) , generator);
259
267
260
268
const exprt conj=combine_lemmas (lemmas, ns);
261
269
const std::string info=create_info (lemmas, ns);
@@ -297,7 +305,7 @@ SCENARIO("instantiate_not_contains",
297
305
298
306
// Create witness for axiom
299
307
symbol_tablet symtab;
300
- namespacet ns (symtab);
308
+ const namespacet ns (symtab);
301
309
string_constraint_generatort::infot info;
302
310
string_constraint_generatort generator (info, ns);
303
311
generator.witness [trivial]=
@@ -314,7 +322,7 @@ SCENARIO("instantiate_not_contains",
314
322
315
323
// Instantiate the lemmas
316
324
std::vector<exprt> lemmas=instantiate_not_contains (
317
- trivial, index_set_a, index_set_b, generator);
325
+ trivial, product ( index_set_a, index_set_b) , generator);
318
326
319
327
const exprt conj=combine_lemmas (lemmas, ns);
320
328
const std::string info=create_info (lemmas, ns);
@@ -356,7 +364,7 @@ SCENARIO("instantiate_not_contains",
356
364
357
365
// Create witness for axiom
358
366
symbol_tablet symtab;
359
- namespacet empty_ns (symtab);
367
+ const namespacet empty_ns (symtab);
360
368
string_constraint_generatort::infot info;
361
369
string_constraint_generatort generator (info, ns);
362
370
generator.witness [trivial]=
@@ -374,7 +382,7 @@ SCENARIO("instantiate_not_contains",
374
382
375
383
// Instantiate the lemmas
376
384
std::vector<exprt> lemmas=instantiate_not_contains (
377
- trivial, index_set_a, index_set_empty, generator);
385
+ trivial, product ( index_set_a, index_set_empty) , generator);
378
386
379
387
const exprt conj=combine_lemmas (lemmas, ns);
380
388
const std::string info=create_info (lemmas, ns);
@@ -416,7 +424,7 @@ SCENARIO("instantiate_not_contains",
416
424
417
425
// Create witness for axiom
418
426
symbol_tablet symtab;
419
- namespacet empty_ns (symtab);
427
+ const namespacet empty_ns (symtab);
420
428
421
429
string_constraint_generatort::infot info;
422
430
string_constraint_generatort generator (info, ns);
@@ -433,7 +441,7 @@ SCENARIO("instantiate_not_contains",
433
441
434
442
// Instantiate the lemmas
435
443
std::vector<exprt> lemmas=instantiate_not_contains (
436
- trivial, index_set_ab, index_set_ab, generator);
444
+ trivial, product ( index_set_ab, index_set_ab) , generator);
437
445
438
446
const exprt conj=combine_lemmas (lemmas, ns);
439
447
const std::string info=create_info (lemmas, ns);
@@ -476,7 +484,7 @@ SCENARIO("instantiate_not_contains",
476
484
477
485
// Create witness for axiom
478
486
symbol_tablet symtab;
479
- namespacet empty_ns (symtab);
487
+ const namespacet empty_ns (symtab);
480
488
string_constraint_generatort::infot info;
481
489
string_constraint_generatort generator (info, ns);
482
490
generator.witness [trivial]=
@@ -493,7 +501,7 @@ SCENARIO("instantiate_not_contains",
493
501
494
502
// Instantiate the lemmas
495
503
std::vector<exprt> lemmas=instantiate_not_contains (
496
- trivial, index_set_ab, index_set_cd, generator);
504
+ trivial, product ( index_set_ab, index_set_cd) , generator);
497
505
498
506
const exprt conj=combine_lemmas (lemmas, ns);
499
507
const std::string info=create_info (lemmas, ns);
0 commit comments