8
8
9
9
package org .sosy_lab .java_smt .solvers .princess ;
10
10
11
- import static com .google .common .base .Preconditions .checkNotNull ;
12
11
import static scala .collection .JavaConverters .asJava ;
13
12
14
13
import ap .api .PartialModel ;
42
41
import java .util .ArrayList ;
43
42
import java .util .LinkedHashSet ;
44
43
import java .util .List ;
45
- import java .util .Map . Entry ;
44
+ import java .util .Map ;
46
45
import java .util .Set ;
47
46
import org .checkerframework .checker .nullness .qual .Nullable ;
48
47
import org .sosy_lab .java_smt .basicimpl .AbstractModel ;
@@ -55,7 +54,7 @@ class PrincessModel extends AbstractModel<IExpression, Sort, PrincessEnvironment
55
54
private final SimpleAPI api ;
56
55
57
56
// Keeps track of the temporary variables created for explicit term evaluations in the model.
58
- private static int counter = 0 ;
57
+ private int counter = 0 ;
59
58
60
59
PrincessModel (
61
60
PrincessAbstractProver <?> pProver ,
@@ -84,7 +83,7 @@ public ImmutableList<ValueAssignment> asList() {
84
83
85
84
// then iterate over the model and generate the assignments
86
85
ImmutableSet .Builder <ValueAssignment > assignments = ImmutableSet .builder ();
87
- for (Entry <IExpression , IExpression > entry : asJava (interpretation ).entrySet ()) {
86
+ for (Map . Entry <IExpression , IExpression > entry : asJava (interpretation ).entrySet ()) {
88
87
if (!entry .getKey ().toString ().equals ("Rat_denom" ) && !isAbbrev (abbrevs , entry .getKey ())) {
89
88
assignments .addAll (getAssignments (entry .getKey (), entry .getValue (), arrays ));
90
89
}
@@ -122,7 +121,7 @@ private boolean isAbbrev(Set<Predicate> abbrevs, IExpression var) {
122
121
private Multimap <IFunApp , ITerm > getArrays (
123
122
scala .collection .Map <IExpression , IExpression > interpretation ) {
124
123
Multimap <IFunApp , ITerm > arrays = ArrayListMultimap .create ();
125
- for (Entry <IExpression , IExpression > entry : asJava (interpretation ).entrySet ()) {
124
+ for (Map . Entry <IExpression , IExpression > entry : asJava (interpretation ).entrySet ()) {
126
125
if (entry .getKey () instanceof IConstant ) {
127
126
ITerm maybeArray = (IConstant ) entry .getKey ();
128
127
IExpression value = entry .getValue ();
@@ -300,28 +299,24 @@ private ITerm simplifyRational(ITerm pTerm) {
300
299
api .addAssertion (fixed );
301
300
}
302
301
303
- IFormula modelAssignment = null ;
304
- try {
305
- if (expr instanceof ITerm ) {
306
- ITerm term = (ITerm ) expr ;
307
- ITerm var = api .createConstant (newVariable , getSort (term ));
308
- api .addAssertion (var .$eq$eq$eq (term ));
309
- api .checkSat (true );
310
- ITerm value = simplifyRational (api .evalToTerm (var ));
311
- modelAssignment = value .$eq$eq$eq (term );
312
- return value ;
313
- } else {
314
- IFormula formula = (IFormula ) expr ;
315
- IFormula var = api .createBooleanVariable (newVariable );
316
- api .addAssertion (var .$less$eq$greater (formula ));
317
- api .checkSat (true );
318
- IFormula value = IBoolLit$ .MODULE$ .apply (api .eval (var ));
319
- modelAssignment = value .$less$eq$greater (formula );
320
- return value ;
321
- }
322
- } finally {
302
+ if (expr instanceof ITerm ) {
303
+ ITerm term = (ITerm ) expr ;
304
+ ITerm var = api .createConstant (newVariable , getSort (term ));
305
+ api .addAssertion (var .$eq$eq$eq (term ));
306
+ api .checkSat (true );
307
+ ITerm value = simplifyRational (api .evalToTerm (var ));
308
+ api .pop ();
309
+ prover .addEvaluatedTerm (value .$eq$eq$eq (term ));
310
+ return value ;
311
+ } else {
312
+ IFormula formula = (IFormula ) expr ;
313
+ IFormula var = api .createBooleanVariable (newVariable );
314
+ api .addAssertion (var .$less$eq$greater (formula ));
315
+ api .checkSat (true );
316
+ IFormula value = IBoolLit$ .MODULE$ .apply (api .eval (var ));
323
317
api .pop ();
324
- prover .addEvaluatedTerm (checkNotNull (modelAssignment ));
318
+ prover .addEvaluatedTerm (value .$less$eq$greater (formula ));
319
+ return value ;
325
320
}
326
321
}
327
322
}
0 commit comments