Skip to content

Commit 0c70424

Browse files
committed
improve counter by making it non-static.
and change import of Map-Entry for consistency.
1 parent e6bc8f1 commit 0c70424

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/org/sosy_lab/java_smt/solvers/princess/PrincessModel.java

+21-26
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.sosy_lab.java_smt.solvers.princess;
1010

11-
import static com.google.common.base.Preconditions.checkNotNull;
1211
import static scala.collection.JavaConverters.asJava;
1312

1413
import ap.api.PartialModel;
@@ -42,7 +41,7 @@
4241
import java.util.ArrayList;
4342
import java.util.LinkedHashSet;
4443
import java.util.List;
45-
import java.util.Map.Entry;
44+
import java.util.Map;
4645
import java.util.Set;
4746
import org.checkerframework.checker.nullness.qual.Nullable;
4847
import org.sosy_lab.java_smt.basicimpl.AbstractModel;
@@ -55,7 +54,7 @@ class PrincessModel extends AbstractModel<IExpression, Sort, PrincessEnvironment
5554
private final SimpleAPI api;
5655

5756
// 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;
5958

6059
PrincessModel(
6160
PrincessAbstractProver<?> pProver,
@@ -84,7 +83,7 @@ public ImmutableList<ValueAssignment> asList() {
8483

8584
// then iterate over the model and generate the assignments
8685
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()) {
8887
if (!entry.getKey().toString().equals("Rat_denom") && !isAbbrev(abbrevs, entry.getKey())) {
8988
assignments.addAll(getAssignments(entry.getKey(), entry.getValue(), arrays));
9089
}
@@ -122,7 +121,7 @@ private boolean isAbbrev(Set<Predicate> abbrevs, IExpression var) {
122121
private Multimap<IFunApp, ITerm> getArrays(
123122
scala.collection.Map<IExpression, IExpression> interpretation) {
124123
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()) {
126125
if (entry.getKey() instanceof IConstant) {
127126
ITerm maybeArray = (IConstant) entry.getKey();
128127
IExpression value = entry.getValue();
@@ -300,28 +299,24 @@ private ITerm simplifyRational(ITerm pTerm) {
300299
api.addAssertion(fixed);
301300
}
302301

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));
323317
api.pop();
324-
prover.addEvaluatedTerm(checkNotNull(modelAssignment));
318+
prover.addEvaluatedTerm(value.$less$eq$greater(formula));
319+
return value;
325320
}
326321
}
327322
}

0 commit comments

Comments
 (0)